@calimero-network/mero-js 22.9.0 → 23.0.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 +22 -2
- package/dist/admin-api/admin-client.js +38 -2
- package/dist/admin-api/admin-types.d.ts +60 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +258 -15
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/index.mjs +258 -15
- package/dist/index.mjs.map +4 -4
- package/dist/namespace-op/namespace-op.d.ts +19 -1
- package/dist/namespace-op/namespace-op.js +19 -1
- package/dist/owner-op/index.d.ts +2 -0
- package/dist/owner-op/index.js +3 -0
- package/dist/owner-op/owner-op.d.ts +119 -0
- package/dist/owner-op/owner-op.js +214 -0
- package/dist/warrant/governance-op.d.ts +31 -1
- package/dist/warrant/governance-op.js +30 -1
- package/dist/warrant/index.d.ts +2 -2
- 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, 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, 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
|
|
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, 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.
|
|
2170
2173
|
*/
|
|
2171
|
-
async disableTeeAuthoringPolicy(groupId) {
|
|
2172
|
-
|
|
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.
|
|
2206
|
+
*/
|
|
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
|
|
7167
|
-
if (
|
|
7168
|
-
if (
|
|
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`);
|
|
@@ -7409,6 +7445,17 @@ function memberRoleSetOp(member, memberRole) {
|
|
|
7409
7445
|
bytes: concat(tag(GROUP_OP.MemberRoleSet), fromHex(member, "member", 32), role(memberRole))
|
|
7410
7446
|
};
|
|
7411
7447
|
}
|
|
7448
|
+
var SUBGROUP_ID_DOMAIN = new TextEncoder().encode("calimero.subgroup.id.v1");
|
|
7449
|
+
async function createdSubgroupId(admin, parentId, restricted, salt) {
|
|
7450
|
+
return hex(
|
|
7451
|
+
await domainHash(SUBGROUP_ID_DOMAIN, [
|
|
7452
|
+
fromHex(admin, "admin", 32),
|
|
7453
|
+
fromHex(parentId, "parentId", 32),
|
|
7454
|
+
new Uint8Array([restricted ? 1 : 0]),
|
|
7455
|
+
fromHex(salt, "salt", 32)
|
|
7456
|
+
])
|
|
7457
|
+
);
|
|
7458
|
+
}
|
|
7412
7459
|
function defaultCapabilitiesSetOp(capabilities) {
|
|
7413
7460
|
if (!Number.isInteger(capabilities) || capabilities < 0 || capabilities > 4294967295) {
|
|
7414
7461
|
throw new Error(`capabilities must be a u32 bit mask, got ${String(capabilities)}`);
|
|
@@ -7431,10 +7478,16 @@ function groupCreatedOp(input) {
|
|
|
7431
7478
|
fromHex(input.groupId, "groupId", 32),
|
|
7432
7479
|
fromHex(input.parentId, "parentId", 32),
|
|
7433
7480
|
tag(input.restricted ? 1 : 0),
|
|
7434
|
-
fromHex(input.admin, "admin", 32)
|
|
7481
|
+
fromHex(input.admin, "admin", 32),
|
|
7482
|
+
fromHex(input.salt, "salt", 32)
|
|
7435
7483
|
)
|
|
7436
7484
|
};
|
|
7437
7485
|
}
|
|
7486
|
+
async function subgroupCreation(input) {
|
|
7487
|
+
const salt = input.salt ?? hex(crypto.getRandomValues(new Uint8Array(32)));
|
|
7488
|
+
const groupId = await createdSubgroupId(input.admin, input.parentId, input.restricted, salt);
|
|
7489
|
+
return { groupId, salt, op: groupCreatedOp({ ...input, groupId, salt }) };
|
|
7490
|
+
}
|
|
7438
7491
|
function groupReparentedOp(childGroupId, newParentId) {
|
|
7439
7492
|
return {
|
|
7440
7493
|
kind: "root",
|
|
@@ -7992,12 +8045,12 @@ function audienceSigningBytes(audience) {
|
|
|
7992
8045
|
);
|
|
7993
8046
|
}
|
|
7994
8047
|
function audienceWire(audience) {
|
|
7995
|
-
const
|
|
8048
|
+
const tag3 = Uint8Array.from([AUDIENCE_TAG[audience.kind]]);
|
|
7996
8049
|
if (audience.kind === "cli") {
|
|
7997
|
-
return
|
|
8050
|
+
return tag3;
|
|
7998
8051
|
}
|
|
7999
8052
|
const body = audienceBody(audience);
|
|
8000
|
-
return concat(
|
|
8053
|
+
return concat(tag3, u32le(body.length), body);
|
|
8001
8054
|
}
|
|
8002
8055
|
async function signLoginStatement(input) {
|
|
8003
8056
|
const node = fromHex(input.node, "node", 32);
|
|
@@ -9682,8 +9735,8 @@ var SIGNATURE_HASHES = {
|
|
|
9682
9735
|
};
|
|
9683
9736
|
function read(bytes, offset, limit) {
|
|
9684
9737
|
if (offset + 2 > limit) throw new Error("it is truncated");
|
|
9685
|
-
const
|
|
9686
|
-
if ((
|
|
9738
|
+
const tag3 = bytes[offset];
|
|
9739
|
+
if ((tag3 & 31) === 31) throw new Error("it uses a tag this parser does not read");
|
|
9687
9740
|
let length = bytes[offset + 1];
|
|
9688
9741
|
let start = offset + 2;
|
|
9689
9742
|
if (length & 128) {
|
|
@@ -9695,7 +9748,7 @@ function read(bytes, offset, limit) {
|
|
|
9695
9748
|
}
|
|
9696
9749
|
const end = start + length;
|
|
9697
9750
|
if (end > limit) throw new Error("it is truncated");
|
|
9698
|
-
return { tag:
|
|
9751
|
+
return { tag: tag3, bytes, offset, start, end };
|
|
9699
9752
|
}
|
|
9700
9753
|
function parseDer(bytes) {
|
|
9701
9754
|
const element = read(bytes, 0, bytes.length);
|
|
@@ -9711,8 +9764,8 @@ function children(element) {
|
|
|
9711
9764
|
}
|
|
9712
9765
|
return out;
|
|
9713
9766
|
}
|
|
9714
|
-
function expectTag(element,
|
|
9715
|
-
if (!element || element.tag !==
|
|
9767
|
+
function expectTag(element, tag3, what) {
|
|
9768
|
+
if (!element || element.tag !== tag3) throw new Error(`${what} is not where it should be`);
|
|
9716
9769
|
return element;
|
|
9717
9770
|
}
|
|
9718
9771
|
function contents(element) {
|
|
@@ -10270,7 +10323,7 @@ function bytes32(value, label2) {
|
|
|
10270
10323
|
}
|
|
10271
10324
|
|
|
10272
10325
|
// src/namespace-op/namespace-op.ts
|
|
10273
|
-
var SIGNED_NAMESPACE_OP_SCHEMA_VERSION =
|
|
10326
|
+
var SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 20;
|
|
10274
10327
|
var NAMESPACE_SIGN_DOMAIN = new TextEncoder().encode("calimero.namespace.v1");
|
|
10275
10328
|
var NAMESPACE_OP_ROOT = 0;
|
|
10276
10329
|
var ROOT_OP2 = {
|
|
@@ -10360,6 +10413,183 @@ async function signMemberJoinOp(input) {
|
|
|
10360
10413
|
return hex(concat(signable, signature, unendorsed));
|
|
10361
10414
|
}
|
|
10362
10415
|
|
|
10416
|
+
// src/owner-op/owner-op.ts
|
|
10417
|
+
var OWNER_OP_SIGN_DOMAIN = new TextEncoder().encode("calimero.account.owner-op.v1");
|
|
10418
|
+
var OWNER_OP_BODY_DOMAIN = new TextEncoder().encode("calimero.account.owner-op.body.v1");
|
|
10419
|
+
var ACCOUNT_ID_DOMAIN2 = new TextEncoder().encode("calimero.account.genesis.v1");
|
|
10420
|
+
var ACCOUNT_GENESIS_VERSION2 = 2;
|
|
10421
|
+
var OWNER_OP_KIND = {
|
|
10422
|
+
transferOwnership: 0,
|
|
10423
|
+
adminChanged: 1,
|
|
10424
|
+
groupDelete: 2,
|
|
10425
|
+
teeAdmissionPolicy: 3,
|
|
10426
|
+
teeAuthoringPolicy: 4,
|
|
10427
|
+
teeReleaseAdmissionPolicy: 5
|
|
10428
|
+
};
|
|
10429
|
+
var GROUP_OP2 = {
|
|
10430
|
+
GroupDelete: 14,
|
|
10431
|
+
TransferOwnership: 21,
|
|
10432
|
+
TeeAuthoringPolicySet: 33,
|
|
10433
|
+
TeeAdmissionPolicySetV2: 37,
|
|
10434
|
+
TeeReleaseAdmissionPolicySetV2: 38,
|
|
10435
|
+
RootGuarded: 42
|
|
10436
|
+
};
|
|
10437
|
+
var ROOT_OP3 = {
|
|
10438
|
+
AdminChanged: 3,
|
|
10439
|
+
RootGuarded: 12
|
|
10440
|
+
};
|
|
10441
|
+
var TEE_MODE = { replica: 0, relay: 1 };
|
|
10442
|
+
var te = new TextEncoder();
|
|
10443
|
+
function tag2(byte) {
|
|
10444
|
+
return new Uint8Array([byte]);
|
|
10445
|
+
}
|
|
10446
|
+
function borshString3(value) {
|
|
10447
|
+
const bytes = te.encode(value);
|
|
10448
|
+
return concat(u32le(bytes.length), bytes);
|
|
10449
|
+
}
|
|
10450
|
+
function borshStrings(values) {
|
|
10451
|
+
return concat(u32le(values.length), ...values.map(borshString3));
|
|
10452
|
+
}
|
|
10453
|
+
function borshBool(value) {
|
|
10454
|
+
return tag2(value ? 1 : 0);
|
|
10455
|
+
}
|
|
10456
|
+
function teeMode(mode) {
|
|
10457
|
+
const byte = TEE_MODE[mode ?? "replica"];
|
|
10458
|
+
if (byte === void 0) {
|
|
10459
|
+
throw new Error(`mode must be replica or relay, got ${String(mode)}`);
|
|
10460
|
+
}
|
|
10461
|
+
return tag2(byte);
|
|
10462
|
+
}
|
|
10463
|
+
function transferOwnershipOp(newOwner) {
|
|
10464
|
+
return {
|
|
10465
|
+
kind: "transferOwnership",
|
|
10466
|
+
plane: "group",
|
|
10467
|
+
bytes: concat(tag2(GROUP_OP2.TransferOwnership), fromHex(newOwner, "newOwner", 32))
|
|
10468
|
+
};
|
|
10469
|
+
}
|
|
10470
|
+
function groupDeleteOp() {
|
|
10471
|
+
return { kind: "groupDelete", plane: "group", bytes: tag2(GROUP_OP2.GroupDelete) };
|
|
10472
|
+
}
|
|
10473
|
+
function adminChangedOp(newAdmin) {
|
|
10474
|
+
return {
|
|
10475
|
+
kind: "adminChanged",
|
|
10476
|
+
plane: "root",
|
|
10477
|
+
bytes: concat(tag2(ROOT_OP3.AdminChanged), fromHex(newAdmin, "newAdmin", 32))
|
|
10478
|
+
};
|
|
10479
|
+
}
|
|
10480
|
+
function teeAuthoringPolicyOp(allowedMrtd) {
|
|
10481
|
+
return {
|
|
10482
|
+
kind: "teeAuthoringPolicy",
|
|
10483
|
+
plane: "group",
|
|
10484
|
+
bytes: concat(tag2(GROUP_OP2.TeeAuthoringPolicySet), borshStrings(allowedMrtd))
|
|
10485
|
+
};
|
|
10486
|
+
}
|
|
10487
|
+
function teeAdmissionPolicyOp(input) {
|
|
10488
|
+
return {
|
|
10489
|
+
kind: "teeAdmissionPolicy",
|
|
10490
|
+
plane: "group",
|
|
10491
|
+
bytes: concat(
|
|
10492
|
+
tag2(GROUP_OP2.TeeAdmissionPolicySetV2),
|
|
10493
|
+
borshStrings(input.allowedMrtd),
|
|
10494
|
+
borshStrings(input.allowedRtmr0),
|
|
10495
|
+
borshStrings(input.allowedRtmr1),
|
|
10496
|
+
borshStrings(input.allowedRtmr2),
|
|
10497
|
+
borshStrings(input.allowedRtmr3),
|
|
10498
|
+
borshStrings(input.allowedTcbStatuses),
|
|
10499
|
+
borshBool(input.acceptMock),
|
|
10500
|
+
teeMode(input.mode)
|
|
10501
|
+
)
|
|
10502
|
+
};
|
|
10503
|
+
}
|
|
10504
|
+
function teeReleaseAdmissionPolicyOp(input) {
|
|
10505
|
+
const minRelease = input.minReleaseVersion === void 0 ? tag2(0) : concat(tag2(1), borshString3(input.minReleaseVersion));
|
|
10506
|
+
return {
|
|
10507
|
+
kind: "teeReleaseAdmissionPolicy",
|
|
10508
|
+
plane: "group",
|
|
10509
|
+
bytes: concat(
|
|
10510
|
+
tag2(GROUP_OP2.TeeReleaseAdmissionPolicySetV2),
|
|
10511
|
+
borshStrings(input.allowedProfiles),
|
|
10512
|
+
minRelease,
|
|
10513
|
+
borshStrings(input.allowedTcbStatuses),
|
|
10514
|
+
borshBool(input.acceptMock),
|
|
10515
|
+
teeMode(input.mode)
|
|
10516
|
+
)
|
|
10517
|
+
};
|
|
10518
|
+
}
|
|
10519
|
+
async function ownerOpDigest(opBytes) {
|
|
10520
|
+
return domainHash(OWNER_OP_BODY_DOMAIN, [opBytes]);
|
|
10521
|
+
}
|
|
10522
|
+
async function ownerOpSigningPayload(input) {
|
|
10523
|
+
return domainHash(OWNER_OP_SIGN_DOMAIN, [
|
|
10524
|
+
fromHex(input.account, "account", 32),
|
|
10525
|
+
fromHex(input.namespaceId, "namespaceId", 32),
|
|
10526
|
+
fromHex(input.groupId, "groupId", 32),
|
|
10527
|
+
tag2(kindByte2(input.kind)),
|
|
10528
|
+
input.opDigest,
|
|
10529
|
+
u64le(input.counter),
|
|
10530
|
+
u32le(input.keyEpoch)
|
|
10531
|
+
]);
|
|
10532
|
+
}
|
|
10533
|
+
function kindByte2(kind) {
|
|
10534
|
+
const byte = OWNER_OP_KIND[kind];
|
|
10535
|
+
if (byte === void 0) {
|
|
10536
|
+
throw new Error(`unknown owner-op kind ${String(kind)}`);
|
|
10537
|
+
}
|
|
10538
|
+
return byte;
|
|
10539
|
+
}
|
|
10540
|
+
var HANDOFF_BYTES = 32 + 4 + 32 + 64;
|
|
10541
|
+
async function signOwnerOpProof(input) {
|
|
10542
|
+
const rootPublicKey = await derivePublicKey(input.rootSecret);
|
|
10543
|
+
const genesis = concat(tag2(ACCOUNT_GENESIS_VERSION2), rootPublicKey);
|
|
10544
|
+
const account = hex(await domainHash(ACCOUNT_ID_DOMAIN2, [genesis]));
|
|
10545
|
+
const keyEpoch = input.keyEpoch ?? 0;
|
|
10546
|
+
const chain = (input.chain ?? []).map((handoff, index) => {
|
|
10547
|
+
const bytes = fromHexUnsized(handoff, `chain[${index}]`);
|
|
10548
|
+
if (bytes.length !== HANDOFF_BYTES) {
|
|
10549
|
+
throw new Error(
|
|
10550
|
+
`chain[${index}] must be a ${HANDOFF_BYTES}-byte RootKeyHandoff, got ${bytes.length}`
|
|
10551
|
+
);
|
|
10552
|
+
}
|
|
10553
|
+
return bytes;
|
|
10554
|
+
});
|
|
10555
|
+
if (keyEpoch > chain.length) {
|
|
10556
|
+
throw new Error(
|
|
10557
|
+
`keyEpoch ${keyEpoch} needs ${keyEpoch} handoffs in chain, got ${chain.length}`
|
|
10558
|
+
);
|
|
10559
|
+
}
|
|
10560
|
+
const opDigest = await ownerOpDigest(input.op.bytes);
|
|
10561
|
+
const payload = await ownerOpSigningPayload({
|
|
10562
|
+
account,
|
|
10563
|
+
namespaceId: input.namespaceId,
|
|
10564
|
+
groupId: input.groupId,
|
|
10565
|
+
kind: input.op.kind,
|
|
10566
|
+
opDigest,
|
|
10567
|
+
counter: input.counter,
|
|
10568
|
+
keyEpoch
|
|
10569
|
+
});
|
|
10570
|
+
const key = await importSigningKey(input.rootSecret);
|
|
10571
|
+
const signature = new Uint8Array(await crypto.subtle.sign("Ed25519", key, payload));
|
|
10572
|
+
return hex(
|
|
10573
|
+
concat(
|
|
10574
|
+
genesis,
|
|
10575
|
+
u32le(chain.length),
|
|
10576
|
+
...chain,
|
|
10577
|
+
fromHex(account, "account", 32),
|
|
10578
|
+
fromHex(input.namespaceId, "namespaceId", 32),
|
|
10579
|
+
fromHex(input.groupId, "groupId", 32),
|
|
10580
|
+
tag2(kindByte2(input.op.kind)),
|
|
10581
|
+
opDigest,
|
|
10582
|
+
u64le(input.counter),
|
|
10583
|
+
u32le(keyEpoch),
|
|
10584
|
+
signature
|
|
10585
|
+
)
|
|
10586
|
+
);
|
|
10587
|
+
}
|
|
10588
|
+
function rootGuardedOpBytes(op, rootProof) {
|
|
10589
|
+
const wrapper = op.plane === "group" ? GROUP_OP2.RootGuarded : ROOT_OP3.RootGuarded;
|
|
10590
|
+
return concat(tag2(wrapper), op.bytes, fromHexUnsized(rootProof, "rootProof"));
|
|
10591
|
+
}
|
|
10592
|
+
|
|
10363
10593
|
// src/nodeDiscovery.ts
|
|
10364
10594
|
var DEFAULT_LOCAL_NODE_PORTS = [2428, 2429, 2528, 2529];
|
|
10365
10595
|
var LOCAL_HOST = "localhost";
|
|
@@ -10528,6 +10758,7 @@ export {
|
|
|
10528
10758
|
MeroClient,
|
|
10529
10759
|
MeroJs,
|
|
10530
10760
|
NODE_RELEASE_SIGNER,
|
|
10761
|
+
OWNER_OP_KIND,
|
|
10531
10762
|
REQUEST_PROOF_HEADER,
|
|
10532
10763
|
RelayClient,
|
|
10533
10764
|
RelayObserver,
|
|
@@ -10549,6 +10780,7 @@ export {
|
|
|
10549
10780
|
accountRootFromPhrase,
|
|
10550
10781
|
accountRootFromSecret,
|
|
10551
10782
|
accountRootSignerFromPhrase,
|
|
10783
|
+
adminChangedOp,
|
|
10552
10784
|
admitterAddrsFromNetworkStatus,
|
|
10553
10785
|
attestKeyBinding,
|
|
10554
10786
|
attestRelayNodeKey,
|
|
@@ -10596,6 +10828,7 @@ export {
|
|
|
10596
10828
|
createSignedReleaseVerifier,
|
|
10597
10829
|
createTimeoutSignal,
|
|
10598
10830
|
createUniversalHttpClient,
|
|
10831
|
+
createdSubgroupId,
|
|
10599
10832
|
creationInitHash,
|
|
10600
10833
|
defaultAdmitters,
|
|
10601
10834
|
defaultAudience,
|
|
@@ -10614,6 +10847,7 @@ export {
|
|
|
10614
10847
|
generateSessionKey,
|
|
10615
10848
|
governanceOpHash,
|
|
10616
10849
|
groupCreatedOp,
|
|
10850
|
+
groupDeleteOp,
|
|
10617
10851
|
groupDeletedOp,
|
|
10618
10852
|
groupInvitationHash,
|
|
10619
10853
|
groupReparentedOp,
|
|
@@ -10632,6 +10866,8 @@ export {
|
|
|
10632
10866
|
namespaceCreatedOp,
|
|
10633
10867
|
nodeEndpoint,
|
|
10634
10868
|
nodeReleaseVersionFromImage,
|
|
10869
|
+
ownerOpDigest,
|
|
10870
|
+
ownerOpSigningPayload,
|
|
10635
10871
|
parseAuthCallback,
|
|
10636
10872
|
parseCreationWarrant,
|
|
10637
10873
|
parseDeviceCredential,
|
|
@@ -10645,6 +10881,7 @@ export {
|
|
|
10645
10881
|
requestBodyHash,
|
|
10646
10882
|
resolveRoot,
|
|
10647
10883
|
resolveRootPair,
|
|
10884
|
+
rootGuardedOpBytes,
|
|
10648
10885
|
routingProofHeaders,
|
|
10649
10886
|
shouldRetain,
|
|
10650
10887
|
signAccountLink,
|
|
@@ -10656,6 +10893,7 @@ export {
|
|
|
10656
10893
|
signGroupInvitation,
|
|
10657
10894
|
signLoginStatement,
|
|
10658
10895
|
signMemberJoinOp,
|
|
10896
|
+
signOwnerOpProof,
|
|
10659
10897
|
signRequest,
|
|
10660
10898
|
signRequestProof,
|
|
10661
10899
|
signRoutingChallenge,
|
|
@@ -10663,6 +10901,11 @@ export {
|
|
|
10663
10901
|
signedPath,
|
|
10664
10902
|
signerFromCryptoKey,
|
|
10665
10903
|
signerFromSecret,
|
|
10904
|
+
subgroupCreation,
|
|
10905
|
+
teeAdmissionPolicyOp,
|
|
10906
|
+
teeAuthoringPolicyOp,
|
|
10907
|
+
teeReleaseAdmissionPolicyOp,
|
|
10908
|
+
transferOwnershipOp,
|
|
10666
10909
|
transportKeyBinding,
|
|
10667
10910
|
trustSignedRelease,
|
|
10668
10911
|
trustedMeasurementsFromReleases,
|