Aktueller Stand
This commit is contained in:
29
backend/node_modules/hono/dist/cjs/utils/jwt/index.js
generated
vendored
Normal file
29
backend/node_modules/hono/dist/cjs/utils/jwt/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jwt_exports = {};
|
||||
__export(jwt_exports, {
|
||||
Jwt: () => Jwt
|
||||
});
|
||||
module.exports = __toCommonJS(jwt_exports);
|
||||
var import_jwt = require("./jwt");
|
||||
const Jwt = { sign: import_jwt.sign, verify: import_jwt.verify, decode: import_jwt.decode, verifyWithJwks: import_jwt.verifyWithJwks };
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Jwt
|
||||
});
|
||||
43
backend/node_modules/hono/dist/cjs/utils/jwt/jwa.js
generated
vendored
Normal file
43
backend/node_modules/hono/dist/cjs/utils/jwt/jwa.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jwa_exports = {};
|
||||
__export(jwa_exports, {
|
||||
AlgorithmTypes: () => AlgorithmTypes
|
||||
});
|
||||
module.exports = __toCommonJS(jwa_exports);
|
||||
var AlgorithmTypes = /* @__PURE__ */ ((AlgorithmTypes2) => {
|
||||
AlgorithmTypes2["HS256"] = "HS256";
|
||||
AlgorithmTypes2["HS384"] = "HS384";
|
||||
AlgorithmTypes2["HS512"] = "HS512";
|
||||
AlgorithmTypes2["RS256"] = "RS256";
|
||||
AlgorithmTypes2["RS384"] = "RS384";
|
||||
AlgorithmTypes2["RS512"] = "RS512";
|
||||
AlgorithmTypes2["PS256"] = "PS256";
|
||||
AlgorithmTypes2["PS384"] = "PS384";
|
||||
AlgorithmTypes2["PS512"] = "PS512";
|
||||
AlgorithmTypes2["ES256"] = "ES256";
|
||||
AlgorithmTypes2["ES384"] = "ES384";
|
||||
AlgorithmTypes2["ES512"] = "ES512";
|
||||
AlgorithmTypes2["EdDSA"] = "EdDSA";
|
||||
return AlgorithmTypes2;
|
||||
})(AlgorithmTypes || {});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
AlgorithmTypes
|
||||
});
|
||||
216
backend/node_modules/hono/dist/cjs/utils/jwt/jws.js
generated
vendored
Normal file
216
backend/node_modules/hono/dist/cjs/utils/jwt/jws.js
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jws_exports = {};
|
||||
__export(jws_exports, {
|
||||
signing: () => signing,
|
||||
verifying: () => verifying
|
||||
});
|
||||
module.exports = __toCommonJS(jws_exports);
|
||||
var import_adapter = require("../../helper/adapter");
|
||||
var import_encode = require("../encode");
|
||||
var import_types = require("./types");
|
||||
var import_utf8 = require("./utf8");
|
||||
async function signing(privateKey, alg, data) {
|
||||
const algorithm = getKeyAlgorithm(alg);
|
||||
const cryptoKey = await importPrivateKey(privateKey, algorithm);
|
||||
return await crypto.subtle.sign(algorithm, cryptoKey, data);
|
||||
}
|
||||
async function verifying(publicKey, alg, signature, data) {
|
||||
const algorithm = getKeyAlgorithm(alg);
|
||||
const cryptoKey = await importPublicKey(publicKey, algorithm);
|
||||
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
||||
}
|
||||
function pemToBinary(pem) {
|
||||
return (0, import_encode.decodeBase64)(pem.replace(/-+(BEGIN|END).*/g, "").replace(/\s/g, ""));
|
||||
}
|
||||
async function importPrivateKey(key, alg) {
|
||||
if (!crypto.subtle || !crypto.subtle.importKey) {
|
||||
throw new Error("`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.");
|
||||
}
|
||||
if (isCryptoKey(key)) {
|
||||
if (key.type !== "private" && key.type !== "secret") {
|
||||
throw new Error(
|
||||
`unexpected key type: CryptoKey.type is ${key.type}, expected private or secret`
|
||||
);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
const usages = [import_types.CryptoKeyUsage.Sign];
|
||||
if (typeof key === "object") {
|
||||
return await crypto.subtle.importKey("jwk", key, alg, false, usages);
|
||||
}
|
||||
if (key.includes("PRIVATE")) {
|
||||
return await crypto.subtle.importKey("pkcs8", pemToBinary(key), alg, false, usages);
|
||||
}
|
||||
return await crypto.subtle.importKey("raw", import_utf8.utf8Encoder.encode(key), alg, false, usages);
|
||||
}
|
||||
async function importPublicKey(key, alg) {
|
||||
if (!crypto.subtle || !crypto.subtle.importKey) {
|
||||
throw new Error("`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.");
|
||||
}
|
||||
if (isCryptoKey(key)) {
|
||||
if (key.type === "public" || key.type === "secret") {
|
||||
return key;
|
||||
}
|
||||
key = await exportPublicJwkFrom(key);
|
||||
}
|
||||
if (typeof key === "string" && key.includes("PRIVATE")) {
|
||||
const privateKey = await crypto.subtle.importKey("pkcs8", pemToBinary(key), alg, true, [
|
||||
import_types.CryptoKeyUsage.Sign
|
||||
]);
|
||||
key = await exportPublicJwkFrom(privateKey);
|
||||
}
|
||||
const usages = [import_types.CryptoKeyUsage.Verify];
|
||||
if (typeof key === "object") {
|
||||
return await crypto.subtle.importKey("jwk", key, alg, false, usages);
|
||||
}
|
||||
if (key.includes("PUBLIC")) {
|
||||
return await crypto.subtle.importKey("spki", pemToBinary(key), alg, false, usages);
|
||||
}
|
||||
return await crypto.subtle.importKey("raw", import_utf8.utf8Encoder.encode(key), alg, false, usages);
|
||||
}
|
||||
async function exportPublicJwkFrom(privateKey) {
|
||||
if (privateKey.type !== "private") {
|
||||
throw new Error(`unexpected key type: ${privateKey.type}`);
|
||||
}
|
||||
if (!privateKey.extractable) {
|
||||
throw new Error("unexpected private key is unextractable");
|
||||
}
|
||||
const jwk = await crypto.subtle.exportKey("jwk", privateKey);
|
||||
const { kty } = jwk;
|
||||
const { alg, e, n } = jwk;
|
||||
const { crv, x, y } = jwk;
|
||||
return { kty, alg, e, n, crv, x, y, key_ops: [import_types.CryptoKeyUsage.Verify] };
|
||||
}
|
||||
function getKeyAlgorithm(name) {
|
||||
switch (name) {
|
||||
case "HS256":
|
||||
return {
|
||||
name: "HMAC",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
}
|
||||
};
|
||||
case "HS384":
|
||||
return {
|
||||
name: "HMAC",
|
||||
hash: {
|
||||
name: "SHA-384"
|
||||
}
|
||||
};
|
||||
case "HS512":
|
||||
return {
|
||||
name: "HMAC",
|
||||
hash: {
|
||||
name: "SHA-512"
|
||||
}
|
||||
};
|
||||
case "RS256":
|
||||
return {
|
||||
name: "RSASSA-PKCS1-v1_5",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
}
|
||||
};
|
||||
case "RS384":
|
||||
return {
|
||||
name: "RSASSA-PKCS1-v1_5",
|
||||
hash: {
|
||||
name: "SHA-384"
|
||||
}
|
||||
};
|
||||
case "RS512":
|
||||
return {
|
||||
name: "RSASSA-PKCS1-v1_5",
|
||||
hash: {
|
||||
name: "SHA-512"
|
||||
}
|
||||
};
|
||||
case "PS256":
|
||||
return {
|
||||
name: "RSA-PSS",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
},
|
||||
saltLength: 32
|
||||
// 256 >> 3
|
||||
};
|
||||
case "PS384":
|
||||
return {
|
||||
name: "RSA-PSS",
|
||||
hash: {
|
||||
name: "SHA-384"
|
||||
},
|
||||
saltLength: 48
|
||||
// 384 >> 3
|
||||
};
|
||||
case "PS512":
|
||||
return {
|
||||
name: "RSA-PSS",
|
||||
hash: {
|
||||
name: "SHA-512"
|
||||
},
|
||||
saltLength: 64
|
||||
// 512 >> 3,
|
||||
};
|
||||
case "ES256":
|
||||
return {
|
||||
name: "ECDSA",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
},
|
||||
namedCurve: "P-256"
|
||||
};
|
||||
case "ES384":
|
||||
return {
|
||||
name: "ECDSA",
|
||||
hash: {
|
||||
name: "SHA-384"
|
||||
},
|
||||
namedCurve: "P-384"
|
||||
};
|
||||
case "ES512":
|
||||
return {
|
||||
name: "ECDSA",
|
||||
hash: {
|
||||
name: "SHA-512"
|
||||
},
|
||||
namedCurve: "P-521"
|
||||
};
|
||||
case "EdDSA":
|
||||
return {
|
||||
name: "Ed25519",
|
||||
namedCurve: "Ed25519"
|
||||
};
|
||||
default:
|
||||
throw new import_types.JwtAlgorithmNotImplemented(name);
|
||||
}
|
||||
}
|
||||
function isCryptoKey(key) {
|
||||
const runtime = (0, import_adapter.getRuntimeKey)();
|
||||
if (runtime === "node" && !!crypto.webcrypto) {
|
||||
return key instanceof crypto.webcrypto.CryptoKey;
|
||||
}
|
||||
return key instanceof CryptoKey;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
signing,
|
||||
verifying
|
||||
});
|
||||
210
backend/node_modules/hono/dist/cjs/utils/jwt/jwt.js
generated
vendored
Normal file
210
backend/node_modules/hono/dist/cjs/utils/jwt/jwt.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jwt_exports = {};
|
||||
__export(jwt_exports, {
|
||||
decode: () => decode,
|
||||
decodeHeader: () => decodeHeader,
|
||||
isTokenHeader: () => isTokenHeader,
|
||||
sign: () => sign,
|
||||
verify: () => verify,
|
||||
verifyWithJwks: () => verifyWithJwks
|
||||
});
|
||||
module.exports = __toCommonJS(jwt_exports);
|
||||
var import_encode = require("../../utils/encode");
|
||||
var import_jwa = require("./jwa");
|
||||
var import_jws = require("./jws");
|
||||
var import_types = require("./types");
|
||||
var import_utf8 = require("./utf8");
|
||||
const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, "");
|
||||
const encodeSignaturePart = (buf) => (0, import_encode.encodeBase64Url)(buf).replace(/=/g, "");
|
||||
const decodeJwtPart = (part) => JSON.parse(import_utf8.utf8Decoder.decode((0, import_encode.decodeBase64Url)(part)));
|
||||
function isTokenHeader(obj) {
|
||||
if (typeof obj === "object" && obj !== null) {
|
||||
const objWithAlg = obj;
|
||||
return "alg" in objWithAlg && Object.values(import_jwa.AlgorithmTypes).includes(objWithAlg.alg) && (!("typ" in objWithAlg) || objWithAlg.typ === "JWT");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const sign = async (payload, privateKey, alg = "HS256") => {
|
||||
const encodedPayload = encodeJwtPart(payload);
|
||||
let encodedHeader;
|
||||
if (typeof privateKey === "object" && "alg" in privateKey) {
|
||||
alg = privateKey.alg;
|
||||
encodedHeader = encodeJwtPart({ alg, typ: "JWT", kid: privateKey.kid });
|
||||
} else {
|
||||
encodedHeader = encodeJwtPart({ alg, typ: "JWT" });
|
||||
}
|
||||
const partialToken = `${encodedHeader}.${encodedPayload}`;
|
||||
const signaturePart = await (0, import_jws.signing)(privateKey, alg, import_utf8.utf8Encoder.encode(partialToken));
|
||||
const signature = encodeSignaturePart(signaturePart);
|
||||
return `${partialToken}.${signature}`;
|
||||
};
|
||||
const verify = async (token, publicKey, algOrOptions) => {
|
||||
if (!algOrOptions) {
|
||||
throw new import_types.JwtAlgorithmRequired();
|
||||
}
|
||||
const {
|
||||
alg,
|
||||
iss,
|
||||
nbf = true,
|
||||
exp = true,
|
||||
iat = true,
|
||||
aud
|
||||
} = typeof algOrOptions === "string" ? { alg: algOrOptions } : algOrOptions;
|
||||
if (!alg) {
|
||||
throw new import_types.JwtAlgorithmRequired();
|
||||
}
|
||||
const tokenParts = token.split(".");
|
||||
if (tokenParts.length !== 3) {
|
||||
throw new import_types.JwtTokenInvalid(token);
|
||||
}
|
||||
const { header, payload } = decode(token);
|
||||
if (!isTokenHeader(header)) {
|
||||
throw new import_types.JwtHeaderInvalid(header);
|
||||
}
|
||||
if (header.alg !== alg) {
|
||||
throw new import_types.JwtAlgorithmMismatch(alg, header.alg);
|
||||
}
|
||||
const now = Date.now() / 1e3 | 0;
|
||||
if (nbf && payload.nbf && payload.nbf > now) {
|
||||
throw new import_types.JwtTokenNotBefore(token);
|
||||
}
|
||||
if (exp && payload.exp && payload.exp <= now) {
|
||||
throw new import_types.JwtTokenExpired(token);
|
||||
}
|
||||
if (iat && payload.iat && now < payload.iat) {
|
||||
throw new import_types.JwtTokenIssuedAt(now, payload.iat);
|
||||
}
|
||||
if (iss) {
|
||||
if (!payload.iss) {
|
||||
throw new import_types.JwtTokenIssuer(iss, null);
|
||||
}
|
||||
if (typeof iss === "string" && payload.iss !== iss) {
|
||||
throw new import_types.JwtTokenIssuer(iss, payload.iss);
|
||||
}
|
||||
if (iss instanceof RegExp && !iss.test(payload.iss)) {
|
||||
throw new import_types.JwtTokenIssuer(iss, payload.iss);
|
||||
}
|
||||
}
|
||||
if (aud) {
|
||||
if (!payload.aud) {
|
||||
throw new import_types.JwtPayloadRequiresAud(payload);
|
||||
}
|
||||
const audiences = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
|
||||
const matched = audiences.some(
|
||||
(payloadAud) => aud instanceof RegExp ? aud.test(payloadAud) : typeof aud === "string" ? payloadAud === aud : Array.isArray(aud) && aud.includes(payloadAud)
|
||||
);
|
||||
if (!matched) {
|
||||
throw new import_types.JwtTokenAudience(aud, payload.aud);
|
||||
}
|
||||
}
|
||||
const headerPayload = token.substring(0, token.lastIndexOf("."));
|
||||
const verified = await (0, import_jws.verifying)(
|
||||
publicKey,
|
||||
alg,
|
||||
(0, import_encode.decodeBase64Url)(tokenParts[2]),
|
||||
import_utf8.utf8Encoder.encode(headerPayload)
|
||||
);
|
||||
if (!verified) {
|
||||
throw new import_types.JwtTokenSignatureMismatched(token);
|
||||
}
|
||||
return payload;
|
||||
};
|
||||
const symmetricAlgorithms = [
|
||||
import_jwa.AlgorithmTypes.HS256,
|
||||
import_jwa.AlgorithmTypes.HS384,
|
||||
import_jwa.AlgorithmTypes.HS512
|
||||
];
|
||||
const verifyWithJwks = async (token, options, init) => {
|
||||
const verifyOpts = options.verification || {};
|
||||
const header = decodeHeader(token);
|
||||
if (!isTokenHeader(header)) {
|
||||
throw new import_types.JwtHeaderInvalid(header);
|
||||
}
|
||||
if (!header.kid) {
|
||||
throw new import_types.JwtHeaderRequiresKid(header);
|
||||
}
|
||||
if (symmetricAlgorithms.includes(header.alg)) {
|
||||
throw new import_types.JwtSymmetricAlgorithmNotAllowed(header.alg);
|
||||
}
|
||||
if (!options.allowedAlgorithms.includes(header.alg)) {
|
||||
throw new import_types.JwtAlgorithmNotAllowed(header.alg, options.allowedAlgorithms);
|
||||
}
|
||||
if (options.jwks_uri) {
|
||||
const response = await fetch(options.jwks_uri, init);
|
||||
if (!response.ok) {
|
||||
throw new Error(`failed to fetch JWKS from ${options.jwks_uri}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
if (!data.keys) {
|
||||
throw new Error('invalid JWKS response. "keys" field is missing');
|
||||
}
|
||||
if (!Array.isArray(data.keys)) {
|
||||
throw new Error('invalid JWKS response. "keys" field is not an array');
|
||||
}
|
||||
if (options.keys) {
|
||||
options.keys.push(...data.keys);
|
||||
} else {
|
||||
options.keys = data.keys;
|
||||
}
|
||||
} else if (!options.keys) {
|
||||
throw new Error('verifyWithJwks requires options for either "keys" or "jwks_uri" or both');
|
||||
}
|
||||
const matchingKey = options.keys.find((key) => key.kid === header.kid);
|
||||
if (!matchingKey) {
|
||||
throw new import_types.JwtTokenInvalid(token);
|
||||
}
|
||||
if (matchingKey.alg && matchingKey.alg !== header.alg) {
|
||||
throw new import_types.JwtAlgorithmMismatch(matchingKey.alg, header.alg);
|
||||
}
|
||||
return await verify(token, matchingKey, {
|
||||
alg: header.alg,
|
||||
...verifyOpts
|
||||
});
|
||||
};
|
||||
const decode = (token) => {
|
||||
try {
|
||||
const [h, p] = token.split(".");
|
||||
const header = decodeJwtPart(h);
|
||||
const payload = decodeJwtPart(p);
|
||||
return {
|
||||
header,
|
||||
payload
|
||||
};
|
||||
} catch {
|
||||
throw new import_types.JwtTokenInvalid(token);
|
||||
}
|
||||
};
|
||||
const decodeHeader = (token) => {
|
||||
try {
|
||||
const [h] = token.split(".");
|
||||
return decodeJwtPart(h);
|
||||
} catch {
|
||||
throw new import_types.JwtTokenInvalid(token);
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
decode,
|
||||
decodeHeader,
|
||||
isTokenHeader,
|
||||
sign,
|
||||
verify,
|
||||
verifyWithJwks
|
||||
});
|
||||
162
backend/node_modules/hono/dist/cjs/utils/jwt/types.js
generated
vendored
Normal file
162
backend/node_modules/hono/dist/cjs/utils/jwt/types.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var types_exports = {};
|
||||
__export(types_exports, {
|
||||
CryptoKeyUsage: () => CryptoKeyUsage,
|
||||
JwtAlgorithmMismatch: () => JwtAlgorithmMismatch,
|
||||
JwtAlgorithmNotAllowed: () => JwtAlgorithmNotAllowed,
|
||||
JwtAlgorithmNotImplemented: () => JwtAlgorithmNotImplemented,
|
||||
JwtAlgorithmRequired: () => JwtAlgorithmRequired,
|
||||
JwtHeaderInvalid: () => JwtHeaderInvalid,
|
||||
JwtHeaderRequiresKid: () => JwtHeaderRequiresKid,
|
||||
JwtPayloadRequiresAud: () => JwtPayloadRequiresAud,
|
||||
JwtSymmetricAlgorithmNotAllowed: () => JwtSymmetricAlgorithmNotAllowed,
|
||||
JwtTokenAudience: () => JwtTokenAudience,
|
||||
JwtTokenExpired: () => JwtTokenExpired,
|
||||
JwtTokenInvalid: () => JwtTokenInvalid,
|
||||
JwtTokenIssuedAt: () => JwtTokenIssuedAt,
|
||||
JwtTokenIssuer: () => JwtTokenIssuer,
|
||||
JwtTokenNotBefore: () => JwtTokenNotBefore,
|
||||
JwtTokenSignatureMismatched: () => JwtTokenSignatureMismatched
|
||||
});
|
||||
module.exports = __toCommonJS(types_exports);
|
||||
class JwtAlgorithmNotImplemented extends Error {
|
||||
constructor(alg) {
|
||||
super(`${alg} is not an implemented algorithm`);
|
||||
this.name = "JwtAlgorithmNotImplemented";
|
||||
}
|
||||
}
|
||||
class JwtAlgorithmRequired extends Error {
|
||||
constructor() {
|
||||
super('JWT verification requires "alg" option to be specified');
|
||||
this.name = "JwtAlgorithmRequired";
|
||||
}
|
||||
}
|
||||
class JwtAlgorithmMismatch extends Error {
|
||||
constructor(expected, actual) {
|
||||
super(`JWT algorithm mismatch: expected "${expected}", got "${actual}"`);
|
||||
this.name = "JwtAlgorithmMismatch";
|
||||
}
|
||||
}
|
||||
class JwtTokenInvalid extends Error {
|
||||
constructor(token) {
|
||||
super(`invalid JWT token: ${token}`);
|
||||
this.name = "JwtTokenInvalid";
|
||||
}
|
||||
}
|
||||
class JwtTokenNotBefore extends Error {
|
||||
constructor(token) {
|
||||
super(`token (${token}) is being used before it's valid`);
|
||||
this.name = "JwtTokenNotBefore";
|
||||
}
|
||||
}
|
||||
class JwtTokenExpired extends Error {
|
||||
constructor(token) {
|
||||
super(`token (${token}) expired`);
|
||||
this.name = "JwtTokenExpired";
|
||||
}
|
||||
}
|
||||
class JwtTokenIssuedAt extends Error {
|
||||
constructor(currentTimestamp, iat) {
|
||||
super(
|
||||
`Invalid "iat" claim, must be a valid number lower than "${currentTimestamp}" (iat: "${iat}")`
|
||||
);
|
||||
this.name = "JwtTokenIssuedAt";
|
||||
}
|
||||
}
|
||||
class JwtTokenIssuer extends Error {
|
||||
constructor(expected, iss) {
|
||||
super(`expected issuer "${expected}", got ${iss ? `"${iss}"` : "none"} `);
|
||||
this.name = "JwtTokenIssuer";
|
||||
}
|
||||
}
|
||||
class JwtHeaderInvalid extends Error {
|
||||
constructor(header) {
|
||||
super(`jwt header is invalid: ${JSON.stringify(header)}`);
|
||||
this.name = "JwtHeaderInvalid";
|
||||
}
|
||||
}
|
||||
class JwtHeaderRequiresKid extends Error {
|
||||
constructor(header) {
|
||||
super(`required "kid" in jwt header: ${JSON.stringify(header)}`);
|
||||
this.name = "JwtHeaderRequiresKid";
|
||||
}
|
||||
}
|
||||
class JwtSymmetricAlgorithmNotAllowed extends Error {
|
||||
constructor(alg) {
|
||||
super(`symmetric algorithm "${alg}" is not allowed for JWK verification`);
|
||||
this.name = "JwtSymmetricAlgorithmNotAllowed";
|
||||
}
|
||||
}
|
||||
class JwtAlgorithmNotAllowed extends Error {
|
||||
constructor(alg, allowedAlgorithms) {
|
||||
super(`algorithm "${alg}" is not in the allowed list: [${allowedAlgorithms.join(", ")}]`);
|
||||
this.name = "JwtAlgorithmNotAllowed";
|
||||
}
|
||||
}
|
||||
class JwtTokenSignatureMismatched extends Error {
|
||||
constructor(token) {
|
||||
super(`token(${token}) signature mismatched`);
|
||||
this.name = "JwtTokenSignatureMismatched";
|
||||
}
|
||||
}
|
||||
class JwtPayloadRequiresAud extends Error {
|
||||
constructor(payload) {
|
||||
super(`required "aud" in jwt payload: ${JSON.stringify(payload)}`);
|
||||
this.name = "JwtPayloadRequiresAud";
|
||||
}
|
||||
}
|
||||
class JwtTokenAudience extends Error {
|
||||
constructor(expected, aud) {
|
||||
super(
|
||||
`expected audience "${Array.isArray(expected) ? expected.join(", ") : expected}", got "${aud}"`
|
||||
);
|
||||
this.name = "JwtTokenAudience";
|
||||
}
|
||||
}
|
||||
var CryptoKeyUsage = /* @__PURE__ */ ((CryptoKeyUsage2) => {
|
||||
CryptoKeyUsage2["Encrypt"] = "encrypt";
|
||||
CryptoKeyUsage2["Decrypt"] = "decrypt";
|
||||
CryptoKeyUsage2["Sign"] = "sign";
|
||||
CryptoKeyUsage2["Verify"] = "verify";
|
||||
CryptoKeyUsage2["DeriveKey"] = "deriveKey";
|
||||
CryptoKeyUsage2["DeriveBits"] = "deriveBits";
|
||||
CryptoKeyUsage2["WrapKey"] = "wrapKey";
|
||||
CryptoKeyUsage2["UnwrapKey"] = "unwrapKey";
|
||||
return CryptoKeyUsage2;
|
||||
})(CryptoKeyUsage || {});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
CryptoKeyUsage,
|
||||
JwtAlgorithmMismatch,
|
||||
JwtAlgorithmNotAllowed,
|
||||
JwtAlgorithmNotImplemented,
|
||||
JwtAlgorithmRequired,
|
||||
JwtHeaderInvalid,
|
||||
JwtHeaderRequiresKid,
|
||||
JwtPayloadRequiresAud,
|
||||
JwtSymmetricAlgorithmNotAllowed,
|
||||
JwtTokenAudience,
|
||||
JwtTokenExpired,
|
||||
JwtTokenInvalid,
|
||||
JwtTokenIssuedAt,
|
||||
JwtTokenIssuer,
|
||||
JwtTokenNotBefore,
|
||||
JwtTokenSignatureMismatched
|
||||
});
|
||||
31
backend/node_modules/hono/dist/cjs/utils/jwt/utf8.js
generated
vendored
Normal file
31
backend/node_modules/hono/dist/cjs/utils/jwt/utf8.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var utf8_exports = {};
|
||||
__export(utf8_exports, {
|
||||
utf8Decoder: () => utf8Decoder,
|
||||
utf8Encoder: () => utf8Encoder
|
||||
});
|
||||
module.exports = __toCommonJS(utf8_exports);
|
||||
const utf8Encoder = new TextEncoder();
|
||||
const utf8Decoder = new TextDecoder();
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
utf8Decoder,
|
||||
utf8Encoder
|
||||
});
|
||||
Reference in New Issue
Block a user