@calimero-network/mero-js 22.9.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/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, 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";
@@ -34,7 +34,9 @@ export { signGroupInvitation, encodeGroupInvitation, groupInvitationHash, defaul
34
34
  export type { GroupInvitationInput } from "./invitation/index.js";
35
35
  export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from "./namespace-op/index.js";
36
36
  export type { SignMemberJoinInput } from "./namespace-op/index.js";
37
- export type { WarrantInput, CreationWarrantInput, CreationWarrantFields, SignedCreationWarrant, GovernanceWarrantInput, GovernanceWarrantFields, GovernanceOp, GovernanceOpKind, GovernanceMemberRole, GroupCreatedInput, NamespaceCreatedInput, } from "./warrant/index.js";
37
+ export { OWNER_OP_KIND, transferOwnershipOp, groupDeleteOp, adminChangedOp, teeAuthoringPolicyOp, teeAdmissionPolicyOp, teeReleaseAdmissionPolicyOp, ownerOpDigest, ownerOpSigningPayload, signOwnerOpProof, rootGuardedOpBytes, } from "./owner-op/index.js";
38
+ export type { OwnerOp, OwnerOpKind, OwnerOpPlane, OwnerOpProofInput, TeeAdmissionPolicyOpInput, TeeReleaseAdmissionPolicyOpInput, } from "./owner-op/index.js";
39
+ export type { WarrantInput, CreationWarrantInput, CreationWarrantFields, SignedCreationWarrant, GovernanceWarrantInput, GovernanceWarrantFields, GovernanceOp, GovernanceOpKind, GovernanceMemberRole, GroupCreatedInput, SubgroupCreation, NamespaceCreatedInput, } from "./warrant/index.js";
38
40
  export { requestBodyHash, signRequest, callerProof, createProofSigner, } from "./request/index.js";
39
41
  export type { CallerProofInput, ProofRequest, ProofSignerOptions, } from "./request/index.js";
40
42
  export type { RequestSigInput } from "./request/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, 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";
@@ -52,6 +52,7 @@ export { signDeviceScope, deviceScopePayload } from "./device-cert/index.js";
52
52
  // Invitations minted off-node, signed by a bound device key.
53
53
  export { signGroupInvitation, encodeGroupInvitation, groupInvitationHash, defaultAdmitters, MAX_INVITATION_VALIDITY_SECS, INVITED_ROLE, } from "./invitation/index.js";
54
54
  export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from "./namespace-op/index.js";
55
+ export { OWNER_OP_KIND, transferOwnershipOp, groupDeleteOp, adminChangedOp, teeAuthoringPolicyOp, teeAdmissionPolicyOp, teeReleaseAdmissionPolicyOp, ownerOpDigest, ownerOpSigningPayload, signOwnerOpProof, rootGuardedOpBytes, } from "./owner-op/index.js";
55
56
  // Login-statement signing — the device's half of a password-free session
56
57
  export { requestBodyHash, signRequest, callerProof, createProofSigner, } from "./request/index.js";
57
58
  export { signLoginStatement } from "./login/index.js";
package/dist/index.mjs CHANGED
@@ -2167,9 +2167,45 @@ var AdminApiClient = class {
2167
2167
  * and admitted TEEs stay members. The node applies the same op as
2168
2168
  * `setTeeAuthoringPolicy(groupId, { allowedMrtd: [] })`. `groupId` must be a
2169
2169
  * namespace root.
2170
+ *
2171
+ * `rootProof` is the signing admin's own root proof for that empty policy
2172
+ * (`teeAuthoringPolicyOp([])`); omit it on a node that holds that root.
2173
+ */
2174
+ async disableTeeAuthoringPolicy(groupId, options = {}) {
2175
+ const path = `/admin-api/groups/${groupId}/settings/tee-authoring-policy`;
2176
+ if (options.rootProof === void 0) {
2177
+ await this.httpClient.delete(path);
2178
+ return;
2179
+ }
2180
+ await this.httpClient.request(path, {
2181
+ method: "DELETE",
2182
+ body: JSON.stringify({ rootProof: options.rootProof }),
2183
+ headers: { "Content-Type": "application/json" }
2184
+ });
2185
+ }
2186
+ // ---- Root-guarded owner ops (core schema 18) ----
2187
+ /**
2188
+ * Hand the group to `newOwner`, who must already be one of its admins.
2189
+ * Owner-only, and it needs the owner account's root proof; see
2190
+ * {@link RootGuardedOpRequest}.
2191
+ */
2192
+ async transferOwnership(groupId, request) {
2193
+ await this.httpClient.post(`/admin-api/groups/${groupId}/transfer-ownership`, request);
2194
+ }
2195
+ /**
2196
+ * Repoint the namespace's admin pin at `newAdmin`, a member of its root.
2197
+ * Owner-only, with the owner account's root proof; see {@link RootGuardedOpRequest}.
2198
+ */
2199
+ async changeNamespaceAdmin(namespaceId, request) {
2200
+ await this.httpClient.post(`/admin-api/namespaces/${namespaceId}/admin`, request);
2201
+ }
2202
+ /**
2203
+ * Delete a group through the owner-only path: it must hold no contexts, and
2204
+ * the op needs the owner account's root proof. {@link deleteGroup} is the
2205
+ * admin-level cascading delete.
2170
2206
  */
2171
- async disableTeeAuthoringPolicy(groupId) {
2172
- await this.httpClient.delete(`/admin-api/groups/${groupId}/settings/tee-authoring-policy`);
2207
+ async ownerDeleteGroup(groupId, request = {}) {
2208
+ await this.httpClient.post(`/admin-api/groups/${groupId}/owner-delete`, request);
2173
2209
  }
2174
2210
  // ---- Group / member / context metadata ----
2175
2211
  async setGroupMetadata(groupId, request) {
@@ -7163,9 +7199,9 @@ function parseCreationWarrant(warrant) {
7163
7199
  const u32 = (what) => view.getUint32(take(4, what).byteOffset, true);
7164
7200
  const u64 = (what) => view.getBigUint64(take(8, what).byteOffset, true);
7165
7201
  const option = (what) => {
7166
- const tag2 = take(1, what)[0];
7167
- if (tag2 === 0) return null;
7168
- if (tag2 !== 1) throw new Error(`${what} has option tag ${tag2}, expected 0 or 1`);
7202
+ const tag3 = take(1, what)[0];
7203
+ if (tag3 === 0) return null;
7204
+ if (tag3 !== 1) throw new Error(`${what} has option tag ${tag3}, expected 0 or 1`);
7169
7205
  const len = u32(what);
7170
7206
  if (len > MAX_LABEL_BYTES) {
7171
7207
  throw new Error(`${what} is ${len} bytes, over the ${MAX_LABEL_BYTES} a node accepts`);
@@ -7354,12 +7390,21 @@ var GROUP_OP = {
7354
7390
  MemberRemoved: 2,
7355
7391
  MemberLeft: 3,
7356
7392
  MemberRoleSet: 4,
7357
- DefaultCapabilitiesSet: 6
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
7358
7402
  };
7359
7403
  var ROOT_OP = {
7360
7404
  GroupCreated: 0,
7361
7405
  GroupReparented: 1,
7362
7406
  GroupDeleted: 2,
7407
+ MemberJoinedOpen: 7,
7363
7408
  NamespaceCreatedV2: 9
7364
7409
  };
7365
7410
  var NAMESPACE_ID_DOMAIN = new TextEncoder().encode("calimero.namespace.id.v1");
@@ -7409,6 +7454,17 @@ function memberRoleSetOp(member, memberRole) {
7409
7454
  bytes: concat(tag(GROUP_OP.MemberRoleSet), fromHex(member, "member", 32), role(memberRole))
7410
7455
  };
7411
7456
  }
7457
+ var SUBGROUP_ID_DOMAIN = new TextEncoder().encode("calimero.subgroup.id.v1");
7458
+ async function createdSubgroupId(admin, parentId, restricted, salt) {
7459
+ return hex(
7460
+ await domainHash(SUBGROUP_ID_DOMAIN, [
7461
+ fromHex(admin, "admin", 32),
7462
+ fromHex(parentId, "parentId", 32),
7463
+ new Uint8Array([restricted ? 1 : 0]),
7464
+ fromHex(salt, "salt", 32)
7465
+ ])
7466
+ );
7467
+ }
7412
7468
  function defaultCapabilitiesSetOp(capabilities) {
7413
7469
  if (!Number.isInteger(capabilities) || capabilities < 0 || capabilities > 4294967295) {
7414
7470
  throw new Error(`capabilities must be a u32 bit mask, got ${String(capabilities)}`);
@@ -7431,10 +7487,16 @@ function groupCreatedOp(input) {
7431
7487
  fromHex(input.groupId, "groupId", 32),
7432
7488
  fromHex(input.parentId, "parentId", 32),
7433
7489
  tag(input.restricted ? 1 : 0),
7434
- fromHex(input.admin, "admin", 32)
7490
+ fromHex(input.admin, "admin", 32),
7491
+ fromHex(input.salt, "salt", 32)
7435
7492
  )
7436
7493
  };
7437
7494
  }
7495
+ async function subgroupCreation(input) {
7496
+ const salt = input.salt ?? hex(crypto.getRandomValues(new Uint8Array(32)));
7497
+ const groupId = await createdSubgroupId(input.admin, input.parentId, input.restricted, salt);
7498
+ return { groupId, salt, op: groupCreatedOp({ ...input, groupId, salt }) };
7499
+ }
7438
7500
  function groupReparentedOp(childGroupId, newParentId) {
7439
7501
  return {
7440
7502
  kind: "root",
@@ -7474,6 +7536,87 @@ function namespaceCreatedOp(input) {
7474
7536
  )
7475
7537
  };
7476
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
+ }
7477
7620
 
7478
7621
  // src/relay/relay-client.ts
7479
7622
  var DEFAULT_TTL_SECONDS = 300;
@@ -7992,12 +8135,12 @@ function audienceSigningBytes(audience) {
7992
8135
  );
7993
8136
  }
7994
8137
  function audienceWire(audience) {
7995
- const tag2 = Uint8Array.from([AUDIENCE_TAG[audience.kind]]);
8138
+ const tag3 = Uint8Array.from([AUDIENCE_TAG[audience.kind]]);
7996
8139
  if (audience.kind === "cli") {
7997
- return tag2;
8140
+ return tag3;
7998
8141
  }
7999
8142
  const body = audienceBody(audience);
8000
- return concat(tag2, u32le(body.length), body);
8143
+ return concat(tag3, u32le(body.length), body);
8001
8144
  }
8002
8145
  async function signLoginStatement(input) {
8003
8146
  const node = fromHex(input.node, "node", 32);
@@ -9682,8 +9825,8 @@ var SIGNATURE_HASHES = {
9682
9825
  };
9683
9826
  function read(bytes, offset, limit) {
9684
9827
  if (offset + 2 > limit) throw new Error("it is truncated");
9685
- const tag2 = bytes[offset];
9686
- if ((tag2 & 31) === 31) throw new Error("it uses a tag this parser does not read");
9828
+ const tag3 = bytes[offset];
9829
+ if ((tag3 & 31) === 31) throw new Error("it uses a tag this parser does not read");
9687
9830
  let length = bytes[offset + 1];
9688
9831
  let start = offset + 2;
9689
9832
  if (length & 128) {
@@ -9695,7 +9838,7 @@ function read(bytes, offset, limit) {
9695
9838
  }
9696
9839
  const end = start + length;
9697
9840
  if (end > limit) throw new Error("it is truncated");
9698
- return { tag: tag2, bytes, offset, start, end };
9841
+ return { tag: tag3, bytes, offset, start, end };
9699
9842
  }
9700
9843
  function parseDer(bytes) {
9701
9844
  const element = read(bytes, 0, bytes.length);
@@ -9711,8 +9854,8 @@ function children(element) {
9711
9854
  }
9712
9855
  return out;
9713
9856
  }
9714
- function expectTag(element, tag2, what) {
9715
- if (!element || element.tag !== tag2) throw new Error(`${what} is not where it should be`);
9857
+ function expectTag(element, tag3, what) {
9858
+ if (!element || element.tag !== tag3) throw new Error(`${what} is not where it should be`);
9716
9859
  return element;
9717
9860
  }
9718
9861
  function contents(element) {
@@ -10270,7 +10413,7 @@ function bytes32(value, label2) {
10270
10413
  }
10271
10414
 
10272
10415
  // src/namespace-op/namespace-op.ts
10273
- var SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 16;
10416
+ var SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 20;
10274
10417
  var NAMESPACE_SIGN_DOMAIN = new TextEncoder().encode("calimero.namespace.v1");
10275
10418
  var NAMESPACE_OP_ROOT = 0;
10276
10419
  var ROOT_OP2 = {
@@ -10360,6 +10503,183 @@ async function signMemberJoinOp(input) {
10360
10503
  return hex(concat(signable, signature, unendorsed));
10361
10504
  }
10362
10505
 
10506
+ // src/owner-op/owner-op.ts
10507
+ var OWNER_OP_SIGN_DOMAIN = new TextEncoder().encode("calimero.account.owner-op.v1");
10508
+ var OWNER_OP_BODY_DOMAIN = new TextEncoder().encode("calimero.account.owner-op.body.v1");
10509
+ var ACCOUNT_ID_DOMAIN2 = new TextEncoder().encode("calimero.account.genesis.v1");
10510
+ var ACCOUNT_GENESIS_VERSION2 = 2;
10511
+ var OWNER_OP_KIND = {
10512
+ transferOwnership: 0,
10513
+ adminChanged: 1,
10514
+ groupDelete: 2,
10515
+ teeAdmissionPolicy: 3,
10516
+ teeAuthoringPolicy: 4,
10517
+ teeReleaseAdmissionPolicy: 5
10518
+ };
10519
+ var GROUP_OP2 = {
10520
+ GroupDelete: 14,
10521
+ TransferOwnership: 21,
10522
+ TeeAuthoringPolicySet: 33,
10523
+ TeeAdmissionPolicySetV2: 37,
10524
+ TeeReleaseAdmissionPolicySetV2: 38,
10525
+ RootGuarded: 42
10526
+ };
10527
+ var ROOT_OP3 = {
10528
+ AdminChanged: 3,
10529
+ RootGuarded: 12
10530
+ };
10531
+ var TEE_MODE = { replica: 0, relay: 1 };
10532
+ var te = new TextEncoder();
10533
+ function tag2(byte) {
10534
+ return new Uint8Array([byte]);
10535
+ }
10536
+ function borshString3(value) {
10537
+ const bytes = te.encode(value);
10538
+ return concat(u32le(bytes.length), bytes);
10539
+ }
10540
+ function borshStrings(values) {
10541
+ return concat(u32le(values.length), ...values.map(borshString3));
10542
+ }
10543
+ function borshBool(value) {
10544
+ return tag2(value ? 1 : 0);
10545
+ }
10546
+ function teeMode(mode) {
10547
+ const byte = TEE_MODE[mode ?? "replica"];
10548
+ if (byte === void 0) {
10549
+ throw new Error(`mode must be replica or relay, got ${String(mode)}`);
10550
+ }
10551
+ return tag2(byte);
10552
+ }
10553
+ function transferOwnershipOp(newOwner) {
10554
+ return {
10555
+ kind: "transferOwnership",
10556
+ plane: "group",
10557
+ bytes: concat(tag2(GROUP_OP2.TransferOwnership), fromHex(newOwner, "newOwner", 32))
10558
+ };
10559
+ }
10560
+ function groupDeleteOp() {
10561
+ return { kind: "groupDelete", plane: "group", bytes: tag2(GROUP_OP2.GroupDelete) };
10562
+ }
10563
+ function adminChangedOp(newAdmin) {
10564
+ return {
10565
+ kind: "adminChanged",
10566
+ plane: "root",
10567
+ bytes: concat(tag2(ROOT_OP3.AdminChanged), fromHex(newAdmin, "newAdmin", 32))
10568
+ };
10569
+ }
10570
+ function teeAuthoringPolicyOp(allowedMrtd) {
10571
+ return {
10572
+ kind: "teeAuthoringPolicy",
10573
+ plane: "group",
10574
+ bytes: concat(tag2(GROUP_OP2.TeeAuthoringPolicySet), borshStrings(allowedMrtd))
10575
+ };
10576
+ }
10577
+ function teeAdmissionPolicyOp(input) {
10578
+ return {
10579
+ kind: "teeAdmissionPolicy",
10580
+ plane: "group",
10581
+ bytes: concat(
10582
+ tag2(GROUP_OP2.TeeAdmissionPolicySetV2),
10583
+ borshStrings(input.allowedMrtd),
10584
+ borshStrings(input.allowedRtmr0),
10585
+ borshStrings(input.allowedRtmr1),
10586
+ borshStrings(input.allowedRtmr2),
10587
+ borshStrings(input.allowedRtmr3),
10588
+ borshStrings(input.allowedTcbStatuses),
10589
+ borshBool(input.acceptMock),
10590
+ teeMode(input.mode)
10591
+ )
10592
+ };
10593
+ }
10594
+ function teeReleaseAdmissionPolicyOp(input) {
10595
+ const minRelease = input.minReleaseVersion === void 0 ? tag2(0) : concat(tag2(1), borshString3(input.minReleaseVersion));
10596
+ return {
10597
+ kind: "teeReleaseAdmissionPolicy",
10598
+ plane: "group",
10599
+ bytes: concat(
10600
+ tag2(GROUP_OP2.TeeReleaseAdmissionPolicySetV2),
10601
+ borshStrings(input.allowedProfiles),
10602
+ minRelease,
10603
+ borshStrings(input.allowedTcbStatuses),
10604
+ borshBool(input.acceptMock),
10605
+ teeMode(input.mode)
10606
+ )
10607
+ };
10608
+ }
10609
+ async function ownerOpDigest(opBytes) {
10610
+ return domainHash(OWNER_OP_BODY_DOMAIN, [opBytes]);
10611
+ }
10612
+ async function ownerOpSigningPayload(input) {
10613
+ return domainHash(OWNER_OP_SIGN_DOMAIN, [
10614
+ fromHex(input.account, "account", 32),
10615
+ fromHex(input.namespaceId, "namespaceId", 32),
10616
+ fromHex(input.groupId, "groupId", 32),
10617
+ tag2(kindByte2(input.kind)),
10618
+ input.opDigest,
10619
+ u64le(input.counter),
10620
+ u32le(input.keyEpoch)
10621
+ ]);
10622
+ }
10623
+ function kindByte2(kind) {
10624
+ const byte = OWNER_OP_KIND[kind];
10625
+ if (byte === void 0) {
10626
+ throw new Error(`unknown owner-op kind ${String(kind)}`);
10627
+ }
10628
+ return byte;
10629
+ }
10630
+ var HANDOFF_BYTES = 32 + 4 + 32 + 64;
10631
+ async function signOwnerOpProof(input) {
10632
+ const rootPublicKey = await derivePublicKey(input.rootSecret);
10633
+ const genesis = concat(tag2(ACCOUNT_GENESIS_VERSION2), rootPublicKey);
10634
+ const account = hex(await domainHash(ACCOUNT_ID_DOMAIN2, [genesis]));
10635
+ const keyEpoch = input.keyEpoch ?? 0;
10636
+ const chain = (input.chain ?? []).map((handoff, index) => {
10637
+ const bytes = fromHexUnsized(handoff, `chain[${index}]`);
10638
+ if (bytes.length !== HANDOFF_BYTES) {
10639
+ throw new Error(
10640
+ `chain[${index}] must be a ${HANDOFF_BYTES}-byte RootKeyHandoff, got ${bytes.length}`
10641
+ );
10642
+ }
10643
+ return bytes;
10644
+ });
10645
+ if (keyEpoch > chain.length) {
10646
+ throw new Error(
10647
+ `keyEpoch ${keyEpoch} needs ${keyEpoch} handoffs in chain, got ${chain.length}`
10648
+ );
10649
+ }
10650
+ const opDigest = await ownerOpDigest(input.op.bytes);
10651
+ const payload = await ownerOpSigningPayload({
10652
+ account,
10653
+ namespaceId: input.namespaceId,
10654
+ groupId: input.groupId,
10655
+ kind: input.op.kind,
10656
+ opDigest,
10657
+ counter: input.counter,
10658
+ keyEpoch
10659
+ });
10660
+ const key = await importSigningKey(input.rootSecret);
10661
+ const signature = new Uint8Array(await crypto.subtle.sign("Ed25519", key, payload));
10662
+ return hex(
10663
+ concat(
10664
+ genesis,
10665
+ u32le(chain.length),
10666
+ ...chain,
10667
+ fromHex(account, "account", 32),
10668
+ fromHex(input.namespaceId, "namespaceId", 32),
10669
+ fromHex(input.groupId, "groupId", 32),
10670
+ tag2(kindByte2(input.op.kind)),
10671
+ opDigest,
10672
+ u64le(input.counter),
10673
+ u32le(keyEpoch),
10674
+ signature
10675
+ )
10676
+ );
10677
+ }
10678
+ function rootGuardedOpBytes(op, rootProof) {
10679
+ const wrapper = op.plane === "group" ? GROUP_OP2.RootGuarded : ROOT_OP3.RootGuarded;
10680
+ return concat(tag2(wrapper), op.bytes, fromHexUnsized(rootProof, "rootProof"));
10681
+ }
10682
+
10363
10683
  // src/nodeDiscovery.ts
10364
10684
  var DEFAULT_LOCAL_NODE_PORTS = [2428, 2429, 2528, 2529];
10365
10685
  var LOCAL_HOST = "localhost";
@@ -10528,6 +10848,7 @@ export {
10528
10848
  MeroClient,
10529
10849
  MeroJs,
10530
10850
  NODE_RELEASE_SIGNER,
10851
+ OWNER_OP_KIND,
10531
10852
  REQUEST_PROOF_HEADER,
10532
10853
  RelayClient,
10533
10854
  RelayObserver,
@@ -10549,6 +10870,7 @@ export {
10549
10870
  accountRootFromPhrase,
10550
10871
  accountRootFromSecret,
10551
10872
  accountRootSignerFromPhrase,
10873
+ adminChangedOp,
10552
10874
  admitterAddrsFromNetworkStatus,
10553
10875
  attestKeyBinding,
10554
10876
  attestRelayNodeKey,
@@ -10569,6 +10891,10 @@ export {
10569
10891
  completeDeviceEnrolment,
10570
10892
  connectCloud,
10571
10893
  connectCloudWithAccount,
10894
+ contextCapabilityGrantedOp,
10895
+ contextCapabilityRevokedOp,
10896
+ contextDetachedOp,
10897
+ contextMetadataSetOp,
10572
10898
  createAccountRootSigner,
10573
10899
  createAdminApiClient,
10574
10900
  createAdminApiClientFromHttpClient,
@@ -10596,6 +10922,7 @@ export {
10596
10922
  createSignedReleaseVerifier,
10597
10923
  createTimeoutSignal,
10598
10924
  createUniversalHttpClient,
10925
+ createdSubgroupId,
10599
10926
  creationInitHash,
10600
10927
  defaultAdmitters,
10601
10928
  defaultAudience,
@@ -10614,8 +10941,10 @@ export {
10614
10941
  generateSessionKey,
10615
10942
  governanceOpHash,
10616
10943
  groupCreatedOp,
10944
+ groupDeleteOp,
10617
10945
  groupDeletedOp,
10618
10946
  groupInvitationHash,
10947
+ groupMetadataSetOp,
10619
10948
  groupReparentedOp,
10620
10949
  hasCap,
10621
10950
  hexEncodeUtf8,
@@ -10625,13 +10954,18 @@ export {
10625
10954
  localNodeUrl,
10626
10955
  login,
10627
10956
  memberAddedOp,
10957
+ memberCapabilitySetOp,
10958
+ memberJoinedOpenOp,
10628
10959
  memberLeftOp,
10960
+ memberMetadataSetOp,
10629
10961
  memberRemovedOp,
10630
10962
  memberRoleSetOp,
10631
10963
  mintDeviceId,
10632
10964
  namespaceCreatedOp,
10633
10965
  nodeEndpoint,
10634
10966
  nodeReleaseVersionFromImage,
10967
+ ownerOpDigest,
10968
+ ownerOpSigningPayload,
10635
10969
  parseAuthCallback,
10636
10970
  parseCreationWarrant,
10637
10971
  parseDeviceCredential,
@@ -10645,6 +10979,7 @@ export {
10645
10979
  requestBodyHash,
10646
10980
  resolveRoot,
10647
10981
  resolveRootPair,
10982
+ rootGuardedOpBytes,
10648
10983
  routingProofHeaders,
10649
10984
  shouldRetain,
10650
10985
  signAccountLink,
@@ -10656,6 +10991,7 @@ export {
10656
10991
  signGroupInvitation,
10657
10992
  signLoginStatement,
10658
10993
  signMemberJoinOp,
10994
+ signOwnerOpProof,
10659
10995
  signRequest,
10660
10996
  signRequestProof,
10661
10997
  signRoutingChallenge,
@@ -10663,6 +10999,12 @@ export {
10663
10999
  signedPath,
10664
11000
  signerFromCryptoKey,
10665
11001
  signerFromSecret,
11002
+ subgroupCreation,
11003
+ subgroupVisibilitySetOp,
11004
+ teeAdmissionPolicyOp,
11005
+ teeAuthoringPolicyOp,
11006
+ teeReleaseAdmissionPolicyOp,
11007
+ transferOwnershipOp,
10666
11008
  transportKeyBinding,
10667
11009
  trustSignedRelease,
10668
11010
  trustedMeasurementsFromReleases,