@libid/contracts 0.17.0 → 0.18.1
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/README.md +108 -47
- package/dist/abis/bindErrors.d.ts +714 -0
- package/dist/abis/bindErrors.d.ts.map +1 -0
- package/dist/abis/bindErrors.js +955 -0
- package/dist/abis/bindErrors.js.map +1 -0
- package/dist/abis/ceremonyPayloads.d.ts +118 -0
- package/dist/abis/ceremonyPayloads.d.ts.map +1 -0
- package/dist/abis/ceremonyPayloads.js +154 -0
- package/dist/abis/ceremonyPayloads.js.map +1 -0
- package/dist/abis/ceremonyProofVerifier.d.ts +6 -6
- package/dist/abis/ceremonyProofVerifier.js +6 -6
- package/dist/abis/ceremonyProofVerifier.js.map +1 -1
- package/dist/abis/handleEscrow.d.ts +56 -16
- package/dist/abis/handleEscrow.d.ts.map +1 -1
- package/dist/abis/handleEscrow.js +71 -19
- package/dist/abis/handleEscrow.js.map +1 -1
- package/dist/abis/honkVerifierErrors.d.ts +54 -0
- package/dist/abis/honkVerifierErrors.d.ts.map +1 -0
- package/dist/abis/honkVerifierErrors.js +71 -0
- package/dist/abis/honkVerifierErrors.js.map +1 -0
- package/dist/abis/identityRegistry.d.ts +123 -157
- package/dist/abis/identityRegistry.d.ts.map +1 -1
- package/dist/abis/identityRegistry.js +150 -194
- package/dist/abis/identityRegistry.js.map +1 -1
- package/dist/abis/index.d.ts +3 -0
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +3 -0
- package/dist/abis/index.js.map +1 -1
- package/dist/calls/handleEscrow.d.ts +1 -0
- package/dist/calls/handleEscrow.d.ts.map +1 -1
- package/dist/calls/handleEscrow.js +7 -0
- package/dist/calls/handleEscrow.js.map +1 -1
- package/dist/calls/identityRegistry.d.ts +2 -1
- package/dist/calls/identityRegistry.d.ts.map +1 -1
- package/dist/calls/identityRegistry.js +9 -2
- package/dist/calls/identityRegistry.js.map +1 -1
- package/dist/ceremony/profiles.d.ts +38 -48
- package/dist/ceremony/profiles.d.ts.map +1 -1
- package/dist/ceremony/profiles.js +31 -36
- package/dist/ceremony/profiles.js.map +1 -1
- package/dist/identity/index.d.ts +1 -3
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +5 -11
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/resolve.d.ts +6 -8
- package/dist/identity/resolve.d.ts.map +1 -1
- package/dist/identity/resolve.js +53 -86
- package/dist/identity/resolve.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/payloads.d.ts +124 -0
- package/dist/payloads.d.ts.map +1 -0
- package/dist/payloads.js +59 -0
- package/dist/payloads.js.map +1 -0
- package/dist/platforms/handle.d.ts +11 -0
- package/dist/platforms/handle.d.ts.map +1 -0
- package/dist/platforms/handle.js +29 -0
- package/dist/platforms/handle.js.map +1 -0
- package/dist/platforms/id.d.ts +8 -0
- package/dist/platforms/id.d.ts.map +1 -0
- package/dist/platforms/id.js +21 -0
- package/dist/platforms/id.js.map +1 -0
- package/dist/platforms/index.d.ts +5 -0
- package/dist/platforms/index.d.ts.map +1 -0
- package/dist/platforms/index.js +8 -0
- package/dist/platforms/index.js.map +1 -0
- package/dist/platforms/node.d.ts +4 -0
- package/dist/platforms/node.d.ts.map +1 -0
- package/dist/platforms/node.js +36 -0
- package/dist/platforms/node.js.map +1 -0
- package/dist/platforms/platforms.d.ts +39 -0
- package/dist/platforms/platforms.d.ts.map +1 -0
- package/dist/platforms/platforms.js +90 -0
- package/dist/platforms/platforms.js.map +1 -0
- package/package.json +11 -3
- package/src/abis/bindErrors.ts +957 -0
- package/src/abis/ceremonyPayloads.ts +156 -0
- package/src/abis/ceremonyProofVerifier.ts +6 -6
- package/src/abis/handleEscrow.ts +71 -19
- package/src/abis/honkVerifierErrors.ts +73 -0
- package/src/abis/identityRegistry.ts +150 -194
- package/src/abis/index.ts +3 -0
- package/src/calls/handleEscrow.ts +12 -0
- package/src/calls/identityRegistry.ts +14 -2
- package/src/ceremony/profiles.ts +53 -65
- package/src/identity/index.ts +5 -11
- package/src/identity/resolve.ts +71 -118
- package/src/index.ts +3 -4
- package/src/payloads.ts +90 -0
- package/src/platforms/handle.ts +36 -0
- package/src/platforms/id.ts +26 -0
- package/src/platforms/index.ts +8 -0
- package/src/platforms/node.ts +41 -0
- package/src/platforms/platforms.ts +114 -0
- package/dist/identity/handle.d.ts +0 -22
- package/dist/identity/handle.d.ts.map +0 -1
- package/dist/identity/handle.js +0 -140
- package/dist/identity/handle.js.map +0 -1
- package/dist/identity/handleVectors.d.ts +0 -50
- package/dist/identity/handleVectors.d.ts.map +0 -1
- package/dist/identity/handleVectors.js +0 -89
- package/dist/identity/handleVectors.js.map +0 -1
- package/dist/identity/node.d.ts +0 -5
- package/dist/identity/node.d.ts.map +0 -1
- package/dist/identity/node.js +0 -19
- package/dist/identity/node.js.map +0 -1
- package/src/identity/handle.ts +0 -176
- package/src/identity/handleVectors.ts +0 -104
- package/src/identity/node.ts +0 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/identity/resolve.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/identity/resolve.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,GAAG;AACH,8EAA8E;AAC9E,6BAA6B;AAE7B,OAAO,EAAgB,SAAS,EAAqB,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAM1E,0EAA0E;AAC1E,eAAe;AACf,MAAM,UAAU,UAAU,CAAmB,WAA2B;IACtE,OAAO,SAAS,CAAC,KAAK,CAAC,W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ED,mFAAmF;AACnF,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAsB,EACtB,MAAe,EACf,IAAY,EACZ,KAAa;IAEb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAsB,MAAM,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3F,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QACtE,UAAU;QACV,MAAM;QACN,UAAU;QACV,aAAa;KACd,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAA;AAC/B,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// @libid/contracts
|
|
2
|
-
///
|
|
3
|
-
/// imports work too: `@libid/contracts/abis`, `@libid/contracts/calls`,
|
|
4
|
-
/// `@libid/contracts/identity` and `@libid/contracts/ceremony`.
|
|
1
|
+
/// @libid/contracts: viem-ready ABIs, call builders, identity helpers and
|
|
2
|
+
/// `bind` payload encoders. Subpaths: `/abis`, `/calls`, `/identity`, `/ceremony`.
|
|
5
3
|
export * from './abis/index.js';
|
|
6
4
|
export * as calls from './calls/index.js';
|
|
7
5
|
export * from './ceremony/index.js';
|
|
8
6
|
export * from './identity/index.js';
|
|
7
|
+
export * from './payloads.js';
|
|
9
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mFAAmF;AAEnF,cAAc,iBAAiB,CAAA;AAE/B,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { type AbiParameterToPrimitiveType, type Hex } from 'viem';
|
|
2
|
+
declare const TLS_NOTARY_PROOF: readonly [{
|
|
3
|
+
readonly name: "payload";
|
|
4
|
+
readonly type: "tuple";
|
|
5
|
+
readonly internalType: "struct TlsNotaryVerifierBase.TlsNotaryProof";
|
|
6
|
+
readonly components: readonly [{
|
|
7
|
+
readonly name: "ceremonyVersion";
|
|
8
|
+
readonly type: "uint16";
|
|
9
|
+
readonly internalType: "uint16";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "operationDomain";
|
|
12
|
+
readonly type: "bytes32";
|
|
13
|
+
readonly internalType: "bytes32";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "authorizationNonce";
|
|
16
|
+
readonly type: "bytes32";
|
|
17
|
+
readonly internalType: "bytes32";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "transactionData";
|
|
20
|
+
readonly type: "bytes";
|
|
21
|
+
readonly internalType: "bytes";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "tokenSession";
|
|
24
|
+
readonly type: "tuple";
|
|
25
|
+
readonly internalType: "struct ICeremony.Attestation";
|
|
26
|
+
readonly components: readonly [{
|
|
27
|
+
readonly name: "attestedData";
|
|
28
|
+
readonly type: "bytes";
|
|
29
|
+
readonly internalType: "bytes";
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "proof";
|
|
32
|
+
readonly type: "bytes";
|
|
33
|
+
readonly internalType: "bytes";
|
|
34
|
+
}];
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "identitySession";
|
|
37
|
+
readonly type: "tuple";
|
|
38
|
+
readonly internalType: "struct ICeremony.Attestation";
|
|
39
|
+
readonly components: readonly [{
|
|
40
|
+
readonly name: "attestedData";
|
|
41
|
+
readonly type: "bytes";
|
|
42
|
+
readonly internalType: "bytes";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "proof";
|
|
45
|
+
readonly type: "bytes";
|
|
46
|
+
readonly internalType: "bytes";
|
|
47
|
+
}];
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "idNode";
|
|
50
|
+
readonly type: "bytes32";
|
|
51
|
+
readonly internalType: "bytes32";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "handleNode";
|
|
54
|
+
readonly type: "bytes32";
|
|
55
|
+
readonly internalType: "bytes32";
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "proof";
|
|
58
|
+
readonly type: "bytes";
|
|
59
|
+
readonly internalType: "bytes";
|
|
60
|
+
}];
|
|
61
|
+
}];
|
|
62
|
+
declare const GOOGLE_PROOF: readonly [{
|
|
63
|
+
readonly name: "payload";
|
|
64
|
+
readonly type: "tuple";
|
|
65
|
+
readonly internalType: "struct GooglePlatformVerifier.GoogleProof";
|
|
66
|
+
readonly components: readonly [{
|
|
67
|
+
readonly name: "ceremonyVersion";
|
|
68
|
+
readonly type: "uint16";
|
|
69
|
+
readonly internalType: "uint16";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "operationDomain";
|
|
72
|
+
readonly type: "bytes32";
|
|
73
|
+
readonly internalType: "bytes32";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "authorizationNonce";
|
|
76
|
+
readonly type: "bytes32";
|
|
77
|
+
readonly internalType: "bytes32";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "transactionData";
|
|
80
|
+
readonly type: "bytes";
|
|
81
|
+
readonly internalType: "bytes";
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "clientIdentifier";
|
|
84
|
+
readonly type: "bytes";
|
|
85
|
+
readonly internalType: "bytes";
|
|
86
|
+
}, {
|
|
87
|
+
readonly name: "idNode";
|
|
88
|
+
readonly type: "bytes32";
|
|
89
|
+
readonly internalType: "bytes32";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "handleNode";
|
|
92
|
+
readonly type: "bytes32";
|
|
93
|
+
readonly internalType: "bytes32";
|
|
94
|
+
}, {
|
|
95
|
+
readonly name: "exp";
|
|
96
|
+
readonly type: "uint64";
|
|
97
|
+
readonly internalType: "uint64";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "modulus";
|
|
100
|
+
readonly type: "bytes32[18]";
|
|
101
|
+
readonly internalType: "bytes32[18]";
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "proof";
|
|
104
|
+
readonly type: "bytes";
|
|
105
|
+
readonly internalType: "bytes";
|
|
106
|
+
}];
|
|
107
|
+
}];
|
|
108
|
+
export type TlsNotaryProof = AbiParameterToPrimitiveType<(typeof TLS_NOTARY_PROOF)[0]>;
|
|
109
|
+
export type GoogleProof = AbiParameterToPrimitiveType<(typeof GOOGLE_PROOF)[0]>;
|
|
110
|
+
export declare function encodeTlsNotaryProof(payload: TlsNotaryProof): Hex;
|
|
111
|
+
export declare function decodeTlsNotaryProof(data: Hex): TlsNotaryProof;
|
|
112
|
+
export declare function encodeGoogleProof(payload: GoogleProof): Hex;
|
|
113
|
+
export declare function decodeGoogleProof(data: Hex): GoogleProof;
|
|
114
|
+
export type GoogleProofFields = Pick<GoogleProof, 'idNode' | 'handleNode' | 'exp' | 'modulus'>;
|
|
115
|
+
export declare class GooglePublicInputMismatch extends Error {
|
|
116
|
+
readonly field: 'count' | 'digest' | 'audience';
|
|
117
|
+
constructor(field: 'count' | 'digest' | 'audience');
|
|
118
|
+
}
|
|
119
|
+
export declare function googleProofFields(publicInputs: readonly Hex[], expected: {
|
|
120
|
+
digest: Hex;
|
|
121
|
+
clientIdentifier: Hex;
|
|
122
|
+
}): GoogleProofFields;
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=payloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../src/payloads.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,2BAA2B,EAGhC,KAAK,GAAG,EAKT,MAAM,MAAM,CAAA;AAcb,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA2B,CAAA;AACjD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwB,CAAA;AAG1C,MAAM,MAAM,cAAc,GAAG,2BAA2B,CAAC,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAGtF,MAAM,MAAM,WAAW,GAAG,2BAA2B,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAG/E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,GAAG,CAEjE;AAGD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,GAAG,cAAc,CAE9D;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,GAAG,CAE3D;AAGD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,WAAW,CAExD;AAGD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,SAAS,CAAC,CAAA;AAI9F,qBAAa,yBAA0B,SAAQ,KAAK;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU;gBAAtC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU;CAM5D;AAKD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,SAAS,GAAG,EAAE,EAC5B,QAAQ,EAAE;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAA;CAAE,GAC/C,iBAAiB,CAcnB"}
|
package/dist/payloads.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// The payloads `IdentityRegistry.bind` carries to a Platform Verifier,
|
|
2
|
+
/// encoded with the tuple types `ceremonyPayloadsAbi` carries, no selector.
|
|
3
|
+
import { decodeAbiParameters, encodeAbiParameters, hexToBigInt, hexToBytes, numberToHex, sha256, } from 'viem';
|
|
4
|
+
import { ceremonyPayloadsAbi } from './abis/ceremonyPayloads.js';
|
|
5
|
+
function inputs(name) {
|
|
6
|
+
const item = ceremonyPayloadsAbi.find((entry) => entry.type === 'function' && entry.name === name);
|
|
7
|
+
if (!item)
|
|
8
|
+
throw new Error(`ceremonyPayloadsAbi has no ${name}`);
|
|
9
|
+
return item.inputs;
|
|
10
|
+
}
|
|
11
|
+
const TLS_NOTARY_PROOF = inputs('tlsNotaryProof');
|
|
12
|
+
const GOOGLE_PROOF = inputs('googleProof');
|
|
13
|
+
/// The `x/v1` or `github/v1` payload, as the verifier decodes it.
|
|
14
|
+
export function encodeTlsNotaryProof(payload) {
|
|
15
|
+
return encodeAbiParameters(TLS_NOTARY_PROOF, [payload]);
|
|
16
|
+
}
|
|
17
|
+
/// A TLSNotary payload back into its fields. Throws on bytes that are not one.
|
|
18
|
+
export function decodeTlsNotaryProof(data) {
|
|
19
|
+
return decodeAbiParameters(TLS_NOTARY_PROOF, data)[0];
|
|
20
|
+
}
|
|
21
|
+
/// The `google/v1` payload, as the verifier decodes it.
|
|
22
|
+
export function encodeGoogleProof(payload) {
|
|
23
|
+
return encodeAbiParameters(GOOGLE_PROOF, [payload]);
|
|
24
|
+
}
|
|
25
|
+
/// A Google payload back into its fields. Throws on bytes that are not one.
|
|
26
|
+
export function decodeGoogleProof(data) {
|
|
27
|
+
return decodeAbiParameters(GOOGLE_PROOF, data)[0];
|
|
28
|
+
}
|
|
29
|
+
/// The oidc-google public input that disagrees with the payload: the verifier
|
|
30
|
+
/// would fail the proof, so a client checks before sending.
|
|
31
|
+
export class GooglePublicInputMismatch extends Error {
|
|
32
|
+
field;
|
|
33
|
+
constructor(field) {
|
|
34
|
+
super(`the proof's ${field} public input${field === 'count' ? 's do' : ' does'} not match the payload`);
|
|
35
|
+
this.field = field;
|
|
36
|
+
this.name = 'GooglePublicInputMismatch';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/// The payload fields from the prover's 57 oidc-google public inputs
|
|
40
|
+
/// (REQ-PLAT-16B), after checking the digest the token's `nonce` carried and
|
|
41
|
+
/// the audience against what the verifier builds them from.
|
|
42
|
+
export function googleProofFields(publicInputs, expected) {
|
|
43
|
+
if (publicInputs.length !== 57)
|
|
44
|
+
throw new GooglePublicInputMismatch('count');
|
|
45
|
+
const field = (i) => hexToBigInt(publicInputs[i]);
|
|
46
|
+
const node = (i) => numberToHex((field(i) << 128n) | field(i + 1), { size: 32 });
|
|
47
|
+
const digest = hexToBytes(expected.digest);
|
|
48
|
+
if (digest.some((b, i) => field(i) !== BigInt(b)))
|
|
49
|
+
throw new GooglePublicInputMismatch('digest');
|
|
50
|
+
if (node(32) !== sha256(expected.clientIdentifier))
|
|
51
|
+
throw new GooglePublicInputMismatch('audience');
|
|
52
|
+
return {
|
|
53
|
+
idNode: node(34),
|
|
54
|
+
handleNode: node(36),
|
|
55
|
+
exp: field(38),
|
|
56
|
+
modulus: publicInputs.slice(39, 57),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.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AAM,EAAE,IAAI,CAAC,EAAE,CAAC;QAChB,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;QACpB,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC;QACd,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAsC;KACzE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Rules {
|
|
2
|
+
/** Bytes the circuit's buffer holds. */
|
|
3
|
+
maxLength: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const RULES_X: Rules;
|
|
6
|
+
export declare const RULES_GITHUB: Rules;
|
|
7
|
+
export declare const RULES_GOOGLE: Rules;
|
|
8
|
+
export declare function rulesFor(platformKey: string): Rules | null;
|
|
9
|
+
export declare function isStringByte(b: number): boolean;
|
|
10
|
+
export declare function normalize(raw: string, rules: Rules): string;
|
|
11
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/platforms/handle.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,KAAK;IACpB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,OAAO,EAAE,KAAwB,CAAA;AAC9C,eAAO,MAAM,YAAY,EAAE,KAA6B,CAAA;AACxD,eAAO,MAAM,YAAY,EAAE,KAA6B,CAAA;AAGxD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAE1D;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE/C;AAID,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAQ3D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// Turns a typed handle into the form the identity circuits hash into a node.
|
|
2
|
+
/// Mirrors the circuits and Rust; all run the `handles.json` vectors.
|
|
3
|
+
import { HandleError, PLATFORM_GITHUB, PLATFORM_GOOGLE, PLATFORM_X, platform } from './platforms.js';
|
|
4
|
+
export const RULES_X = PLATFORM_X.rules;
|
|
5
|
+
export const RULES_GITHUB = PLATFORM_GITHUB.rules;
|
|
6
|
+
export const RULES_GOOGLE = PLATFORM_GOOGLE.rules;
|
|
7
|
+
/// The rules for a platform key from the generated table.
|
|
8
|
+
export function rulesFor(platformKey) {
|
|
9
|
+
return platform(platformKey)?.rules ?? null;
|
|
10
|
+
}
|
|
11
|
+
/// A byte of a JSON string as sent: printable ASCII, not `"` or `\`.
|
|
12
|
+
export function isStringByte(b) {
|
|
13
|
+
return b >= 0x20 && b <= 0x7e && b !== 0x22 && b !== 0x5c;
|
|
14
|
+
}
|
|
15
|
+
/// The handle with A-Z folded. Throws a `HandleError` unless it is one JSON
|
|
16
|
+
/// string as a platform sends it, no longer than the circuit's buffer.
|
|
17
|
+
export function normalize(raw, rules) {
|
|
18
|
+
// Bytes, not code units: the circuits measure and refuse bytes.
|
|
19
|
+
const input = new TextEncoder().encode(raw);
|
|
20
|
+
if (input.length === 0)
|
|
21
|
+
throw new HandleError('Empty');
|
|
22
|
+
if (input.length > rules.maxLength)
|
|
23
|
+
throw new HandleError('TooLong');
|
|
24
|
+
if (!input.every(isStringByte))
|
|
25
|
+
throw new HandleError('BadCharacter');
|
|
26
|
+
// ASCII alone, so this folds A-Z and nothing else.
|
|
27
|
+
return raw.toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../src/platforms/handle.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,sEAAsE;AAEtE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAQpG,MAAM,CAAC,MAAM,OAAO,GAAU,UAAU,CAAC,KAAK,CAAA;AAC9C,MAAM,CAAC,MAAM,YAAY,GAAU,eAAe,CAAC,KAAK,CAAA;AACxD,MAAM,CAAC,MAAM,YAAY,GAAU,eAAe,CAAC,KAAK,CAAA;AAExD,0DAA0D;AAC1D,MAAM,UAAU,QAAQ,CAAC,WAAmB;IAC1C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,IAAI,IAAI,CAAA;AAC7C,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAA;AAC3D,CAAC;AAED,4EAA4E;AAC5E,uEAAuE;AACvE,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,KAAY;IACjD,gEAAgE;IAChE,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;IACtD,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS;QAAE,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC,CAAA;IACpE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,cAAc,CAAC,CAAA;IACrE,mDAAmD;IACnD,OAAO,GAAG,CAAC,WAAW,EAAE,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface IdRules {
|
|
2
|
+
/** Bytes the circuit's buffer holds. */
|
|
3
|
+
maxLength: number;
|
|
4
|
+
/** True: ASCII digits. False: printable ASCII without a quote or backslash. */
|
|
5
|
+
decimal: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function checkId(platformKey: string, id: string): void;
|
|
8
|
+
//# sourceMappingURL=id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/platforms/id.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,OAAO;IACtB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAA;CACjB;AAGD,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAU7D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// The id check the identity circuits apply: an id is hashed exactly as the
|
|
2
|
+
/// platform sent it, so it is checked and never normalized.
|
|
3
|
+
import { isStringByte } from './handle.js';
|
|
4
|
+
import { IdError, platform } from './platforms.js';
|
|
5
|
+
/// Accept an id exactly as given, or throw an `IdError` saying why no circuit would hash it.
|
|
6
|
+
export function checkId(platformKey, id) {
|
|
7
|
+
const rules = platform(platformKey)?.idRules;
|
|
8
|
+
if (rules === undefined)
|
|
9
|
+
throw new Error(`unknown platform ${JSON.stringify(platformKey)}`);
|
|
10
|
+
const bytes = new TextEncoder().encode(id);
|
|
11
|
+
if (bytes.length === 0)
|
|
12
|
+
throw new IdError('Empty');
|
|
13
|
+
if (bytes.length > rules.maxLength)
|
|
14
|
+
throw new IdError('TooLong');
|
|
15
|
+
for (const b of bytes) {
|
|
16
|
+
const ok = rules.decimal ? b >= 0x30 && b <= 0x39 : isStringByte(b);
|
|
17
|
+
if (!ok)
|
|
18
|
+
throw new IdError('BadCharacter');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/platforms/id.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4DAA4D;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAUlD,6FAA6F;AAC7F,MAAM,UAAU,OAAO,CAAC,WAAmB,EAAE,EAAU;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC5C,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAC3F,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS;QAAE,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAAA;IAChE,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,EAAE;YAAE,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// The platform table, the checks the identity circuits apply to handles and
|
|
2
|
+
/// ids (normalization, the id check and the refusals they throw) and the node
|
|
3
|
+
/// derivation. Loads without viem; the registry reads are in `../identity`.
|
|
4
|
+
export * from './handle.js';
|
|
5
|
+
export * from './id.js';
|
|
6
|
+
export * from './node.js';
|
|
7
|
+
export * from './platforms.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAE5E,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function handleNode(platformKey: string, raw: string): `0x${string}`;
|
|
2
|
+
export declare function foldedHandleNode(platformKey: string, text: string): `0x${string}`;
|
|
3
|
+
export declare function idNode(platformKey: string, id: string): `0x${string}`;
|
|
4
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/platforms/node.ts"],"names":[],"mappings":"AAuBA,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAG1E;AAID,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAGjF;AAID,wBAAgB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAGrE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// The keys a binding is stored under, `SHA256(tag || value)`, computed
|
|
2
|
+
/// locally so the handle or id never reaches an RPC.
|
|
3
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
4
|
+
import { bytesToHex, concatBytes, utf8ToBytes } from '@noble/hashes/utils.js';
|
|
5
|
+
import { normalize } from './handle.js';
|
|
6
|
+
import { checkId } from './id.js';
|
|
7
|
+
import { platform } from './platforms.js';
|
|
8
|
+
function keysOf(platformKey) {
|
|
9
|
+
const keys = platform(platformKey);
|
|
10
|
+
if (keys === undefined)
|
|
11
|
+
throw new Error(`unknown platform ${JSON.stringify(platformKey)}`);
|
|
12
|
+
return keys;
|
|
13
|
+
}
|
|
14
|
+
/// `SHA256(tag || value)` as lowercase `0x` hex.
|
|
15
|
+
function nodeOf(tag, value) {
|
|
16
|
+
return `0x${bytesToHex(sha256(concatBytes(utf8ToBytes(tag), value)))}`;
|
|
17
|
+
}
|
|
18
|
+
/// The node a typed handle is bound under: normalized, then hashed under
|
|
19
|
+
/// its handle tag. Throws `HandleError` for text no binding can have.
|
|
20
|
+
export function handleNode(platformKey, raw) {
|
|
21
|
+
const keys = keysOf(platformKey);
|
|
22
|
+
return nodeOf(keys.handleTag, utf8ToBytes(normalize(raw, keys.rules)));
|
|
23
|
+
}
|
|
24
|
+
/// The node `depositToHandle` and the registry's `handleNodeOf` derive from
|
|
25
|
+
/// `text`: A-Z folded, nothing checked, so text no circuit hashes has one too.
|
|
26
|
+
export function foldedHandleNode(platformKey, text) {
|
|
27
|
+
const bytes = utf8ToBytes(text).map((b) => (b >= 0x41 && b <= 0x5a ? b + 0x20 : b));
|
|
28
|
+
return nodeOf(keysOf(platformKey).handleTag, bytes);
|
|
29
|
+
}
|
|
30
|
+
/// The node an id is bound under: the id as given, under its user-id tag.
|
|
31
|
+
/// Throws `IdError` for an id no circuit hashes.
|
|
32
|
+
export function idNode(platformKey, id) {
|
|
33
|
+
checkId(platformKey, id);
|
|
34
|
+
return nodeOf(keysOf(platformKey).userIdTag, utf8ToBytes(id));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/platforms/node.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,qDAAqD;A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AAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnF,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AACrD,CAAC;AAED,0EAA0E;AAC1E,iDAAiD;AACjD,MAAM,UAAU,MAAM,CAAC,WAAmB,EAAE,EAAU;IACpD,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;IACxB,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Rules } from './handle.js';
|
|
2
|
+
import type { IdRules } from './id.js';
|
|
3
|
+
/** A platform: its key, node tags and buffers. */
|
|
4
|
+
export interface Platform {
|
|
5
|
+
/** keccak256 of this string is the platform id. */
|
|
6
|
+
key: string;
|
|
7
|
+
/** An id node is SHA256 of this tag, then the id. */
|
|
8
|
+
userIdTag: string;
|
|
9
|
+
/** A handle node is SHA256 of this tag, then the normalized handle. */
|
|
10
|
+
handleTag: string;
|
|
11
|
+
rules: Rules;
|
|
12
|
+
idRules: IdRules;
|
|
13
|
+
}
|
|
14
|
+
/** keccak256 of this string is the platform id. */
|
|
15
|
+
export declare const PLATFORM_GOOGLE_KEY = "google";
|
|
16
|
+
/** keccak256 of this string is the platform id. */
|
|
17
|
+
export declare const PLATFORM_X_KEY = "x";
|
|
18
|
+
/** keccak256 of this string is the platform id. */
|
|
19
|
+
export declare const PLATFORM_GITHUB_KEY = "github";
|
|
20
|
+
export declare const PLATFORM_GOOGLE: Platform;
|
|
21
|
+
export declare const PLATFORM_X: Platform;
|
|
22
|
+
export declare const PLATFORM_GITHUB: Platform;
|
|
23
|
+
/** Every platform, in table order. */
|
|
24
|
+
export declare const PLATFORMS: readonly Platform[];
|
|
25
|
+
/** The platform with this key, if the table names it. */
|
|
26
|
+
export declare function platform(key: string): Platform | undefined;
|
|
27
|
+
/** Which refusal a handle or an id met, as the shared table names it. */
|
|
28
|
+
export type RefusalKind = 'Empty' | 'TooLong' | 'BadCharacter';
|
|
29
|
+
/** Why a handle was refused. */
|
|
30
|
+
export declare class HandleError extends Error {
|
|
31
|
+
readonly kind: RefusalKind;
|
|
32
|
+
constructor(kind: RefusalKind);
|
|
33
|
+
}
|
|
34
|
+
/** Why no circuit would hash an id. */
|
|
35
|
+
export declare class IdError extends Error {
|
|
36
|
+
readonly kind: RefusalKind;
|
|
37
|
+
constructor(kind: RefusalKind);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=platforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../../src/platforms/platforms.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,kDAAkD;AAClD,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAA;IACX,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;IACjB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAC3C,mDAAmD;AACnD,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAE3C,eAAO,MAAM,eAAe,EAAE,QAW7B,CAAA;AACD,eAAO,MAAM,UAAU,EAAE,QAWxB,CAAA;AACD,eAAO,MAAM,eAAe,EAAE,QAW7B,CAAA;AAED,sCAAsC;AACtC,eAAO,MAAM,SAAS,EAAE,SAAS,QAAQ,EAAmD,CAAA;AAE5F,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE1D;AAED,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAA;AAE9D,gCAAgC;AAChC,qBAAa,WAAY,SAAQ,KAAK;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW;gBAAjB,IAAI,EAAE,WAAW;CAIvC;AAaD,uCAAuC;AACvC,qBAAa,OAAQ,SAAQ,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,WAAW;gBAAjB,IAAI,EAAE,WAAW;CAIvC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Generated by scripts/regen-identity-handles.py. Do not edit.
|
|
2
|
+
// The sources are the pinned libID-circuits release's platforms.json and handles.json,
|
|
3
|
+
// vendored into solidity/contracts/circuits/ by scripts/vendor-circuit-verifiers.sh.
|
|
4
|
+
/** keccak256 of this string is the platform id. */
|
|
5
|
+
export const PLATFORM_GOOGLE_KEY = 'google';
|
|
6
|
+
/** keccak256 of this string is the platform id. */
|
|
7
|
+
export const PLATFORM_X_KEY = 'x';
|
|
8
|
+
/** keccak256 of this string is the platform id. */
|
|
9
|
+
export const PLATFORM_GITHUB_KEY = 'github';
|
|
10
|
+
export const PLATFORM_GOOGLE = {
|
|
11
|
+
key: PLATFORM_GOOGLE_KEY,
|
|
12
|
+
userIdTag: 'libid.google.user-id',
|
|
13
|
+
handleTag: 'libid.google.handle',
|
|
14
|
+
rules: {
|
|
15
|
+
maxLength: 62,
|
|
16
|
+
},
|
|
17
|
+
idRules: {
|
|
18
|
+
maxLength: 31,
|
|
19
|
+
decimal: false,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const PLATFORM_X = {
|
|
23
|
+
key: PLATFORM_X_KEY,
|
|
24
|
+
userIdTag: 'libid.x.user-id',
|
|
25
|
+
handleTag: 'libid.x.handle',
|
|
26
|
+
rules: {
|
|
27
|
+
maxLength: 39,
|
|
28
|
+
},
|
|
29
|
+
idRules: {
|
|
30
|
+
maxLength: 20,
|
|
31
|
+
decimal: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const PLATFORM_GITHUB = {
|
|
35
|
+
key: PLATFORM_GITHUB_KEY,
|
|
36
|
+
userIdTag: 'libid.github.user-id',
|
|
37
|
+
handleTag: 'libid.github.handle',
|
|
38
|
+
rules: {
|
|
39
|
+
maxLength: 39,
|
|
40
|
+
},
|
|
41
|
+
idRules: {
|
|
42
|
+
maxLength: 20,
|
|
43
|
+
decimal: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/** Every platform, in table order. */
|
|
47
|
+
export const PLATFORMS = [PLATFORM_GOOGLE, PLATFORM_X, PLATFORM_GITHUB];
|
|
48
|
+
/** The platform with this key, if the table names it. */
|
|
49
|
+
export function platform(key) {
|
|
50
|
+
return PLATFORMS.find((p) => p.key === key);
|
|
51
|
+
}
|
|
52
|
+
/** Why a handle was refused. */
|
|
53
|
+
export class HandleError extends Error {
|
|
54
|
+
kind;
|
|
55
|
+
constructor(kind) {
|
|
56
|
+
super(handleRefusal(kind));
|
|
57
|
+
this.kind = kind;
|
|
58
|
+
this.name = 'HandleError';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function handleRefusal(kind) {
|
|
62
|
+
switch (kind) {
|
|
63
|
+
case 'Empty':
|
|
64
|
+
return 'the handle is empty';
|
|
65
|
+
case 'TooLong':
|
|
66
|
+
return 'the handle is too long for this platform';
|
|
67
|
+
case 'BadCharacter':
|
|
68
|
+
return 'the handle has a byte outside printable ASCII, or a quote or backslash';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Why no circuit would hash an id. */
|
|
72
|
+
export class IdError extends Error {
|
|
73
|
+
kind;
|
|
74
|
+
constructor(kind) {
|
|
75
|
+
super(idRefusal(kind));
|
|
76
|
+
this.kind = kind;
|
|
77
|
+
this.name = 'IdError';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function idRefusal(kind) {
|
|
81
|
+
switch (kind) {
|
|
82
|
+
case 'Empty':
|
|
83
|
+
return 'the id is empty';
|
|
84
|
+
case 'TooLong':
|
|
85
|
+
return 'the id is too long for this platform';
|
|
86
|
+
case 'BadCharacter':
|
|
87
|
+
return 'the id has a byte this platform does not allow';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=platforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platforms.js","sourceRoot":"","sources":["../../src/platforms/platforms.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uFAAuF;AACvF,qFAAqF;AAoBrF,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAC3C,mDAAmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,GAAG,EAAE,mBAAmB;IACxB,SAAS,EAAE,sBAAsB;IACjC,SAAS,EAAE,qBAAqB;IAChC,KAAK,EAAE;QACL,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE;QACP,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,KAAK;KACf;CACF,CAAA;AACD,MAAM,CAAC,MAAM,UAAU,GAAa;IAClC,GAAG,EAAE,cAAc;IACnB,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE;QACL,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE;QACP,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,IAAI;KACd;CACF,CAAA;AACD,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,GAAG,EAAE,mBAAmB;IACxB,SAAS,EAAE,sBAAsB;IACjC,SAAS,EAAE,qBAAqB;I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AAO,gDAAgD,CAAA;IAC3D,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libid/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "Typed viem-ready ABIs and call builders for the libid contracts, plus the identity helper layer (handle normalization, handle resolution).",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"src",
|
|
18
|
-
"!src/**/*.test.ts"
|
|
18
|
+
"!src/**/*.test.ts",
|
|
19
|
+
"!src/platforms/vectors.ts"
|
|
19
20
|
],
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
@@ -30,6 +31,10 @@
|
|
|
30
31
|
"types": "./dist/ceremony/index.d.ts",
|
|
31
32
|
"default": "./dist/ceremony/index.js"
|
|
32
33
|
},
|
|
34
|
+
"./platforms": {
|
|
35
|
+
"types": "./dist/platforms/index.d.ts",
|
|
36
|
+
"default": "./dist/platforms/index.js"
|
|
37
|
+
},
|
|
33
38
|
"./identity": {
|
|
34
39
|
"types": "./dist/identity/index.d.ts",
|
|
35
40
|
"default": "./dist/identity/index.js"
|
|
@@ -39,6 +44,9 @@
|
|
|
39
44
|
"default": "./dist/calls/index.js"
|
|
40
45
|
}
|
|
41
46
|
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@noble/hashes": "^1.8.0 || ^2.0.0"
|
|
49
|
+
},
|
|
42
50
|
"peerDependencies": {
|
|
43
51
|
"viem": "^2.48.11"
|
|
44
52
|
},
|
|
@@ -52,7 +60,7 @@
|
|
|
52
60
|
"tsx": "^4.20.0",
|
|
53
61
|
"typescript": "^5.9.0",
|
|
54
62
|
"viem": "^2.48.11",
|
|
55
|
-
"vitest": "^
|
|
63
|
+
"vitest": "^4.1.11"
|
|
56
64
|
},
|
|
57
65
|
"scripts": {
|
|
58
66
|
"codegen": "node scripts/codegen.mjs",
|