screenshotone-api-sdk 1.1.3 → 1.1.4
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/dist/signature.js +3 -1
- package/package.json +1 -1
- package/src/signature.ts +4 -1
package/dist/signature.js
CHANGED
|
@@ -4,7 +4,9 @@ exports.signQueryString = void 0;
|
|
|
4
4
|
const webcrypto_1 = require("@peculiar/webcrypto");
|
|
5
5
|
const encoder = new TextEncoder();
|
|
6
6
|
async function signQueryString(queryString, secretKey) {
|
|
7
|
-
const webCrypto =
|
|
7
|
+
const webCrypto = typeof globalThis.crypto !== "undefined"
|
|
8
|
+
? globalThis.crypto
|
|
9
|
+
: new webcrypto_1.Crypto();
|
|
8
10
|
let algorithm = { name: "HMAC", hash: "SHA-256" };
|
|
9
11
|
let key = await webCrypto.subtle.importKey("raw", encoder.encode(secretKey), algorithm, false, ["sign", "verify"]);
|
|
10
12
|
const digest = await webCrypto.subtle.sign(algorithm.name, key, encoder.encode(queryString));
|
package/package.json
CHANGED
package/src/signature.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { Crypto } from "@peculiar/webcrypto";
|
|
|
3
3
|
const encoder = new TextEncoder();
|
|
4
4
|
|
|
5
5
|
export async function signQueryString(queryString: string, secretKey: string) {
|
|
6
|
-
const webCrypto =
|
|
6
|
+
const webCrypto =
|
|
7
|
+
typeof globalThis.crypto !== "undefined"
|
|
8
|
+
? globalThis.crypto
|
|
9
|
+
: new Crypto();
|
|
7
10
|
|
|
8
11
|
let algorithm = { name: "HMAC", hash: "SHA-256" };
|
|
9
12
|
let key = await webCrypto.subtle.importKey(
|