Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation(crypto): rename an export to match style guide, deprecating original and two other obsolete imports #4525

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crypto/_benches/bench.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env -S deno bench
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import {
crypto as stdCrypto,
wasmDigestAlgorithms as DIGEST_ALGORITHM_NAMES,
} from "../mod.ts";
import { crypto as stdCrypto, DIGEST_ALGORITHM_NAMES } from "../mod.ts";

import nodeCrypto from "node:crypto";

Expand Down
29 changes: 22 additions & 7 deletions crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@
* @module
*/
import {
DIGEST_ALGORITHM_NAMES as wasmDigestAlgorithms,
type DigestAlgorithmName as WasmDigestAlgorithm,
DIGEST_ALGORITHM_NAMES,
type DigestAlgorithmName,
instantiateWasm,
} from "./_wasm/mod.ts";

export { type WasmDigestAlgorithm, wasmDigestAlgorithms };
export { DIGEST_ALGORITHM_NAMES, type DigestAlgorithmName };

/** Digest algorithms supported by WebCrypto. */
const WEB_CRYPTO_DIGEST_ALGORITHM_NAMES = [
Expand Down Expand Up @@ -219,7 +219,7 @@ const stdCrypto: StdCrypto = ((x) => x)({
bytes
) {
return webCrypto.subtle.digest(algorithm, bytes);
} else if (wasmDigestAlgorithms.includes(name as WasmDigestAlgorithm)) {
} else if (DIGEST_ALGORITHM_NAMES.includes(name as DigestAlgorithmName)) {
if (bytes) {
// Otherwise, we use our bundled Wasm implementation via digestSync
// if it supports the algorithm.
Expand Down Expand Up @@ -294,11 +294,26 @@ const stdCrypto: StdCrypto = ((x) => x)({
},
});

/** FNV (Fowler/Noll/Vo) algorithms names. */
/**
* A FNV (Fowler/Noll/Vo) digest algorithm name supported by std/crypto.
*
* @deprecated (will be removed in 1.0.0)
*/
export type FNVAlgorithms = "FNV32" | "FNV32A" | "FNV64" | "FNV64A";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of this export is minimal. A removal version of v1 instead of sooner is overkill and would be non-impactful to remove sooner. See https://github.com/search?q=%22FNVAlgorithms%22&type=code and notice they're almost entirely forks of std. WDYT, @kt3k?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no benefit of removing them earlier in my view.

Breaking at 1.0 is more obvious and less confusing. That is better than breaking at random 0.x version in my view


/** Extended digest algorithm names. */
export type DigestAlgorithmName = WasmDigestAlgorithm | FNVAlgorithms;
/**
* Digest algorithm names supported by std/crypto with a Wasm implementation.
*
* @deprecated (will be removed in 1.0.0) Consider using {@linkcode DIGEST_ALGORITHM_NAMES} instead.
*/
export const wasmDigestAlgorithms = DIGEST_ALGORITHM_NAMES;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* A digest algorithm name supported by std/crypto with a Wasm implementation.
*
* @deprecated (will be removed in 1.0.0) Consider using {@linkcode DigestAlgorithmName} instead.
*/
export type WasmDigestAlgorithm = DigestAlgorithmName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/*
* The largest digest length the current Wasm implementation can support. This
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { assert, assertEquals, assertInstanceOf, fail } from "../assert/mod.ts";
import {
crypto as stdCrypto,
DIGEST_ALGORITHM_NAMES,
type DigestAlgorithmName,
wasmDigestAlgorithms as DIGEST_ALGORITHM_NAMES,
} from "./mod.ts";
import { repeat } from "../bytes/repeat.ts";
import { encodeHex } from "../encoding/hex.ts";
Expand Down