@calimero-network/mero-js 2.0.0 → 2.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-client.d.ts +11 -3
- package/dist/admin-api/admin-client.d.ts.map +1 -1
- package/dist/admin-api/admin-client.js +39 -5
- package/dist/admin-api/admin-client.js.map +1 -1
- package/dist/admin-api/admin-types.d.ts +61 -22
- package/dist/admin-api/admin-types.d.ts.map +1 -1
- package/dist/capabilities.d.ts +31 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +42 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +67 -6
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -6
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var index_exports = {};
|
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
AdminApiClient: () => AdminApiClient,
|
|
23
23
|
AuthApiClient: () => AuthApiClient,
|
|
24
|
+
CAPABILITIES: () => CAPABILITIES,
|
|
24
25
|
CloudClient: () => CloudClient,
|
|
25
26
|
HTTPError: () => HTTPError,
|
|
26
27
|
LocalStorageTokenStore: () => LocalStorageTokenStore,
|
|
@@ -48,8 +49,11 @@ __export(index_exports, {
|
|
|
48
49
|
createRetryableMethod: () => createRetryableMethod,
|
|
49
50
|
createTimeoutSignal: () => createTimeoutSignal,
|
|
50
51
|
createUniversalHttpClient: () => createUniversalHttpClient,
|
|
52
|
+
hasCap: () => hasCap,
|
|
51
53
|
parseAuthCallback: () => parseAuthCallback,
|
|
52
|
-
|
|
54
|
+
withCap: () => withCap,
|
|
55
|
+
withRetry: () => withRetry,
|
|
56
|
+
withoutCap: () => withoutCap
|
|
53
57
|
});
|
|
54
58
|
module.exports = __toCommonJS(index_exports);
|
|
55
59
|
|
|
@@ -952,6 +956,14 @@ var AdminApiClient = class {
|
|
|
952
956
|
async getGroupInfo(groupId) {
|
|
953
957
|
return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}`));
|
|
954
958
|
}
|
|
959
|
+
/** Thin wrapper over {@link getGroupInfo}: returns the group's `defaultCapabilities` bitmask. */
|
|
960
|
+
async getDefaultCapabilities(groupId) {
|
|
961
|
+
return (await this.getGroupInfo(groupId)).defaultCapabilities;
|
|
962
|
+
}
|
|
963
|
+
/** Thin wrapper over {@link getGroupInfo}: returns the group's `subgroupVisibility`. */
|
|
964
|
+
async getSubgroupVisibility(groupId) {
|
|
965
|
+
return (await this.getGroupInfo(groupId)).subgroupVisibility;
|
|
966
|
+
}
|
|
955
967
|
async deleteGroup(groupId, request) {
|
|
956
968
|
if (request) {
|
|
957
969
|
return unwrap(
|
|
@@ -965,7 +977,16 @@ var AdminApiClient = class {
|
|
|
965
977
|
return unwrap(await this.httpClient.delete(`/admin-api/groups/${groupId}`));
|
|
966
978
|
}
|
|
967
979
|
async listGroupMembers(groupId) {
|
|
968
|
-
|
|
980
|
+
const response = await this.httpClient.get(
|
|
981
|
+
`/admin-api/groups/${groupId}/members`
|
|
982
|
+
);
|
|
983
|
+
if (!Array.isArray(response?.members)) {
|
|
984
|
+
const safeId = String(groupId).replace(/[\r\n\t\s]/g, "").slice(0, 64);
|
|
985
|
+
throw new Error(
|
|
986
|
+
`Invalid listGroupMembers response for group ${safeId}: missing or non-array \`members\` field`
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
return response;
|
|
969
990
|
}
|
|
970
991
|
async listGroupContexts(groupId) {
|
|
971
992
|
return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}/contexts`));
|
|
@@ -1001,11 +1022,28 @@ var AdminApiClient = class {
|
|
|
1001
1022
|
async updateGroupSettings(groupId, request) {
|
|
1002
1023
|
await this.httpClient.patch(`/admin-api/groups/${groupId}`, request);
|
|
1003
1024
|
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1025
|
+
// ---- Group / member / context metadata ----
|
|
1026
|
+
async setGroupMetadata(groupId, request) {
|
|
1027
|
+
await this.httpClient.put(`/admin-api/groups/${groupId}/metadata`, request);
|
|
1028
|
+
}
|
|
1029
|
+
async getGroupMetadata(groupId) {
|
|
1030
|
+
return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}/metadata`)).data;
|
|
1031
|
+
}
|
|
1032
|
+
async setMemberMetadata(groupId, identity, request) {
|
|
1033
|
+
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/metadata`, request);
|
|
1006
1034
|
}
|
|
1007
|
-
async
|
|
1008
|
-
|
|
1035
|
+
async getMemberMetadata(groupId, identity) {
|
|
1036
|
+
return unwrap(
|
|
1037
|
+
await this.httpClient.get(`/admin-api/groups/${groupId}/members/${identity}/metadata`)
|
|
1038
|
+
).data;
|
|
1039
|
+
}
|
|
1040
|
+
async setContextMetadata(groupId, contextId, request) {
|
|
1041
|
+
await this.httpClient.put(`/admin-api/groups/${groupId}/contexts/${contextId}/metadata`, request);
|
|
1042
|
+
}
|
|
1043
|
+
async getContextMetadata(groupId, contextId) {
|
|
1044
|
+
return unwrap(
|
|
1045
|
+
await this.httpClient.get(`/admin-api/groups/${groupId}/contexts/${contextId}/metadata`)
|
|
1046
|
+
).data;
|
|
1009
1047
|
}
|
|
1010
1048
|
async syncGroup(groupId, request) {
|
|
1011
1049
|
return unwrap(await this.httpClient.post(`/admin-api/groups/${groupId}/sync`, request ?? {}));
|
|
@@ -1935,4 +1973,27 @@ var CloudClient = class {
|
|
|
1935
1973
|
window.open(`${this.baseUrl}/disable-ha?${params.toString()}`);
|
|
1936
1974
|
}
|
|
1937
1975
|
};
|
|
1976
|
+
|
|
1977
|
+
// src/capabilities.ts
|
|
1978
|
+
var CAPABILITIES = {
|
|
1979
|
+
CAN_CREATE_CONTEXT: 1 << 0,
|
|
1980
|
+
CAN_INVITE_MEMBERS: 1 << 1,
|
|
1981
|
+
CAN_JOIN_OPEN_SUBGROUPS: 1 << 2,
|
|
1982
|
+
MANAGE_MEMBERS: 1 << 3,
|
|
1983
|
+
MANAGE_APPLICATION: 1 << 4,
|
|
1984
|
+
CAN_CREATE_SUBGROUP: 1 << 5,
|
|
1985
|
+
CAN_DELETE_SUBGROUP: 1 << 6,
|
|
1986
|
+
CAN_MANAGE_VISIBILITY: 1 << 7,
|
|
1987
|
+
CAN_MANAGE_METADATA: 1 << 8
|
|
1988
|
+
};
|
|
1989
|
+
function hasCap(mask, cap) {
|
|
1990
|
+
const capU32 = cap >>> 0;
|
|
1991
|
+
return (mask & capU32) >>> 0 === capU32;
|
|
1992
|
+
}
|
|
1993
|
+
function withCap(mask, cap) {
|
|
1994
|
+
return (mask | cap) >>> 0;
|
|
1995
|
+
}
|
|
1996
|
+
function withoutCap(mask, cap) {
|
|
1997
|
+
return (mask & ~cap) >>> 0;
|
|
1998
|
+
}
|
|
1938
1999
|
//# sourceMappingURL=index.cjs.map
|