@sd-jwt/core 0.2.1 → 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.
- package/LICENSE +201 -0
- package/dist/index.d.mts +106 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +606 -0
- package/dist/index.mjs +586 -0
- package/package.json +60 -48
- package/src/decoy.ts +15 -0
- package/src/index.ts +235 -0
- package/src/jwt.ts +107 -0
- package/src/kbjwt.ts +45 -0
- package/src/sdjwt.ts +318 -0
- package/src/test/decoy.spec.ts +30 -0
- package/src/test/index.spec.ts +379 -0
- package/src/test/jwt.spec.ts +141 -0
- package/src/test/kbjwt.spec.ts +275 -0
- package/src/test/pass.spec.ts +6 -0
- package/src/test/sdjwt.spec.ts +382 -0
- package/test/app-e2e.spec.ts +248 -0
- package/test/array_data_types.json +29 -0
- package/test/array_full_sd.json +21 -0
- package/test/array_in_sd.json +13 -0
- package/test/array_nested_in_plain.json +20 -0
- package/test/array_none_disclosed.json +17 -0
- package/test/array_of_nulls.json +15 -0
- package/test/array_of_objects.json +58 -0
- package/test/array_of_scalars.json +15 -0
- package/test/array_recursive_sd.json +35 -0
- package/test/array_recursive_sd_some_disclosed.json +55 -0
- package/test/complex.json +43 -0
- package/test/header_mod.json +44 -0
- package/test/json_serialization.json +44 -0
- package/test/key_binding.json +44 -0
- package/test/no_sd.json +36 -0
- package/test/object_data_types.json +60 -0
- package/test/recursions.json +98 -0
- package/tsconfig.json +7 -0
- package/vitest.config.mts +4 -0
- package/README.md +0 -97
- package/build/base64url.d.ts +0 -28
- package/build/base64url.js +0 -40
- package/build/base64url.js.map +0 -1
- package/build/hasherAlgorithm.d.ts +0 -70
- package/build/hasherAlgorithm.js +0 -75
- package/build/hasherAlgorithm.js.map +0 -1
- package/build/index.d.ts +0 -13
- package/build/index.js +0 -20
- package/build/index.js.map +0 -1
- package/build/jwt/compact.d.ts +0 -6
- package/build/jwt/compact.js +0 -27
- package/build/jwt/compact.js.map +0 -1
- package/build/jwt/error.d.ts +0 -2
- package/build/jwt/error.js +0 -7
- package/build/jwt/error.js.map +0 -1
- package/build/jwt/index.d.ts +0 -2
- package/build/jwt/index.js +0 -19
- package/build/jwt/index.js.map +0 -1
- package/build/jwt/jwt.d.ts +0 -208
- package/build/jwt/jwt.js +0 -325
- package/build/jwt/jwt.js.map +0 -1
- package/build/keyBinding/index.d.ts +0 -1
- package/build/keyBinding/index.js +0 -18
- package/build/keyBinding/index.js.map +0 -1
- package/build/keyBinding/keyBinding.d.ts +0 -64
- package/build/keyBinding/keyBinding.js +0 -119
- package/build/keyBinding/keyBinding.js.map +0 -1
- package/build/sdJwt/compact.d.ts +0 -8
- package/build/sdJwt/compact.js +0 -39
- package/build/sdJwt/compact.js.map +0 -1
- package/build/sdJwt/decoys.d.ts +0 -3
- package/build/sdJwt/decoys.js +0 -35
- package/build/sdJwt/decoys.js.map +0 -1
- package/build/sdJwt/disclosureFrame.d.ts +0 -8
- package/build/sdJwt/disclosureFrame.js +0 -87
- package/build/sdJwt/disclosureFrame.js.map +0 -1
- package/build/sdJwt/disclosureMapping.d.ts +0 -43
- package/build/sdJwt/disclosureMapping.js +0 -278
- package/build/sdJwt/disclosureMapping.js.map +0 -1
- package/build/sdJwt/disclosures.d.ts +0 -33
- package/build/sdJwt/disclosures.js +0 -114
- package/build/sdJwt/disclosures.js.map +0 -1
- package/build/sdJwt/error.d.ts +0 -2
- package/build/sdJwt/error.js +0 -7
- package/build/sdJwt/error.js.map +0 -1
- package/build/sdJwt/index.d.ts +0 -6
- package/build/sdJwt/index.js +0 -23
- package/build/sdJwt/index.js.map +0 -1
- package/build/sdJwt/presentationFrame.d.ts +0 -3
- package/build/sdJwt/presentationFrame.js +0 -64
- package/build/sdJwt/presentationFrame.js.map +0 -1
- package/build/sdJwt/sdJwt.d.ts +0 -206
- package/build/sdJwt/sdJwt.js +0 -442
- package/build/sdJwt/sdJwt.js.map +0 -1
- package/build/sdJwt/swapClaim.d.ts +0 -2
- package/build/sdJwt/swapClaim.js +0 -79
- package/build/sdJwt/swapClaim.js.map +0 -1
- package/build/sdJwt/types.d.ts +0 -5
- package/build/sdJwt/types.js +0 -3
- package/build/sdJwt/types.js.map +0 -1
- package/build/sdJwtVc/error.d.ts +0 -2
- package/build/sdJwtVc/error.js +0 -7
- package/build/sdJwtVc/error.js.map +0 -1
- package/build/sdJwtVc/index.d.ts +0 -2
- package/build/sdJwtVc/index.js +0 -19
- package/build/sdJwtVc/index.js.map +0 -1
- package/build/sdJwtVc/sdJwtVc.d.ts +0 -47
- package/build/sdJwtVc/sdJwtVc.js +0 -149
- package/build/sdJwtVc/sdJwtVc.js.map +0 -1
- package/build/signatureAndEncryptionAlgorithm.d.ts +0 -105
- package/build/signatureAndEncryptionAlgorithm.js +0 -110
- package/build/signatureAndEncryptionAlgorithm.js.map +0 -1
- package/build/types/disclosure.d.ts +0 -5
- package/build/types/disclosure.js +0 -3
- package/build/types/disclosure.js.map +0 -1
- package/build/types/frame.d.ts +0 -5
- package/build/types/frame.js +0 -3
- package/build/types/frame.js.map +0 -1
- package/build/types/hasher.d.ts +0 -14
- package/build/types/hasher.js +0 -3
- package/build/types/hasher.js.map +0 -1
- package/build/types/index.d.ts +0 -5
- package/build/types/index.js +0 -22
- package/build/types/index.js.map +0 -1
- package/build/types/present.d.ts +0 -2
- package/build/types/present.js +0 -3
- package/build/types/present.js.map +0 -1
- package/build/types/saltGenerator.d.ts +0 -17
- package/build/types/saltGenerator.js +0 -3
- package/build/types/saltGenerator.js.map +0 -1
- package/build/types/signer.d.ts +0 -2
- package/build/types/signer.js +0 -3
- package/build/types/signer.js.map +0 -1
- package/build/types/utils.d.ts +0 -2
- package/build/types/utils.js +0 -3
- package/build/types/utils.js.map +0 -1
- package/build/types/verifier.d.ts +0 -14
- package/build/types/verifier.js +0 -3
- package/build/types/verifier.js.map +0 -1
- package/build/utils/index.d.ts +0 -2
- package/build/utils/index.js +0 -19
- package/build/utils/index.js.map +0 -1
- package/build/utils/traverse.d.ts +0 -8
- package/build/utils/traverse.js +0 -29
- package/build/utils/traverse.js.map +0 -1
- package/build/utils/utils.d.ts +0 -8
- package/build/utils/utils.js +0 -118
- package/build/utils/utils.js.map +0 -1
package/build/base64url.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Buffer } from 'buffer';
|
|
3
|
-
export declare class Base64url {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Encode into base64url string
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
static encode(input: string | Uint8Array | Buffer): string;
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Encode from JSON into a base64url string
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
static encodeFromJson(input: Record<string, unknown> | Array<unknown>): string;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* Decode from base64url into JSON
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
static decodeToJson<T extends Record<string, unknown> | Array<unknown> = Record<string, unknown>>(input: string): T;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* Decode from base64url into a byte array
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
static decode(input: string): Uint8Array;
|
|
28
|
-
}
|
package/build/base64url.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Base64url = void 0;
|
|
4
|
-
const buffer_1 = require("buffer");
|
|
5
|
-
class Base64url {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* Encode into base64url string
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
static encode(input) {
|
|
12
|
-
return buffer_1.Buffer.from(input).toString('base64url');
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* Encode from JSON into a base64url string
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
static encodeFromJson(input) {
|
|
20
|
-
return buffer_1.Buffer.from(JSON.stringify(input)).toString('base64url');
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* Decode from base64url into JSON
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
static decodeToJson(input) {
|
|
28
|
-
return JSON.parse(buffer_1.Buffer.from(input, 'base64url').toString());
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* Decode from base64url into a byte array
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
static decode(input) {
|
|
36
|
-
return Uint8Array.from(buffer_1.Buffer.from(input, 'base64url'));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.Base64url = Base64url;
|
|
40
|
-
//# sourceMappingURL=base64url.js.map
|
package/build/base64url.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64url.js","sourceRoot":"","sources":["../src/base64url.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,MAAa,SAAS;IAClB;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAmC;QACpD,OAAO,eAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACnD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CACxB,KAA+C;QAE/C,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACnE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAKxB,KAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAM,CAAA;IACtE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAa;QAC9B,OAAO,UAAU,CAAC,IAAI,CAAC,eAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;IAC3D,CAAC;CACJ;AA3CD,8BA2CC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export declare enum HasherAlgorithm {
|
|
2
|
-
/**
|
|
3
|
-
* Sha-256: 256 bits. [RFC6920] (current)
|
|
4
|
-
*/
|
|
5
|
-
Sha256 = "sha-256",
|
|
6
|
-
/**
|
|
7
|
-
* Sha-256-128: 128 bits. [RFC6920] (current)
|
|
8
|
-
*/
|
|
9
|
-
Sha256_128 = "sha-256-128",
|
|
10
|
-
/**
|
|
11
|
-
* Sha-256-120: 120 bits. [RFC6920] (current)
|
|
12
|
-
*/
|
|
13
|
-
Sha256_120 = "sha-256-120",
|
|
14
|
-
/**
|
|
15
|
-
* Sha-256-96: 96 bits. [RFC6920] (current)
|
|
16
|
-
*/
|
|
17
|
-
Sha256_96 = "sha-256-96",
|
|
18
|
-
/**
|
|
19
|
-
* Sha-256-64: 64 bits. [RFC6920] (current)
|
|
20
|
-
*/
|
|
21
|
-
Sha256_64 = "sha-256-64",
|
|
22
|
-
/**
|
|
23
|
-
* Sha-256-32: 32 bits. [RFC6920] (current)
|
|
24
|
-
*/
|
|
25
|
-
Sha256_32 = "sha-256-32",
|
|
26
|
-
/**
|
|
27
|
-
* Sha-384: 384 bits. [FIPS 180-4] (current)
|
|
28
|
-
*/
|
|
29
|
-
Sha384 = "sha-384",
|
|
30
|
-
/**
|
|
31
|
-
* Sha-512: 512 bits. [FIPS 180-4] (current)
|
|
32
|
-
*/
|
|
33
|
-
Sha512 = "sha-512",
|
|
34
|
-
/**
|
|
35
|
-
* Sha3-224: 224 bits. [FIPS 202] (current)
|
|
36
|
-
*/
|
|
37
|
-
Sha3_224 = "sha3-224",
|
|
38
|
-
/**
|
|
39
|
-
* Sha3-256: 256 bits. [FIPS 202] (current)
|
|
40
|
-
*/
|
|
41
|
-
Sha3_256 = "sha3-256",
|
|
42
|
-
/**
|
|
43
|
-
* Sha3-384: 384 bits. [FIPS 202] (current)
|
|
44
|
-
*/
|
|
45
|
-
Sha3_384 = "sha3-384",
|
|
46
|
-
/**
|
|
47
|
-
* Sha3-512: 512 bits. [FIPS 202] (current)
|
|
48
|
-
*/
|
|
49
|
-
Sha3_512 = "sha3-512",
|
|
50
|
-
/**
|
|
51
|
-
* Blake2s-256: 256 bits. [RFC7693] (current)
|
|
52
|
-
*/
|
|
53
|
-
Blake2s_256 = "blake2s-256",
|
|
54
|
-
/**
|
|
55
|
-
* Blake2b-256: 256 bits. [RFC7693] (current)
|
|
56
|
-
*/
|
|
57
|
-
Blake2b_256 = "blake2b-256",
|
|
58
|
-
/**
|
|
59
|
-
* Blake2b-512: 512 bits. [RFC7693] (current)
|
|
60
|
-
*/
|
|
61
|
-
Blake2b_512 = "blake2b-512",
|
|
62
|
-
/**
|
|
63
|
-
* K12-256: 256 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
|
|
64
|
-
*/
|
|
65
|
-
K12_256 = "k12-256",
|
|
66
|
-
/**
|
|
67
|
-
* K12-512: 512 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
|
|
68
|
-
*/
|
|
69
|
-
K12_512 = "k12-512"
|
|
70
|
-
}
|
package/build/hasherAlgorithm.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HasherAlgorithm = void 0;
|
|
4
|
-
var HasherAlgorithm;
|
|
5
|
-
(function (HasherAlgorithm) {
|
|
6
|
-
/**
|
|
7
|
-
* Sha-256: 256 bits. [RFC6920] (current)
|
|
8
|
-
*/
|
|
9
|
-
HasherAlgorithm["Sha256"] = "sha-256";
|
|
10
|
-
/**
|
|
11
|
-
* Sha-256-128: 128 bits. [RFC6920] (current)
|
|
12
|
-
*/
|
|
13
|
-
HasherAlgorithm["Sha256_128"] = "sha-256-128";
|
|
14
|
-
/**
|
|
15
|
-
* Sha-256-120: 120 bits. [RFC6920] (current)
|
|
16
|
-
*/
|
|
17
|
-
HasherAlgorithm["Sha256_120"] = "sha-256-120";
|
|
18
|
-
/**
|
|
19
|
-
* Sha-256-96: 96 bits. [RFC6920] (current)
|
|
20
|
-
*/
|
|
21
|
-
HasherAlgorithm["Sha256_96"] = "sha-256-96";
|
|
22
|
-
/**
|
|
23
|
-
* Sha-256-64: 64 bits. [RFC6920] (current)
|
|
24
|
-
*/
|
|
25
|
-
HasherAlgorithm["Sha256_64"] = "sha-256-64";
|
|
26
|
-
/**
|
|
27
|
-
* Sha-256-32: 32 bits. [RFC6920] (current)
|
|
28
|
-
*/
|
|
29
|
-
HasherAlgorithm["Sha256_32"] = "sha-256-32";
|
|
30
|
-
/**
|
|
31
|
-
* Sha-384: 384 bits. [FIPS 180-4] (current)
|
|
32
|
-
*/
|
|
33
|
-
HasherAlgorithm["Sha384"] = "sha-384";
|
|
34
|
-
/**
|
|
35
|
-
* Sha-512: 512 bits. [FIPS 180-4] (current)
|
|
36
|
-
*/
|
|
37
|
-
HasherAlgorithm["Sha512"] = "sha-512";
|
|
38
|
-
/**
|
|
39
|
-
* Sha3-224: 224 bits. [FIPS 202] (current)
|
|
40
|
-
*/
|
|
41
|
-
HasherAlgorithm["Sha3_224"] = "sha3-224";
|
|
42
|
-
/**
|
|
43
|
-
* Sha3-256: 256 bits. [FIPS 202] (current)
|
|
44
|
-
*/
|
|
45
|
-
HasherAlgorithm["Sha3_256"] = "sha3-256";
|
|
46
|
-
/**
|
|
47
|
-
* Sha3-384: 384 bits. [FIPS 202] (current)
|
|
48
|
-
*/
|
|
49
|
-
HasherAlgorithm["Sha3_384"] = "sha3-384";
|
|
50
|
-
/**
|
|
51
|
-
* Sha3-512: 512 bits. [FIPS 202] (current)
|
|
52
|
-
*/
|
|
53
|
-
HasherAlgorithm["Sha3_512"] = "sha3-512";
|
|
54
|
-
/**
|
|
55
|
-
* Blake2s-256: 256 bits. [RFC7693] (current)
|
|
56
|
-
*/
|
|
57
|
-
HasherAlgorithm["Blake2s_256"] = "blake2s-256";
|
|
58
|
-
/**
|
|
59
|
-
* Blake2b-256: 256 bits. [RFC7693] (current)
|
|
60
|
-
*/
|
|
61
|
-
HasherAlgorithm["Blake2b_256"] = "blake2b-256";
|
|
62
|
-
/**
|
|
63
|
-
* Blake2b-512: 512 bits. [RFC7693] (current)
|
|
64
|
-
*/
|
|
65
|
-
HasherAlgorithm["Blake2b_512"] = "blake2b-512";
|
|
66
|
-
/**
|
|
67
|
-
* K12-256: 256 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
|
|
68
|
-
*/
|
|
69
|
-
HasherAlgorithm["K12_256"] = "k12-256";
|
|
70
|
-
/**
|
|
71
|
-
* K12-512: 512 bits. [draft-irtf-cfrg-kangarootwelve-06] (current)
|
|
72
|
-
*/
|
|
73
|
-
HasherAlgorithm["K12_512"] = "k12-512";
|
|
74
|
-
})(HasherAlgorithm || (exports.HasherAlgorithm = HasherAlgorithm = {}));
|
|
75
|
-
//# sourceMappingURL=hasherAlgorithm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hasherAlgorithm.js","sourceRoot":"","sources":["../src/hasherAlgorithm.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAqEX;AArED,WAAY,eAAe;IACvB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,6CAA0B,CAAA;IAC1B;;OAEG;IACH,6CAA0B,CAAA;IAC1B;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,2CAAwB,CAAA;IACxB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,qCAAkB,CAAA;IAClB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,wCAAqB,CAAA;IACrB;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,8CAA2B,CAAA;IAC3B;;OAEG;IACH,sCAAmB,CAAA;IACnB;;OAEG;IACH,sCAAmB,CAAA;AACvB,CAAC,EArEW,eAAe,+BAAf,eAAe,QAqE1B"}
|
package/build/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type { SdJwtOptions, SdJwtAdditionalOptions, SdJwtVerificationResult } from './sdJwt';
|
|
2
|
-
export type { KeyBindingHeader, KeyBindingPayload, KeyBindingOptions, KeyBindingAdditionalOptions, KeyBindingVerificationResult } from './keyBinding';
|
|
3
|
-
export type { JwtOptions, JwtAdditionalOptions, JwtVerificationResult } from './jwt';
|
|
4
|
-
export type { Signer, Verifier, VerifyOptions, SaltGenerator, DisclosureItem, DisclosureFrame } from './types';
|
|
5
|
-
export type { SdJwtVcVerificationResult } from './sdJwtVc';
|
|
6
|
-
export { SignatureAndEncryptionAlgorithm } from './signatureAndEncryptionAlgorithm';
|
|
7
|
-
export { SdJwt, Disclosure, SdJwtError } from './sdJwt';
|
|
8
|
-
export { KeyBinding } from './keyBinding';
|
|
9
|
-
export { Jwt, JwtError } from './jwt';
|
|
10
|
-
export { SdJwtVc, SdJwtVcError } from './sdJwtVc';
|
|
11
|
-
export type { Hasher, AsyncHasher, HasherAndAlgorithm } from '@sd-jwt/types';
|
|
12
|
-
export { HasherAlgorithm } from '@sd-jwt/types';
|
|
13
|
-
export type { PresentationFrame } from '@sd-jwt/present';
|
package/build/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HasherAlgorithm = exports.SdJwtVcError = exports.SdJwtVc = exports.JwtError = exports.Jwt = exports.KeyBinding = exports.SdJwtError = exports.Disclosure = exports.SdJwt = exports.SignatureAndEncryptionAlgorithm = void 0;
|
|
4
|
-
var signatureAndEncryptionAlgorithm_1 = require("./signatureAndEncryptionAlgorithm");
|
|
5
|
-
Object.defineProperty(exports, "SignatureAndEncryptionAlgorithm", { enumerable: true, get: function () { return signatureAndEncryptionAlgorithm_1.SignatureAndEncryptionAlgorithm; } });
|
|
6
|
-
var sdJwt_1 = require("./sdJwt");
|
|
7
|
-
Object.defineProperty(exports, "SdJwt", { enumerable: true, get: function () { return sdJwt_1.SdJwt; } });
|
|
8
|
-
Object.defineProperty(exports, "Disclosure", { enumerable: true, get: function () { return sdJwt_1.Disclosure; } });
|
|
9
|
-
Object.defineProperty(exports, "SdJwtError", { enumerable: true, get: function () { return sdJwt_1.SdJwtError; } });
|
|
10
|
-
var keyBinding_1 = require("./keyBinding");
|
|
11
|
-
Object.defineProperty(exports, "KeyBinding", { enumerable: true, get: function () { return keyBinding_1.KeyBinding; } });
|
|
12
|
-
var jwt_1 = require("./jwt");
|
|
13
|
-
Object.defineProperty(exports, "Jwt", { enumerable: true, get: function () { return jwt_1.Jwt; } });
|
|
14
|
-
Object.defineProperty(exports, "JwtError", { enumerable: true, get: function () { return jwt_1.JwtError; } });
|
|
15
|
-
var sdJwtVc_1 = require("./sdJwtVc");
|
|
16
|
-
Object.defineProperty(exports, "SdJwtVc", { enumerable: true, get: function () { return sdJwtVc_1.SdJwtVc; } });
|
|
17
|
-
Object.defineProperty(exports, "SdJwtVcError", { enumerable: true, get: function () { return sdJwtVc_1.SdJwtVcError; } });
|
|
18
|
-
var types_1 = require("@sd-jwt/types");
|
|
19
|
-
Object.defineProperty(exports, "HasherAlgorithm", { enumerable: true, get: function () { return types_1.HasherAlgorithm; } });
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA+BA,qFAAmF;AAA1E,kJAAA,+BAA+B,OAAA;AAExC,iCAAuD;AAA9C,8FAAA,KAAK,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,mGAAA,UAAU,OAAA;AACtC,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,6BAAqC;AAA5B,0FAAA,GAAG,OAAA;AAAE,+FAAA,QAAQ,OAAA;AACtB,qCAAiD;AAAxC,kGAAA,OAAO,OAAA;AAAE,uGAAA,YAAY,OAAA;AAI9B,uCAA+C;AAAtC,wGAAA,eAAe,OAAA"}
|
package/build/jwt/compact.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type ExpandedJwt<H extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> = Record<string, unknown>> = {
|
|
2
|
-
header: H;
|
|
3
|
-
payload: P;
|
|
4
|
-
signature: Uint8Array;
|
|
5
|
-
};
|
|
6
|
-
export declare const jwtFromCompact: <H extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> = Record<string, unknown>>(compact: string) => ExpandedJwt<H, P>;
|
package/build/jwt/compact.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtFromCompact = void 0;
|
|
4
|
-
const base64url_1 = require("../base64url");
|
|
5
|
-
const error_1 = require("./error");
|
|
6
|
-
const jwtFromCompact = (compact) => {
|
|
7
|
-
if (compact.includes('~')) {
|
|
8
|
-
throw new error_1.JwtError('compact JWT includes `~` which is only allowed in an sd-jwt. Please use sdJwtFromCompact() instead.');
|
|
9
|
-
}
|
|
10
|
-
if ((compact.match(/\./g) || []).length !== 2) {
|
|
11
|
-
throw new error_1.JwtError('compact JWT must include two periods (.)');
|
|
12
|
-
}
|
|
13
|
-
const [compactHeader, compactPayload, encodedSignature] = compact.split('.');
|
|
14
|
-
if (!encodedSignature || encodedSignature.length === 0) {
|
|
15
|
-
throw new error_1.JwtError('A signature must be provided within the context of sd-jwt');
|
|
16
|
-
}
|
|
17
|
-
const header = base64url_1.Base64url.decodeToJson(compactHeader);
|
|
18
|
-
const payload = base64url_1.Base64url.decodeToJson(compactPayload);
|
|
19
|
-
const signature = base64url_1.Base64url.decode(encodedSignature);
|
|
20
|
-
return {
|
|
21
|
-
header,
|
|
22
|
-
payload,
|
|
23
|
-
signature
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
exports.jwtFromCompact = jwtFromCompact;
|
|
27
|
-
//# sourceMappingURL=compact.js.map
|
package/build/jwt/compact.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compact.js","sourceRoot":"","sources":["../../src/jwt/compact.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AACxC,mCAAkC;AAW3B,MAAM,cAAc,GAAG,CAI1B,OAAe,EACE,EAAE;IACnB,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,gBAAQ,CACd,qGAAqG,CACxG,CAAA;IACL,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,gBAAQ,CAAC,0CAA0C,CAAC,CAAA;IAClE,CAAC;IAED,MAAM,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE5E,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,gBAAQ,CACd,2DAA2D,CAC9D,CAAA;IACL,CAAC;IAED,MAAM,MAAM,GAAG,qBAAS,CAAC,YAAY,CAAI,aAAa,CAAC,CAAA;IACvD,MAAM,OAAO,GAAG,qBAAS,CAAC,YAAY,CAAI,cAAc,CAAC,CAAA;IACzD,MAAM,SAAS,GAAG,qBAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAEpD,OAAO;QACH,MAAM;QACN,OAAO;QACP,SAAS;KACZ,CAAA;AACL,CAAC,CAAA;AAjCY,QAAA,cAAc,kBAiC1B"}
|
package/build/jwt/error.d.ts
DELETED
package/build/jwt/error.js
DELETED
package/build/jwt/error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/jwt/error.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;CAAG;AAAtC,4BAAsC"}
|
package/build/jwt/index.d.ts
DELETED
package/build/jwt/index.js
DELETED
|
@@ -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("./jwt"), exports);
|
|
18
|
-
__exportStar(require("./error"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/build/jwt/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jwt/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,0CAAuB"}
|
package/build/jwt/jwt.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { MakePropertyRequired, Signer } from '../types';
|
|
2
|
-
import { Verifier } from '../types';
|
|
3
|
-
type ReturnJwtWithHeaderAndPayload<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends Jwt<H, P>> = MakePropertyRequired<T, 'header' | 'payload'>;
|
|
4
|
-
type ReturnJwtWithHeader<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends Jwt<H, P>> = MakePropertyRequired<T, 'header'>;
|
|
5
|
-
type ReturnJwtWithPayload<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends Jwt<H, P>> = MakePropertyRequired<T, 'payload'>;
|
|
6
|
-
type ReturnJwtWithSignature<H extends Record<string, unknown>, P extends Record<string, unknown>, T extends Jwt<H, P>> = MakePropertyRequired<T, 'signature'>;
|
|
7
|
-
export type JwtOptions<H extends Record<string, unknown>, P extends Record<string, unknown>> = {
|
|
8
|
-
header?: H;
|
|
9
|
-
payload?: P;
|
|
10
|
-
signature?: Uint8Array;
|
|
11
|
-
};
|
|
12
|
-
export type JwtAdditionalOptions<Header extends Record<string, unknown> = Record<string, unknown>> = {
|
|
13
|
-
signer?: Signer<Header>;
|
|
14
|
-
};
|
|
15
|
-
export type JwtVerificationResult = {
|
|
16
|
-
isValid: boolean;
|
|
17
|
-
isSignatureValid: boolean;
|
|
18
|
-
isNotBeforeValid?: boolean;
|
|
19
|
-
isExpiryTimeValid?: boolean;
|
|
20
|
-
areRequiredClaimsIncluded?: boolean;
|
|
21
|
-
};
|
|
22
|
-
export declare class Jwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> {
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* non-compact structure for a header of a JWT.
|
|
26
|
-
*
|
|
27
|
-
* Defined in: {@link https://datatracker.ietf.org/doc/html/rfc7519#section-5 | RFC 7519}
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
header?: Header;
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* non-compact structure for a payload of a JWT.
|
|
34
|
-
*
|
|
35
|
-
* Defined in: {@link https://datatracker.ietf.org/doc/html/rfc7519#section-4 | RFC 7519}
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
payload?: Payload;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* Signature over the BASE64URL(HEADER) || '.' || BASE64URL(PAYLOAD).
|
|
42
|
-
*
|
|
43
|
-
* Defined in: {@link https://datatracker.ietf.org/doc/html/rfc7515 | RFC 7515}
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
signature?: Uint8Array;
|
|
47
|
-
/**
|
|
48
|
-
* When the JWT was initialized from it's compact variant we store the compact version, so we can use it when needing the encoded version.
|
|
49
|
-
*/
|
|
50
|
-
compact?: string;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* Callback that will be used when creating a signature over the JWT.
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
signer?: Signer<Header>;
|
|
57
|
-
constructor(options?: JwtOptions<Header, Payload>, additionalOptions?: JwtAdditionalOptions);
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* Instantiate a JWT from a compact format.
|
|
61
|
-
*
|
|
62
|
-
* Two generics may be supplied for typing on the Header and Payload. These are not enforced.
|
|
63
|
-
*
|
|
64
|
-
* Defined in: {@link https://datatracker.ietf.org/doc/html/rfc7519#section-3 | RFC 7519 }
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
static fromCompact<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(compact: string): ReturnJwtWithHeaderAndPayload<Header, Payload, Jwt<Header, Payload>>;
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* Replaces the current Header a new one.
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
withHeader(header: Header): ReturnJwtWithHeader<Header, Payload, this>;
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* Add a new claim to the Header, overriding the old one if it already is on there.
|
|
77
|
-
*
|
|
78
|
-
*/
|
|
79
|
-
addHeaderClaim(item: keyof Header | string, value: Header[typeof item] | unknown): ReturnJwtWithHeader<Header, Payload, this>;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* Replaces the current Payload a new one.
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
withPayload(payload: Payload): ReturnJwtWithPayload<Header, Payload, this>;
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* Add a new claim to the Payload, overriding the old one if it already is on there.
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
addPayloadClaim(item: keyof Payload | string, value: Payload[typeof item] | unknown): ReturnJwtWithPayload<Header, Payload, this>;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* Manually append a signature to the JWT. This signature is not validated.
|
|
95
|
-
*
|
|
96
|
-
* @note Only use this if the supplying a signing callback does not fit your use case.
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
withSignature(signature: Uint8Array): ReturnJwtWithSignature<Header, Payload, this>;
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
* Add a signing callback to the JWT that will be used for creating the signature.
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
withSigner(signer: Signer): this;
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* Assert that there is a Header on the JWT.
|
|
109
|
-
*
|
|
110
|
-
* @throws when the Header is not defined
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
assertHeader(): void;
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* Assert that there is a Payload on the JWT.
|
|
117
|
-
*
|
|
118
|
-
* @throws when the Payload is not defined
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
assertPayload(): void;
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* Assert that there is a Signature on the JWT.
|
|
125
|
-
*
|
|
126
|
-
* @throws when the Signature is not defined
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
assertSignature(): void;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
* Assert that there is a Signing callback on the JWT.
|
|
133
|
-
*
|
|
134
|
-
* @throws when the Signer is not defined
|
|
135
|
-
*
|
|
136
|
-
*/
|
|
137
|
-
assertSigner(): void;
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
* Assert that there is a specific claim, possibly with value, in the Header.
|
|
141
|
-
*
|
|
142
|
-
*/
|
|
143
|
-
assertClaimInHeader(claimKey: keyof Header | string, claimValue?: Header[typeof claimKey] | unknown): void;
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* Assert that there is a specific claim, possibly with value, in the Payload.
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
assertClaimInPayload(claimKey: keyof Payload | string, claimValue?: Payload[typeof claimKey] | unknown): void;
|
|
150
|
-
private assertClaimInObject;
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* Get a claim within the payload.
|
|
154
|
-
*
|
|
155
|
-
* @throws when the payload is not defined
|
|
156
|
-
* @throws when the claim could not be found at any level
|
|
157
|
-
*
|
|
158
|
-
*/
|
|
159
|
-
getClaimInPayload<T>(claimKey: keyof Payload | string): T;
|
|
160
|
-
/**
|
|
161
|
-
*
|
|
162
|
-
* Get a claim within the payload.
|
|
163
|
-
*
|
|
164
|
-
* @throws when the payload is not defined
|
|
165
|
-
* @throws when the claim could not be found at any level
|
|
166
|
-
*
|
|
167
|
-
*/
|
|
168
|
-
getClaimInHeader<T>(claimKey: keyof Header | string): T;
|
|
169
|
-
private getClaimInObject;
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
* Returns a string of what needs to be signed.
|
|
173
|
-
*
|
|
174
|
-
* Defined in: {@link https://datatracker.ietf.org/doc/html/rfc7519#section-3 | RFC 7519}
|
|
175
|
-
*
|
|
176
|
-
*/
|
|
177
|
-
get signableInput(): string;
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
* Sign the Header and Payload and append the signature to the JWT.
|
|
181
|
-
*
|
|
182
|
-
*/
|
|
183
|
-
signAndAdd(): Promise<ReturnJwtWithSignature<Header, Payload, this>>;
|
|
184
|
-
private get compactHeader();
|
|
185
|
-
private get compactPayload();
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
* Create a compact format of the JWT.
|
|
189
|
-
*
|
|
190
|
-
* This will add a signature if there is none.
|
|
191
|
-
*
|
|
192
|
-
* @throws When the signature and signer are not defined
|
|
193
|
-
*
|
|
194
|
-
*/
|
|
195
|
-
toCompact(): Promise<string>;
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
198
|
-
* Verify the JWT.
|
|
199
|
-
*
|
|
200
|
-
* - Check the nbf claim with `now`
|
|
201
|
-
* - Check the exp claim with `now`
|
|
202
|
-
* - Additionally validate any required claims
|
|
203
|
-
* - Additionally pass in a specific publicKeyJwk to validate the signature
|
|
204
|
-
*
|
|
205
|
-
*/
|
|
206
|
-
verify(verifySignature: Verifier<Header>, requiredClaims?: Array<keyof Payload | string>, publicKeyJwk?: Record<string, unknown>): Promise<JwtVerificationResult>;
|
|
207
|
-
}
|
|
208
|
-
export {};
|