@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.
Files changed (81) hide show
  1. package/dist/index.cjs +485 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +297 -0
  4. package/dist/index.d.ts +296 -8
  5. package/dist/index.js +425 -26
  6. package/dist/index.js.map +1 -1
  7. package/package.json +22 -13
  8. package/dist/dpop/DPoP.d.ts +0 -60
  9. package/dist/dpop/DPoP.d.ts.map +0 -1
  10. package/dist/dpop/DPoP.js +0 -184
  11. package/dist/dpop/DPoP.js.map +0 -1
  12. package/dist/dpop/index.d.ts +0 -2
  13. package/dist/dpop/index.d.ts.map +0 -1
  14. package/dist/dpop/index.js +0 -18
  15. package/dist/dpop/index.js.map +0 -1
  16. package/dist/hasher.d.ts +0 -3
  17. package/dist/hasher.d.ts.map +0 -1
  18. package/dist/hasher.js +0 -19
  19. package/dist/hasher.js.map +0 -1
  20. package/dist/index.d.ts.map +0 -1
  21. package/dist/jwt/Jwk.types.d.ts +0 -36
  22. package/dist/jwt/Jwk.types.d.ts.map +0 -1
  23. package/dist/jwt/Jwk.types.js +0 -3
  24. package/dist/jwt/Jwk.types.js.map +0 -1
  25. package/dist/jwt/JwkThumbprint.d.ts +0 -6
  26. package/dist/jwt/JwkThumbprint.d.ts.map +0 -1
  27. package/dist/jwt/JwkThumbprint.js +0 -102
  28. package/dist/jwt/JwkThumbprint.js.map +0 -1
  29. package/dist/jwt/Jwt.types.d.ts +0 -23
  30. package/dist/jwt/Jwt.types.d.ts.map +0 -1
  31. package/dist/jwt/Jwt.types.js +0 -12
  32. package/dist/jwt/Jwt.types.js.map +0 -1
  33. package/dist/jwt/JwtIssuer.d.ts +0 -51
  34. package/dist/jwt/JwtIssuer.d.ts.map +0 -1
  35. package/dist/jwt/JwtIssuer.js +0 -3
  36. package/dist/jwt/JwtIssuer.js.map +0 -1
  37. package/dist/jwt/JwtVerifier.d.ts +0 -72
  38. package/dist/jwt/JwtVerifier.d.ts.map +0 -1
  39. package/dist/jwt/JwtVerifier.js +0 -80
  40. package/dist/jwt/JwtVerifier.js.map +0 -1
  41. package/dist/jwt/index.d.ts +0 -7
  42. package/dist/jwt/index.d.ts.map +0 -1
  43. package/dist/jwt/index.js +0 -23
  44. package/dist/jwt/index.js.map +0 -1
  45. package/dist/jwt/jwtUtils.d.ts +0 -26
  46. package/dist/jwt/jwtUtils.d.ts.map +0 -1
  47. package/dist/jwt/jwtUtils.js +0 -62
  48. package/dist/jwt/jwtUtils.js.map +0 -1
  49. package/dist/oauth/DynamicClientRegistration.types.d.ts +0 -19
  50. package/dist/oauth/DynamicClientRegistration.types.d.ts.map +0 -1
  51. package/dist/oauth/DynamicClientRegistration.types.js +0 -3
  52. package/dist/oauth/DynamicClientRegistration.types.js.map +0 -1
  53. package/dist/oauth/index.d.ts +0 -2
  54. package/dist/oauth/index.d.ts.map +0 -1
  55. package/dist/oauth/index.js +0 -18
  56. package/dist/oauth/index.js.map +0 -1
  57. package/dist/types/digest.types.d.ts +0 -2
  58. package/dist/types/digest.types.d.ts.map +0 -1
  59. package/dist/types/digest.types.js +0 -3
  60. package/dist/types/digest.types.js.map +0 -1
  61. package/dist/types/index.d.ts +0 -2
  62. package/dist/types/index.d.ts.map +0 -1
  63. package/dist/types/index.js +0 -18
  64. package/dist/types/index.js.map +0 -1
  65. package/lib/__tests__/dpop.spec.ts +0 -124
  66. package/lib/dpop/DPoP.ts +0 -242
  67. package/lib/dpop/index.ts +0 -1
  68. package/lib/hasher.ts +0 -18
  69. package/lib/index.ts +0 -11
  70. package/lib/jwt/Jwk.types.ts +0 -38
  71. package/lib/jwt/JwkThumbprint.ts +0 -65
  72. package/lib/jwt/Jwt.types.ts +0 -26
  73. package/lib/jwt/JwtIssuer.ts +0 -60
  74. package/lib/jwt/JwtVerifier.ts +0 -130
  75. package/lib/jwt/__tests__/JwkThumbprint.spec.ts +0 -16
  76. package/lib/jwt/index.ts +0 -6
  77. package/lib/jwt/jwtUtils.ts +0 -71
  78. package/lib/oauth/DynamicClientRegistration.types.ts +0 -20
  79. package/lib/oauth/index.ts +0 -1
  80. package/lib/types/digest.types.ts +0 -1
  81. package/lib/types/index.ts +0 -1
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getJwtVerifierWithContext = exports.getJwkVerifier = exports.getX5cVerifier = exports.getDidJwtVerifier = void 0;
13
- const getDidJwtVerifier = (jwt, options) => {
14
- const { type } = options;
15
- if (!jwt.header.kid)
16
- throw new Error(`Received an invalid JWT. Missing kid header.`);
17
- if (!jwt.header.alg)
18
- throw new Error(`Received an invalid JWT. Missing alg header.`);
19
- if (!jwt.header.kid.includes('#')) {
20
- throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`);
21
- }
22
- return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg };
23
- };
24
- exports.getDidJwtVerifier = getDidJwtVerifier;
25
- const getIssuer = (type, payload) => {
26
- // For 'request-object' the `iss` value is not required so we map the issuer to client_id
27
- if (type === 'request-object') {
28
- if (!payload.client_id) {
29
- throw new Error('Missing required field client_id in request object JWT');
30
- }
31
- return payload.client_id;
32
- }
33
- if (typeof payload.iss !== 'string') {
34
- throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`);
35
- }
36
- return payload.iss;
37
- };
38
- const getX5cVerifier = (jwt, options) => {
39
- const { type } = options;
40
- if (!jwt.header.x5c)
41
- throw new Error(`Received an invalid JWT. Missing x5c header.`);
42
- if (!jwt.header.alg)
43
- throw new Error(`Received an invalid JWT. Missing alg header.`);
44
- if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {
45
- throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`);
46
- }
47
- return {
48
- method: 'x5c',
49
- x5c: jwt.header.x5c,
50
- issuer: getIssuer(type, jwt.payload),
51
- type: type,
52
- alg: jwt.header.alg,
53
- };
54
- };
55
- exports.getX5cVerifier = getX5cVerifier;
56
- const getJwkVerifier = (jwt, options) => __awaiter(void 0, void 0, void 0, function* () {
57
- const { type } = options;
58
- if (!jwt.header.jwk)
59
- throw new Error(`Received an invalid JWT. Missing jwk header.`);
60
- if (!jwt.header.alg)
61
- throw new Error(`Received an invalid JWT. Missing alg header.`);
62
- if (typeof jwt.header.jwk !== 'object') {
63
- throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`);
64
- }
65
- return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg };
66
- });
67
- exports.getJwkVerifier = getJwkVerifier;
68
- const getJwtVerifierWithContext = (jwt, options) => __awaiter(void 0, void 0, void 0, function* () {
69
- var _a;
70
- const { header, payload } = jwt;
71
- if ((_a = header.kid) === null || _a === void 0 ? void 0 : _a.startsWith('did:'))
72
- return (0, exports.getDidJwtVerifier)({ header, payload }, options);
73
- else if (jwt.header.x5c)
74
- return (0, exports.getX5cVerifier)({ header, payload }, options);
75
- else if (jwt.header.jwk)
76
- return (0, exports.getJwkVerifier)({ header, payload }, options);
77
- return { method: 'custom', type: options.type };
78
- });
79
- exports.getJwtVerifierWithContext = getJwtVerifierWithContext;
80
- //# sourceMappingURL=JwtVerifier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JwtVerifier.js","sourceRo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,CAAC,CAAC;IAErF,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,mCAAmC,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;AAC3E,CAAC,CAAA,CAAC;AAVW,QAAA,cAAc,kBAUzB;AAEK,MAAM,yBAAyB,GAAG,CACvC,GAA+C,EAC/C,OAA0B,EACJ,EAAE;;IACxB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAEhC,IAAI,MAAA,MAAM,CAAC,GAAG,0CAAE,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAA,yBAAiB,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;SACtF,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG;QAAE,OAAO,IAAA,sBAAc,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;SACxE,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG;QAAE,OAAO,IAAA,sBAAc,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAE7E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC,CAAA,CAAC;AAXW,QAAA,yBAAyB,6BAWpC"}
@@ -1,7 +0,0 @@
1
- export * from './JwkThumbprint';
2
- export * from './Jwt.types';
3
- export * from './JwtIssuer';
4
- export * from './JwtVerifier';
5
- export * from './jwtUtils';
6
- export * from './Jwk.types';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/jwt/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
package/dist/jwt/index.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./JwkThumbprint"), exports);
18
- __exportStar(require("./Jwt.types"), exports);
19
- __exportStar(require("./JwtIssuer"), exports);
20
- __exportStar(require("./JwtVerifier"), exports);
21
- __exportStar(require("./jwtUtils"), exports);
22
- __exportStar(require("./Jwk.types"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/jwt/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,8CAA4B;AAC5B,8CAA4B;AAC5B,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B"}
@@ -1,26 +0,0 @@
1
- import { JwtHeader, JwtPayload } from '..';
2
- export type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';
3
- export type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';
4
- export declare function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string): {
5
- header: NonNullable<Header>;
6
- payload: NonNullable<Payload>;
7
- };
8
- export declare function getNowSkewed(now?: number, skewTime?: number): {
9
- nowSkewedPast: number;
10
- nowSkewedFuture: number;
11
- };
12
- /**
13
- * Returns the current unix timestamp in seconds.
14
- */
15
- export declare function epochTime(): number;
16
- export declare const BASE64_URL_REGEX: RegExp;
17
- export declare const isJws: (jws: string) => boolean;
18
- export declare const isJwe: (jwe: string) => boolean;
19
- export declare const decodeProtectedHeader: (jwt: string) => import("jwt-decode").JwtHeader;
20
- export declare const decodeJwt: (jwt: string) => JwtPayload;
21
- export declare const checkExp: (input: {
22
- exp: number;
23
- now?: number;
24
- clockSkew?: number;
25
- }) => boolean;
26
- //# sourceMappingURL=jwtUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jwtUtils.d.ts","sourceRoot":"","sources":["../../lib/jwt/jwtUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAE3C,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,gBAAgB,GAAG,sBAAsB,GAAG,MAAM,CAAC;AAEtF,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,mBAAmB,GAAG,QAAQ,CAAC;AAEzF,wBAAgB,QAAQ,CAAC,MAAM,GAAG,SAAS,EAAE,OAAO,GAAG,UAAU,EAAE,GAAG,EAAE,MAAM;;;EAQ7E;AAWD,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;;;EAQ3D;AAED;;GAEG;AACH,wBAAgB,SAAS,WAExB;AAED,eAAO,MAAM,gBAAgB,QAA2E,CAAC;AAEzG,eAAO,MAAM,KAAK,QAAS,MAAM,YAGhC,CAAC;AACF,eAAO,MAAM,KAAK,QAAS,MAAM,YAGhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAS,MAAM,mCAEhD,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,UAEvC,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,YAGA,CAAC"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkExp = exports.decodeJwt = exports.decodeProtectedHeader = exports.isJwe = exports.isJws = exports.BASE64_URL_REGEX = exports.epochTime = exports.getNowSkewed = exports.parseJWT = void 0;
4
- const jwt_decode_1 = require("jwt-decode");
5
- function parseJWT(jwt) {
6
- const header = (0, jwt_decode_1.jwtDecode)(jwt, { header: true });
7
- const payload = (0, jwt_decode_1.jwtDecode)(jwt, { header: false });
8
- if (!payload || !header) {
9
- throw new Error('Jwt Payload and/or Header could not be parsed');
10
- }
11
- return { header, payload };
12
- }
13
- exports.parseJWT = parseJWT;
14
- /**
15
- * The maximum allowed clock skew time in seconds. If an time based validation
16
- * is performed against current time (`now`), the validation can be of by the skew
17
- * time.
18
- *
19
- * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5
20
- */
21
- const DEFAULT_SKEW_TIME = 60;
22
- function getNowSkewed(now, skewTime) {
23
- const _now = now ? now : epochTime();
24
- const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;
25
- return {
26
- nowSkewedPast: _now - _skewTime,
27
- nowSkewedFuture: _now + _skewTime,
28
- };
29
- }
30
- exports.getNowSkewed = getNowSkewed;
31
- /**
32
- * Returns the current unix timestamp in seconds.
33
- */
34
- function epochTime() {
35
- return Math.floor(Date.now() / 1000);
36
- }
37
- exports.epochTime = epochTime;
38
- exports.BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
39
- const isJws = (jws) => {
40
- const jwsParts = jws.split('.');
41
- return jwsParts.length === 3 && jwsParts.every((part) => exports.BASE64_URL_REGEX.test(part));
42
- };
43
- exports.isJws = isJws;
44
- const isJwe = (jwe) => {
45
- const jweParts = jwe.split('.');
46
- return jweParts.length === 5 && jweParts.every((part) => exports.BASE64_URL_REGEX.test(part));
47
- };
48
- exports.isJwe = isJwe;
49
- const decodeProtectedHeader = (jwt) => {
50
- return (0, jwt_decode_1.jwtDecode)(jwt, { header: true });
51
- };
52
- exports.decodeProtectedHeader = decodeProtectedHeader;
53
- const decodeJwt = (jwt) => {
54
- return (0, jwt_decode_1.jwtDecode)(jwt, { header: false });
55
- };
56
- exports.decodeJwt = decodeJwt;
57
- const checkExp = (input) => {
58
- const { exp, now, clockSkew } = input;
59
- return exp < (now !== null && now !== void 0 ? now : Date.now() / 1000) - (clockSkew !== null && clockSkew !== void 0 ? clockSkew : 120);
60
- };
61
- exports.checkExp = checkExp;
62
- //# sourceMappingURL=jwtUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jwtUtils.js","sourceRoot":"","sources":["../../lib/jwt/jwtUtils.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAQvC,SAAgB,QAAQ,CAA2C,GAAW;IAC5E,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAS,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAA,sBAAS,EAAU,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE3D,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AARD,4BAQC;AAED;;;;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,GAAW,EAAE,EAAE;IACnD,OAAO,IAAA,sBAAS,EAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEK,MAAM,SAAS,GAAG,CAAC,GAAW,EAAc,EAAE;IACnD,OAAO,IAAA,sBAAS,EAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,QAAQ,GAAG,CAAC,KAIxB,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACtC,OAAO,GAAG,GAAG,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC,CAAC;AAC/D,CAAC,CAAC;AAPW,QAAA,QAAQ,YAOnB"}
@@ -1,19 +0,0 @@
1
- import { JWKS } from '../jwt';
2
- export interface DynamicRegistrationClientMetadata {
3
- redirect_uris?: string[];
4
- token_endpoint_auth_method?: string;
5
- grant_types?: string;
6
- response_types?: string;
7
- client_name?: string;
8
- client_uri?: string;
9
- logo_uri?: string;
10
- scope?: string;
11
- contacts?: string[];
12
- tos_uri?: string;
13
- policy_uri?: string;
14
- jwks_uri?: string;
15
- jwks?: JWKS;
16
- software_id?: string;
17
- software_version?: string;
18
- }
19
- //# sourceMappingURL=DynamicClientRegistration.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicClientRegistration.types.d.ts","sourceRoot":"","sources":["../../lib/oauth/DynamicClientRegistration.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,WAAW,iCAAiC;IAChD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=DynamicClientRegistration.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicClientRegistration.types.js","sourceRoot":"","sources":["../../lib/oauth/DynamicClientRegistration.types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * from './DynamicClientRegistration.types';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/oauth/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./DynamicClientRegistration.types"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/oauth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD"}
@@ -1,2 +0,0 @@
1
- export type DigestAlgorithm = 'sha256' | 'sha384' | 'sha512';
2
- //# sourceMappingURL=digest.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"digest.types.d.ts","sourceRoot":"","sources":["../../lib/types/digest.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=digest.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"digest.types.js","sourceRoot":"","sources":["../../lib/types/digest.types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * from './digest.types';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./digest.types"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -1,124 +0,0 @@
1
- import { createDPoP, getCreateDPoPOptions, verifyDPoP } from '../dpop';
2
-
3
- describe('dpop', () => {
4
- const alg = 'HS256';
5
- const jwk = { kty: 'Ed25519', crv: 'Ed25519', x: '123', y: '123' };
6
- const jwtIssuer = { alg, jwk };
7
- const htm = 'POST';
8
- const htu = 'https://example.com/token';
9
- const nonce = 'nonce';
10
- const jwtPayloadProps = { htm, htu, nonce } as const;
11
- const jwtHeaderProps = { alg, jwk, typ: 'dpop+jwt' };
12
- const unsignedDpop =
13
- 'eyJhbGciOiJIUzI1NiIsImp3ayI6eyJrdHkiOiJFZDI1NTE5IiwiY3J2IjoiRWQyNTUxOSIsIngiOiIxMjMiLCJ5IjoiMTIzIn0sInR5cCI6ImRwb3Arand0In0.eyJodG0iOiJQT1NUIiwiaHR1IjoiaHR0cHM6Ly9leGFtcGxlLmNvbS90b2tlbiIsIm5vbmNlIjoibm9uY2UiLCJpYXQiOjE3MjIzMjcxOTQsImp0aSI6Ijk4OWNiZTc4LWI1ZTYtNDViYS1iYjMzLWQ0MGE4ZGEwZjFhYSJ9';
14
-
15
- it('should create a dpop with valid options', async () => {
16
- const dpop = await createDPoP({
17
- jwtIssuer,
18
- jwtPayloadProps,
19
- createJwtCallback: async (dpopJwtIssuerWithContext, jwt) => {
20
- expect(dpopJwtIssuerWithContext.alg).toEqual(alg);
21
- expect(dpopJwtIssuerWithContext.jwk).toEqual(jwk);
22
- expect(dpopJwtIssuerWithContext.dPoPSigningAlgValuesSupported).toBeUndefined();
23
- expect(dpopJwtIssuerWithContext.type).toEqual('dpop');
24
-
25
- expect(jwt.header).toStrictEqual(jwtHeaderProps);
26
- expect(jwt.payload).toStrictEqual({
27
- ...jwtPayloadProps,
28
- iat: expect.any(Number),
29
- jti: expect.any(String),
30
- });
31
-
32
- return unsignedDpop;
33
- },
34
- });
35
-
36
- expect(unsignedDpop).toEqual(dpop);
37
- expect.assertions(7);
38
- });
39
-
40
- it('should create a dpop with valid createDPoPOptions', async () => {
41
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
- const { htm, htu, ...rest } = jwtPayloadProps;
43
- const options = getCreateDPoPOptions(
44
- {
45
- jwtIssuer,
46
- jwtPayloadProps: rest,
47
- createJwtCallback: async (dpopJwtIssuerWithContext, jwt) => {
48
- expect(dpopJwtIssuerWithContext.alg).toEqual(alg);
49
- expect(dpopJwtIssuerWithContext.jwk).toEqual(jwk);
50
- expect(dpopJwtIssuerWithContext.dPoPSigningAlgValuesSupported).toBeUndefined();
51
- expect(dpopJwtIssuerWithContext.type).toEqual('dpop');
52
-
53
- expect(jwt.header).toStrictEqual(jwtHeaderProps);
54
- expect(jwt.payload).toStrictEqual({
55
- ...jwtPayloadProps,
56
- iat: expect.any(Number),
57
- jti: expect.any(String),
58
- });
59
-
60
- return unsignedDpop;
61
- },
62
- },
63
- htu + '?123412341#xyaksdjfaksdjf',
64
- );
65
-
66
- const dpop = await createDPoP(options);
67
-
68
- expect(unsignedDpop).toEqual(dpop);
69
- expect.assertions(7);
70
- });
71
-
72
- it('verify dpop fails if jwtVerifyCallback throws an error', async () => {
73
- await expect(
74
- verifyDPoP(
75
- {
76
- headers: { dpop: unsignedDpop },
77
- fullUrl: htu + '?123412341#xyaksdjfaksdjf',
78
- method: 'POST',
79
- },
80
- {
81
- jwtVerifyCallback: async () => {
82
- throw new Error('jwtVerifyCallback');
83
- },
84
- expectedNonce: 'nonce',
85
- expectAccessToken: false,
86
- now: 1722327194,
87
- },
88
- ),
89
- ).rejects.toThrow();
90
- });
91
-
92
- it('should verify a dpop with valid options', async () => {
93
- const dpop = await verifyDPoP(
94
- {
95
- headers: { dpop: unsignedDpop },
96
- fullUrl: htu + '?123412341#xyaksdjfaksdjf',
97
- method: 'POST',
98
- },
99
- {
100
- jwtVerifyCallback: async (jwtVerifier, jwt) => {
101
- expect(jwtVerifier.method).toEqual('jwk');
102
- expect(jwtVerifier.jwk).toEqual(jwk);
103
- expect(jwtVerifier.type).toEqual('dpop');
104
- expect(jwtVerifier.alg).toEqual(alg);
105
-
106
- expect(jwt.header).toStrictEqual(jwtHeaderProps);
107
- expect(jwt.payload).toStrictEqual({
108
- ...jwtPayloadProps,
109
- iat: expect.any(Number),
110
- jti: expect.any(String),
111
- });
112
- expect(jwt.raw).toEqual(unsignedDpop);
113
-
114
- return true;
115
- },
116
- expectAccessToken: false,
117
- expectedNonce: 'nonce',
118
- now: 1722327194,
119
- },
120
- );
121
- expect(dpop).toStrictEqual(jwk);
122
- expect.assertions(8);
123
- });
124
- });