@sphereon/oid4vc-common
Advanced tools
Comparing version 0.16.1-next.50 to 0.16.1-next.66
@@ -16,2 +16,12 @@ import { JwtHeader, JwtPayload } from '..'; | ||
export declare function epochTime(): number; | ||
export declare const BASE64_URL_REGEX: RegExp; | ||
export declare const isJws: (jws: string) => boolean; | ||
export declare const isJwe: (jwe: string) => boolean; | ||
export declare const decodeProtectedHeader: (jwt: string) => import("jwt-decode").JwtHeader; | ||
export declare const decodeJwt: (jwt: string) => JwtPayload; | ||
export declare const checkExp: (input: { | ||
exp: number; | ||
now?: number; | ||
clockSkew?: number; | ||
}) => boolean; | ||
//# sourceMappingURL=jwtUtils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.epochTime = exports.getNowSkewed = exports.parseJWT = void 0; | ||
exports.checkExp = exports.decodeJwt = exports.decodeProtectedHeader = exports.isJwe = exports.isJws = exports.BASE64_URL_REGEX = exports.epochTime = exports.getNowSkewed = exports.parseJWT = void 0; | ||
const jwt_decode_1 = require("jwt-decode"); | ||
@@ -38,2 +38,26 @@ function parseJWT(jwt) { | ||
exports.epochTime = epochTime; | ||
exports.BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/; | ||
const isJws = (jws) => { | ||
const jwsParts = jws.split('.'); | ||
return jwsParts.length === 3 && jwsParts.every((part) => exports.BASE64_URL_REGEX.test(part)); | ||
}; | ||
exports.isJws = isJws; | ||
const isJwe = (jwe) => { | ||
const jweParts = jwe.split('.'); | ||
return jweParts.length === 5 && jweParts.every((part) => exports.BASE64_URL_REGEX.test(part)); | ||
}; | ||
exports.isJwe = isJwe; | ||
const decodeProtectedHeader = (jwt) => { | ||
return (0, jwt_decode_1.jwtDecode)(jwt, { header: true }); | ||
}; | ||
exports.decodeProtectedHeader = decodeProtectedHeader; | ||
const decodeJwt = (jwt) => { | ||
return (0, jwt_decode_1.jwtDecode)(jwt, { header: false }); | ||
}; | ||
exports.decodeJwt = decodeJwt; | ||
const checkExp = (input) => { | ||
const { exp, now, clockSkew } = input; | ||
return exp < (now !== null && now !== void 0 ? now : Date.now() / 1000) - (clockSkew !== null && clockSkew !== void 0 ? clockSkew : 120); | ||
}; | ||
exports.checkExp = checkExp; | ||
//# sourceMappingURL=jwtUtils.js.map |
@@ -44,1 +44,29 @@ import { jwtDecode } from 'jwt-decode'; | ||
} | ||
export const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/; | ||
export const isJws = (jws: string) => { | ||
const jwsParts = jws.split('.'); | ||
return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part)); | ||
}; | ||
export const isJwe = (jwe: string) => { | ||
const jweParts = jwe.split('.'); | ||
return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part)); | ||
}; | ||
export const decodeProtectedHeader = (jwt: string) => { | ||
return jwtDecode(jwt, { header: true }); | ||
}; | ||
export const decodeJwt = (jwt: string): JwtPayload => { | ||
return jwtDecode(jwt, { header: false }); | ||
}; | ||
export const checkExp = (input: { | ||
exp: number; | ||
now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC). | ||
clockSkew?: number; | ||
}) => { | ||
const { exp, now, clockSkew } = input; | ||
return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120); | ||
}; |
{ | ||
"name": "@sphereon/oid4vc-common", | ||
"version": "0.16.1-next.50+5ea7ad2", | ||
"version": "0.16.1-next.66+f4f0362", | ||
"description": "OpenID 4 Verifiable Credentials Common", | ||
@@ -55,3 +55,3 @@ "source": "lib/index.ts", | ||
}, | ||
"gitHead": "5ea7ad2b66385f5de13f79e0fee138f2c68e0cab" | ||
"gitHead": "f4f0362304526923e3f530bb9cb57782e30da377" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
102247
1511