@calimero-network/mero-js 23.0.0 → 23.1.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-types.d.ts +3 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +100 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +100 -1
- package/dist/index.mjs.map +2 -2
- package/dist/warrant/governance-op.d.ts +36 -0
- package/dist/warrant/governance-op.js +115 -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
|
@@ -21,7 +21,7 @@ export * from "./cloud/index.js";
|
|
|
21
21
|
export * from "./sealed/index.js";
|
|
22
22
|
export * from "./relay/index.js";
|
|
23
23
|
export * from "./request-proof/index.js";
|
|
24
|
-
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
24
|
+
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";
|
|
25
25
|
export { signerFromSecret, signerFromCryptoKey } from "./signer/index.js";
|
|
26
26
|
export type { Signer } from "./signer/index.js";
|
|
27
27
|
export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, createAccountRootSigner, accountRootSignerFromPhrase, signAccountLink, signAccountLogin, resolveRoot, resolveRootPair, } from "./account/index.js";
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export * from "./relay/index.js";
|
|
|
34
34
|
// Request proofs — a caller's identity on the request itself, no session needed
|
|
35
35
|
export * from "./request-proof/index.js";
|
|
36
36
|
// Warrant signing — mint the author's consent for a relay to run one intent
|
|
37
|
-
export { signWarrant, intentHash, signCreationWarrant, parseCreationWarrant, creationInitHash, signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from "./warrant/index.js";
|
|
37
|
+
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";
|
|
38
38
|
// Who signs — a key's capability, separated from its material, so a
|
|
39
39
|
// non-extractable key can be used wherever a hex secret could.
|
|
40
40
|
export { signerFromSecret, signerFromCryptoKey } from "./signer/index.js";
|
package/dist/index.mjs
CHANGED
|
@@ -7390,12 +7390,21 @@ var GROUP_OP = {
|
|
|
7390
7390
|
MemberRemoved: 2,
|
|
7391
7391
|
MemberLeft: 3,
|
|
7392
7392
|
MemberRoleSet: 4,
|
|
7393
|
-
|
|
7393
|
+
MemberCapabilitySet: 5,
|
|
7394
|
+
DefaultCapabilitiesSet: 6,
|
|
7395
|
+
ContextDetached: 9,
|
|
7396
|
+
SubgroupVisibilitySet: 10,
|
|
7397
|
+
GroupMetadataSet: 11,
|
|
7398
|
+
MemberMetadataSet: 12,
|
|
7399
|
+
ContextMetadataSet: 13,
|
|
7400
|
+
ContextCapabilityGranted: 16,
|
|
7401
|
+
ContextCapabilityRevoked: 17
|
|
7394
7402
|
};
|
|
7395
7403
|
var ROOT_OP = {
|
|
7396
7404
|
GroupCreated: 0,
|
|
7397
7405
|
GroupReparented: 1,
|
|
7398
7406
|
GroupDeleted: 2,
|
|
7407
|
+
MemberJoinedOpen: 7,
|
|
7399
7408
|
NamespaceCreatedV2: 9
|
|
7400
7409
|
};
|
|
7401
7410
|
var NAMESPACE_ID_DOMAIN = new TextEncoder().encode("calimero.namespace.id.v1");
|
|
@@ -7527,6 +7536,87 @@ function namespaceCreatedOp(input) {
|
|
|
7527
7536
|
)
|
|
7528
7537
|
};
|
|
7529
7538
|
}
|
|
7539
|
+
function str(value) {
|
|
7540
|
+
const bytes = new TextEncoder().encode(value);
|
|
7541
|
+
return concat(u32le(bytes.length), bytes);
|
|
7542
|
+
}
|
|
7543
|
+
function optionalStr(value) {
|
|
7544
|
+
return value === void 0 ? tag(0) : concat(tag(1), str(value));
|
|
7545
|
+
}
|
|
7546
|
+
function stringMap(data = {}) {
|
|
7547
|
+
const enc = new TextEncoder();
|
|
7548
|
+
const entries = Object.entries(data).map(([k, v]) => [enc.encode(k), v, k]).sort(([a], [b]) => {
|
|
7549
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) if (a[i] !== b[i]) return a[i] - b[i];
|
|
7550
|
+
return a.length - b.length;
|
|
7551
|
+
});
|
|
7552
|
+
return concat(u32le(entries.length), ...entries.flatMap(([, v, k]) => [str(k), str(v)]));
|
|
7553
|
+
}
|
|
7554
|
+
function relayableMask(capabilities, what) {
|
|
7555
|
+
if (!Number.isInteger(capabilities) || capabilities < 0 || capabilities > 4294967295) {
|
|
7556
|
+
throw new Error(`${what} must be a u32 bit mask, got ${String(capabilities)}`);
|
|
7557
|
+
}
|
|
7558
|
+
if (hasCap(capabilities, CAPABILITIES.CAN_AUTHOR_ON_BEHALF)) {
|
|
7559
|
+
throw new Error(`${what} may not include CAN_AUTHOR_ON_BEHALF (512): a relay never carries a change to it`);
|
|
7560
|
+
}
|
|
7561
|
+
return capabilities;
|
|
7562
|
+
}
|
|
7563
|
+
function memberCapabilitySetOp(member, capabilities) {
|
|
7564
|
+
return {
|
|
7565
|
+
kind: "group",
|
|
7566
|
+
bytes: concat(tag(GROUP_OP.MemberCapabilitySet), fromHex(member, "member", 32), u32le(relayableMask(capabilities, "capabilities")))
|
|
7567
|
+
};
|
|
7568
|
+
}
|
|
7569
|
+
function contextDetachedOp(contextId) {
|
|
7570
|
+
return { kind: "group", bytes: concat(tag(GROUP_OP.ContextDetached), fromHex(contextId, "contextId", 32)) };
|
|
7571
|
+
}
|
|
7572
|
+
function subgroupVisibilitySetOp(mode) {
|
|
7573
|
+
if (mode !== "open" && mode !== "restricted") throw new Error(`mode must be open or restricted, got ${String(mode)}`);
|
|
7574
|
+
return { kind: "group", bytes: concat(tag(GROUP_OP.SubgroupVisibilitySet), tag(mode === "open" ? 0 : 1)) };
|
|
7575
|
+
}
|
|
7576
|
+
function groupMetadataSetOp(input = {}) {
|
|
7577
|
+
return { kind: "group", bytes: concat(tag(GROUP_OP.GroupMetadataSet), optionalStr(input.name), stringMap(input.data)) };
|
|
7578
|
+
}
|
|
7579
|
+
function memberMetadataSetOp(member, input = {}) {
|
|
7580
|
+
return {
|
|
7581
|
+
kind: "group",
|
|
7582
|
+
bytes: concat(tag(GROUP_OP.MemberMetadataSet), fromHex(member, "member", 32), optionalStr(input.name), stringMap(input.data))
|
|
7583
|
+
};
|
|
7584
|
+
}
|
|
7585
|
+
function contextMetadataSetOp(contextId, input = {}) {
|
|
7586
|
+
return {
|
|
7587
|
+
kind: "group",
|
|
7588
|
+
bytes: concat(tag(GROUP_OP.ContextMetadataSet), fromHex(contextId, "contextId", 32), optionalStr(input.name), stringMap(input.data))
|
|
7589
|
+
};
|
|
7590
|
+
}
|
|
7591
|
+
function contextCapability(capability) {
|
|
7592
|
+
if (!Number.isInteger(capability) || capability < 1 || capability > 255) {
|
|
7593
|
+
throw new Error(`capability must be a non-zero u8, got ${String(capability)}`);
|
|
7594
|
+
}
|
|
7595
|
+
return tag(capability);
|
|
7596
|
+
}
|
|
7597
|
+
function contextCapabilityGrantedOp(contextId, member, capability) {
|
|
7598
|
+
return {
|
|
7599
|
+
kind: "group",
|
|
7600
|
+
bytes: concat(tag(GROUP_OP.ContextCapabilityGranted), fromHex(contextId, "contextId", 32), fromHex(member, "member", 32), contextCapability(capability))
|
|
7601
|
+
};
|
|
7602
|
+
}
|
|
7603
|
+
function contextCapabilityRevokedOp(contextId, member, capability) {
|
|
7604
|
+
return {
|
|
7605
|
+
kind: "group",
|
|
7606
|
+
bytes: concat(tag(GROUP_OP.ContextCapabilityRevoked), fromHex(contextId, "contextId", 32), fromHex(member, "member", 32), contextCapability(capability))
|
|
7607
|
+
};
|
|
7608
|
+
}
|
|
7609
|
+
function memberJoinedOpenOp(input) {
|
|
7610
|
+
return {
|
|
7611
|
+
kind: "root",
|
|
7612
|
+
bytes: concat(
|
|
7613
|
+
tag(ROOT_OP.MemberJoinedOpen),
|
|
7614
|
+
fromHex(input.member, "member", 32),
|
|
7615
|
+
fromHex(input.groupId, "groupId", 32),
|
|
7616
|
+
fromHexUnsized(input.credential, "credential")
|
|
7617
|
+
)
|
|
7618
|
+
};
|
|
7619
|
+
}
|
|
7530
7620
|
|
|
7531
7621
|
// src/relay/relay-client.ts
|
|
7532
7622
|
var DEFAULT_TTL_SECONDS = 300;
|
|
@@ -10801,6 +10891,10 @@ export {
|
|
|
10801
10891
|
completeDeviceEnrolment,
|
|
10802
10892
|
connectCloud,
|
|
10803
10893
|
connectCloudWithAccount,
|
|
10894
|
+
contextCapabilityGrantedOp,
|
|
10895
|
+
contextCapabilityRevokedOp,
|
|
10896
|
+
contextDetachedOp,
|
|
10897
|
+
contextMetadataSetOp,
|
|
10804
10898
|
createAccountRootSigner,
|
|
10805
10899
|
createAdminApiClient,
|
|
10806
10900
|
createAdminApiClientFromHttpClient,
|
|
@@ -10850,6 +10944,7 @@ export {
|
|
|
10850
10944
|
groupDeleteOp,
|
|
10851
10945
|
groupDeletedOp,
|
|
10852
10946
|
groupInvitationHash,
|
|
10947
|
+
groupMetadataSetOp,
|
|
10853
10948
|
groupReparentedOp,
|
|
10854
10949
|
hasCap,
|
|
10855
10950
|
hexEncodeUtf8,
|
|
@@ -10859,7 +10954,10 @@ export {
|
|
|
10859
10954
|
localNodeUrl,
|
|
10860
10955
|
login,
|
|
10861
10956
|
memberAddedOp,
|
|
10957
|
+
memberCapabilitySetOp,
|
|
10958
|
+
memberJoinedOpenOp,
|
|
10862
10959
|
memberLeftOp,
|
|
10960
|
+
memberMetadataSetOp,
|
|
10863
10961
|
memberRemovedOp,
|
|
10864
10962
|
memberRoleSetOp,
|
|
10865
10963
|
mintDeviceId,
|
|
@@ -10902,6 +11000,7 @@ export {
|
|
|
10902
11000
|
signerFromCryptoKey,
|
|
10903
11001
|
signerFromSecret,
|
|
10904
11002
|
subgroupCreation,
|
|
11003
|
+
subgroupVisibilitySetOp,
|
|
10905
11004
|
teeAdmissionPolicyOp,
|
|
10906
11005
|
teeAuthoringPolicyOp,
|
|
10907
11006
|
teeReleaseAdmissionPolicyOp,
|