@calimero-network/mero-js 24.3.0 → 24.4.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/dist/admin-api/admin-types.d.ts +19 -0
- package/dist/cloud/enrol-redirect.d.ts +3 -3
- package/dist/cloud/enrol-redirect.js +3 -3
- package/dist/device-cert/device-cert.d.ts +6 -4
- package/dist/device-cert/device-cert.js +11 -4
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +2 -2
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
|
@@ -375,6 +375,25 @@ export interface Namespace {
|
|
|
375
375
|
* this is absent only on nodes that predate it.
|
|
376
376
|
*/
|
|
377
377
|
founding?: NamespaceFounding;
|
|
378
|
+
/**
|
|
379
|
+
* Group ops this node logged but holds unapplied, because their group's
|
|
380
|
+
* history is sealed under a key it lacks: their effects are missing here until
|
|
381
|
+
* that key arrives. What explains a subgroup that looks stale on this node and
|
|
382
|
+
* current on another. Absent when nothing is held, and on nodes that predate it.
|
|
383
|
+
*/
|
|
384
|
+
heldOps?: NamespaceHeldOps;
|
|
385
|
+
}
|
|
386
|
+
/** The group ops a namespace holds unapplied on the node that answered. */
|
|
387
|
+
export interface NamespaceHeldOps {
|
|
388
|
+
ops: NamespaceHeldOp[];
|
|
389
|
+
/** Holds past the node's listing bound, counted but not listed. */
|
|
390
|
+
untracked: number;
|
|
391
|
+
}
|
|
392
|
+
export interface NamespaceHeldOp {
|
|
393
|
+
/** Hex id of the namespace op in the governance DAG. */
|
|
394
|
+
deltaId: string;
|
|
395
|
+
/** Hex id of the group whose sealed history it waits on. */
|
|
396
|
+
groupId: string;
|
|
378
397
|
}
|
|
379
398
|
/**
|
|
380
399
|
* The founder and salt a namespace id was derived from:
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
* - the credential certifies **the key this app asked about** — otherwise the
|
|
35
35
|
* app stores a credential it cannot sign for, and every warrant it mints is
|
|
36
36
|
* refused somewhere far from here;
|
|
37
|
-
* - the credential is **internally consistent** — the root signed it
|
|
38
|
-
* account it names is the one that root derives
|
|
39
|
-
* verifyDeviceCredential});
|
|
37
|
+
* - the credential is **internally consistent** — the root signed it, the
|
|
38
|
+
* account it names is the one that root derives, and its device id was
|
|
39
|
+
* minted for that account ({@link verifyDeviceCredential});
|
|
40
40
|
* - the account reported beside it is **the account the credential names** —
|
|
41
41
|
* the app shows that id to a person and keys state by it, so a mismatch is a
|
|
42
42
|
* credential filed under someone else's name.
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
* - the credential certifies **the key this app asked about** — otherwise the
|
|
35
35
|
* app stores a credential it cannot sign for, and every warrant it mints is
|
|
36
36
|
* refused somewhere far from here;
|
|
37
|
-
* - the credential is **internally consistent** — the root signed it
|
|
38
|
-
* account it names is the one that root derives
|
|
39
|
-
* verifyDeviceCredential});
|
|
37
|
+
* - the credential is **internally consistent** — the root signed it, the
|
|
38
|
+
* account it names is the one that root derives, and its device id was
|
|
39
|
+
* minted for that account ({@link verifyDeviceCredential});
|
|
40
40
|
* - the account reported beside it is **the account the credential names** —
|
|
41
41
|
* the app shows that id to a person and keys state by it, so a mismatch is a
|
|
42
42
|
* credential filed under someone else's name.
|
|
@@ -155,14 +155,16 @@ export interface DeviceCredential {
|
|
|
155
155
|
*/
|
|
156
156
|
export declare function parseDeviceCredential(credential: string): DeviceCredential;
|
|
157
157
|
/**
|
|
158
|
-
* Check that a credential says what it claims: the root signed it,
|
|
159
|
-
* account it names is the one that root derives
|
|
158
|
+
* Check that a credential says what it claims: the root signed it, the
|
|
159
|
+
* account it names is the one that root derives, and the device id was minted
|
|
160
|
+
* for that account.
|
|
160
161
|
*
|
|
161
|
-
*
|
|
162
|
+
* The first two matter and neither implies the other. The signature says the
|
|
162
163
|
* genesis root consented to these exact keys; the account derivation says the
|
|
163
164
|
* certificate cannot have been re-pointed at a different account while keeping a
|
|
164
165
|
* signature that verifies. A caller that checked only the first would accept a
|
|
165
|
-
* certificate naming an account whose root never signed anything.
|
|
166
|
+
* certificate naming an account whose root never signed anything. The third
|
|
167
|
+
* stops a root claiming a device id minted for another account.
|
|
166
168
|
*
|
|
167
169
|
* What it does **not** establish is that the account is one the caller wanted.
|
|
168
170
|
* Anyone can mint a root offline and certify any public key with it, so a
|
|
@@ -182,14 +182,16 @@ export function parseDeviceCredential(credential) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
|
-
* Check that a credential says what it claims: the root signed it,
|
|
186
|
-
* account it names is the one that root derives
|
|
185
|
+
* Check that a credential says what it claims: the root signed it, the
|
|
186
|
+
* account it names is the one that root derives, and the device id was minted
|
|
187
|
+
* for that account.
|
|
187
188
|
*
|
|
188
|
-
*
|
|
189
|
+
* The first two matter and neither implies the other. The signature says the
|
|
189
190
|
* genesis root consented to these exact keys; the account derivation says the
|
|
190
191
|
* certificate cannot have been re-pointed at a different account while keeping a
|
|
191
192
|
* signature that verifies. A caller that checked only the first would accept a
|
|
192
|
-
* certificate naming an account whose root never signed anything.
|
|
193
|
+
* certificate naming an account whose root never signed anything. The third
|
|
194
|
+
* stops a root claiming a device id minted for another account.
|
|
193
195
|
*
|
|
194
196
|
* What it does **not** establish is that the account is one the caller wanted.
|
|
195
197
|
* Anyone can mint a root offline and certify any public key with it, so a
|
|
@@ -206,6 +208,11 @@ export async function verifyDeviceCredential(credential) {
|
|
|
206
208
|
throw new Error(`this credential names account ${parsed.account}, but its root key ` +
|
|
207
209
|
`derives ${derived} — the certificate was re-pointed at another account`);
|
|
208
210
|
}
|
|
211
|
+
const nonce = fromHex(parsed.device, 'device', 32).subarray(0, 16);
|
|
212
|
+
if ((await mintDeviceId(parsed.account, nonce)) !== parsed.device) {
|
|
213
|
+
throw new Error(`this credential names device ${parsed.device}, which was not minted for ` +
|
|
214
|
+
`account ${parsed.account}; core refuses it`);
|
|
215
|
+
}
|
|
209
216
|
const signed = await verifySignature(parsed.rootPublicKey, fromHex(parsed.signature, 'signature', 64), await deviceCertPayload(parsed));
|
|
210
217
|
if (!signed) {
|
|
211
218
|
throw new Error(`the root key of account ${parsed.account} did not sign this certificate`);
|