@calimero-network/mero-js 22.8.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 +38 -2
- package/dist/admin-api/admin-client.js +56 -2
- package/dist/admin-api/admin-types.d.ts +94 -0
- package/dist/device-cert/device-cert.d.ts +11 -0
- package/dist/device-cert/device-cert.js +1 -2
- package/dist/device-cert/device-scope.d.ts +58 -0
- package/dist/device-cert/device-scope.js +76 -0
- package/dist/device-cert/index.d.ts +2 -0
- package/dist/device-cert/index.js +1 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +435 -34
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +8 -2
- package/dist/index.js +7 -1
- package/dist/index.mjs +435 -34
- package/dist/index.mjs.map +4 -4
- package/dist/invitation/index.d.ts +2 -0
- package/dist/invitation/index.js +2 -0
- package/dist/invitation/invitation.d.ts +106 -0
- package/dist/invitation/invitation.js +104 -0
- package/dist/namespace-op/namespace-op.d.ts +19 -1
- package/dist/namespace-op/namespace-op.js +23 -15
- 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
|
@@ -52,6 +52,17 @@ export declare function memberRemovedOp(member: string): GovernanceOp;
|
|
|
52
52
|
export declare function memberLeftOp(member: string): GovernanceOp;
|
|
53
53
|
/** Set `member`'s role (an account, hex). */
|
|
54
54
|
export declare function memberRoleSetOp(member: string, memberRole: GovernanceMemberRole): GovernanceOp;
|
|
55
|
+
/**
|
|
56
|
+
* The id `admin` derives for a subgroup under `parentId` with birth visibility
|
|
57
|
+
* `restricted` and `salt` (all hex), as core's `created_subgroup_id` does:
|
|
58
|
+
* `domain_hash("calimero.subgroup.id.v1", [admin, parentId, [restricted], salt])`.
|
|
59
|
+
*
|
|
60
|
+
* A subgroup's id is bound to its create, so nobody but its creator can name
|
|
61
|
+
* it: a node refuses a `GroupCreated` whose fields do not reproduce its id.
|
|
62
|
+
* That is what stops a second member racing a concurrent create for an id it
|
|
63
|
+
* saw gossiped.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createdSubgroupId(admin: string, parentId: string, restricted: boolean, salt: string): Promise<string>;
|
|
55
66
|
/**
|
|
56
67
|
* Set the group's default capability mask (`MemberCapabilities` bits, a `u32`),
|
|
57
68
|
* the capabilities every member holds without a per-member grant. Needs admin.
|
|
@@ -63,7 +74,11 @@ export declare function memberRoleSetOp(member: string, memberRole: GovernanceMe
|
|
|
63
74
|
export declare function defaultCapabilitiesSetOp(capabilities: number): GovernanceOp;
|
|
64
75
|
/** What a subgroup is created with. */
|
|
65
76
|
export interface GroupCreatedInput {
|
|
66
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The new subgroup's id, hex (32 bytes). It must be
|
|
79
|
+
* `createdSubgroupId(admin, parentId, restricted, salt)`; a node refuses any
|
|
80
|
+
* other. {@link subgroupCreation} draws the salt and derives it for you.
|
|
81
|
+
*/
|
|
67
82
|
groupId: string;
|
|
68
83
|
/** The group it is nested under, hex: the namespace root or an existing subgroup. */
|
|
69
84
|
parentId: string;
|
|
@@ -74,6 +89,8 @@ export interface GroupCreatedInput {
|
|
|
74
89
|
* refuses any other, since the op is applied as the author.
|
|
75
90
|
*/
|
|
76
91
|
admin: string;
|
|
92
|
+
/** The salt `groupId` was derived with, hex (32 bytes). Random; need not be kept. */
|
|
93
|
+
salt: string;
|
|
77
94
|
}
|
|
78
95
|
/**
|
|
79
96
|
* Create a subgroup under `parentId`, a root op published on the namespace.
|
|
@@ -82,6 +99,19 @@ export interface GroupCreatedInput {
|
|
|
82
99
|
* relay, becomes the new subgroup's admin.
|
|
83
100
|
*/
|
|
84
101
|
export declare function groupCreatedOp(input: GroupCreatedInput): GovernanceOp;
|
|
102
|
+
/** A new subgroup's create: its derived id, the salt it was derived with, and the op. */
|
|
103
|
+
export interface SubgroupCreation {
|
|
104
|
+
groupId: string;
|
|
105
|
+
salt: string;
|
|
106
|
+
op: GovernanceOp;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create a subgroup under `parentId`: draws a fresh salt (unless one is given),
|
|
110
|
+
* derives the id with {@link createdSubgroupId}, and encodes the op.
|
|
111
|
+
*/
|
|
112
|
+
export declare function subgroupCreation(input: Omit<GroupCreatedInput, 'groupId' | 'salt'> & {
|
|
113
|
+
salt?: string;
|
|
114
|
+
}): Promise<SubgroupCreation>;
|
|
85
115
|
/** Move `childGroupId` under `newParentId`, a root op. */
|
|
86
116
|
export declare function groupReparentedOp(childGroupId: string, newParentId: string): GovernanceOp;
|
|
87
117
|
/**
|
|
@@ -100,6 +100,26 @@ export function memberRoleSetOp(member, memberRole) {
|
|
|
100
100
|
bytes: concat(tag(GROUP_OP.MemberRoleSet), fromHex(member, 'member', 32), role(memberRole)),
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
+
/** Domain of core's `created_subgroup_id`. */
|
|
104
|
+
const SUBGROUP_ID_DOMAIN = new TextEncoder().encode('calimero.subgroup.id.v1');
|
|
105
|
+
/**
|
|
106
|
+
* The id `admin` derives for a subgroup under `parentId` with birth visibility
|
|
107
|
+
* `restricted` and `salt` (all hex), as core's `created_subgroup_id` does:
|
|
108
|
+
* `domain_hash("calimero.subgroup.id.v1", [admin, parentId, [restricted], salt])`.
|
|
109
|
+
*
|
|
110
|
+
* A subgroup's id is bound to its create, so nobody but its creator can name
|
|
111
|
+
* it: a node refuses a `GroupCreated` whose fields do not reproduce its id.
|
|
112
|
+
* That is what stops a second member racing a concurrent create for an id it
|
|
113
|
+
* saw gossiped.
|
|
114
|
+
*/
|
|
115
|
+
export async function createdSubgroupId(admin, parentId, restricted, salt) {
|
|
116
|
+
return hex(await domainHash(SUBGROUP_ID_DOMAIN, [
|
|
117
|
+
fromHex(admin, 'admin', 32),
|
|
118
|
+
fromHex(parentId, 'parentId', 32),
|
|
119
|
+
new Uint8Array([restricted ? 1 : 0]),
|
|
120
|
+
fromHex(salt, 'salt', 32),
|
|
121
|
+
]));
|
|
122
|
+
}
|
|
103
123
|
/**
|
|
104
124
|
* Set the group's default capability mask (`MemberCapabilities` bits, a `u32`),
|
|
105
125
|
* the capabilities every member holds without a per-member grant. Needs admin.
|
|
@@ -130,9 +150,18 @@ export function defaultCapabilitiesSetOp(capabilities) {
|
|
|
130
150
|
export function groupCreatedOp(input) {
|
|
131
151
|
return {
|
|
132
152
|
kind: 'root',
|
|
133
|
-
bytes: concat(tag(ROOT_OP.GroupCreated), fromHex(input.groupId, 'groupId', 32), fromHex(input.parentId, 'parentId', 32), tag(input.restricted ? 1 : 0), fromHex(input.admin, 'admin', 32)),
|
|
153
|
+
bytes: concat(tag(ROOT_OP.GroupCreated), fromHex(input.groupId, 'groupId', 32), fromHex(input.parentId, 'parentId', 32), tag(input.restricted ? 1 : 0), fromHex(input.admin, 'admin', 32), fromHex(input.salt, 'salt', 32)),
|
|
134
154
|
};
|
|
135
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Create a subgroup under `parentId`: draws a fresh salt (unless one is given),
|
|
158
|
+
* derives the id with {@link createdSubgroupId}, and encodes the op.
|
|
159
|
+
*/
|
|
160
|
+
export async function subgroupCreation(input) {
|
|
161
|
+
const salt = input.salt ?? hex(crypto.getRandomValues(new Uint8Array(32)));
|
|
162
|
+
const groupId = await createdSubgroupId(input.admin, input.parentId, input.restricted, salt);
|
|
163
|
+
return { groupId, salt, op: groupCreatedOp({ ...input, groupId, salt }) };
|
|
164
|
+
}
|
|
136
165
|
/** Move `childGroupId` under `newParentId`, a root op. */
|
|
137
166
|
export function groupReparentedOp(childGroupId, newParentId) {
|
|
138
167
|
return {
|
package/dist/warrant/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { signCreationWarrant, parseCreationWarrant, creationInitHash, } from './
|
|
|
4
4
|
export type { CreationWarrantInput, CreationWarrantFields, SignedCreationWarrant, } from './creation-warrant.js';
|
|
5
5
|
export { signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, } from './governance-warrant.js';
|
|
6
6
|
export type { GovernanceWarrantInput, GovernanceWarrantFields, } from './governance-warrant.js';
|
|
7
|
-
export { memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from './governance-op.js';
|
|
8
|
-
export type { GovernanceOp, GovernanceOpKind, GovernanceMemberRole, GroupCreatedInput, NamespaceCreatedInput, } from './governance-op.js';
|
|
7
|
+
export { memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from './governance-op.js';
|
|
8
|
+
export type { GovernanceOp, GovernanceOpKind, GovernanceMemberRole, GroupCreatedInput, SubgroupCreation, NamespaceCreatedInput, } from './governance-op.js';
|
package/dist/warrant/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export { signWarrant, intentHash } from './warrant.js';
|
|
3
3
|
export { signCreationWarrant, parseCreationWarrant, creationInitHash, } from './creation-warrant.js';
|
|
4
4
|
export { signGovernanceWarrant, parseGovernanceWarrant, governanceOpHash, } from './governance-warrant.js';
|
|
5
|
-
export { memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from './governance-op.js';
|
|
5
|
+
export { memberAddedOp, memberRemovedOp, memberLeftOp, memberRoleSetOp, groupCreatedOp, createdSubgroupId, subgroupCreation, groupReparentedOp, groupDeletedOp, namespaceCreatedOp, defaultCapabilitiesSetOp, foundedNamespaceId, } from './governance-op.js';
|