@calimero-network/mero-js 23.3.0 → 23.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/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +44 -16
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +44 -16
- package/dist/index.mjs.map +3 -3
- package/dist/relay/relay-client.d.ts +19 -0
- package/dist/relay/relay-client.js +26 -16
- package/dist/warrant/governance-op.d.ts +14 -5
- package/dist/warrant/governance-op.js +26 -0
- package/dist/warrant/index.d.ts +1 -1
- package/dist/warrant/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export * from "./cloud/index.js";
|
|
|
23
23
|
export * from "./sealed/index.js";
|
|
24
24
|
export * from "./relay/index.js";
|
|
25
25
|
export * from "./request-proof/index.js";
|
|
26
|
-
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, memberCapabilitySetOp, contextDetachedOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, contextCapabilityGrantedOp, contextCapabilityRevokedOp, memberJoinedOpenOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
26
|
+
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, memberCapabilitySetOp, contextDetachedOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, contextCapabilityGrantedOp, contextCapabilityRevokedOp, memberJoinedOpenOp, namespaceCreatedOp, defaultCapabilitiesSetOp, targetApplicationSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
27
27
|
export { signerFromSecret, signerFromCryptoKey } from "./signer/index.js";
|
|
28
28
|
export type { Signer } from "./signer/index.js";
|
|
29
29
|
export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, createAccountRootSigner, accountRootSignerFromPhrase, signAccountLink, signAccountLogin, resolveRoot, resolveRootPair, } from "./account/index.js";
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export * from "./relay/index.js";
|
|
|
36
36
|
// Request proofs — a caller's identity on the request itself, no session needed
|
|
37
37
|
export * from "./request-proof/index.js";
|
|
38
38
|
// Warrant signing — mint the author's consent for a relay to run one intent
|
|
39
|
-
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, memberCapabilitySetOp, contextDetachedOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, contextCapabilityGrantedOp, contextCapabilityRevokedOp, memberJoinedOpenOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
39
|
+
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, memberCapabilitySetOp, contextDetachedOp, subgroupVisibilitySetOp, groupMetadataSetOp, memberMetadataSetOp, contextMetadataSetOp, contextCapabilityGrantedOp, contextCapabilityRevokedOp, memberJoinedOpenOp, namespaceCreatedOp, defaultCapabilitiesSetOp, targetApplicationSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
40
40
|
// Who signs — a key's capability, separated from its material, so a
|
|
41
41
|
// non-extractable key can be used wherever a hex secret could.
|
|
42
42
|
export { signerFromSecret, signerFromCryptoKey } from "./signer/index.js";
|
package/dist/index.mjs
CHANGED
|
@@ -7409,6 +7409,7 @@ var GROUP_OP = {
|
|
|
7409
7409
|
MemberRoleSet: 4,
|
|
7410
7410
|
MemberCapabilitySet: 5,
|
|
7411
7411
|
DefaultCapabilitiesSet: 6,
|
|
7412
|
+
TargetApplicationSet: 7,
|
|
7412
7413
|
ContextDetached: 9,
|
|
7413
7414
|
SubgroupVisibilitySet: 10,
|
|
7414
7415
|
GroupMetadataSet: 11,
|
|
@@ -7482,6 +7483,23 @@ async function createdSubgroupId(admin, parentId, restricted, salt) {
|
|
|
7482
7483
|
])
|
|
7483
7484
|
);
|
|
7484
7485
|
}
|
|
7486
|
+
function borshString2(value, what) {
|
|
7487
|
+
if (value.length === 0) throw new Error(`${what} must not be empty`);
|
|
7488
|
+
const bytes = new TextEncoder().encode(value);
|
|
7489
|
+
return concat(u32le(bytes.length), bytes);
|
|
7490
|
+
}
|
|
7491
|
+
function targetApplicationSetOp(input) {
|
|
7492
|
+
return {
|
|
7493
|
+
kind: "group",
|
|
7494
|
+
bytes: concat(
|
|
7495
|
+
tag(GROUP_OP.TargetApplicationSet),
|
|
7496
|
+
CLEARED_HASH,
|
|
7497
|
+
fromHex(input.applicationId, "applicationId", 32),
|
|
7498
|
+
borshString2(input.package, "package"),
|
|
7499
|
+
borshString2(input.version, "version")
|
|
7500
|
+
)
|
|
7501
|
+
};
|
|
7502
|
+
}
|
|
7485
7503
|
function defaultCapabilitiesSetOp(capabilities) {
|
|
7486
7504
|
if (!Number.isInteger(capabilities) || capabilities < 0 || capabilities > 4294967295) {
|
|
7487
7505
|
throw new Error(`capabilities must be a u32 bit mask, got ${String(capabilities)}`);
|
|
@@ -7936,6 +7954,7 @@ var RelayClient = class {
|
|
|
7936
7954
|
salt
|
|
7937
7955
|
});
|
|
7938
7956
|
const capabilitiesOp = input.defaultCapabilities === void 0 ? void 0 : defaultCapabilitiesSetOp(input.defaultCapabilities);
|
|
7957
|
+
const applicationOp = input.application ? targetApplicationSetOp(input.application) : void 0;
|
|
7939
7958
|
const signer = await this.authorSigner();
|
|
7940
7959
|
const nonce2 = await this.config.nonces.next();
|
|
7941
7960
|
const ttl = this.config.ttlSeconds ?? DEFAULT_TTL_SECONDS;
|
|
@@ -7955,17 +7974,25 @@ var RelayClient = class {
|
|
|
7955
7974
|
teeEnabled: data.teeEnabled ?? false,
|
|
7956
7975
|
...data.teeError ? { teeError: data.teeError } : {}
|
|
7957
7976
|
};
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7977
|
+
let result = founded;
|
|
7978
|
+
const message = (err) => err instanceof Error ? err.message : String(err);
|
|
7979
|
+
if (applicationOp) {
|
|
7980
|
+
try {
|
|
7981
|
+
await this.govern({ groupId: founded.namespaceId, op: applicationOp });
|
|
7982
|
+
result = { ...result, applicationSet: true };
|
|
7983
|
+
} catch (err) {
|
|
7984
|
+
result = { ...result, applicationSet: false, applicationError: message(err) };
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
if (capabilitiesOp) {
|
|
7988
|
+
try {
|
|
7989
|
+
await this.govern({ groupId: founded.namespaceId, op: capabilitiesOp });
|
|
7990
|
+
result = { ...result, defaultCapabilitiesSet: true };
|
|
7991
|
+
} catch (err) {
|
|
7992
|
+
result = { ...result, defaultCapabilitiesSet: false, defaultCapabilitiesError: message(err) };
|
|
7993
|
+
}
|
|
7968
7994
|
}
|
|
7995
|
+
return result;
|
|
7969
7996
|
}
|
|
7970
7997
|
async postGovernance(groupId, op, warrant) {
|
|
7971
7998
|
const body = await this.json("POST", `/admin-api/groups/${encodeURIComponent(groupId)}/governance-intents`, {
|
|
@@ -10615,7 +10642,7 @@ function optionalBytes32(value, label2) {
|
|
|
10615
10642
|
}
|
|
10616
10643
|
return concat(new Uint8Array([1]), new Uint8Array(value));
|
|
10617
10644
|
}
|
|
10618
|
-
function
|
|
10645
|
+
function borshString3(value) {
|
|
10619
10646
|
const bytes = new TextEncoder().encode(value);
|
|
10620
10647
|
return concat(u32le(bytes.length), bytes);
|
|
10621
10648
|
}
|
|
@@ -10629,7 +10656,7 @@ function encodeSignedInvitation(signed) {
|
|
|
10629
10656
|
// ...then the enclosing SignedGroupOpenInvitation, in declaration order.
|
|
10630
10657
|
// `inviter_account` sits between the signature and the addresses; putting it
|
|
10631
10658
|
// anywhere else still encodes 32 bytes and still verifies as nothing.
|
|
10632
|
-
|
|
10659
|
+
borshString3(signed.inviter_signature),
|
|
10633
10660
|
signed.inviter_account ? concat(new Uint8Array([1]), fromHex(signed.inviter_account, "inviter_account", 32)) : new Uint8Array([0]),
|
|
10634
10661
|
// A `Vec<String>`, so each entry is a bare borsh string. This carried an
|
|
10635
10662
|
// enum until core dropped the URL variant, and an enum writes a
|
|
@@ -10637,7 +10664,7 @@ function encodeSignedInvitation(signed) {
|
|
|
10637
10664
|
// every following byte and fail as `invalid invitation signature`, pointing
|
|
10638
10665
|
// nowhere near this line.
|
|
10639
10666
|
u32le(admitterAddrs.length),
|
|
10640
|
-
...admitterAddrs.map(
|
|
10667
|
+
...admitterAddrs.map(borshString3),
|
|
10641
10668
|
optionalBytes32(signed.application_id, "application_id"),
|
|
10642
10669
|
// Borsh order follows core's field order, where this is `bytecode_id`; the
|
|
10643
10670
|
// JSON key is `app_key`, a rename covering both directions that core pins in
|
|
@@ -10710,12 +10737,12 @@ var te = new TextEncoder();
|
|
|
10710
10737
|
function tag2(byte) {
|
|
10711
10738
|
return new Uint8Array([byte]);
|
|
10712
10739
|
}
|
|
10713
|
-
function
|
|
10740
|
+
function borshString4(value) {
|
|
10714
10741
|
const bytes = te.encode(value);
|
|
10715
10742
|
return concat(u32le(bytes.length), bytes);
|
|
10716
10743
|
}
|
|
10717
10744
|
function borshStrings(values) {
|
|
10718
|
-
return concat(u32le(values.length), ...values.map(
|
|
10745
|
+
return concat(u32le(values.length), ...values.map(borshString4));
|
|
10719
10746
|
}
|
|
10720
10747
|
function borshBool(value) {
|
|
10721
10748
|
return tag2(value ? 1 : 0);
|
|
@@ -10769,7 +10796,7 @@ function teeAdmissionPolicyOp(input) {
|
|
|
10769
10796
|
};
|
|
10770
10797
|
}
|
|
10771
10798
|
function teeReleaseAdmissionPolicyOp(input) {
|
|
10772
|
-
const minRelease = input.minReleaseVersion === void 0 ? tag2(0) : concat(tag2(1),
|
|
10799
|
+
const minRelease = input.minReleaseVersion === void 0 ? tag2(0) : concat(tag2(1), borshString4(input.minReleaseVersion));
|
|
10773
10800
|
return {
|
|
10774
10801
|
kind: "teeReleaseAdmissionPolicy",
|
|
10775
10802
|
plane: "group",
|
|
@@ -11184,6 +11211,7 @@ export {
|
|
|
11184
11211
|
subgroupCreation,
|
|
11185
11212
|
subgroupVisibilitySetOp,
|
|
11186
11213
|
subscribePresence,
|
|
11214
|
+
targetApplicationSetOp,
|
|
11187
11215
|
teeAdmissionPolicyOp,
|
|
11188
11216
|
teeAuthoringPolicyOp,
|
|
11189
11217
|
teeReleaseAdmissionPolicyOp,
|