@calimero-network/mero-js 24.2.0 → 24.3.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/dist/admin-api/admin-client.d.ts +7 -5
- package/dist/admin-api/admin-client.js +7 -5
- package/dist/admin-api/admin-types.d.ts +12 -4
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +38 -21
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +38 -21
- package/dist/index.mjs.map +3 -3
- package/dist/relay/relay-client.d.ts +15 -8
- package/dist/relay/relay-client.js +15 -15
- package/dist/warrant/warrant.d.ts +21 -19
- package/dist/warrant/warrant.js +30 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1484,16 +1484,18 @@ var AdminApiClient = class {
|
|
|
1484
1484
|
* Ask what this node can do for a member in `contextId`, before they sign
|
|
1485
1485
|
* anything.
|
|
1486
1486
|
*
|
|
1487
|
-
* The
|
|
1488
|
-
* account and key go in the warrant's `executor` and `executor_key`,
|
|
1489
|
-
* whether this node holds `CAN_AUTHOR_ON_BEHALF` on the
|
|
1487
|
+
* The facts {@link performIntent} needs and a client cannot derive: whose
|
|
1488
|
+
* account and key go in the warrant's `executor` and `executor_key`, which
|
|
1489
|
+
* release it pins, and whether this node holds `CAN_AUTHOR_ON_BEHALF` on the
|
|
1490
|
+
* owning group.
|
|
1490
1491
|
* `canAuthorOnBehalf: false` comes back as an answer rather than an error, as
|
|
1491
1492
|
* it is the default state of every context, so a caller can say "an admin of
|
|
1492
1493
|
* `groupId` must grant it to `executorAccount`" instead of presenting a
|
|
1493
1494
|
* warrant that will be refused after the author has spent a nonce on it.
|
|
1494
1495
|
*
|
|
1495
|
-
* `404` means the context belongs to no group,
|
|
1496
|
-
* yet
|
|
1496
|
+
* `404` means the context belongs to no group, this node holds no account or
|
|
1497
|
+
* identity in it yet, or its group names no release yet; no warrant can be
|
|
1498
|
+
* spent here until that changes.
|
|
1497
1499
|
*
|
|
1498
1500
|
* For a caller with no credential on the node at all — a browser tab holding
|
|
1499
1501
|
* one signing key — use `RelayClient`, which reads this same route on a node
|
|
@@ -7190,7 +7192,7 @@ function splitVersion2(version) {
|
|
|
7190
7192
|
var SIGN_DOMAIN2 = new TextEncoder().encode("calimero.warrant.v2");
|
|
7191
7193
|
var INTENT_DOMAIN = new TextEncoder().encode("calimero.warrant.intent.v1");
|
|
7192
7194
|
var MAX_CITED_HEADS = 64;
|
|
7193
|
-
var
|
|
7195
|
+
var MAX_RELEASE_VERSION_LEN = 256;
|
|
7194
7196
|
async function intentHash(method, argsJson) {
|
|
7195
7197
|
const args = new TextEncoder().encode(JSON.stringify(argsJson));
|
|
7196
7198
|
return domainHash(INTENT_DOMAIN, [new TextEncoder().encode(method), args]);
|
|
@@ -7200,11 +7202,8 @@ async function signWarrant(input) {
|
|
|
7200
7202
|
const authorAccount = fromHex(input.authorAccount, "authorAccount", 32);
|
|
7201
7203
|
const executor = fromHex(input.executor, "executor", 32);
|
|
7202
7204
|
const executorKey = fromHex(input.executorKey, "executorKey", 32);
|
|
7203
|
-
const
|
|
7204
|
-
|
|
7205
|
-
"appVersion",
|
|
7206
|
-
32
|
|
7207
|
-
);
|
|
7205
|
+
const releaseBytecodeId = fromHex(input.releaseBytecodeId, "releaseBytecodeId", 32);
|
|
7206
|
+
const releaseVersion2 = releaseVersionBytes(input.releaseVersion ?? "");
|
|
7208
7207
|
const accountHeads = citedHeads(input.accountHeads, "accountHeads");
|
|
7209
7208
|
const governanceFloor = citedHeads(input.governanceFloor, "governanceFloor");
|
|
7210
7209
|
const signer = await resolveSigner(input.deviceSecret, input.signer, "deviceSecret");
|
|
@@ -7219,7 +7218,8 @@ async function signWarrant(input) {
|
|
|
7219
7218
|
publicKey,
|
|
7220
7219
|
executor,
|
|
7221
7220
|
executorKey,
|
|
7222
|
-
|
|
7221
|
+
releaseBytecodeId,
|
|
7222
|
+
releaseVersion2,
|
|
7223
7223
|
method,
|
|
7224
7224
|
commitment,
|
|
7225
7225
|
u64le(accountHeads.length),
|
|
@@ -7237,7 +7237,9 @@ async function signWarrant(input) {
|
|
|
7237
7237
|
publicKey,
|
|
7238
7238
|
executor,
|
|
7239
7239
|
executorKey,
|
|
7240
|
-
|
|
7240
|
+
releaseBytecodeId,
|
|
7241
|
+
u32le(releaseVersion2.length),
|
|
7242
|
+
releaseVersion2,
|
|
7241
7243
|
u32le(method.length),
|
|
7242
7244
|
method,
|
|
7243
7245
|
commitment,
|
|
@@ -7258,6 +7260,18 @@ function checkedSignature(signature) {
|
|
|
7258
7260
|
}
|
|
7259
7261
|
return signature;
|
|
7260
7262
|
}
|
|
7263
|
+
function releaseVersionBytes(version) {
|
|
7264
|
+
const bytes = new TextEncoder().encode(version);
|
|
7265
|
+
checkReleaseVersionLength(bytes.length);
|
|
7266
|
+
return bytes;
|
|
7267
|
+
}
|
|
7268
|
+
function checkReleaseVersionLength(len) {
|
|
7269
|
+
if (len > MAX_RELEASE_VERSION_LEN) {
|
|
7270
|
+
throw new Error(
|
|
7271
|
+
`releaseVersion is ${len} bytes, over the ${MAX_RELEASE_VERSION_LEN} a node accepts`
|
|
7272
|
+
);
|
|
7273
|
+
}
|
|
7274
|
+
}
|
|
7261
7275
|
function citedHeads(heads, label2) {
|
|
7262
7276
|
const list = heads ?? [];
|
|
7263
7277
|
if (list.length > MAX_CITED_HEADS) {
|
|
@@ -7895,7 +7909,6 @@ var RelayClient = class {
|
|
|
7895
7909
|
"GET",
|
|
7896
7910
|
`/admin-api/contexts/${encodeURIComponent(contextId)}/intents`
|
|
7897
7911
|
);
|
|
7898
|
-
this.checkedExecutor(body.data);
|
|
7899
7912
|
return body.data;
|
|
7900
7913
|
}
|
|
7901
7914
|
/**
|
|
@@ -7906,7 +7919,13 @@ var RelayClient = class {
|
|
|
7906
7919
|
* apply. Nothing accumulates and nothing is reusable.
|
|
7907
7920
|
*/
|
|
7908
7921
|
async execute(contextId, method, argsJson = {}) {
|
|
7909
|
-
const
|
|
7922
|
+
const described = await this.describe(contextId);
|
|
7923
|
+
const executor = this.checkedExecutor(described);
|
|
7924
|
+
const releaseBytecodeId = hex(
|
|
7925
|
+
fromHex(described.releaseBytecodeId ?? "", "the relay's releaseBytecodeId", 32)
|
|
7926
|
+
);
|
|
7927
|
+
const releaseVersion2 = described.releaseVersion ?? "";
|
|
7928
|
+
releaseVersionBytes(releaseVersion2);
|
|
7910
7929
|
const signer = await this.authorSigner();
|
|
7911
7930
|
const nonce2 = await this.config.nonces.next();
|
|
7912
7931
|
const ttl = this.config.ttlSeconds ?? DEFAULT_TTL_SECONDS;
|
|
@@ -7915,6 +7934,8 @@ var RelayClient = class {
|
|
|
7915
7934
|
authorAccount: this.config.authorAccount,
|
|
7916
7935
|
executor: executor.executorAccount,
|
|
7917
7936
|
executorKey: executor.executorKey,
|
|
7937
|
+
releaseBytecodeId,
|
|
7938
|
+
releaseVersion: releaseVersion2,
|
|
7918
7939
|
method,
|
|
7919
7940
|
argsJson,
|
|
7920
7941
|
nonce: nonce2,
|
|
@@ -7925,10 +7946,7 @@ var RelayClient = class {
|
|
|
7925
7946
|
"POST",
|
|
7926
7947
|
`/admin-api/contexts/${encodeURIComponent(contextId)}/intents`,
|
|
7927
7948
|
{ method, argsJson, warrant, authorProof: this.config.authorProof }
|
|
7928
|
-
)
|
|
7929
|
-
if (err instanceof IntentRefusedError) this.executor = void 0;
|
|
7930
|
-
throw err;
|
|
7931
|
-
});
|
|
7949
|
+
);
|
|
7932
7950
|
return { rootHash: body.data.rootHash, returns: body.data.returns ?? null };
|
|
7933
7951
|
}
|
|
7934
7952
|
/**
|
|
@@ -8174,7 +8192,7 @@ var RelayClient = class {
|
|
|
8174
8192
|
return body.data;
|
|
8175
8193
|
}
|
|
8176
8194
|
/**
|
|
8177
|
-
* The relay's answer, checked against a configured account
|
|
8195
|
+
* The relay's answer, checked against a configured account.
|
|
8178
8196
|
* Decoded here so a relay naming no key is refused before a nonce is taken.
|
|
8179
8197
|
*/
|
|
8180
8198
|
checkedExecutor(answered) {
|
|
@@ -8188,7 +8206,6 @@ var RelayClient = class {
|
|
|
8188
8206
|
`configured executorAccount ${configured} is not the relay's account ${executor.executorAccount}; a warrant naming it would be unspendable`
|
|
8189
8207
|
);
|
|
8190
8208
|
}
|
|
8191
|
-
this.executor = executor;
|
|
8192
8209
|
return executor;
|
|
8193
8210
|
}
|
|
8194
8211
|
/**
|