Skip to content

Commit

Permalink
deprecation(crypto): rename an export to match style guide, deprecati…
Browse files Browse the repository at this point in the history
…ng original and two other obsolete imports (#4525)
  • Loading branch information
jeremyBanks authored Mar 28, 2024
1 parent 5746475 commit 9af0532
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
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";

/** 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;

/**
* 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;

/*
* 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

0 comments on commit 9af0532

Please sign in to comment.