discord-verify
Advanced tools
Comparing version 0.0.2-beta.9 to 0.0.2-beta.10
@@ -1,10 +0,1 @@ | ||
import type { Request, SubtleCryptoImportKeyAlgorithm } from "./types"; | ||
export { hexToBinary, validate } from "./lib/verify"; | ||
/** | ||
* Validates a request from Discord | ||
* @param request Request to verify | ||
* @param publicKey The application's public key | ||
* @param algorithm The name of the crypto algorithm to use | ||
* @returns Whether the request is valid or not | ||
*/ | ||
export declare function isValidRequest(request: Request, publicKey: string, algorithm?: SubtleCryptoImportKeyAlgorithm | string): Promise<boolean>; | ||
export * from "./src/node"; |
@@ -1,15 +0,2 @@ | ||
// @ts-expect-error Crypto types are not defined yet | ||
import crypto from "node:crypto"; | ||
import { isValidRequest as verifyRequest } from "./lib/verify"; | ||
export { hexToBinary, validate } from "./lib/verify"; | ||
/** | ||
* Validates a request from Discord | ||
* @param request Request to verify | ||
* @param publicKey The application's public key | ||
* @param algorithm The name of the crypto algorithm to use | ||
* @returns Whether the request is valid or not | ||
*/ | ||
export async function isValidRequest(request, publicKey, algorithm = "Ed25519") { | ||
return verifyRequest(request, publicKey, crypto.subtle, algorithm); | ||
} | ||
export * from "./src/node"; | ||
//# sourceMappingURL=node.js.map |
@@ -1,10 +0,1 @@ | ||
import type { Request, SubtleCryptoImportKeyAlgorithm } from "./types"; | ||
export { hexToBinary, PlatformAlgorithm, validate } from "./lib/verify"; | ||
/** | ||
* Validates a request from Discord | ||
* @param request Request to verify | ||
* @param publicKey The application's public key | ||
* @param algorithm The name of the crypto algorithm to use | ||
* @returns Whether the request is valid or not | ||
*/ | ||
export declare function isValidRequest(request: Request, publicKey: string, algorithm?: SubtleCryptoImportKeyAlgorithm | string): Promise<boolean>; | ||
export * from "./src/web"; |
@@ -1,15 +0,2 @@ | ||
import { isValidRequest as verifyRequest } from "./lib/verify"; | ||
export { hexToBinary, PlatformAlgorithm, validate } from "./lib/verify"; | ||
/** | ||
* Validates a request from Discord | ||
* @param request Request to verify | ||
* @param publicKey The application's public key | ||
* @param algorithm The name of the crypto algorithm to use | ||
* @returns Whether the request is valid or not | ||
*/ | ||
export async function isValidRequest(request, publicKey, algorithm = "Ed25519") { | ||
// @ts-expect-error We don't have this defined globally due to conflicts | ||
const subtleCrypto = crypto.subtle; | ||
return verifyRequest(request, publicKey, subtleCrypto, algorithm); | ||
} | ||
export * from "./src/web"; | ||
//# sourceMappingURL=web.js.map |
{ | ||
"name": "discord-verify", | ||
"version": "0.0.2-beta.9", | ||
"version": "0.0.2-beta.10", | ||
"author": "Ian Mitchell", | ||
@@ -8,5 +8,13 @@ "description": "A library for verifying the authenticity of requests coming from the Discord Interactions API", | ||
"homepage": "https://github.com/ianmitchell/interaction-kit/tree/main/packages/discord-verify", | ||
"exports": "./dist/web.js", | ||
"main": "./dist/web.js", | ||
"typings": "dist/web.d.ts", | ||
"exports": { | ||
"./web": { | ||
"import": "./web.js", | ||
"types": "./web.d.ts" | ||
}, | ||
"./node": { | ||
"import": "./node.js", | ||
"types": "./node.d.ts" | ||
} | ||
}, | ||
"main": "./web.js", | ||
"type": "module", | ||
@@ -13,0 +21,0 @@ "scripts": { |
@@ -5,8 +5,11 @@ import type { | ||
SubtleCryptoImportKeyAlgorithm, | ||
TextEncoderInstance, | ||
} from "../types"; | ||
// @ts-expect-error We don't have this defined globally due to conflicts | ||
const encoder: TextEncoderInstance = new TextEncoder(); | ||
export declare class TextEncoder { | ||
constructor(); | ||
encode(input?: string): Uint8Array; | ||
} | ||
const encoder = new TextEncoder(); | ||
/** | ||
@@ -13,0 +16,0 @@ * Helper method that takes in a hex string and converts it to its binary representation. |
@@ -16,5 +16,1 @@ /** | ||
export type { Request } from "./request"; | ||
export interface TextEncoderInstance { | ||
encode(input?: string): Uint8Array; | ||
} |
@@ -9,2 +9,6 @@ import { isValidRequest as verifyRequest } from "./lib/verify"; | ||
declare const crypto: { | ||
subtle: SubtleCrypto; | ||
}; | ||
/** | ||
@@ -22,5 +26,3 @@ * Validates a request from Discord | ||
) { | ||
// @ts-expect-error We don't have this defined globally due to conflicts | ||
const subtleCrypto: SubtleCrypto = crypto.subtle; | ||
return verifyRequest(request, publicKey, subtleCrypto, algorithm); | ||
return verifyRequest(request, publicKey, crypto.subtle, algorithm); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24588
33
1