@sphereon/oid4vc-common 0.17.0 → 0.17.1-feature.esm.cjs.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +485 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +297 -0
- package/dist/index.d.ts +296 -8
- package/dist/index.js +425 -26
- package/dist/index.js.map +1 -1
- package/package.json +22 -13
- package/dist/dpop/DPoP.d.ts +0 -60
- package/dist/dpop/DPoP.d.ts.map +0 -1
- package/dist/dpop/DPoP.js +0 -184
- package/dist/dpop/DPoP.js.map +0 -1
- package/dist/dpop/index.d.ts +0 -2
- package/dist/dpop/index.d.ts.map +0 -1
- package/dist/dpop/index.js +0 -18
- package/dist/dpop/index.js.map +0 -1
- package/dist/hasher.d.ts +0 -3
- package/dist/hasher.d.ts.map +0 -1
- package/dist/hasher.js +0 -19
- package/dist/hasher.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/jwt/Jwk.types.d.ts +0 -36
- package/dist/jwt/Jwk.types.d.ts.map +0 -1
- package/dist/jwt/Jwk.types.js +0 -3
- package/dist/jwt/Jwk.types.js.map +0 -1
- package/dist/jwt/JwkThumbprint.d.ts +0 -6
- package/dist/jwt/JwkThumbprint.d.ts.map +0 -1
- package/dist/jwt/JwkThumbprint.js +0 -102
- package/dist/jwt/JwkThumbprint.js.map +0 -1
- package/dist/jwt/Jwt.types.d.ts +0 -23
- package/dist/jwt/Jwt.types.d.ts.map +0 -1
- package/dist/jwt/Jwt.types.js +0 -12
- package/dist/jwt/Jwt.types.js.map +0 -1
- package/dist/jwt/JwtIssuer.d.ts +0 -51
- package/dist/jwt/JwtIssuer.d.ts.map +0 -1
- package/dist/jwt/JwtIssuer.js +0 -3
- package/dist/jwt/JwtIssuer.js.map +0 -1
- package/dist/jwt/JwtVerifier.d.ts +0 -72
- package/dist/jwt/JwtVerifier.d.ts.map +0 -1
- package/dist/jwt/JwtVerifier.js +0 -80
- package/dist/jwt/JwtVerifier.js.map +0 -1
- package/dist/jwt/index.d.ts +0 -7
- package/dist/jwt/index.d.ts.map +0 -1
- package/dist/jwt/index.js +0 -23
- package/dist/jwt/index.js.map +0 -1
- package/dist/jwt/jwtUtils.d.ts +0 -26
- package/dist/jwt/jwtUtils.d.ts.map +0 -1
- package/dist/jwt/jwtUtils.js +0 -62
- package/dist/jwt/jwtUtils.js.map +0 -1
- package/dist/oauth/DynamicClientRegistration.types.d.ts +0 -19
- package/dist/oauth/DynamicClientRegistration.types.d.ts.map +0 -1
- package/dist/oauth/DynamicClientRegistration.types.js +0 -3
- package/dist/oauth/DynamicClientRegistration.types.js.map +0 -1
- package/dist/oauth/index.d.ts +0 -2
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js +0 -18
- package/dist/oauth/index.js.map +0 -1
- package/dist/types/digest.types.d.ts +0 -2
- package/dist/types/digest.types.d.ts.map +0 -1
- package/dist/types/digest.types.js +0 -3
- package/dist/types/digest.types.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/types/index.js.map +0 -1
- package/lib/__tests__/dpop.spec.ts +0 -124
- package/lib/dpop/DPoP.ts +0 -242
- package/lib/dpop/index.ts +0 -1
- package/lib/hasher.ts +0 -18
- package/lib/index.ts +0 -11
- package/lib/jwt/Jwk.types.ts +0 -38
- package/lib/jwt/JwkThumbprint.ts +0 -65
- package/lib/jwt/Jwt.types.ts +0 -26
- package/lib/jwt/JwtIssuer.ts +0 -60
- package/lib/jwt/JwtVerifier.ts +0 -130
- package/lib/jwt/__tests__/JwkThumbprint.spec.ts +0 -16
- package/lib/jwt/index.ts +0 -6
- package/lib/jwt/jwtUtils.ts +0 -71
- package/lib/oauth/DynamicClientRegistration.types.ts +0 -20
- package/lib/oauth/index.ts +0 -1
- package/lib/types/digest.types.ts +0 -1
- package/lib/types/index.ts +0 -1
package/lib/jwt/jwtUtils.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jwtDecode } from 'jwt-decode';
|
|
2
|
-
|
|
3
|
-
import { JwtHeader, JwtPayload } from '..';
|
|
4
|
-
|
|
5
|
-
export type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';
|
|
6
|
-
|
|
7
|
-
export type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';
|
|
8
|
-
|
|
9
|
-
export function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {
|
|
10
|
-
const header = jwtDecode<Header>(jwt, { header: true });
|
|
11
|
-
const payload = jwtDecode<Payload>(jwt, { header: false });
|
|
12
|
-
|
|
13
|
-
if (!payload || !header) {
|
|
14
|
-
throw new Error('Jwt Payload and/or Header could not be parsed');
|
|
15
|
-
}
|
|
16
|
-
return { header, payload };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The maximum allowed clock skew time in seconds. If an time based validation
|
|
21
|
-
* is performed against current time (`now`), the validation can be of by the skew
|
|
22
|
-
* time.
|
|
23
|
-
*
|
|
24
|
-
* See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5
|
|
25
|
-
*/
|
|
26
|
-
const DEFAULT_SKEW_TIME = 60;
|
|
27
|
-
|
|
28
|
-
export function getNowSkewed(now?: number, skewTime?: number) {
|
|
29
|
-
const _now = now ? now : epochTime();
|
|
30
|
-
const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
nowSkewedPast: _now - _skewTime,
|
|
34
|
-
nowSkewedFuture: _now + _skewTime,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns the current unix timestamp in seconds.
|
|
40
|
-
*/
|
|
41
|
-
export function epochTime() {
|
|
42
|
-
return Math.floor(Date.now() / 1000);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
46
|
-
|
|
47
|
-
export const isJws = (jws: string) => {
|
|
48
|
-
const jwsParts = jws.split('.');
|
|
49
|
-
return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));
|
|
50
|
-
};
|
|
51
|
-
export const isJwe = (jwe: string) => {
|
|
52
|
-
const jweParts = jwe.split('.');
|
|
53
|
-
return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const decodeProtectedHeader = (jwt: string) => {
|
|
57
|
-
return jwtDecode(jwt, { header: true });
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const decodeJwt = (jwt: string): JwtPayload => {
|
|
61
|
-
return jwtDecode(jwt, { header: false });
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const checkExp = (input: {
|
|
65
|
-
exp: number;
|
|
66
|
-
now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
67
|
-
clockSkew?: number;
|
|
68
|
-
}) => {
|
|
69
|
-
const { exp, now, clockSkew } = input;
|
|
70
|
-
return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);
|
|
71
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JWKS } from '../jwt';
|
|
2
|
-
|
|
3
|
-
// https://www.rfc-editor.org/rfc/rfc7591.html#section-2
|
|
4
|
-
export interface DynamicRegistrationClientMetadata {
|
|
5
|
-
redirect_uris?: string[];
|
|
6
|
-
token_endpoint_auth_method?: string;
|
|
7
|
-
grant_types?: string;
|
|
8
|
-
response_types?: string;
|
|
9
|
-
client_name?: string;
|
|
10
|
-
client_uri?: string;
|
|
11
|
-
logo_uri?: string;
|
|
12
|
-
scope?: string;
|
|
13
|
-
contacts?: string[];
|
|
14
|
-
tos_uri?: string;
|
|
15
|
-
policy_uri?: string;
|
|
16
|
-
jwks_uri?: string;
|
|
17
|
-
jwks?: JWKS;
|
|
18
|
-
software_id?: string;
|
|
19
|
-
software_version?: string;
|
|
20
|
-
}
|
package/lib/oauth/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DynamicClientRegistration.types';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type DigestAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
package/lib/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './digest.types';
|