@libid/contracts 0.16.0 → 0.18.0
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 -2
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +5 -10
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/node.d.ts +3 -3
- package/dist/identity/node.d.ts.map +1 -1
- package/dist/identity/node.js +25 -16
- package/dist/identity/node.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 +54 -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 +4 -0
- package/dist/platforms/index.d.ts.map +1 -0
- package/dist/platforms/index.js +7 -0
- package/dist/platforms/index.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 +8 -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 -10
- package/src/identity/node.ts +25 -21
- package/src/identity/resolve.ts +72 -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 +7 -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/src/identity/handle.ts +0 -176
- package/src/identity/handleVectors.ts +0 -104
package/dist/identity/resolve.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
///
|
|
1
|
+
/// Reads identities from the `IdentityRegistry` through view calls.
|
|
2
2
|
///
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
|
|
6
|
-
///
|
|
7
|
-
/// The client and the contract address are arguments rather than imports. This
|
|
8
|
-
/// package ships separately from the repository it currently lives in, so it
|
|
9
|
-
/// carries no configuration of its own and reaches for nothing outside itself.
|
|
10
|
-
import { keccak256, toHex, zeroAddress } from 'viem';
|
|
3
|
+
/// The caller passes the client and the contract address; the package carries
|
|
4
|
+
/// no network configuration.
|
|
5
|
+
import { keccak256, toHex, zeroAddress, zeroHash } from 'viem';
|
|
11
6
|
import { identityRegistryAbi } from '../abis/identityRegistry.js';
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import { HandleError, PLATFORMS } from '../platforms/index.js';
|
|
8
|
+
import { handleNode } from './node.js';
|
|
9
|
+
/// A platform id is `keccak256` of its platform key, as `CeremonyProfile`
|
|
10
|
+
/// derives it.
|
|
14
11
|
export function platformId(platformKey) {
|
|
15
12
|
return keccak256(toHex(platformKey));
|
|
16
13
|
}
|
|
17
|
-
/// One view call.
|
|
18
|
-
///
|
|
19
|
-
/// Routed through a narrow cast for one reason:
|
|
20
|
-
/// viem's `PublicClient`, without its chain type parameters, types
|
|
21
|
-
/// `authorizationList` as required even for a read. The alternative is to
|
|
22
|
-
/// spread that noise across every call site here.
|
|
14
|
+
/// One view call. The cast is there because viem's `PublicClient`, without its
|
|
15
|
+
/// chain type parameters, types `authorizationList` as required even for a read.
|
|
23
16
|
function read(reader, functionName, args) {
|
|
24
17
|
return reader.client.readContract({
|
|
25
18
|
authorizationList: undefined,
|
|
@@ -29,90 +22,65 @@ function read(reader, functionName, args) {
|
|
|
29
22
|
args,
|
|
30
23
|
});
|
|
31
24
|
}
|
|
32
|
-
/// The
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const rules = await read(reader, 'rulesOf', [platformId]);
|
|
36
|
-
return {
|
|
37
|
-
maxLength: Number(rules.maxLength),
|
|
38
|
-
stripLeadingAt: rules.stripLeadingAt,
|
|
39
|
-
isEmail: rules.isEmail,
|
|
40
|
-
allowUnderscore: rules.allowUnderscore,
|
|
41
|
-
allowHyphen: rules.allowHyphen,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/// The holder that proved this id, or `null`.
|
|
45
|
-
export async function resolveId(reader, platformId, id) {
|
|
46
|
-
const holder = await read(reader, 'resolveId', [platformId, id]);
|
|
25
|
+
/// The holder that proved this id node (`idNode(platformKey, id)`), or `null`.
|
|
26
|
+
export async function resolveId(reader, idNode) {
|
|
27
|
+
const holder = await read(reader, 'resolveId', [idNode]);
|
|
47
28
|
return holder === zeroAddress ? null : holder;
|
|
48
29
|
}
|
|
49
|
-
/// The
|
|
50
|
-
|
|
51
|
-
///
|
|
52
|
-
///
|
|
53
|
-
///
|
|
54
|
-
///
|
|
55
|
-
///
|
|
56
|
-
///
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
/// The generated platforms, keyed by platform id.
|
|
31
|
+
const PLATFORM_BY_ID = new Map(PLATFORMS.map((p) => [platformId(p.key), p]));
|
|
32
|
+
/// Resolve a handle and report whether an id node still agrees with it.
|
|
33
|
+
/// Read it before signing to warn the payer; do not let it block a transfer.
|
|
34
|
+
/// Only the handle's node is sent. Text no circuit hashes is sent as the zero
|
|
35
|
+
/// node and resolves to `{holder: null, idAgrees: false}`. Reverts such as
|
|
36
|
+
/// `UnknownPlatform` propagate; a platform missing from this package's table
|
|
37
|
+
/// throws.
|
|
38
|
+
export async function resolveHandleAndId(reader, id, handle, idNode) {
|
|
39
|
+
const keys = PLATFORM_BY_ID.get(id.toLowerCase());
|
|
40
|
+
let node = zeroHash;
|
|
41
|
+
if (keys !== undefined) {
|
|
42
|
+
try {
|
|
43
|
+
node = handleNode(keys.key, handle);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
if (!(e instanceof HandleError))
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// The chain goes first, so a platform it does not know reverts UnknownPlatform there.
|
|
51
|
+
const [holder, idAgrees] = await read(reader, 'resolveHandleNodeAndId', [
|
|
52
|
+
id,
|
|
53
|
+
node,
|
|
54
|
+
idNode,
|
|
55
|
+
]);
|
|
56
|
+
if (keys === undefined)
|
|
57
|
+
throw new Error(`platform ${id} is not in this package's handle table`);
|
|
58
|
+
return { holder: holder === zeroAddress ? null : holder, idAgrees };
|
|
59
|
+
}
|
|
60
|
+
/// The holder that last proved this handle, or `null`. Only the handle's node
|
|
61
|
+
/// is sent; text no circuit hashes also answers `null`. Reverts such as
|
|
62
|
+
/// `UnknownPlatform` propagate.
|
|
60
63
|
export async function resolveHandle(reader, platformId, handle) {
|
|
61
|
-
|
|
62
|
-
return holder === zeroAddress ? null : holder;
|
|
64
|
+
return (await resolveHandleAndId(reader, platformId, handle, zeroHash)).holder;
|
|
63
65
|
}
|
|
64
|
-
/// The handle to show for a holder, or `null`.
|
|
65
|
-
///
|
|
66
|
-
/// Forward-checked on chain: empty once the stored handle resolves somewhere
|
|
67
|
-
/// else. ENS asks integrators to perform that check themselves and warns that
|
|
68
|
-
/// skipping it displays an ENS primary name that no longer resolves back; here
|
|
69
|
-
/// it cannot be skipped, because the contract does it.
|
|
66
|
+
/// The handle to show for a holder, or `null`. Forward-checked on chain:
|
|
67
|
+
/// empty once the stored handle resolves somewhere else.
|
|
70
68
|
export async function publishedHandleOf(reader, holder, platformId) {
|
|
71
69
|
const handle = await read(reader, 'publishedHandleOf', [holder, platformId]);
|
|
72
70
|
return handle.length === 0 ? null : handle;
|
|
73
71
|
}
|
|
74
|
-
/// Resolve a handle and report whether an id still agrees with it.
|
|
75
|
-
///
|
|
76
|
-
/// **Read this before signing, and do not let it block a transfer.** A handle
|
|
77
|
-
/// that will not route is not a handle: sending to a handle means sending to
|
|
78
|
-
/// whoever proved it last, which is what the handle now means. What the flag is
|
|
79
|
-
/// for is telling whoever is paying that the identity they think they are
|
|
80
|
-
/// paying is not the one that has the handle today — a decision they can only
|
|
81
|
-
/// make beforehand.
|
|
82
|
-
///
|
|
83
|
-
/// Both halves are needed. A handle on its own has nothing to disagree with.
|
|
84
|
-
///
|
|
85
|
-
/// A handle the platform's rules reject resolves to `{holder: null, idAgrees:
|
|
86
|
-
/// false}`, the same as one nobody has proved — see `resolveHandle`.
|
|
87
|
-
export async function resolveHandleAndId(reader, platformId, handle, id) {
|
|
88
|
-
const [holder, idAgrees] = await read(reader, 'resolveHandleAndId', [
|
|
89
|
-
platformId,
|
|
90
|
-
handle,
|
|
91
|
-
id,
|
|
92
|
-
]);
|
|
93
|
-
return { holder: holder === zeroAddress ? null : holder, idAgrees };
|
|
94
|
-
}
|
|
95
72
|
/// How many identities a holder has, on every platform together.
|
|
96
73
|
export async function identityCount(reader, holder) {
|
|
97
74
|
return read(reader, 'identityCount', [holder]);
|
|
98
75
|
}
|
|
99
|
-
///
|
|
100
|
-
///
|
|
101
|
-
/// clipped to the list. A `from` past the end answers an empty page. A reader
|
|
102
|
-
/// that wants one platform filters a page by `platformId`.
|
|
103
|
-
///
|
|
104
|
-
/// Order is arbitrary and changes when an identity leaves the list, so two
|
|
105
|
-
/// pages read across a removal may overlap or skip. A reader that needs every
|
|
106
|
-
/// identity reads `identityCount` and the pages against one block.
|
|
107
|
-
///
|
|
108
|
-
/// A list is as long as its holder made it, and a call's gas is not. A caller
|
|
109
|
-
/// enumerating a holder it did not choose keeps `limit` small and pages.
|
|
76
|
+
/// The holder's identities at indices `[from, from + limit)`, clipped to the list.
|
|
77
|
+
/// Order is arbitrary and changes on removal: read every page against one block.
|
|
110
78
|
export async function identitiesOf(reader, holder, from, limit) {
|
|
111
79
|
const page = await read(reader, 'identitiesOf', [holder, from, limit]);
|
|
112
|
-
return page.map(({ platformId,
|
|
80
|
+
return page.map(({ platformId, idNode, handleNode, handleCurrent }) => ({
|
|
113
81
|
platformId,
|
|
114
|
-
|
|
115
|
-
|
|
82
|
+
idNode,
|
|
83
|
+
handleNode,
|
|
116
84
|
handleCurrent,
|
|
117
85
|
}));
|
|
118
86
|
}
|
|
@@ -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,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAMtC,0EAA0E;AAC1E,eAAe;AACf,MAAM,UAAU,UAAU,CAAmB,WAA2B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MAAM,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,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 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C,UAAU,CAAC,CAAA;IACjD,OAAO;QACL,MAAM,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,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// The platform table and the checks the identity circuits apply to handles
|
|
2
|
+
/// and ids: normalization, the id check and the refusals they throw. Loads
|
|
3
|
+
/// without viem; node hashing and the registry reads are in `../identity`.
|
|
4
|
+
export * from './handle.js';
|
|
5
|
+
export * from './id.js';
|
|
6
|
+
export * from './platforms.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAE3E,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA"}
|
|
@@ -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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