@upstash/qstash 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/_util/asserts.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv32.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv64.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/index.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/util.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs +631 -630
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/mod.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0/crypto/mod.js → std@0.171.0/crypto/crypto.js} +3 -5
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/keystack.js +1 -1
- package/esm/deps/deno.land/std@0.171.0/crypto/mod.js +13 -0
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/timing_safe_equal.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0/crypto/util.js → std@0.171.0/crypto/to_hash_string.js} +7 -6
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64url.js +1 -1
- package/esm/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/hex.js +1 -1
- package/esm/pkg/client/client.js +7 -7
- package/package.json +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/_util/asserts.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv32.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv64.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/index.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/util.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs +631 -630
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/mod.js +1 -1
- package/script/deps/deno.land/{std@0.167.0/crypto/mod.js → std@0.171.0/crypto/crypto.js} +4 -8
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/keystack.js +1 -1
- package/script/deps/deno.land/std@0.171.0/crypto/mod.js +29 -0
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/timing_safe_equal.js +1 -1
- package/script/deps/deno.land/std@0.171.0/crypto/to_hash_string.js +32 -0
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64url.js +1 -1
- package/script/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/hex.js +1 -1
- package/script/pkg/client/client.js +7 -7
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/_util/asserts.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv32.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/fnv64.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/index.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_fnv/util.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.mts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/_wasm/mod.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0/crypto/mod.d.ts → std@0.171.0/crypto/crypto.d.ts} +2 -4
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/keystack.d.ts +0 -0
- package/types/deps/deno.land/std@0.171.0/crypto/mod.d.ts +12 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/crypto/timing_safe_equal.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0/crypto/util.d.ts → std@0.171.0/crypto/to_hash_string.d.ts} +2 -1
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/base64url.d.ts +0 -0
- package/types/deps/deno.land/{std@0.167.0 → std@0.171.0}/encoding/hex.d.ts +0 -0
- package/types/pkg/client/messages.d.ts +1 -1
- package/types/pkg/receiver.d.ts +1 -1
- package/script/deps/deno.land/std@0.167.0/crypto/util.js +0 -54
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.digestAlgorithms = exports.instantiateWasm = exports.DigestContext = void 0;
|
|
4
|
-
// Copyright 2018-
|
|
4
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
5
5
|
var deno_std_wasm_crypto_generated_js_1 = require("./lib/deno_std_wasm_crypto.generated.js");
|
|
6
6
|
Object.defineProperty(exports, "DigestContext", { enumerable: true, get: function () { return deno_std_wasm_crypto_generated_js_1.DigestContext; } });
|
|
7
7
|
Object.defineProperty(exports, "instantiateWasm", { enumerable: true, get: function () { return deno_std_wasm_crypto_generated_js_1.instantiate; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.crypto =
|
|
27
|
+
exports.crypto = void 0;
|
|
28
28
|
/**
|
|
29
29
|
* Extensions to the
|
|
30
30
|
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
@@ -51,7 +51,7 @@ exports.crypto = exports.toHashString = exports.KeyStack = void 0;
|
|
|
51
51
|
* WebCrypto
|
|
52
52
|
*
|
|
53
53
|
* ```ts
|
|
54
|
-
* // https://deno.land/std/crypto/
|
|
54
|
+
* // https://deno.land/std/crypto/crypto.ts
|
|
55
55
|
* const webCryptoDigestAlgorithms = [
|
|
56
56
|
* "SHA-384",
|
|
57
57
|
* "SHA-256",
|
|
@@ -64,7 +64,7 @@ exports.crypto = exports.toHashString = exports.KeyStack = void 0;
|
|
|
64
64
|
* Wasm/Rust
|
|
65
65
|
*
|
|
66
66
|
* ```ts
|
|
67
|
-
* // https://deno.land/std/_wasm_crypto/
|
|
67
|
+
* // https://deno.land/std/_wasm_crypto/crypto.ts
|
|
68
68
|
* export const digestAlgorithms = [
|
|
69
69
|
* "BLAKE2B-256",
|
|
70
70
|
* "BLAKE2B-384",
|
|
@@ -197,10 +197,6 @@ const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
|
197
197
|
const mod_js_1 = require("./_wasm/mod.js");
|
|
198
198
|
const timing_safe_equal_js_1 = require("./timing_safe_equal.js");
|
|
199
199
|
const index_js_1 = require("./_fnv/index.js");
|
|
200
|
-
var keystack_js_1 = require("./keystack.js");
|
|
201
|
-
Object.defineProperty(exports, "KeyStack", { enumerable: true, get: function () { return keystack_js_1.KeyStack; } });
|
|
202
|
-
var util_js_1 = require("./util.js");
|
|
203
|
-
Object.defineProperty(exports, "toHashString", { enumerable: true, get: function () { return util_js_1.toHashString; } });
|
|
204
200
|
/**
|
|
205
201
|
* A copy of the global WebCrypto interface, with methods bound so they're
|
|
206
202
|
* safe to re-export.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
5
|
if (k2 === undefined) k2 = k;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
/**
|
|
19
|
+
* Extensions to the
|
|
20
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
21
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
22
|
+
* APIs when possible.
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
__exportStar(require("./crypto.js"), exports);
|
|
27
|
+
__exportStar(require("./keystack.js"), exports);
|
|
28
|
+
__exportStar(require("./timing_safe_equal.js"), exports);
|
|
29
|
+
__exportStar(require("./to_hash_string.js"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.timingSafeEqual = void 0;
|
|
5
5
|
const asserts_js_1 = require("../_util/asserts.js");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHashString = void 0;
|
|
4
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
5
|
+
const hex_js_1 = require("../encoding/hex.js");
|
|
6
|
+
const base64_js_1 = require("../encoding/base64.js");
|
|
7
|
+
const decoder = new TextDecoder();
|
|
8
|
+
/**
|
|
9
|
+
* Converts a hash to a string with a given encoding.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { crypto } from "https://deno.land/std@$STD_VERSION/crypto/crypto.ts";
|
|
13
|
+
* import { toHashString } from "https://deno.land/std@$STD_VERSION/crypto/to_hash_string.ts"
|
|
14
|
+
*
|
|
15
|
+
* const hash = await crypto.subtle.digest("SHA-384", new TextEncoder().encode("You hear that Mr. Anderson?"));
|
|
16
|
+
*
|
|
17
|
+
* // Hex encoding by default
|
|
18
|
+
* console.log(toHashString(hash));
|
|
19
|
+
*
|
|
20
|
+
* // Or with base64 encoding
|
|
21
|
+
* console.log(toHashString(hash, "base64"));
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function toHashString(hash, encoding = "hex") {
|
|
25
|
+
switch (encoding) {
|
|
26
|
+
case "hex":
|
|
27
|
+
return decoder.decode((0, hex_js_1.encode)(new Uint8Array(hash)));
|
|
28
|
+
case "base64":
|
|
29
|
+
return (0, base64_js_1.encode)(hash);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.toHashString = toHashString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.decode = exports.encode = void 0;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
3
3
|
// https://github.com/golang/go/blob/master/LICENSE
|
|
4
|
-
// Copyright 2018-
|
|
4
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.decode = exports.encode = void 0;
|
|
7
7
|
/** Port of the Go
|
|
@@ -59,25 +59,25 @@ class Client {
|
|
|
59
59
|
throw new Error("Either url or topic must be set");
|
|
60
60
|
}
|
|
61
61
|
const headers = new Headers(req.headers);
|
|
62
|
-
if (req.delay) {
|
|
62
|
+
if (typeof req.delay !== "undefined") {
|
|
63
63
|
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
|
|
64
64
|
}
|
|
65
|
-
if (req.notBefore) {
|
|
65
|
+
if (typeof req.notBefore !== "undefined") {
|
|
66
66
|
headers.set("Upstash-Not-Before", req.notBefore.toFixed());
|
|
67
67
|
}
|
|
68
|
-
if (req.deduplicationId) {
|
|
68
|
+
if (typeof req.deduplicationId !== "undefined") {
|
|
69
69
|
headers.set("Upstash-Deduplication-Id", req.deduplicationId);
|
|
70
70
|
}
|
|
71
|
-
if (req.contentBasedDeduplication) {
|
|
71
|
+
if (typeof req.contentBasedDeduplication !== "undefined") {
|
|
72
72
|
headers.set("Upstash-Content-Based-Deduplication", "true");
|
|
73
73
|
}
|
|
74
|
-
if (req.retries) {
|
|
74
|
+
if (typeof req.retries !== "undefined") {
|
|
75
75
|
headers.set("Upstash-Retries", req.retries.toFixed());
|
|
76
76
|
}
|
|
77
|
-
if (req.callback) {
|
|
77
|
+
if (typeof req.callback !== "undefined") {
|
|
78
78
|
headers.set("Upstash-Callback", req.callback);
|
|
79
79
|
}
|
|
80
|
-
if (req.cron) {
|
|
80
|
+
if (typeof req.cron !== "undefined") {
|
|
81
81
|
headers.set("Upstash-Cron", req.cron);
|
|
82
82
|
}
|
|
83
83
|
const res = await this.http.request({
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* WebCrypto
|
|
25
25
|
*
|
|
26
26
|
* ```ts
|
|
27
|
-
* // https://deno.land/std/crypto/
|
|
27
|
+
* // https://deno.land/std/crypto/crypto.ts
|
|
28
28
|
* const webCryptoDigestAlgorithms = [
|
|
29
29
|
* "SHA-384",
|
|
30
30
|
* "SHA-256",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* Wasm/Rust
|
|
38
38
|
*
|
|
39
39
|
* ```ts
|
|
40
|
-
* // https://deno.land/std/_wasm_crypto/
|
|
40
|
+
* // https://deno.land/std/_wasm_crypto/crypto.ts
|
|
41
41
|
* export const digestAlgorithms = [
|
|
42
42
|
* "BLAKE2B-256",
|
|
43
43
|
* "BLAKE2B-384",
|
|
@@ -168,8 +168,6 @@
|
|
|
168
168
|
*/
|
|
169
169
|
import * as dntShim from "../../../../_dnt.shims.js";
|
|
170
170
|
import { DigestAlgorithm as WasmDigestAlgorithm } from "./_wasm/mod.js";
|
|
171
|
-
export { type Data, type Key, KeyStack } from "./keystack.js";
|
|
172
|
-
export { toHashString } from "./util.js";
|
|
173
171
|
/** Extensions to the web standard `SubtleCrypto` interface. */
|
|
174
172
|
export interface StdSubtleCrypto extends dntShim.SubtleCrypto {
|
|
175
173
|
/**
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensions to the
|
|
3
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
4
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
5
|
+
* APIs when possible.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export * from "./crypto.js";
|
|
10
|
+
export * from "./keystack.js";
|
|
11
|
+
export * from "./timing_safe_equal.js";
|
|
12
|
+
export * from "./to_hash_string.js";
|
|
File without changes
|
package/types/deps/deno.land/{std@0.167.0/crypto/util.d.ts → std@0.171.0/crypto/to_hash_string.d.ts}
RENAMED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Converts a hash to a string with a given encoding.
|
|
3
3
|
* @example
|
|
4
4
|
* ```ts
|
|
5
|
-
* import { crypto
|
|
5
|
+
* import { crypto } from "https://deno.land/std@$STD_VERSION/crypto/crypto.ts";
|
|
6
|
+
* import { toHashString } from "https://deno.land/std@$STD_VERSION/crypto/to_hash_string.ts"
|
|
6
7
|
*
|
|
7
8
|
* const hash = await crypto.subtle.digest("SHA-384", new TextEncoder().encode("You hear that Mr. Anderson?"));
|
|
8
9
|
*
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/types/pkg/receiver.d.ts
CHANGED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.toHashString = void 0;
|
|
27
|
-
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
28
|
-
const hex = __importStar(require("../encoding/hex.js"));
|
|
29
|
-
const base64 = __importStar(require("../encoding/base64.js"));
|
|
30
|
-
const decoder = new TextDecoder();
|
|
31
|
-
/**
|
|
32
|
-
* Converts a hash to a string with a given encoding.
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* import { crypto, toHashString } from "https://deno.land/std@$STD_VERSION/crypto/mod.ts";
|
|
36
|
-
*
|
|
37
|
-
* const hash = await crypto.subtle.digest("SHA-384", new TextEncoder().encode("You hear that Mr. Anderson?"));
|
|
38
|
-
*
|
|
39
|
-
* // Hex encoding by default
|
|
40
|
-
* console.log(toHashString(hash));
|
|
41
|
-
*
|
|
42
|
-
* // Or with base64 encoding
|
|
43
|
-
* console.log(toHashString(hash, "base64"));
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
function toHashString(hash, encoding = "hex") {
|
|
47
|
-
switch (encoding) {
|
|
48
|
-
case "hex":
|
|
49
|
-
return decoder.decode(hex.encode(new Uint8Array(hash)));
|
|
50
|
-
case "base64":
|
|
51
|
-
return base64.encode(hash);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.toHashString = toHashString;
|