discord-verify
Advanced tools
Comparing version 0.0.2-beta.21 to 0.0.2-beta.22
@@ -1,3 +0,3 @@ | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-206a2779.js'; | ||
export { P as PlatformAlgorithm, h as hexStringToBinary, v as verify } from './verify-206a2779.js'; | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-e358995c.js'; | ||
export { P as PlatformAlgorithm, h as hexStringToBinary, v as verify } from './verify-e358995c.js'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -80,3 +80,4 @@ "use strict"; | ||
Node18: "Ed25519", | ||
Node16: { | ||
Node16: "Ed25519", | ||
Node16_Old: { | ||
name: "NODE-ED25519", | ||
@@ -119,7 +120,15 @@ namedCurve: "NODE-ED25519", | ||
// src/node.ts | ||
function getAlgo(major, minor) { | ||
if (major > 16 || major === 16 && minor >= 17) { | ||
return PlatformAlgorithm.Node18; | ||
} | ||
return PlatformAlgorithm.Node16; | ||
} | ||
async function isValidRequest2(request, publicKey, algorithm) { | ||
const [majorVersion] = import_node_process.default.versions.node.split("."); | ||
const algo = majorVersion >= 18 ? PlatformAlgorithm.Node18 : PlatformAlgorithm.Node16; | ||
const [major, minor] = import_node_process.default.versions.node.split("."); | ||
const majorVersion = Number(major); | ||
const minorVersion = Number(minor); | ||
const algo = algorithm ?? getAlgo(majorVersion, minorVersion); | ||
const subtleCrypto = majorVersion >= 18 ? import_node_crypto.default.subtle : import_node_crypto.default.webcrypto.subtle; | ||
return isValidRequest(request, publicKey, subtleCrypto, algorithm ?? algo); | ||
return isValidRequest(request, publicKey, subtleCrypto, algo); | ||
} | ||
@@ -126,0 +135,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -1,3 +0,3 @@ | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-206a2779.js'; | ||
export { P as PlatformAlgorithm, h as hexStringToBinary, v as verify } from './verify-206a2779.js'; | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-e358995c.js'; | ||
export { P as PlatformAlgorithm, h as hexStringToBinary, v as verify } from './verify-e358995c.js'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -70,3 +70,4 @@ "use strict"; | ||
Node18: "Ed25519", | ||
Node16: { | ||
Node16: "Ed25519", | ||
Node16_Old: { | ||
name: "NODE-ED25519", | ||
@@ -73,0 +74,0 @@ namedCurve: "NODE-ED25519", |
{ | ||
"name": "discord-verify", | ||
"version": "0.0.2-beta.21", | ||
"version": "0.0.2-beta.22", | ||
"author": "Ian Mitchell", | ||
@@ -5,0 +5,0 @@ "description": "A library for verifying the authenticity of requests coming from the Discord Interactions API", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41170
16
699