@sd-jwt/core 0.3.0 → 2.0.2-next.26

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 (107) hide show
  1. package/LICENSE +201 -0
  2. package/dist/index.d.mts +106 -0
  3. package/dist/index.d.ts +106 -0
  4. package/dist/index.js +606 -0
  5. package/dist/index.mjs +586 -0
  6. package/package.json +60 -48
  7. package/src/decoy.ts +15 -0
  8. package/src/index.ts +235 -0
  9. package/src/jwt.ts +107 -0
  10. package/src/kbjwt.ts +45 -0
  11. package/src/sdjwt.ts +318 -0
  12. package/src/test/decoy.spec.ts +30 -0
  13. package/src/test/index.spec.ts +379 -0
  14. package/src/test/jwt.spec.ts +141 -0
  15. package/src/test/kbjwt.spec.ts +275 -0
  16. package/src/test/pass.spec.ts +6 -0
  17. package/src/test/sdjwt.spec.ts +382 -0
  18. package/test/app-e2e.spec.ts +248 -0
  19. package/test/array_data_types.json +29 -0
  20. package/test/array_full_sd.json +21 -0
  21. package/test/array_in_sd.json +13 -0
  22. package/test/array_nested_in_plain.json +20 -0
  23. package/test/array_none_disclosed.json +17 -0
  24. package/test/array_of_nulls.json +15 -0
  25. package/test/array_of_objects.json +58 -0
  26. package/test/array_of_scalars.json +15 -0
  27. package/test/array_recursive_sd.json +35 -0
  28. package/test/array_recursive_sd_some_disclosed.json +55 -0
  29. package/test/complex.json +43 -0
  30. package/test/header_mod.json +44 -0
  31. package/test/json_serialization.json +44 -0
  32. package/test/key_binding.json +44 -0
  33. package/test/no_sd.json +36 -0
  34. package/test/object_data_types.json +60 -0
  35. package/test/recursions.json +98 -0
  36. package/tsconfig.json +7 -0
  37. package/vitest.config.mts +4 -0
  38. package/README.md +0 -97
  39. package/build/index.d.ts +0 -13
  40. package/build/index.js +0 -20
  41. package/build/index.js.map +0 -1
  42. package/build/jwt/error.d.ts +0 -2
  43. package/build/jwt/error.js +0 -7
  44. package/build/jwt/error.js.map +0 -1
  45. package/build/jwt/index.d.ts +0 -2
  46. package/build/jwt/index.js +0 -19
  47. package/build/jwt/index.js.map +0 -1
  48. package/build/jwt/jwt.d.ts +0 -208
  49. package/build/jwt/jwt.js +0 -325
  50. package/build/jwt/jwt.js.map +0 -1
  51. package/build/keyBinding/index.d.ts +0 -1
  52. package/build/keyBinding/index.js +0 -18
  53. package/build/keyBinding/index.js.map +0 -1
  54. package/build/keyBinding/keyBinding.d.ts +0 -64
  55. package/build/keyBinding/keyBinding.js +0 -119
  56. package/build/keyBinding/keyBinding.js.map +0 -1
  57. package/build/sdJwt/decoys.d.ts +0 -3
  58. package/build/sdJwt/decoys.js +0 -35
  59. package/build/sdJwt/decoys.js.map +0 -1
  60. package/build/sdJwt/disclosureFrame.d.ts +0 -8
  61. package/build/sdJwt/disclosureFrame.js +0 -87
  62. package/build/sdJwt/disclosureFrame.js.map +0 -1
  63. package/build/sdJwt/disclosures.d.ts +0 -33
  64. package/build/sdJwt/disclosures.js +0 -114
  65. package/build/sdJwt/disclosures.js.map +0 -1
  66. package/build/sdJwt/error.d.ts +0 -2
  67. package/build/sdJwt/error.js +0 -7
  68. package/build/sdJwt/error.js.map +0 -1
  69. package/build/sdJwt/index.d.ts +0 -6
  70. package/build/sdJwt/index.js +0 -23
  71. package/build/sdJwt/index.js.map +0 -1
  72. package/build/sdJwt/sdJwt.d.ts +0 -206
  73. package/build/sdJwt/sdJwt.js +0 -442
  74. package/build/sdJwt/sdJwt.js.map +0 -1
  75. package/build/sdJwt/types.d.ts +0 -5
  76. package/build/sdJwt/types.js +0 -3
  77. package/build/sdJwt/types.js.map +0 -1
  78. package/build/sdJwtVc/error.d.ts +0 -2
  79. package/build/sdJwtVc/error.js +0 -7
  80. package/build/sdJwtVc/error.js.map +0 -1
  81. package/build/sdJwtVc/index.d.ts +0 -2
  82. package/build/sdJwtVc/index.js +0 -19
  83. package/build/sdJwtVc/index.js.map +0 -1
  84. package/build/sdJwtVc/sdJwtVc.d.ts +0 -47
  85. package/build/sdJwtVc/sdJwtVc.js +0 -149
  86. package/build/sdJwtVc/sdJwtVc.js.map +0 -1
  87. package/build/signatureAndEncryptionAlgorithm.d.ts +0 -105
  88. package/build/signatureAndEncryptionAlgorithm.js +0 -110
  89. package/build/signatureAndEncryptionAlgorithm.js.map +0 -1
  90. package/build/types/disclosure.d.ts +0 -5
  91. package/build/types/disclosure.js +0 -3
  92. package/build/types/disclosure.js.map +0 -1
  93. package/build/types/index.d.ts +0 -5
  94. package/build/types/index.js +0 -22
  95. package/build/types/index.js.map +0 -1
  96. package/build/types/saltGenerator.d.ts +0 -17
  97. package/build/types/saltGenerator.js +0 -3
  98. package/build/types/saltGenerator.js.map +0 -1
  99. package/build/types/signer.d.ts +0 -2
  100. package/build/types/signer.js +0 -3
  101. package/build/types/signer.js.map +0 -1
  102. package/build/types/utils.d.ts +0 -2
  103. package/build/types/utils.js +0 -3
  104. package/build/types/utils.js.map +0 -1
  105. package/build/types/verifier.d.ts +0 -14
  106. package/build/types/verifier.js +0 -3
  107. package/build/types/verifier.js.map +0 -1
@@ -1,2 +0,0 @@
1
- export declare class SdJwtVcError extends Error {
2
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SdJwtVcError = void 0;
4
- class SdJwtVcError extends Error {
5
- }
6
- exports.SdJwtVcError = SdJwtVcError;
7
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/sdJwtVc/error.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;CAAG;AAA1C,oCAA0C"}
@@ -1,2 +0,0 @@
1
- export * from './sdJwtVc';
2
- export * from './error';
@@ -1,19 +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("./sdJwtVc"), exports);
18
- __exportStar(require("./error"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdJwtVc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,0CAAuB"}
@@ -1,47 +0,0 @@
1
- import { ReturnSdJwtWithHeaderAndPayload } from '../sdJwt';
2
- import { SdJwt, SdJwtVerificationResult } from '../sdJwt';
3
- import { Verifier } from '../types';
4
- export type SdJwtVcVerificationResult = SdJwtVerificationResult & {
5
- containsExpectedKeyBinding?: boolean;
6
- containsRequiredVcProperties: boolean;
7
- };
8
- export declare class SdJwtVc<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> extends SdJwt<Header, Payload> {
9
- assertNonSelectivelyDisclosableClaims(): void;
10
- private validateSdJwtVc;
11
- /**
12
- *
13
- * Instantiate a sd-jwt-vc from a compact format.
14
- *
15
- * @throws when the compact sd-jwt-vc is not a valid sd-jwt-vc
16
- *
17
- */
18
- static fromCompact<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(compact: string): ReturnSdJwtWithHeaderAndPayload<Header, Payload, SdJwtVc<Header, Payload>>;
19
- /**
20
- *
21
- * Verify the sd-jwt-vc.
22
- *
23
- * It validates the following properties:
24
- * - sd-jwt issuer signature
25
- * - Optionally, the required claims
26
- * - The `nbf` and `exp` claims
27
- * - Whether the key binding is valid
28
- * - Whether the expected key binding is used
29
- * - Whether the required sd-jwt-vc properties are included
30
- *
31
- */
32
- verify(verifier: Verifier<Header>, requiredClaimKeys?: Array<keyof Payload | string>, expectedCnfClaim?: Record<string, unknown>, kbJwtPublicKeyJwk?: Record<string, unknown>, issuerPublicKeyJwk?: Record<string, unknown>): Promise<SdJwtVcVerificationResult>;
33
- /**
34
- *
35
- * Create a compact format of the sd-jwt-vc.
36
- *
37
- * This will
38
- * - Apply the disclosure frame
39
- * - Add a signature if there is none
40
- *
41
- * @throws when the sd-jwt-vc is not conformant to the specification
42
- * @throws When the signature and signer are not defined
43
- * @throws When a claim is requested to be selectively disclosable, but it was not found in the payload
44
- *
45
- */
46
- toCompact(): Promise<string>;
47
- }
@@ -1,149 +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.SdJwtVc = void 0;
13
- const sdJwt_1 = require("../sdJwt");
14
- const sdJwt_2 = require("../sdJwt");
15
- const jwt_1 = require("../jwt");
16
- const decode_1 = require("@sd-jwt/decode");
17
- const keyBinding_1 = require("../keyBinding");
18
- class SdJwtVc extends sdJwt_2.SdJwt {
19
- assertNonSelectivelyDisclosableClaims() {
20
- if (!this.disclosureFrame)
21
- return;
22
- const nonSelectivelyDisclosableClaims = [
23
- 'iss',
24
- 'iat',
25
- 'nbf',
26
- 'exp',
27
- 'cnf',
28
- 'vct',
29
- 'status'
30
- ];
31
- for (const claimKey of nonSelectivelyDisclosableClaims) {
32
- this.assertNonSelectivelyDisclosableClaim(claimKey);
33
- }
34
- }
35
- validateSdJwtVc(expectedCnfClaim) {
36
- try {
37
- this.assertNonSelectivelyDisclosableClaims();
38
- this.assertHeader();
39
- this.assertPayload();
40
- this.assertClaimInHeader('typ', 'vc+sd-jwt');
41
- this.assertClaimInHeader('alg');
42
- this.assertClaimInPayload('iss');
43
- this.assertClaimInPayload('vct');
44
- this.assertClaimInPayload('iat');
45
- if (expectedCnfClaim) {
46
- this.assertClaimInPayload('cnf', expectedCnfClaim);
47
- }
48
- }
49
- catch (e) {
50
- if (e instanceof Error) {
51
- e.message = `jwt is not valid for usage with sd-jwt-vc. Error: ${e.message}`;
52
- }
53
- throw e;
54
- }
55
- }
56
- /**
57
- *
58
- * Instantiate a sd-jwt-vc from a compact format.
59
- *
60
- * @throws when the compact sd-jwt-vc is not a valid sd-jwt-vc
61
- *
62
- */
63
- static fromCompact(compact) {
64
- const { disclosures: d, keyBinding: kb, signature, payload, header } = (0, decode_1.sdJwtVcFromCompact)(compact);
65
- const disclosures = d === null || d === void 0 ? void 0 : d.map((disclosure) => new sdJwt_1.Disclosure(disclosure.salt, disclosure.value, disclosure.key));
66
- const keyBinding = kb
67
- ? new keyBinding_1.KeyBinding()
68
- .withHeader(kb.header)
69
- .withPayload(kb.payload)
70
- .withSignature(kb.signature)
71
- : undefined;
72
- const sdJwtVc = new SdJwtVc({
73
- header,
74
- payload,
75
- signature,
76
- disclosures,
77
- keyBinding
78
- });
79
- sdJwtVc.compact = compact;
80
- return sdJwtVc;
81
- }
82
- /**
83
- *
84
- * Verify the sd-jwt-vc.
85
- *
86
- * It validates the following properties:
87
- * - sd-jwt issuer signature
88
- * - Optionally, the required claims
89
- * - The `nbf` and `exp` claims
90
- * - Whether the key binding is valid
91
- * - Whether the expected key binding is used
92
- * - Whether the required sd-jwt-vc properties are included
93
- *
94
- */
95
- verify(verifier, requiredClaimKeys, expectedCnfClaim, kbJwtPublicKeyJwk, issuerPublicKeyJwk) {
96
- const _super = Object.create(null, {
97
- verify: { get: () => super.verify }
98
- });
99
- var _a, _b;
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const kbJwtPublicKeyJwkToUse = kbJwtPublicKeyJwk !== null && kbJwtPublicKeyJwk !== void 0 ? kbJwtPublicKeyJwk : (_b = (_a = this.payload) === null || _a === void 0 ? void 0 : _a.cnf) === null || _b === void 0 ? void 0 : _b.jwk;
102
- const sdJwtVerificationResult = (yield _super.verify.call(this, verifier, requiredClaimKeys, kbJwtPublicKeyJwkToUse, issuerPublicKeyJwk));
103
- try {
104
- sdJwtVerificationResult.containsRequiredVcProperties = true;
105
- this.validateSdJwtVc(expectedCnfClaim);
106
- if (expectedCnfClaim) {
107
- sdJwtVerificationResult.containsExpectedKeyBinding = true;
108
- }
109
- }
110
- catch (e) {
111
- if (e instanceof jwt_1.JwtError &&
112
- e.message ==
113
- "jwt is not valid for usage with sd-jwt-vc. Error: Claim key 'cnf' was found, but values did not match within the payload") {
114
- sdJwtVerificationResult.containsExpectedKeyBinding = false;
115
- }
116
- else {
117
- sdJwtVerificationResult.containsRequiredVcProperties = false;
118
- }
119
- // The verification result is not valid if an error occurred
120
- sdJwtVerificationResult.isValid = false;
121
- }
122
- return sdJwtVerificationResult;
123
- });
124
- }
125
- /**
126
- *
127
- * Create a compact format of the sd-jwt-vc.
128
- *
129
- * This will
130
- * - Apply the disclosure frame
131
- * - Add a signature if there is none
132
- *
133
- * @throws when the sd-jwt-vc is not conformant to the specification
134
- * @throws When the signature and signer are not defined
135
- * @throws When a claim is requested to be selectively disclosable, but it was not found in the payload
136
- *
137
- */
138
- toCompact() {
139
- const _super = Object.create(null, {
140
- toCompact: { get: () => super.toCompact }
141
- });
142
- return __awaiter(this, void 0, void 0, function* () {
143
- this.validateSdJwtVc();
144
- return yield _super.toCompact.call(this);
145
- });
146
- }
147
- }
148
- exports.SdJwtVc = SdJwtVc;
149
- //# sourceMappingURL=sdJwtVc.js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8B,CAAA;YAE/B,IAAI,CAAC;gBACD,uBAAuB,CAAC,4BAA4B,GAAG,IAAI,CAAA;gBAC3D,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAA;gBAEtC,IAAI,gBAAgB,EAAE,CAAC;oBACnB,uBAAuB,CAAC,0BAA0B,GAAG,IAAI,CAAA;gBAC7D,CAAC;YACL,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IACI,CAAC,YAAY,cAAQ;oBACrB,CAAC,CAAC,OAAO;wBACL,0HAA0H,EAChI,CAAC;oBACC,uBAAuB,CAAC,0BAA0B,GAAG,KAAK,CAAA;gBAC9D,CAAC;qBAAM,CAAC;oBACJ,uBAAuB,CAAC,4BAA4B,GAAG,KAAK,CAAA;gBAChE,CAAC;gBAED,4DAA4D;gBAC5D,uBAAuB,CAAC,OAAO,GAAG,KAAK,CAAA;YAC3C,CAAC;YAED,OAAO,uBAAuB,CAAA;;KACjC;IAED;;;;;;;;;;;;OAYG;IACY,SAAS;;;;;YACpB,IAAI,CAAC,eAAe,EAAE,CAAA;YACtB,OAAO,MAAM,OAAM,SAAS,WAAE,CAAA;QAClC,CAAC;KAAA;CACJ;AA9KD,0BA8KC"}
@@ -1,105 +0,0 @@
1
- /**
2
- * Enumeration representing various JSON Web Token (JWT) algorithms for digital signatures and encryption.
3
- */
4
- export declare enum SignatureAndEncryptionAlgorithm {
5
- /**
6
- * RSASSA-PKCS1-v1_5 using SHA-256
7
- */
8
- RS256 = "RS256",
9
- /**
10
- * RSASSA-PKCS1-v1_5 using SHA-384
11
- */
12
- RS384 = "RS384",
13
- /**
14
- * RSASSA-PKCS1-v1_5 using SHA-512
15
- */
16
- RS512 = "RS512",
17
- /**
18
- * ECDSA using P-256 and SHA-256
19
- */
20
- ES256 = "ES256",
21
- /**
22
- * ECDSA using P-384 and SHA-384
23
- */
24
- ES384 = "ES384",
25
- /**
26
- * ECDSA using P-521 and SHA-512
27
- */
28
- ES512 = "ES512",
29
- /**
30
- * RSA-PSS using SHA-256
31
- */
32
- PS256 = "PS256",
33
- /**
34
- * RSA-PSS using SHA-384
35
- */
36
- PS384 = "PS384",
37
- /**
38
- * RSA-PSS using SHA-512
39
- */
40
- PS512 = "PS512",
41
- /**
42
- * No digital signature or MAC performed
43
- */
44
- none = "none",
45
- /**
46
- * RSAES-PKCS1-v1_5
47
- */
48
- RSA1_5 = "RSA1_5",
49
- /**
50
- * RSAES OAEP
51
- */
52
- RSA_OAEP = "RSA-OAEP",
53
- /**
54
- * RSAES OAEP using SHA-256
55
- */
56
- RSA_OAEP_256 = "RSA-OAEP-256",
57
- /**
58
- * AES Key Wrap using 128-bit key
59
- */
60
- A128KW = "A128KW",
61
- /**
62
- * AES Key Wrap using 192-bit key
63
- */
64
- A192KW = "A192KW",
65
- /**
66
- * AES Key Wrap using 256-bit key
67
- */
68
- A256KW = "A256KW",
69
- /**
70
- * Direct use of a shared symmetric key
71
- */
72
- dir = "dir",
73
- /**
74
- * ECDH-ES using Concat KDF
75
- */
76
- ECDH_ES = "ECDH-ES",
77
- /**
78
- * EdDSA signature algorithms
79
- */
80
- EdDSA = "EdDSA",
81
- /**
82
- * ECDH-ES using Concat KDF and "A128KW" wrapping
83
- */
84
- ECDH_ES_A128KW = "ECDH-ES+A128KW",
85
- /**
86
- * ECDH-ES using Concat KDF and "A192KW" wrapping
87
- */
88
- ECDH_ES_A192KW = "ECDH-ES+A192KW",
89
- /**
90
- * ECDH-ES using Concat KDF and "A256KW" wrapping
91
- */
92
- ECDH_ES_A256KW = "ECDH-ES+A256KW",
93
- /**
94
- * Key wrapping with AES GCM using 128-bit key
95
- */
96
- A128GCMKW = "A128GCMKW",
97
- /**
98
- * Key wrapping with AES GCM using 192-bit key
99
- */
100
- A192GCMKW = "A192GCMKW",
101
- /**
102
- * Key wrapping with AES GCM using 256-bit key
103
- */
104
- A256GCMKW = "A256GCMKW"
105
- }
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignatureAndEncryptionAlgorithm = void 0;
4
- /**
5
- * Enumeration representing various JSON Web Token (JWT) algorithms for digital signatures and encryption.
6
- */
7
- var SignatureAndEncryptionAlgorithm;
8
- (function (SignatureAndEncryptionAlgorithm) {
9
- /**
10
- * RSASSA-PKCS1-v1_5 using SHA-256
11
- */
12
- SignatureAndEncryptionAlgorithm["RS256"] = "RS256";
13
- /**
14
- * RSASSA-PKCS1-v1_5 using SHA-384
15
- */
16
- SignatureAndEncryptionAlgorithm["RS384"] = "RS384";
17
- /**
18
- * RSASSA-PKCS1-v1_5 using SHA-512
19
- */
20
- SignatureAndEncryptionAlgorithm["RS512"] = "RS512";
21
- /**
22
- * ECDSA using P-256 and SHA-256
23
- */
24
- SignatureAndEncryptionAlgorithm["ES256"] = "ES256";
25
- /**
26
- * ECDSA using P-384 and SHA-384
27
- */
28
- SignatureAndEncryptionAlgorithm["ES384"] = "ES384";
29
- /**
30
- * ECDSA using P-521 and SHA-512
31
- */
32
- SignatureAndEncryptionAlgorithm["ES512"] = "ES512";
33
- /**
34
- * RSA-PSS using SHA-256
35
- */
36
- SignatureAndEncryptionAlgorithm["PS256"] = "PS256";
37
- /**
38
- * RSA-PSS using SHA-384
39
- */
40
- SignatureAndEncryptionAlgorithm["PS384"] = "PS384";
41
- /**
42
- * RSA-PSS using SHA-512
43
- */
44
- SignatureAndEncryptionAlgorithm["PS512"] = "PS512";
45
- /**
46
- * No digital signature or MAC performed
47
- */
48
- SignatureAndEncryptionAlgorithm["none"] = "none";
49
- /**
50
- * RSAES-PKCS1-v1_5
51
- */
52
- SignatureAndEncryptionAlgorithm["RSA1_5"] = "RSA1_5";
53
- /**
54
- * RSAES OAEP
55
- */
56
- SignatureAndEncryptionAlgorithm["RSA_OAEP"] = "RSA-OAEP";
57
- /**
58
- * RSAES OAEP using SHA-256
59
- */
60
- SignatureAndEncryptionAlgorithm["RSA_OAEP_256"] = "RSA-OAEP-256";
61
- /**
62
- * AES Key Wrap using 128-bit key
63
- */
64
- SignatureAndEncryptionAlgorithm["A128KW"] = "A128KW";
65
- /**
66
- * AES Key Wrap using 192-bit key
67
- */
68
- SignatureAndEncryptionAlgorithm["A192KW"] = "A192KW";
69
- /**
70
- * AES Key Wrap using 256-bit key
71
- */
72
- SignatureAndEncryptionAlgorithm["A256KW"] = "A256KW";
73
- /**
74
- * Direct use of a shared symmetric key
75
- */
76
- SignatureAndEncryptionAlgorithm["dir"] = "dir";
77
- /**
78
- * ECDH-ES using Concat KDF
79
- */
80
- SignatureAndEncryptionAlgorithm["ECDH_ES"] = "ECDH-ES";
81
- /**
82
- * EdDSA signature algorithms
83
- */
84
- SignatureAndEncryptionAlgorithm["EdDSA"] = "EdDSA";
85
- /**
86
- * ECDH-ES using Concat KDF and "A128KW" wrapping
87
- */
88
- SignatureAndEncryptionAlgorithm["ECDH_ES_A128KW"] = "ECDH-ES+A128KW";
89
- /**
90
- * ECDH-ES using Concat KDF and "A192KW" wrapping
91
- */
92
- SignatureAndEncryptionAlgorithm["ECDH_ES_A192KW"] = "ECDH-ES+A192KW";
93
- /**
94
- * ECDH-ES using Concat KDF and "A256KW" wrapping
95
- */
96
- SignatureAndEncryptionAlgorithm["ECDH_ES_A256KW"] = "ECDH-ES+A256KW";
97
- /**
98
- * Key wrapping with AES GCM using 128-bit key
99
- */
100
- SignatureAndEncryptionAlgorithm["A128GCMKW"] = "A128GCMKW";
101
- /**
102
- * Key wrapping with AES GCM using 192-bit key
103
- */
104
- SignatureAndEncryptionAlgorithm["A192GCMKW"] = "A192GCMKW";
105
- /**
106
- * Key wrapping with AES GCM using 256-bit key
107
- */
108
- SignatureAndEncryptionAlgorithm["A256GCMKW"] = "A256GCMKW";
109
- })(SignatureAndEncryptionAlgorithm || (exports.SignatureAndEncryptionAlgorithm = SignatureAndEncryptionAlgorithm = {}));
110
- //# sourceMappingURL=signatureAndEncryptionAlgorithm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signatureAndEncryptionAlgorithm.js","sourceRoot":"","sources":["../src/signatureAndEncryptionAlgorithm.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,+BA6HX;AA7HD,WAAY,+BAA+B;IACvC;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,gDAAa,CAAA;IAEb;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,gEAA6B,CAAA;IAE7B;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,oDAAiB,CAAA;IAEjB;;OAEG;IACH,8CAAW,CAAA;IAEX;;OAEG;IACH,sDAAmB,CAAA;IAEnB;;OAEG;IACH,kDAAe,CAAA;IAEf;;OAEG;IACH,oEAAiC,CAAA;IAEjC;;OAEG;IACH,oEAAiC,CAAA;IAEjC;;OAEG;IACH,oEAAiC,CAAA;IAEjC;;OAEG;IACH,0DAAuB,CAAA;IAEvB;;OAEG;IACH,0DAAuB,CAAA;IAEvB;;OAEG;IACH,0DAAuB,CAAA;AAC3B,CAAC,EA7HW,+BAA+B,+CAA/B,+BAA+B,QA6H1C"}
@@ -1,5 +0,0 @@
1
- import { BaseFrame } from '@sd-jwt/types';
2
- export type DisclosureItem = [string, string, unknown] | [string, unknown];
3
- export type DisclosureFrame<T> = BaseFrame<T, {
4
- __decoyCount?: number;
5
- }>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=disclosure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"disclosure.js","sourceRoot":"","sources":["../../src/types/disclosure.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- export * from './utils';
2
- export * from './signer';
3
- export * from './verifier';
4
- export * from './disclosure';
5
- export * from './saltGenerator';
@@ -1,22 +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("./utils"), exports);
18
- __exportStar(require("./signer"), exports);
19
- __exportStar(require("./verifier"), exports);
20
- __exportStar(require("./disclosure"), exports);
21
- __exportStar(require("./saltGenerator"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,2CAAwB;AACxB,6CAA0B;AAC1B,+CAA4B;AAC5B,kDAA+B"}
@@ -1,17 +0,0 @@
1
- import { OrPromise } from './utils';
2
- /**
3
- * Function which returns a salt generated by a CSPRNG.
4
- *
5
- * Recommended size is 128 bits (i.e. 16 bytes).
6
- *
7
- * Salts will not be seeded and a new one will be used for each claim.
8
- *
9
- * @example
10
- *
11
- * Node.js: `crypto.randomBytes(128 / 8)`
12
- *
13
- * React Native: `expo-standard-web-crypto`
14
- *
15
- * Browser: `crypto.getRandomValues(new Uint8Array(128 / 8))`
16
- */
17
- export type SaltGenerator = () => OrPromise<string>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=saltGenerator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"saltGenerator.js","sourceRoot":"","sources":["../../src/types/saltGenerator.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { OrPromise } from './utils';
2
- export type Signer<Header extends Record<string, unknown> = Record<string, unknown>> = (input: string, header: Header) => OrPromise<Uint8Array>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=signer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export type OrPromise<T> = T | Promise<T>;
2
- export type MakePropertyRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
1
- import { OrPromise } from './utils';
2
- export type VerifyOptions<Header extends Record<string, unknown>> = {
3
- message: string;
4
- signature: Uint8Array;
5
- header: Header;
6
- /**
7
- * The public key jwk is included when the `sd-jwt` has the following properties:
8
- *
9
- * - A `cnf` claim inside the cleartext payload
10
- * - A Keybinding at the end
11
- */
12
- publicKeyJwk?: Record<string, unknown>;
13
- };
14
- export type Verifier<Header extends Record<string, unknown> = Record<string, unknown>, options extends VerifyOptions<Header> = VerifyOptions<Header>> = (options: options) => OrPromise<boolean>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=verifier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../src/types/verifier.ts"],"names":[],"mappings":""}