@metamask-previews/kyc-controller 0.0.0-preview-e57e5c3dc → 0.0.0-preview-c449b8da8
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/CHANGELOG.md +0 -8
- package/README.md +2 -10
- package/dist/index.cjs +10 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -24
- package/dist/KycController-method-action-types.cjs +0 -7
- package/dist/KycController-method-action-types.cjs.map +0 -1
- package/dist/KycController-method-action-types.d.cts +0 -168
- package/dist/KycController-method-action-types.d.cts.map +0 -1
- package/dist/KycController-method-action-types.d.mts +0 -168
- package/dist/KycController-method-action-types.d.mts.map +0 -1
- package/dist/KycController-method-action-types.mjs +0 -6
- package/dist/KycController-method-action-types.mjs.map +0 -1
- package/dist/KycController.cjs +0 -1085
- package/dist/KycController.cjs.map +0 -1
- package/dist/KycController.d.cts +0 -255
- package/dist/KycController.d.cts.map +0 -1
- package/dist/KycController.d.mts +0 -255
- package/dist/KycController.d.mts.map +0 -1
- package/dist/KycController.mjs +0 -1080
- package/dist/KycController.mjs.map +0 -1
- package/dist/KycService-method-action-types.cjs +0 -7
- package/dist/KycService-method-action-types.cjs.map +0 -1
- package/dist/KycService-method-action-types.d.cts +0 -121
- package/dist/KycService-method-action-types.d.cts.map +0 -1
- package/dist/KycService-method-action-types.d.mts +0 -121
- package/dist/KycService-method-action-types.d.mts.map +0 -1
- package/dist/KycService-method-action-types.mjs +0 -6
- package/dist/KycService-method-action-types.mjs.map +0 -1
- package/dist/KycService.cjs +0 -417
- package/dist/KycService.cjs.map +0 -1
- package/dist/KycService.d.cts +0 -307
- package/dist/KycService.d.cts.map +0 -1
- package/dist/KycService.d.mts +0 -307
- package/dist/KycService.d.mts.map +0 -1
- package/dist/KycService.mjs +0 -413
- package/dist/KycService.mjs.map +0 -1
- package/dist/countryCodes.cjs +0 -274
- package/dist/countryCodes.cjs.map +0 -1
- package/dist/countryCodes.d.cts +0 -18
- package/dist/countryCodes.d.cts.map +0 -1
- package/dist/countryCodes.d.mts +0 -18
- package/dist/countryCodes.d.mts.map +0 -1
- package/dist/countryCodes.mjs +0 -270
- package/dist/countryCodes.mjs.map +0 -1
- package/dist/crypto.cjs +0 -154
- package/dist/crypto.cjs.map +0 -1
- package/dist/crypto.d.cts +0 -84
- package/dist/crypto.d.cts.map +0 -1
- package/dist/crypto.d.mts +0 -84
- package/dist/crypto.d.mts.map +0 -1
- package/dist/crypto.mjs +0 -149
- package/dist/crypto.mjs.map +0 -1
- package/dist/encoding.cjs +0 -40
- package/dist/encoding.cjs.map +0 -1
- package/dist/encoding.d.cts +0 -24
- package/dist/encoding.d.cts.map +0 -1
- package/dist/encoding.d.mts +0 -24
- package/dist/encoding.d.mts.map +0 -1
- package/dist/encoding.mjs +0 -35
- package/dist/encoding.mjs.map +0 -1
- package/dist/selectors.cjs +0 -30
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -24
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -24
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs +0 -24
- package/dist/selectors.mjs.map +0 -1
- package/dist/types.cjs +0 -10
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -124
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts +0 -124
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs +0 -9
- package/dist/types.mjs.map +0 -1
- package/dist/ukyc/constants.cjs +0 -75
- package/dist/ukyc/constants.cjs.map +0 -1
- package/dist/ukyc/constants.d.cts +0 -69
- package/dist/ukyc/constants.d.cts.map +0 -1
- package/dist/ukyc/constants.d.mts +0 -69
- package/dist/ukyc/constants.d.mts.map +0 -1
- package/dist/ukyc/constants.mjs +0 -72
- package/dist/ukyc/constants.mjs.map +0 -1
- package/dist/ukyc/deriveClientMaterial.cjs +0 -65
- package/dist/ukyc/deriveClientMaterial.cjs.map +0 -1
- package/dist/ukyc/deriveClientMaterial.d.cts +0 -54
- package/dist/ukyc/deriveClientMaterial.d.cts.map +0 -1
- package/dist/ukyc/deriveClientMaterial.d.mts +0 -54
- package/dist/ukyc/deriveClientMaterial.d.mts.map +0 -1
- package/dist/ukyc/deriveClientMaterial.mjs +0 -60
- package/dist/ukyc/deriveClientMaterial.mjs.map +0 -1
- package/dist/ukyc/jwtChain.cjs +0 -54
- package/dist/ukyc/jwtChain.cjs.map +0 -1
- package/dist/ukyc/jwtChain.d.cts +0 -40
- package/dist/ukyc/jwtChain.d.cts.map +0 -1
- package/dist/ukyc/jwtChain.d.mts +0 -40
- package/dist/ukyc/jwtChain.d.mts.map +0 -1
- package/dist/ukyc/jwtChain.mjs +0 -50
- package/dist/ukyc/jwtChain.mjs.map +0 -1
- package/dist/ukyc/localUserSecret.cjs +0 -98
- package/dist/ukyc/localUserSecret.cjs.map +0 -1
- package/dist/ukyc/localUserSecret.d.cts +0 -65
- package/dist/ukyc/localUserSecret.d.cts.map +0 -1
- package/dist/ukyc/localUserSecret.d.mts +0 -65
- package/dist/ukyc/localUserSecret.d.mts.map +0 -1
- package/dist/ukyc/localUserSecret.mjs +0 -92
- package/dist/ukyc/localUserSecret.mjs.map +0 -1
- package/dist/ukyc/storageAccessToken.cjs +0 -139
- package/dist/ukyc/storageAccessToken.cjs.map +0 -1
- package/dist/ukyc/storageAccessToken.d.cts +0 -99
- package/dist/ukyc/storageAccessToken.d.cts.map +0 -1
- package/dist/ukyc/storageAccessToken.d.mts +0 -99
- package/dist/ukyc/storageAccessToken.d.mts.map +0 -1
- package/dist/ukyc/storageAccessToken.mjs +0 -133
- package/dist/ukyc/storageAccessToken.mjs.map +0 -1
- package/dist/ukyc/testToken.cjs +0 -61
- package/dist/ukyc/testToken.cjs.map +0 -1
- package/dist/ukyc/testToken.d.cts +0 -50
- package/dist/ukyc/testToken.d.cts.map +0 -1
- package/dist/ukyc/testToken.d.mts +0 -50
- package/dist/ukyc/testToken.d.mts.map +0 -1
- package/dist/ukyc/testToken.mjs +0 -57
- package/dist/ukyc/testToken.mjs.map +0 -1
- package/dist/ukyc/wrapEncryptionKey.cjs +0 -28
- package/dist/ukyc/wrapEncryptionKey.cjs.map +0 -1
- package/dist/ukyc/wrapEncryptionKey.d.cts +0 -34
- package/dist/ukyc/wrapEncryptionKey.d.cts.map +0 -1
- package/dist/ukyc/wrapEncryptionKey.d.mts +0 -34
- package/dist/ukyc/wrapEncryptionKey.d.mts.map +0 -1
- package/dist/ukyc/wrapEncryptionKey.mjs +0 -25
- package/dist/ukyc/wrapEncryptionKey.mjs.map +0 -1
- package/dist/ukyc/wrapUserKey.cjs +0 -80
- package/dist/ukyc/wrapUserKey.cjs.map +0 -1
- package/dist/ukyc/wrapUserKey.d.cts +0 -26
- package/dist/ukyc/wrapUserKey.d.cts.map +0 -1
- package/dist/ukyc/wrapUserKey.d.mts +0 -26
- package/dist/ukyc/wrapUserKey.d.mts.map +0 -1
- package/dist/ukyc/wrapUserKey.mjs +0 -76
- package/dist/ukyc/wrapUserKey.mjs.map +0 -1
- package/dist/ukyc/wrappedRelayPayload.cjs +0 -32
- package/dist/ukyc/wrappedRelayPayload.cjs.map +0 -1
- package/dist/ukyc/wrappedRelayPayload.d.cts +0 -35
- package/dist/ukyc/wrappedRelayPayload.d.cts.map +0 -1
- package/dist/ukyc/wrappedRelayPayload.d.mts +0 -35
- package/dist/ukyc/wrappedRelayPayload.d.mts.map +0 -1
- package/dist/ukyc/wrappedRelayPayload.mjs +0 -28
- package/dist/ukyc/wrappedRelayPayload.mjs.map +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants for the UKYC client-derived key material and storage-authorization
|
|
3
|
-
* layer. See the architecture doc, section "Client-Derived Material".
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Fully-qualified key path for the `local_user_secret` in Encrypted User
|
|
7
|
-
* Storage.
|
|
8
|
-
*/
|
|
9
|
-
export declare const UKYC_LOCAL_USER_SECRET_PATH: "ukyc.local_user_secret";
|
|
10
|
-
/**
|
|
11
|
-
* Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
|
|
12
|
-
* entropy and matches the input length expected by the HKDF-SHA256 derivations
|
|
13
|
-
* below.
|
|
14
|
-
*/
|
|
15
|
-
export declare const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
|
|
16
|
-
/**
|
|
17
|
-
* Byte length of each value derived from `local_user_secret`.
|
|
18
|
-
*
|
|
19
|
-
* `signingKey` is 32 bytes because it is used directly as the Ed25519
|
|
20
|
-
* private key (for Ed25519 the 32-byte seed *is* the private key).
|
|
21
|
-
*/
|
|
22
|
-
export declare const UKYC_DERIVED_KEY_SIZES: {
|
|
23
|
-
readonly storageId: 32;
|
|
24
|
-
readonly dataEncryptionKey: 32;
|
|
25
|
-
readonly signingKey: 32;
|
|
26
|
-
readonly relayTunnelKey: 32;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* HKDF `info` labels providing domain separation between the values derived
|
|
30
|
-
* from `local_user_secret`.
|
|
31
|
-
*/
|
|
32
|
-
export declare const UKYC_KDF_INFO: {
|
|
33
|
-
readonly storageId: "metamask.ukyc.storage.v1.storage_id";
|
|
34
|
-
readonly dataEncryptionKey: "metamask.ukyc.storage.v1.data_encryption_key";
|
|
35
|
-
readonly signingKey: "metamask.ukyc.storage.v1.signing_key";
|
|
36
|
-
readonly relayTunnelKey: "metamask.ukyc.storage.v1.relay_tunnel_key";
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Version bound into every `storage_access_token` payload.
|
|
40
|
-
*/
|
|
41
|
-
export declare const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
|
|
42
|
-
/**
|
|
43
|
-
* Audience identifying the UKYC user-storage service. Required by UKYC Storage
|
|
44
|
-
* when it verifies a `storage_access_token`.
|
|
45
|
-
*/
|
|
46
|
-
export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE: "metamask:user-storage:ukyc";
|
|
47
|
-
/**
|
|
48
|
-
* Audience identifying the idOS Kwil credential-registry nodes. Required by
|
|
49
|
-
* idOS Kwil when it verifies a `storage_access_token`.
|
|
50
|
-
*/
|
|
51
|
-
export declare const UKYC_KWIL_AUDIENCE: "idos:kwil";
|
|
52
|
-
/**
|
|
53
|
-
* Full audience list bound into every `storage_access_token` payload. `aud`
|
|
54
|
-
* lists every verifier that may accept the token, so both UKYC Storage and
|
|
55
|
-
* idOS Kwil can each find their own entry.
|
|
56
|
-
*/
|
|
57
|
-
export declare const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES: readonly ["metamask:user-storage:ukyc", "idos:kwil"];
|
|
58
|
-
/**
|
|
59
|
-
* Authorization scheme under which a signed `storage_access_token` envelope is
|
|
60
|
-
* carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
|
|
61
|
-
* The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
|
|
62
|
-
*/
|
|
63
|
-
export declare const UKYC_CAPABILITY_AUTH_SCHEME: "AccessToken";
|
|
64
|
-
/**
|
|
65
|
-
* Standard well-known path where the Fractal encryption service publishes its
|
|
66
|
-
* JWKS (the Ed25519 public keys used to sign the `jwtChain`).
|
|
67
|
-
*/
|
|
68
|
-
export declare const UKYC_JWKS_PATH = "/.well-known/jwks.json";
|
|
69
|
-
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B,0BAAoC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;CAKzB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,kCAAkC,8BACR,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAuB,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,sDAGtC,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,eAAyB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,cAAc,2BAA2B,CAAC"}
|
package/dist/ukyc/constants.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants for the UKYC client-derived key material and storage-authorization
|
|
3
|
-
* layer. See the architecture doc, section "Client-Derived Material".
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Fully-qualified key path for the `local_user_secret` in Encrypted User
|
|
7
|
-
* Storage.
|
|
8
|
-
*/
|
|
9
|
-
export const UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret`;
|
|
10
|
-
/**
|
|
11
|
-
* Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high
|
|
12
|
-
* entropy and matches the input length expected by the HKDF-SHA256 derivations
|
|
13
|
-
* below.
|
|
14
|
-
*/
|
|
15
|
-
export const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;
|
|
16
|
-
/**
|
|
17
|
-
* Byte length of each value derived from `local_user_secret`.
|
|
18
|
-
*
|
|
19
|
-
* `signingKey` is 32 bytes because it is used directly as the Ed25519
|
|
20
|
-
* private key (for Ed25519 the 32-byte seed *is* the private key).
|
|
21
|
-
*/
|
|
22
|
-
export const UKYC_DERIVED_KEY_SIZES = {
|
|
23
|
-
storageId: 32,
|
|
24
|
-
dataEncryptionKey: 32,
|
|
25
|
-
signingKey: 32,
|
|
26
|
-
relayTunnelKey: 32,
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* HKDF `info` labels providing domain separation between the values derived
|
|
30
|
-
* from `local_user_secret`.
|
|
31
|
-
*/
|
|
32
|
-
export const UKYC_KDF_INFO = {
|
|
33
|
-
storageId: 'metamask.ukyc.storage.v1.storage_id',
|
|
34
|
-
dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',
|
|
35
|
-
signingKey: 'metamask.ukyc.storage.v1.signing_key',
|
|
36
|
-
relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Version bound into every `storage_access_token` payload.
|
|
40
|
-
*/
|
|
41
|
-
export const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;
|
|
42
|
-
/**
|
|
43
|
-
* Audience identifying the UKYC user-storage service. Required by UKYC Storage
|
|
44
|
-
* when it verifies a `storage_access_token`.
|
|
45
|
-
*/
|
|
46
|
-
export const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE = 'metamask:user-storage:ukyc';
|
|
47
|
-
/**
|
|
48
|
-
* Audience identifying the idOS Kwil credential-registry nodes. Required by
|
|
49
|
-
* idOS Kwil when it verifies a `storage_access_token`.
|
|
50
|
-
*/
|
|
51
|
-
export const UKYC_KWIL_AUDIENCE = 'idos:kwil';
|
|
52
|
-
/**
|
|
53
|
-
* Full audience list bound into every `storage_access_token` payload. `aud`
|
|
54
|
-
* lists every verifier that may accept the token, so both UKYC Storage and
|
|
55
|
-
* idOS Kwil can each find their own entry.
|
|
56
|
-
*/
|
|
57
|
-
export const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [
|
|
58
|
-
UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,
|
|
59
|
-
UKYC_KWIL_AUDIENCE,
|
|
60
|
-
];
|
|
61
|
-
/**
|
|
62
|
-
* Authorization scheme under which a signed `storage_access_token` envelope is
|
|
63
|
-
* carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.
|
|
64
|
-
* The credentials portion is what `encodeStorageAccessTokenForHeader` returns.
|
|
65
|
-
*/
|
|
66
|
-
export const UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken';
|
|
67
|
-
/**
|
|
68
|
-
* Standard well-known path where the Fractal encryption service publishes its
|
|
69
|
-
* JWKS (the Ed25519 public keys used to sign the `jwtChain`).
|
|
70
|
-
*/
|
|
71
|
-
export const UKYC_JWKS_PATH = '/.well-known/jwks.json';
|
|
72
|
-
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/ukyc/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAiC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,EAAE;IACb,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;CACV,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,qCAAqC;IAChD,iBAAiB,EAAE,8CAA8C;IACjE,UAAU,EAAE,sCAAsC;IAClD,cAAc,EAAE,2CAA2C;CACnD,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC7C,4BAAqC,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,kCAAkC;IAClC,kBAAkB;CACV,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,aAAsB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["/**\n * Constants for the UKYC client-derived key material and storage-authorization\n * layer. See the architecture doc, section \"Client-Derived Material\".\n */\n\n/**\n * Fully-qualified key path for the `local_user_secret` in Encrypted User\n * Storage.\n */\nexport const UKYC_LOCAL_USER_SECRET_PATH = `ukyc.local_user_secret` as const;\n\n/**\n * Size of the `local_user_secret` in bytes. 32 bytes (256 bits) provides high\n * entropy and matches the input length expected by the HKDF-SHA256 derivations\n * below.\n */\nexport const UKYC_LOCAL_USER_SECRET_SIZE_BYTES = 32;\n\n/**\n * Byte length of each value derived from `local_user_secret`.\n *\n * `signingKey` is 32 bytes because it is used directly as the Ed25519\n * private key (for Ed25519 the 32-byte seed *is* the private key).\n */\nexport const UKYC_DERIVED_KEY_SIZES = {\n storageId: 32,\n dataEncryptionKey: 32,\n signingKey: 32,\n relayTunnelKey: 32,\n} as const;\n\n/**\n * HKDF `info` labels providing domain separation between the values derived\n * from `local_user_secret`.\n */\nexport const UKYC_KDF_INFO = {\n storageId: 'metamask.ukyc.storage.v1.storage_id',\n dataEncryptionKey: 'metamask.ukyc.storage.v1.data_encryption_key',\n signingKey: 'metamask.ukyc.storage.v1.signing_key',\n relayTunnelKey: 'metamask.ukyc.storage.v1.relay_tunnel_key',\n} as const;\n\n/**\n * Version bound into every `storage_access_token` payload.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_VERSION = 1;\n\n/**\n * Audience identifying the UKYC user-storage service. Required by UKYC Storage\n * when it verifies a `storage_access_token`.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE =\n 'metamask:user-storage:ukyc' as const;\n\n/**\n * Audience identifying the idOS Kwil credential-registry nodes. Required by\n * idOS Kwil when it verifies a `storage_access_token`.\n */\nexport const UKYC_KWIL_AUDIENCE = 'idos:kwil' as const;\n\n/**\n * Full audience list bound into every `storage_access_token` payload. `aud`\n * lists every verifier that may accept the token, so both UKYC Storage and\n * idOS Kwil can each find their own entry.\n */\nexport const UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES = [\n UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,\n UKYC_KWIL_AUDIENCE,\n] as const;\n\n/**\n * Authorization scheme under which a signed `storage_access_token` envelope is\n * carried to UKYC Storage: `Authorization: AccessToken <base64url(envelope)>`.\n * The credentials portion is what `encodeStorageAccessTokenForHeader` returns.\n */\nexport const UKYC_CAPABILITY_AUTH_SCHEME = 'AccessToken' as const;\n\n/**\n * Standard well-known path where the Fractal encryption service publishes its\n * JWKS (the Ed25519 public keys used to sign the `jwtChain`).\n */\nexport const UKYC_JWKS_PATH = '/.well-known/jwks.json';\n"]}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeClientMaterial = exports.deriveClientMaterial = void 0;
|
|
4
|
-
const utils_1 = require("@metamask/utils");
|
|
5
|
-
const ed25519_1 = require("@noble/curves/ed25519");
|
|
6
|
-
const hkdf_1 = require("@noble/hashes/hkdf");
|
|
7
|
-
const sha2_1 = require("@noble/hashes/sha2");
|
|
8
|
-
const constants_js_1 = require("./constants.cjs");
|
|
9
|
-
const encoding_js_1 = require("../encoding.cjs");
|
|
10
|
-
/**
|
|
11
|
-
* Derives a single labeled value from `local_user_secret`.
|
|
12
|
-
*
|
|
13
|
-
* No salt is used: `local_user_secret` is already a high-entropy
|
|
14
|
-
* uniformly-random secret, so per-output domain separation comes entirely from
|
|
15
|
-
* the `info` label.
|
|
16
|
-
*
|
|
17
|
-
* @param localUserSecret - The root `local_user_secret` bytes.
|
|
18
|
-
* @param info - Domain-separation label for this output.
|
|
19
|
-
* @param length - Desired output length in bytes.
|
|
20
|
-
* @returns The derived bytes.
|
|
21
|
-
*/
|
|
22
|
-
function deriveLabeled(localUserSecret, info, length) {
|
|
23
|
-
return (0, hkdf_1.hkdf)(sha2_1.sha256, localUserSecret, undefined, (0, utils_1.stringToBytes)(info), length);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Derives all UKYC client material from the root `local_user_secret`.
|
|
27
|
-
*
|
|
28
|
-
* This is a pure function of `local_user_secret`: the same input always yields
|
|
29
|
-
* the same outputs, which is what makes `storage_id` and `signing_key` stable
|
|
30
|
-
* across sessions and devices.
|
|
31
|
-
*
|
|
32
|
-
* @param localUserSecret - The `local_user_secret` produced by
|
|
33
|
-
* `getOrCreateLocalUserSecret`.
|
|
34
|
-
* @returns The derived {@link UkycClientMaterial}.
|
|
35
|
-
*/
|
|
36
|
-
function deriveClientMaterial(localUserSecret) {
|
|
37
|
-
const storageId = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.storageId, constants_js_1.UKYC_DERIVED_KEY_SIZES.storageId);
|
|
38
|
-
const dataEncryptionKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.dataEncryptionKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.dataEncryptionKey);
|
|
39
|
-
const signingKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.signingKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.signingKey);
|
|
40
|
-
const relayTunnelKey = deriveLabeled(localUserSecret, constants_js_1.UKYC_KDF_INFO.relayTunnelKey, constants_js_1.UKYC_DERIVED_KEY_SIZES.relayTunnelKey);
|
|
41
|
-
const signingPublicKey = ed25519_1.ed25519.getPublicKey(signingKey);
|
|
42
|
-
return {
|
|
43
|
-
storageId,
|
|
44
|
-
dataEncryptionKey,
|
|
45
|
-
signingKey,
|
|
46
|
-
signingPublicKey,
|
|
47
|
-
relayTunnelKey,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
exports.deriveClientMaterial = deriveClientMaterial;
|
|
51
|
-
/**
|
|
52
|
-
* Encodes the non-secret client material into the base64url wire shapes used by
|
|
53
|
-
* the UKYC storage API (`storage_id` and `signing_public_key`).
|
|
54
|
-
*
|
|
55
|
-
* @param material - The derived client material.
|
|
56
|
-
* @returns The base64url-encoded, non-secret fields.
|
|
57
|
-
*/
|
|
58
|
-
function encodeClientMaterial(material) {
|
|
59
|
-
return {
|
|
60
|
-
storageId: (0, encoding_js_1.toBase64Url)(material.storageId),
|
|
61
|
-
signingPublicKey: (0, encoding_js_1.toBase64Url)(material.signingPublicKey),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.encodeClientMaterial = encodeClientMaterial;
|
|
65
|
-
//# sourceMappingURL=deriveClientMaterial.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deriveClientMaterial.cjs","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAChD,mDAAgD;AAChD,6CAA0C;AAC1C,6CAA4C;AAE5C,kDAAuE;AACvE,iDAA6C;AAsC7C;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CACpB,eAA2B,EAC3B,IAAY,EACZ,MAAc;IAEd,OAAO,IAAA,WAAI,EAAC,aAAM,EAAE,eAAe,EAAE,SAAS,EAAE,IAAA,qBAAa,EAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,eAA2B;IAE3B,MAAM,SAAS,GAAG,aAAa,CAC7B,eAAe,EACf,4BAAa,CAAC,SAAS,EACvB,qCAAsB,CAAC,SAAS,CACjC,CAAC;IAEF,MAAM,iBAAiB,GAAG,aAAa,CACrC,eAAe,EACf,4BAAa,CAAC,iBAAiB,EAC/B,qCAAsB,CAAC,iBAAiB,CACzC,CAAC;IAEF,MAAM,UAAU,GAAG,aAAa,CAC9B,eAAe,EACf,4BAAa,CAAC,UAAU,EACxB,qCAAsB,CAAC,UAAU,CAClC,CAAC;IAEF,MAAM,cAAc,GAAG,aAAa,CAClC,eAAe,EACf,4BAAa,CAAC,cAAc,EAC5B,qCAAsB,CAAC,cAAc,CACtC,CAAC;IAEF,MAAM,gBAAgB,GAAG,iBAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAE1D,OAAO;QACL,SAAS;QACT,iBAAiB;QACjB,UAAU;QACV,gBAAgB;QAChB,cAAc;KACf,CAAC;AACJ,CAAC;AApCD,oDAoCC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,gBAAgB,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,gBAAgB,CAAC;KACzD,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["import { stringToBytes } from '@metamask/utils';\nimport { ed25519 } from '@noble/curves/ed25519';\nimport { hkdf } from '@noble/hashes/hkdf';\nimport { sha256 } from '@noble/hashes/sha2';\n\nimport { UKYC_DERIVED_KEY_SIZES, UKYC_KDF_INFO } from './constants.js';\nimport { toBase64Url } from '../encoding.js';\n\n/**\n * Derives UKYC client material from the root `local_user_secret` using\n * HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,\n * section \"Client-Derived Material\".\n */\n\n/**\n * The set of values derived from `local_user_secret`.\n */\nexport type UkycClientMaterial = {\n /** Opaque lookup key for the encrypted KYC object. */\n storageId: Uint8Array;\n /** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */\n dataEncryptionKey: Uint8Array;\n /**\n * Ed25519 private key used to sign `storage_access_token` capabilities. For\n * Ed25519 the 32-byte HKDF output *is* the private key. The private half\n * never leaves the device.\n */\n signingKey: Uint8Array;\n /** Public half of `signingKey`, registered with the object on first write. */\n signingPublicKey: Uint8Array;\n /** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */\n relayTunnelKey: Uint8Array;\n};\n\n/**\n * The same material with byte fields base64url-encoded, matching the wire\n * shapes in the architecture doc (`storage_id` as an opaque id, public key as a\n * \"base64url public key\"). Secret material is intentionally omitted.\n */\nexport type EncodedUkycClientMaterial = {\n storageId: string;\n signingPublicKey: string;\n};\n\n/**\n * Derives a single labeled value from `local_user_secret`.\n *\n * No salt is used: `local_user_secret` is already a high-entropy\n * uniformly-random secret, so per-output domain separation comes entirely from\n * the `info` label.\n *\n * @param localUserSecret - The root `local_user_secret` bytes.\n * @param info - Domain-separation label for this output.\n * @param length - Desired output length in bytes.\n * @returns The derived bytes.\n */\nfunction deriveLabeled(\n localUserSecret: Uint8Array,\n info: string,\n length: number,\n): Uint8Array {\n return hkdf(sha256, localUserSecret, undefined, stringToBytes(info), length);\n}\n\n/**\n * Derives all UKYC client material from the root `local_user_secret`.\n *\n * This is a pure function of `local_user_secret`: the same input always yields\n * the same outputs, which is what makes `storage_id` and `signing_key` stable\n * across sessions and devices.\n *\n * @param localUserSecret - The `local_user_secret` produced by\n * `getOrCreateLocalUserSecret`.\n * @returns The derived {@link UkycClientMaterial}.\n */\nexport function deriveClientMaterial(\n localUserSecret: Uint8Array,\n): UkycClientMaterial {\n const storageId = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.storageId,\n UKYC_DERIVED_KEY_SIZES.storageId,\n );\n\n const dataEncryptionKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.dataEncryptionKey,\n UKYC_DERIVED_KEY_SIZES.dataEncryptionKey,\n );\n\n const signingKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.signingKey,\n UKYC_DERIVED_KEY_SIZES.signingKey,\n );\n\n const relayTunnelKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.relayTunnelKey,\n UKYC_DERIVED_KEY_SIZES.relayTunnelKey,\n );\n\n const signingPublicKey = ed25519.getPublicKey(signingKey);\n\n return {\n storageId,\n dataEncryptionKey,\n signingKey,\n signingPublicKey,\n relayTunnelKey,\n };\n}\n\n/**\n * Encodes the non-secret client material into the base64url wire shapes used by\n * the UKYC storage API (`storage_id` and `signing_public_key`).\n *\n * @param material - The derived client material.\n * @returns The base64url-encoded, non-secret fields.\n */\nexport function encodeClientMaterial(\n material: UkycClientMaterial,\n): EncodedUkycClientMaterial {\n return {\n storageId: toBase64Url(material.storageId),\n signingPublicKey: toBase64Url(material.signingPublicKey),\n };\n}\n"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derives UKYC client material from the root `local_user_secret` using
|
|
3
|
-
* HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,
|
|
4
|
-
* section "Client-Derived Material".
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* The set of values derived from `local_user_secret`.
|
|
8
|
-
*/
|
|
9
|
-
export type UkycClientMaterial = {
|
|
10
|
-
/** Opaque lookup key for the encrypted KYC object. */
|
|
11
|
-
storageId: Uint8Array;
|
|
12
|
-
/** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */
|
|
13
|
-
dataEncryptionKey: Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Ed25519 private key used to sign `storage_access_token` capabilities. For
|
|
16
|
-
* Ed25519 the 32-byte HKDF output *is* the private key. The private half
|
|
17
|
-
* never leaves the device.
|
|
18
|
-
*/
|
|
19
|
-
signingKey: Uint8Array;
|
|
20
|
-
/** Public half of `signingKey`, registered with the object on first write. */
|
|
21
|
-
signingPublicKey: Uint8Array;
|
|
22
|
-
/** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */
|
|
23
|
-
relayTunnelKey: Uint8Array;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* The same material with byte fields base64url-encoded, matching the wire
|
|
27
|
-
* shapes in the architecture doc (`storage_id` as an opaque id, public key as a
|
|
28
|
-
* "base64url public key"). Secret material is intentionally omitted.
|
|
29
|
-
*/
|
|
30
|
-
export type EncodedUkycClientMaterial = {
|
|
31
|
-
storageId: string;
|
|
32
|
-
signingPublicKey: string;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Derives all UKYC client material from the root `local_user_secret`.
|
|
36
|
-
*
|
|
37
|
-
* This is a pure function of `local_user_secret`: the same input always yields
|
|
38
|
-
* the same outputs, which is what makes `storage_id` and `signing_key` stable
|
|
39
|
-
* across sessions and devices.
|
|
40
|
-
*
|
|
41
|
-
* @param localUserSecret - The `local_user_secret` produced by
|
|
42
|
-
* `getOrCreateLocalUserSecret`.
|
|
43
|
-
* @returns The derived {@link UkycClientMaterial}.
|
|
44
|
-
*/
|
|
45
|
-
export declare function deriveClientMaterial(localUserSecret: Uint8Array): UkycClientMaterial;
|
|
46
|
-
/**
|
|
47
|
-
* Encodes the non-secret client material into the base64url wire shapes used by
|
|
48
|
-
* the UKYC storage API (`storage_id` and `signing_public_key`).
|
|
49
|
-
*
|
|
50
|
-
* @param material - The derived client material.
|
|
51
|
-
* @returns The base64url-encoded, non-secret fields.
|
|
52
|
-
*/
|
|
53
|
-
export declare function encodeClientMaterial(material: UkycClientMaterial): EncodedUkycClientMaterial;
|
|
54
|
-
//# sourceMappingURL=deriveClientMaterial.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deriveClientMaterial.d.cts","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sDAAsD;IACtD,SAAS,EAAE,UAAU,CAAC;IACtB,iFAAiF;IACjF,iBAAiB,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB,8EAA8E;IAC9E,gBAAgB,EAAE,UAAU,CAAC;IAC7B,mFAAmF;IACnF,cAAc,EAAE,UAAU,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,UAAU,GAC1B,kBAAkB,CAkCpB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,kBAAkB,GAC3B,yBAAyB,CAK3B"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derives UKYC client material from the root `local_user_secret` using
|
|
3
|
-
* HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,
|
|
4
|
-
* section "Client-Derived Material".
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* The set of values derived from `local_user_secret`.
|
|
8
|
-
*/
|
|
9
|
-
export type UkycClientMaterial = {
|
|
10
|
-
/** Opaque lookup key for the encrypted KYC object. */
|
|
11
|
-
storageId: Uint8Array;
|
|
12
|
-
/** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */
|
|
13
|
-
dataEncryptionKey: Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Ed25519 private key used to sign `storage_access_token` capabilities. For
|
|
16
|
-
* Ed25519 the 32-byte HKDF output *is* the private key. The private half
|
|
17
|
-
* never leaves the device.
|
|
18
|
-
*/
|
|
19
|
-
signingKey: Uint8Array;
|
|
20
|
-
/** Public half of `signingKey`, registered with the object on first write. */
|
|
21
|
-
signingPublicKey: Uint8Array;
|
|
22
|
-
/** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */
|
|
23
|
-
relayTunnelKey: Uint8Array;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* The same material with byte fields base64url-encoded, matching the wire
|
|
27
|
-
* shapes in the architecture doc (`storage_id` as an opaque id, public key as a
|
|
28
|
-
* "base64url public key"). Secret material is intentionally omitted.
|
|
29
|
-
*/
|
|
30
|
-
export type EncodedUkycClientMaterial = {
|
|
31
|
-
storageId: string;
|
|
32
|
-
signingPublicKey: string;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Derives all UKYC client material from the root `local_user_secret`.
|
|
36
|
-
*
|
|
37
|
-
* This is a pure function of `local_user_secret`: the same input always yields
|
|
38
|
-
* the same outputs, which is what makes `storage_id` and `signing_key` stable
|
|
39
|
-
* across sessions and devices.
|
|
40
|
-
*
|
|
41
|
-
* @param localUserSecret - The `local_user_secret` produced by
|
|
42
|
-
* `getOrCreateLocalUserSecret`.
|
|
43
|
-
* @returns The derived {@link UkycClientMaterial}.
|
|
44
|
-
*/
|
|
45
|
-
export declare function deriveClientMaterial(localUserSecret: Uint8Array): UkycClientMaterial;
|
|
46
|
-
/**
|
|
47
|
-
* Encodes the non-secret client material into the base64url wire shapes used by
|
|
48
|
-
* the UKYC storage API (`storage_id` and `signing_public_key`).
|
|
49
|
-
*
|
|
50
|
-
* @param material - The derived client material.
|
|
51
|
-
* @returns The base64url-encoded, non-secret fields.
|
|
52
|
-
*/
|
|
53
|
-
export declare function encodeClientMaterial(material: UkycClientMaterial): EncodedUkycClientMaterial;
|
|
54
|
-
//# sourceMappingURL=deriveClientMaterial.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deriveClientMaterial.d.mts","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sDAAsD;IACtD,SAAS,EAAE,UAAU,CAAC;IACtB,iFAAiF;IACjF,iBAAiB,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB,8EAA8E;IAC9E,gBAAgB,EAAE,UAAU,CAAC;IAC7B,mFAAmF;IACnF,cAAc,EAAE,UAAU,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAsBF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,UAAU,GAC1B,kBAAkB,CAkCpB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,kBAAkB,GAC3B,yBAAyB,CAK3B"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { stringToBytes } from "@metamask/utils";
|
|
2
|
-
import { ed25519 } from "@noble/curves/ed25519";
|
|
3
|
-
import { hkdf } from "@noble/hashes/hkdf";
|
|
4
|
-
import { sha256 } from "@noble/hashes/sha2";
|
|
5
|
-
import { UKYC_DERIVED_KEY_SIZES, UKYC_KDF_INFO } from "./constants.mjs";
|
|
6
|
-
import { toBase64Url } from "../encoding.mjs";
|
|
7
|
-
/**
|
|
8
|
-
* Derives a single labeled value from `local_user_secret`.
|
|
9
|
-
*
|
|
10
|
-
* No salt is used: `local_user_secret` is already a high-entropy
|
|
11
|
-
* uniformly-random secret, so per-output domain separation comes entirely from
|
|
12
|
-
* the `info` label.
|
|
13
|
-
*
|
|
14
|
-
* @param localUserSecret - The root `local_user_secret` bytes.
|
|
15
|
-
* @param info - Domain-separation label for this output.
|
|
16
|
-
* @param length - Desired output length in bytes.
|
|
17
|
-
* @returns The derived bytes.
|
|
18
|
-
*/
|
|
19
|
-
function deriveLabeled(localUserSecret, info, length) {
|
|
20
|
-
return hkdf(sha256, localUserSecret, undefined, stringToBytes(info), length);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Derives all UKYC client material from the root `local_user_secret`.
|
|
24
|
-
*
|
|
25
|
-
* This is a pure function of `local_user_secret`: the same input always yields
|
|
26
|
-
* the same outputs, which is what makes `storage_id` and `signing_key` stable
|
|
27
|
-
* across sessions and devices.
|
|
28
|
-
*
|
|
29
|
-
* @param localUserSecret - The `local_user_secret` produced by
|
|
30
|
-
* `getOrCreateLocalUserSecret`.
|
|
31
|
-
* @returns The derived {@link UkycClientMaterial}.
|
|
32
|
-
*/
|
|
33
|
-
export function deriveClientMaterial(localUserSecret) {
|
|
34
|
-
const storageId = deriveLabeled(localUserSecret, UKYC_KDF_INFO.storageId, UKYC_DERIVED_KEY_SIZES.storageId);
|
|
35
|
-
const dataEncryptionKey = deriveLabeled(localUserSecret, UKYC_KDF_INFO.dataEncryptionKey, UKYC_DERIVED_KEY_SIZES.dataEncryptionKey);
|
|
36
|
-
const signingKey = deriveLabeled(localUserSecret, UKYC_KDF_INFO.signingKey, UKYC_DERIVED_KEY_SIZES.signingKey);
|
|
37
|
-
const relayTunnelKey = deriveLabeled(localUserSecret, UKYC_KDF_INFO.relayTunnelKey, UKYC_DERIVED_KEY_SIZES.relayTunnelKey);
|
|
38
|
-
const signingPublicKey = ed25519.getPublicKey(signingKey);
|
|
39
|
-
return {
|
|
40
|
-
storageId,
|
|
41
|
-
dataEncryptionKey,
|
|
42
|
-
signingKey,
|
|
43
|
-
signingPublicKey,
|
|
44
|
-
relayTunnelKey,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Encodes the non-secret client material into the base64url wire shapes used by
|
|
49
|
-
* the UKYC storage API (`storage_id` and `signing_public_key`).
|
|
50
|
-
*
|
|
51
|
-
* @param material - The derived client material.
|
|
52
|
-
* @returns The base64url-encoded, non-secret fields.
|
|
53
|
-
*/
|
|
54
|
-
export function encodeClientMaterial(material) {
|
|
55
|
-
return {
|
|
56
|
-
storageId: toBase64Url(material.storageId),
|
|
57
|
-
signingPublicKey: toBase64Url(material.signingPublicKey),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=deriveClientMaterial.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deriveClientMaterial.mjs","sourceRoot":"","sources":["../../src/ukyc/deriveClientMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB;AAChD,OAAO,EAAE,OAAO,EAAE,8BAA8B;AAChD,OAAO,EAAE,IAAI,EAAE,2BAA2B;AAC1C,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAE5C,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,wBAAuB;AACvE,OAAO,EAAE,WAAW,EAAE,wBAAuB;AAsC7C;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CACpB,eAA2B,EAC3B,IAAY,EACZ,MAAc;IAEd,OAAO,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,eAA2B;IAE3B,MAAM,SAAS,GAAG,aAAa,CAC7B,eAAe,EACf,aAAa,CAAC,SAAS,EACvB,sBAAsB,CAAC,SAAS,CACjC,CAAC;IAEF,MAAM,iBAAiB,GAAG,aAAa,CACrC,eAAe,EACf,aAAa,CAAC,iBAAiB,EAC/B,sBAAsB,CAAC,iBAAiB,CACzC,CAAC;IAEF,MAAM,UAAU,GAAG,aAAa,CAC9B,eAAe,EACf,aAAa,CAAC,UAAU,EACxB,sBAAsB,CAAC,UAAU,CAClC,CAAC;IAEF,MAAM,cAAc,GAAG,aAAa,CAClC,eAAe,EACf,aAAa,CAAC,cAAc,EAC5B,sBAAsB,CAAC,cAAc,CACtC,CAAC;IAEF,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAE1D,OAAO;QACL,SAAS;QACT,iBAAiB;QACjB,UAAU;QACV,gBAAgB;QAChB,cAAc;KACf,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA4B;IAE5B,OAAO;QACL,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,gBAAgB,EAAE,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KACzD,CAAC;AACJ,CAAC","sourcesContent":["import { stringToBytes } from '@metamask/utils';\nimport { ed25519 } from '@noble/curves/ed25519';\nimport { hkdf } from '@noble/hashes/hkdf';\nimport { sha256 } from '@noble/hashes/sha2';\n\nimport { UKYC_DERIVED_KEY_SIZES, UKYC_KDF_INFO } from './constants.js';\nimport { toBase64Url } from '../encoding.js';\n\n/**\n * Derives UKYC client material from the root `local_user_secret` using\n * HKDF-SHA256 with domain-separated `info` labels — see the architecture doc,\n * section \"Client-Derived Material\".\n */\n\n/**\n * The set of values derived from `local_user_secret`.\n */\nexport type UkycClientMaterial = {\n /** Opaque lookup key for the encrypted KYC object. */\n storageId: Uint8Array;\n /** Symmetric key that encrypts `encrypted_kyc_data` (or wraps per-blob keys). */\n dataEncryptionKey: Uint8Array;\n /**\n * Ed25519 private key used to sign `storage_access_token` capabilities. For\n * Ed25519 the 32-byte HKDF output *is* the private key. The private half\n * never leaves the device.\n */\n signingKey: Uint8Array;\n /** Public half of `signingKey`, registered with the object on first write. */\n signingPublicKey: Uint8Array;\n /** Key for establishing/authenticating the encrypted tunnel to idOS, if needed. */\n relayTunnelKey: Uint8Array;\n};\n\n/**\n * The same material with byte fields base64url-encoded, matching the wire\n * shapes in the architecture doc (`storage_id` as an opaque id, public key as a\n * \"base64url public key\"). Secret material is intentionally omitted.\n */\nexport type EncodedUkycClientMaterial = {\n storageId: string;\n signingPublicKey: string;\n};\n\n/**\n * Derives a single labeled value from `local_user_secret`.\n *\n * No salt is used: `local_user_secret` is already a high-entropy\n * uniformly-random secret, so per-output domain separation comes entirely from\n * the `info` label.\n *\n * @param localUserSecret - The root `local_user_secret` bytes.\n * @param info - Domain-separation label for this output.\n * @param length - Desired output length in bytes.\n * @returns The derived bytes.\n */\nfunction deriveLabeled(\n localUserSecret: Uint8Array,\n info: string,\n length: number,\n): Uint8Array {\n return hkdf(sha256, localUserSecret, undefined, stringToBytes(info), length);\n}\n\n/**\n * Derives all UKYC client material from the root `local_user_secret`.\n *\n * This is a pure function of `local_user_secret`: the same input always yields\n * the same outputs, which is what makes `storage_id` and `signing_key` stable\n * across sessions and devices.\n *\n * @param localUserSecret - The `local_user_secret` produced by\n * `getOrCreateLocalUserSecret`.\n * @returns The derived {@link UkycClientMaterial}.\n */\nexport function deriveClientMaterial(\n localUserSecret: Uint8Array,\n): UkycClientMaterial {\n const storageId = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.storageId,\n UKYC_DERIVED_KEY_SIZES.storageId,\n );\n\n const dataEncryptionKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.dataEncryptionKey,\n UKYC_DERIVED_KEY_SIZES.dataEncryptionKey,\n );\n\n const signingKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.signingKey,\n UKYC_DERIVED_KEY_SIZES.signingKey,\n );\n\n const relayTunnelKey = deriveLabeled(\n localUserSecret,\n UKYC_KDF_INFO.relayTunnelKey,\n UKYC_DERIVED_KEY_SIZES.relayTunnelKey,\n );\n\n const signingPublicKey = ed25519.getPublicKey(signingKey);\n\n return {\n storageId,\n dataEncryptionKey,\n signingKey,\n signingPublicKey,\n relayTunnelKey,\n };\n}\n\n/**\n * Encodes the non-secret client material into the base64url wire shapes used by\n * the UKYC storage API (`storage_id` and `signing_public_key`).\n *\n * @param material - The derived client material.\n * @returns The base64url-encoded, non-secret fields.\n */\nexport function encodeClientMaterial(\n material: UkycClientMaterial,\n): EncodedUkycClientMaterial {\n return {\n storageId: toBase64Url(material.storageId),\n signingPublicKey: toBase64Url(material.signingPublicKey),\n };\n}\n"]}
|
package/dist/ukyc/jwtChain.cjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyJwtChain = void 0;
|
|
4
|
-
const utils_1 = require("@metamask/utils");
|
|
5
|
-
const ed25519_1 = require("@noble/curves/ed25519");
|
|
6
|
-
const encoding_js_1 = require("../encoding.cjs");
|
|
7
|
-
/**
|
|
8
|
-
* Decodes a base64url JWT segment into a parsed JSON object.
|
|
9
|
-
*
|
|
10
|
-
* @param segment - The base64url-encoded segment.
|
|
11
|
-
* @param label - Human-readable segment name for error messages.
|
|
12
|
-
* @returns The parsed JSON object.
|
|
13
|
-
*/
|
|
14
|
-
function decodeJsonSegment(segment, label) {
|
|
15
|
-
try {
|
|
16
|
-
return JSON.parse((0, utils_1.bytesToString)((0, encoding_js_1.base64UrlToBytes)(segment)));
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
throw new Error(`UKYC: failed to decode jwtChain ${label}: ${String(error)}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Verifies `jwtChain` against `keys`: matches the JWT header `kid` to a
|
|
24
|
-
* published Ed25519 signing key and checks the EdDSA signature over the
|
|
25
|
-
* `header.payload` input. Returns the decoded, verified payload.
|
|
26
|
-
*
|
|
27
|
-
* @param keys - The JWKS keys published by the Fractal encryption service.
|
|
28
|
-
* @param jwtChain - The compact-serialized EdDSA JWT from `getWrappingKey`.
|
|
29
|
-
* @returns The verified JWT payload.
|
|
30
|
-
*/
|
|
31
|
-
function verifyJwtChain(keys, jwtChain) {
|
|
32
|
-
const [headerSegment, payloadSegment, signatureSegment] = jwtChain.split('.');
|
|
33
|
-
if (!headerSegment || !payloadSegment || !signatureSegment) {
|
|
34
|
-
throw new Error('UKYC: jwtChain is not a well-formed JWT (expected 3 segments).');
|
|
35
|
-
}
|
|
36
|
-
const header = decodeJsonSegment(headerSegment, 'header');
|
|
37
|
-
if (header.alg !== 'EdDSA') {
|
|
38
|
-
throw new Error(`UKYC: unsupported jwtChain alg "${String(header.alg)}" (expected EdDSA).`);
|
|
39
|
-
}
|
|
40
|
-
const jwk = keys.find((key) => key.kid === header.kid);
|
|
41
|
-
if (!jwk) {
|
|
42
|
-
throw new Error(`UKYC: no JWKS key matches jwtChain kid "${String(header.kid)}".`);
|
|
43
|
-
}
|
|
44
|
-
if (jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519') {
|
|
45
|
-
throw new Error(`UKYC: JWKS key ${jwk.kid} is not an Ed25519 OKP key (kty=${jwk.kty}, crv=${jwk.crv}).`);
|
|
46
|
-
}
|
|
47
|
-
const isValid = ed25519_1.ed25519.verify((0, encoding_js_1.base64UrlToBytes)(signatureSegment), new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), (0, encoding_js_1.base64UrlToBytes)(jwk.x));
|
|
48
|
-
if (!isValid) {
|
|
49
|
-
throw new Error('UKYC: jwtChain signature verification failed against JWKS.');
|
|
50
|
-
}
|
|
51
|
-
return decodeJsonSegment(payloadSegment, 'payload');
|
|
52
|
-
}
|
|
53
|
-
exports.verifyJwtChain = verifyJwtChain;
|
|
54
|
-
//# sourceMappingURL=jwtChain.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwtChain.cjs","sourceRoot":"","sources":["../../src/ukyc/jwtChain.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAChD,mDAAgD;AAEhD,iDAAkD;AA0ClD;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAO,OAAe,EAAE,KAAa;IAC7D,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,qBAAa,EAAC,IAAA,8BAAgB,EAAC,OAAO,CAAC,CAAC,CAAS,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mCAAmC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAC7D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAW,EAAE,QAAgB;IAC1D,MAAM,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9E,IAAI,CAAC,aAAa,IAAI,CAAC,cAAc,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAY,aAAa,EAAE,QAAQ,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,mCAAmC,MAAM,CACvC,MAAM,CAAC,GAAG,CACX,qBAAqB,CACvB,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,2CAA2C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAClE,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,CAAC,GAAG,KAAK,KAAK,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,kBAAkB,GAAG,CAAC,GAAG,mCAAmC,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,IAAI,CACxF,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,iBAAO,CAAC,MAAM,CAC5B,IAAA,8BAAgB,EAAC,gBAAgB,CAAC,EAClC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,aAAa,IAAI,cAAc,EAAE,CAAC,EAC9D,IAAA,8BAAgB,EAAC,GAAG,CAAC,CAAC,CAAC,CACxB,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB,CAAkB,cAAc,EAAE,SAAS,CAAC,CAAC;AACvE,CAAC;AAzCD,wCAyCC","sourcesContent":["import { bytesToString } from '@metamask/utils';\nimport { ed25519 } from '@noble/curves/ed25519';\n\nimport { base64UrlToBytes } from '../encoding.js';\n\n/**\n * Verifies the `jwtChain` returned by the Fractal encryption service against\n * its published JWKS.\n *\n * The signature check is done with `@noble/curves` (rather than WebCrypto\n * `subtle`) because not every MetaMask runtime exposes a `subtle`\n * implementation for Ed25519; JWT parsing is a plain base64url/JSON decode, so\n * no `jose` dependency is required.\n */\n\n/**\n * A single Ed25519 (OKP) JSON Web Key from the Fractal JWKS.\n */\nexport type Jwk = {\n kty: string;\n crv: string;\n x: string;\n kid: string;\n use?: string;\n alg?: string;\n};\n\n/**\n * The verified `jwtChain` payload. `sessionServerPublicKeyX` attests the\n * server's X25519 public key so the client can confirm the value returned\n * out-of-band by `getWrappingKey` was not tampered with.\n */\nexport type JwtChainPayload = {\n sessionServerPublicKeyX: string;\n nonce: string;\n};\n\n/**\n * The protected header of a compact JWT.\n */\ntype JwtHeader = {\n alg?: string;\n kid?: string;\n};\n\n/**\n * Decodes a base64url JWT segment into a parsed JSON object.\n *\n * @param segment - The base64url-encoded segment.\n * @param label - Human-readable segment name for error messages.\n * @returns The parsed JSON object.\n */\nfunction decodeJsonSegment<Type>(segment: string, label: string): Type {\n try {\n return JSON.parse(bytesToString(base64UrlToBytes(segment))) as Type;\n } catch (error) {\n throw new Error(\n `UKYC: failed to decode jwtChain ${label}: ${String(error)}`,\n );\n }\n}\n\n/**\n * Verifies `jwtChain` against `keys`: matches the JWT header `kid` to a\n * published Ed25519 signing key and checks the EdDSA signature over the\n * `header.payload` input. Returns the decoded, verified payload.\n *\n * @param keys - The JWKS keys published by the Fractal encryption service.\n * @param jwtChain - The compact-serialized EdDSA JWT from `getWrappingKey`.\n * @returns The verified JWT payload.\n */\nexport function verifyJwtChain(keys: Jwk[], jwtChain: string): JwtChainPayload {\n const [headerSegment, payloadSegment, signatureSegment] = jwtChain.split('.');\n if (!headerSegment || !payloadSegment || !signatureSegment) {\n throw new Error(\n 'UKYC: jwtChain is not a well-formed JWT (expected 3 segments).',\n );\n }\n\n const header = decodeJsonSegment<JwtHeader>(headerSegment, 'header');\n if (header.alg !== 'EdDSA') {\n throw new Error(\n `UKYC: unsupported jwtChain alg \"${String(\n header.alg,\n )}\" (expected EdDSA).`,\n );\n }\n\n const jwk = keys.find((key) => key.kid === header.kid);\n if (!jwk) {\n throw new Error(\n `UKYC: no JWKS key matches jwtChain kid \"${String(header.kid)}\".`,\n );\n }\n if (jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519') {\n throw new Error(\n `UKYC: JWKS key ${jwk.kid} is not an Ed25519 OKP key (kty=${jwk.kty}, crv=${jwk.crv}).`,\n );\n }\n\n const isValid = ed25519.verify(\n base64UrlToBytes(signatureSegment),\n new TextEncoder().encode(`${headerSegment}.${payloadSegment}`),\n base64UrlToBytes(jwk.x),\n );\n if (!isValid) {\n throw new Error(\n 'UKYC: jwtChain signature verification failed against JWKS.',\n );\n }\n\n return decodeJsonSegment<JwtChainPayload>(payloadSegment, 'payload');\n}\n"]}
|
package/dist/ukyc/jwtChain.d.cts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies the `jwtChain` returned by the Fractal encryption service against
|
|
3
|
-
* its published JWKS.
|
|
4
|
-
*
|
|
5
|
-
* The signature check is done with `@noble/curves` (rather than WebCrypto
|
|
6
|
-
* `subtle`) because not every MetaMask runtime exposes a `subtle`
|
|
7
|
-
* implementation for Ed25519; JWT parsing is a plain base64url/JSON decode, so
|
|
8
|
-
* no `jose` dependency is required.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A single Ed25519 (OKP) JSON Web Key from the Fractal JWKS.
|
|
12
|
-
*/
|
|
13
|
-
export type Jwk = {
|
|
14
|
-
kty: string;
|
|
15
|
-
crv: string;
|
|
16
|
-
x: string;
|
|
17
|
-
kid: string;
|
|
18
|
-
use?: string;
|
|
19
|
-
alg?: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The verified `jwtChain` payload. `sessionServerPublicKeyX` attests the
|
|
23
|
-
* server's X25519 public key so the client can confirm the value returned
|
|
24
|
-
* out-of-band by `getWrappingKey` was not tampered with.
|
|
25
|
-
*/
|
|
26
|
-
export type JwtChainPayload = {
|
|
27
|
-
sessionServerPublicKeyX: string;
|
|
28
|
-
nonce: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Verifies `jwtChain` against `keys`: matches the JWT header `kid` to a
|
|
32
|
-
* published Ed25519 signing key and checks the EdDSA signature over the
|
|
33
|
-
* `header.payload` input. Returns the decoded, verified payload.
|
|
34
|
-
*
|
|
35
|
-
* @param keys - The JWKS keys published by the Fractal encryption service.
|
|
36
|
-
* @param jwtChain - The compact-serialized EdDSA JWT from `getWrappingKey`.
|
|
37
|
-
* @returns The verified JWT payload.
|
|
38
|
-
*/
|
|
39
|
-
export declare function verifyJwtChain(keys: Jwk[], jwtChain: string): JwtChainPayload;
|
|
40
|
-
//# sourceMappingURL=jwtChain.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwtChain.d.cts","sourceRoot":"","sources":["../../src/ukyc/jwtChain.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,EAAE,MAAM,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA2BF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAyC7E"}
|
package/dist/ukyc/jwtChain.d.mts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies the `jwtChain` returned by the Fractal encryption service against
|
|
3
|
-
* its published JWKS.
|
|
4
|
-
*
|
|
5
|
-
* The signature check is done with `@noble/curves` (rather than WebCrypto
|
|
6
|
-
* `subtle`) because not every MetaMask runtime exposes a `subtle`
|
|
7
|
-
* implementation for Ed25519; JWT parsing is a plain base64url/JSON decode, so
|
|
8
|
-
* no `jose` dependency is required.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A single Ed25519 (OKP) JSON Web Key from the Fractal JWKS.
|
|
12
|
-
*/
|
|
13
|
-
export type Jwk = {
|
|
14
|
-
kty: string;
|
|
15
|
-
crv: string;
|
|
16
|
-
x: string;
|
|
17
|
-
kid: string;
|
|
18
|
-
use?: string;
|
|
19
|
-
alg?: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The verified `jwtChain` payload. `sessionServerPublicKeyX` attests the
|
|
23
|
-
* server's X25519 public key so the client can confirm the value returned
|
|
24
|
-
* out-of-band by `getWrappingKey` was not tampered with.
|
|
25
|
-
*/
|
|
26
|
-
export type JwtChainPayload = {
|
|
27
|
-
sessionServerPublicKeyX: string;
|
|
28
|
-
nonce: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Verifies `jwtChain` against `keys`: matches the JWT header `kid` to a
|
|
32
|
-
* published Ed25519 signing key and checks the EdDSA signature over the
|
|
33
|
-
* `header.payload` input. Returns the decoded, verified payload.
|
|
34
|
-
*
|
|
35
|
-
* @param keys - The JWKS keys published by the Fractal encryption service.
|
|
36
|
-
* @param jwtChain - The compact-serialized EdDSA JWT from `getWrappingKey`.
|
|
37
|
-
* @returns The verified JWT payload.
|
|
38
|
-
*/
|
|
39
|
-
export declare function verifyJwtChain(keys: Jwk[], jwtChain: string): JwtChainPayload;
|
|
40
|
-
//# sourceMappingURL=jwtChain.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwtChain.d.mts","sourceRoot":"","sources":["../../src/ukyc/jwtChain.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,EAAE,MAAM,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA2BF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAyC7E"}
|
package/dist/ukyc/jwtChain.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { bytesToString } from "@metamask/utils";
|
|
2
|
-
import { ed25519 } from "@noble/curves/ed25519";
|
|
3
|
-
import { base64UrlToBytes } from "../encoding.mjs";
|
|
4
|
-
/**
|
|
5
|
-
* Decodes a base64url JWT segment into a parsed JSON object.
|
|
6
|
-
*
|
|
7
|
-
* @param segment - The base64url-encoded segment.
|
|
8
|
-
* @param label - Human-readable segment name for error messages.
|
|
9
|
-
* @returns The parsed JSON object.
|
|
10
|
-
*/
|
|
11
|
-
function decodeJsonSegment(segment, label) {
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(bytesToString(base64UrlToBytes(segment)));
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
throw new Error(`UKYC: failed to decode jwtChain ${label}: ${String(error)}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Verifies `jwtChain` against `keys`: matches the JWT header `kid` to a
|
|
21
|
-
* published Ed25519 signing key and checks the EdDSA signature over the
|
|
22
|
-
* `header.payload` input. Returns the decoded, verified payload.
|
|
23
|
-
*
|
|
24
|
-
* @param keys - The JWKS keys published by the Fractal encryption service.
|
|
25
|
-
* @param jwtChain - The compact-serialized EdDSA JWT from `getWrappingKey`.
|
|
26
|
-
* @returns The verified JWT payload.
|
|
27
|
-
*/
|
|
28
|
-
export function verifyJwtChain(keys, jwtChain) {
|
|
29
|
-
const [headerSegment, payloadSegment, signatureSegment] = jwtChain.split('.');
|
|
30
|
-
if (!headerSegment || !payloadSegment || !signatureSegment) {
|
|
31
|
-
throw new Error('UKYC: jwtChain is not a well-formed JWT (expected 3 segments).');
|
|
32
|
-
}
|
|
33
|
-
const header = decodeJsonSegment(headerSegment, 'header');
|
|
34
|
-
if (header.alg !== 'EdDSA') {
|
|
35
|
-
throw new Error(`UKYC: unsupported jwtChain alg "${String(header.alg)}" (expected EdDSA).`);
|
|
36
|
-
}
|
|
37
|
-
const jwk = keys.find((key) => key.kid === header.kid);
|
|
38
|
-
if (!jwk) {
|
|
39
|
-
throw new Error(`UKYC: no JWKS key matches jwtChain kid "${String(header.kid)}".`);
|
|
40
|
-
}
|
|
41
|
-
if (jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519') {
|
|
42
|
-
throw new Error(`UKYC: JWKS key ${jwk.kid} is not an Ed25519 OKP key (kty=${jwk.kty}, crv=${jwk.crv}).`);
|
|
43
|
-
}
|
|
44
|
-
const isValid = ed25519.verify(base64UrlToBytes(signatureSegment), new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), base64UrlToBytes(jwk.x));
|
|
45
|
-
if (!isValid) {
|
|
46
|
-
throw new Error('UKYC: jwtChain signature verification failed against JWKS.');
|
|
47
|
-
}
|
|
48
|
-
return decodeJsonSegment(payloadSegment, 'payload');
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=jwtChain.mjs.map
|