修改后台权限
This commit is contained in:
30
node_modules/jose/dist/webapi/util/base64url.js
generated
vendored
Normal file
30
node_modules/jose/dist/webapi/util/base64url.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { encoder, decoder } from '../lib/buffer_utils.js';
|
||||
import { encodeBase64, decodeBase64 } from '../lib/base64.js';
|
||||
export function decode(input) {
|
||||
if (Uint8Array.fromBase64) {
|
||||
return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {
|
||||
alphabet: 'base64url',
|
||||
});
|
||||
}
|
||||
let encoded = input;
|
||||
if (encoded instanceof Uint8Array) {
|
||||
encoded = decoder.decode(encoded);
|
||||
}
|
||||
encoded = encoded.replace(/-/g, '+').replace(/_/g, '/');
|
||||
try {
|
||||
return decodeBase64(encoded);
|
||||
}
|
||||
catch {
|
||||
throw new TypeError('The input to be decoded is not correctly encoded.');
|
||||
}
|
||||
}
|
||||
export function encode(input) {
|
||||
let unencoded = input;
|
||||
if (typeof unencoded === 'string') {
|
||||
unencoded = encoder.encode(unencoded);
|
||||
}
|
||||
if (Uint8Array.prototype.toBase64) {
|
||||
return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });
|
||||
}
|
||||
return encodeBase64(unencoded).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||
}
|
||||
32
node_modules/jose/dist/webapi/util/decode_jwt.js
generated
vendored
Normal file
32
node_modules/jose/dist/webapi/util/decode_jwt.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { decode as b64u } from './base64url.js';
|
||||
import { decoder } from '../lib/buffer_utils.js';
|
||||
import { isObject } from '../lib/type_checks.js';
|
||||
import { JWTInvalid } from './errors.js';
|
||||
export function decodeJwt(jwt) {
|
||||
if (typeof jwt !== 'string')
|
||||
throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
|
||||
const { 1: payload, length } = jwt.split('.');
|
||||
if (length === 5)
|
||||
throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');
|
||||
if (length !== 3)
|
||||
throw new JWTInvalid('Invalid JWT');
|
||||
if (!payload)
|
||||
throw new JWTInvalid('JWTs must contain a payload');
|
||||
let decoded;
|
||||
try {
|
||||
decoded = b64u(payload);
|
||||
}
|
||||
catch {
|
||||
throw new JWTInvalid('Failed to base64url decode the payload');
|
||||
}
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(decoder.decode(decoded));
|
||||
}
|
||||
catch {
|
||||
throw new JWTInvalid('Failed to parse the decoded payload as JSON');
|
||||
}
|
||||
if (!isObject(result))
|
||||
throw new JWTInvalid('Invalid JWT Claims Set');
|
||||
return result;
|
||||
}
|
||||
34
node_modules/jose/dist/webapi/util/decode_protected_header.js
generated
vendored
Normal file
34
node_modules/jose/dist/webapi/util/decode_protected_header.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { decode as b64u } from './base64url.js';
|
||||
import { decoder } from '../lib/buffer_utils.js';
|
||||
import { isObject } from '../lib/type_checks.js';
|
||||
export function decodeProtectedHeader(token) {
|
||||
let protectedB64u;
|
||||
if (typeof token === 'string') {
|
||||
const parts = token.split('.');
|
||||
if (parts.length === 3 || parts.length === 5) {
|
||||
;
|
||||
[protectedB64u] = parts;
|
||||
}
|
||||
}
|
||||
else if (typeof token === 'object' && token) {
|
||||
if ('protected' in token) {
|
||||
protectedB64u = token.protected;
|
||||
}
|
||||
else {
|
||||
throw new TypeError('Token does not contain a Protected Header');
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (typeof protectedB64u !== 'string' || !protectedB64u) {
|
||||
throw new Error();
|
||||
}
|
||||
const result = JSON.parse(decoder.decode(b64u(protectedB64u)));
|
||||
if (!isObject(result)) {
|
||||
throw new Error();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch {
|
||||
throw new TypeError('Invalid Token or Protected Header formatting');
|
||||
}
|
||||
}
|
||||
99
node_modules/jose/dist/webapi/util/errors.js
generated
vendored
Normal file
99
node_modules/jose/dist/webapi/util/errors.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
export class JOSEError extends Error {
|
||||
static code = 'ERR_JOSE_GENERIC';
|
||||
code = 'ERR_JOSE_GENERIC';
|
||||
constructor(message, options) {
|
||||
super(message, options);
|
||||
this.name = this.constructor.name;
|
||||
Error.captureStackTrace?.(this, this.constructor);
|
||||
}
|
||||
}
|
||||
export class JWTClaimValidationFailed extends JOSEError {
|
||||
static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
||||
code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
||||
claim;
|
||||
reason;
|
||||
payload;
|
||||
constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {
|
||||
super(message, { cause: { claim, reason, payload } });
|
||||
this.claim = claim;
|
||||
this.reason = reason;
|
||||
this.payload = payload;
|
||||
}
|
||||
}
|
||||
export class JWTExpired extends JOSEError {
|
||||
static code = 'ERR_JWT_EXPIRED';
|
||||
code = 'ERR_JWT_EXPIRED';
|
||||
claim;
|
||||
reason;
|
||||
payload;
|
||||
constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {
|
||||
super(message, { cause: { claim, reason, payload } });
|
||||
this.claim = claim;
|
||||
this.reason = reason;
|
||||
this.payload = payload;
|
||||
}
|
||||
}
|
||||
export class JOSEAlgNotAllowed extends JOSEError {
|
||||
static code = 'ERR_JOSE_ALG_NOT_ALLOWED';
|
||||
code = 'ERR_JOSE_ALG_NOT_ALLOWED';
|
||||
}
|
||||
export class JOSENotSupported extends JOSEError {
|
||||
static code = 'ERR_JOSE_NOT_SUPPORTED';
|
||||
code = 'ERR_JOSE_NOT_SUPPORTED';
|
||||
}
|
||||
export class JWEDecryptionFailed extends JOSEError {
|
||||
static code = 'ERR_JWE_DECRYPTION_FAILED';
|
||||
code = 'ERR_JWE_DECRYPTION_FAILED';
|
||||
constructor(message = 'decryption operation failed', options) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
export class JWEInvalid extends JOSEError {
|
||||
static code = 'ERR_JWE_INVALID';
|
||||
code = 'ERR_JWE_INVALID';
|
||||
}
|
||||
export class JWSInvalid extends JOSEError {
|
||||
static code = 'ERR_JWS_INVALID';
|
||||
code = 'ERR_JWS_INVALID';
|
||||
}
|
||||
export class JWTInvalid extends JOSEError {
|
||||
static code = 'ERR_JWT_INVALID';
|
||||
code = 'ERR_JWT_INVALID';
|
||||
}
|
||||
export class JWKInvalid extends JOSEError {
|
||||
static code = 'ERR_JWK_INVALID';
|
||||
code = 'ERR_JWK_INVALID';
|
||||
}
|
||||
export class JWKSInvalid extends JOSEError {
|
||||
static code = 'ERR_JWKS_INVALID';
|
||||
code = 'ERR_JWKS_INVALID';
|
||||
}
|
||||
export class JWKSNoMatchingKey extends JOSEError {
|
||||
static code = 'ERR_JWKS_NO_MATCHING_KEY';
|
||||
code = 'ERR_JWKS_NO_MATCHING_KEY';
|
||||
constructor(message = 'no applicable key found in the JSON Web Key Set', options) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
export class JWKSMultipleMatchingKeys extends JOSEError {
|
||||
[Symbol.asyncIterator];
|
||||
static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
||||
code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
||||
constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
export class JWKSTimeout extends JOSEError {
|
||||
static code = 'ERR_JWKS_TIMEOUT';
|
||||
code = 'ERR_JWKS_TIMEOUT';
|
||||
constructor(message = 'request timed out', options) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
export class JWSSignatureVerificationFailed extends JOSEError {
|
||||
static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
||||
code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
||||
constructor(message = 'signature verification failed', options) {
|
||||
super(message, options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user