discord-verify
Advanced tools
Comparing version 0.0.2-beta.12 to 0.0.2-beta.13
@@ -1,1 +0,13 @@ | ||
export * from "./src/node"; | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-ebfcae1c.js'; | ||
export { h as hexToBinary, v as validate } from './verify-ebfcae1c.js'; | ||
/** | ||
* 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 | ||
*/ | ||
declare function isValidRequest(request: Request, publicKey: string, algorithm?: SubtleCryptoImportKeyAlgorithm | string): Promise<boolean>; | ||
export { isValidRequest }; |
@@ -1,28 +0,21 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
import { | ||
hexToBinary, | ||
isValidRequest, | ||
validate | ||
} from "./chunk-6MTO3YXM.js"; | ||
// src/node.ts | ||
import crypto from "crypto"; | ||
async function isValidRequest2(request, publicKey, algorithm = "Ed25519") { | ||
return isValidRequest( | ||
request, | ||
publicKey, | ||
crypto.subtle, | ||
algorithm | ||
); | ||
} | ||
export { | ||
hexToBinary, | ||
isValidRequest2 as isValidRequest, | ||
validate | ||
}; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./src/node"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./src/node"), exports); | ||
}); | ||
//# sourceMappingURL=node.js.map |
@@ -1,1 +0,13 @@ | ||
export * from "./src/web"; | ||
import { R as Request, S as SubtleCryptoImportKeyAlgorithm } from './verify-ebfcae1c.js'; | ||
export { P as PlatformAlgorithm, h as hexToBinary, v as validate } from './verify-ebfcae1c.js'; | ||
/** | ||
* 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 | ||
*/ | ||
declare function isValidRequest(request: Request, publicKey: string, algorithm?: SubtleCryptoImportKeyAlgorithm | string): Promise<boolean>; | ||
export { isValidRequest }; |
@@ -1,28 +0,17 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
import { | ||
PlatformAlgorithm, | ||
hexToBinary, | ||
isValidRequest, | ||
validate | ||
} from "./chunk-6MTO3YXM.js"; | ||
// src/web.ts | ||
async function isValidRequest2(request, publicKey, algorithm = "Ed25519") { | ||
return isValidRequest(request, publicKey, crypto.subtle, algorithm); | ||
} | ||
export { | ||
PlatformAlgorithm, | ||
hexToBinary, | ||
isValidRequest2 as isValidRequest, | ||
validate | ||
}; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./src/web"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./src/web"), exports); | ||
}); | ||
//# sourceMappingURL=web.js.map |
{ | ||
"name": "discord-verify", | ||
"version": "0.0.2-beta.12", | ||
"version": "0.0.2-beta.13", | ||
"author": "Ian Mitchell", | ||
@@ -9,2 +9,6 @@ "description": "A library for verifying the authenticity of requests coming from the Discord Interactions API", | ||
"exports": { | ||
".": { | ||
"import": "./dist/web.js", | ||
"types": "./dist/web.d.ts" | ||
}, | ||
"./web": { | ||
@@ -16,10 +20,10 @@ "import": "./dist/web.js", | ||
"import": "./dist/node.js", | ||
"require": "./dist/node.cjs", | ||
"types": "./dist/node.d.ts" | ||
} | ||
}, | ||
"main": "./web.js", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"build": "tsc", | ||
"build": "tsup web.ts node.ts --format cjs,esm --dts --clean", | ||
"typecheck": "tsc --noEmit", | ||
@@ -26,0 +30,0 @@ "prettier": "prettier src/**/*.ts --check", |
@@ -1,5 +0,10 @@ | ||
// @ts-expect-error Crypto types are not defined yet | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error | ||
// @ts-ignore-error Node Crypto types are not well defined yet | ||
import crypto from "node:crypto"; | ||
import { isValidRequest as verifyRequest } from "./lib/verify"; | ||
import type { Request, SubtleCryptoImportKeyAlgorithm } from "./types"; | ||
import type { | ||
Request, | ||
SubtleCrypto, | ||
SubtleCryptoImportKeyAlgorithm, | ||
} from "./types"; | ||
export { hexToBinary, validate } from "./lib/verify"; | ||
@@ -19,3 +24,10 @@ | ||
) { | ||
return verifyRequest(request, publicKey, crypto.subtle, algorithm); | ||
return verifyRequest( | ||
request, | ||
publicKey, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error | ||
// @ts-ignore-error Node Crypto types are not well defined yet | ||
crypto.subtle as SubtleCrypto, | ||
algorithm | ||
); | ||
} |
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
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
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
695
24571
17
1