@calimero-network/mero-js 2.0.1 → 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/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
- withRetry: () => withRetry
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(
@@ -1010,11 +1022,28 @@ var AdminApiClient = class {
1010
1022
  async updateGroupSettings(groupId, request) {
1011
1023
  await this.httpClient.patch(`/admin-api/groups/${groupId}`, request);
1012
1024
  }
1013
- async setGroupAlias(groupId, request) {
1014
- await this.httpClient.put(`/admin-api/groups/${groupId}/alias`, request);
1025
+ // ---- Group / member / context metadata ----
1026
+ async setGroupMetadata(groupId, request) {
1027
+ await this.httpClient.put(`/admin-api/groups/${groupId}/metadata`, request);
1015
1028
  }
1016
- async setMemberAlias(groupId, identity, request) {
1017
- await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/alias`, request);
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);
1034
+ }
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;
1018
1047
  }
1019
1048
  async syncGroup(groupId, request) {
1020
1049
  return unwrap(await this.httpClient.post(`/admin-api/groups/${groupId}/sync`, request ?? {}));
@@ -1944,4 +1973,27 @@ var CloudClient = class {
1944
1973
  window.open(`${this.baseUrl}/disable-ha?${params.toString()}`);
1945
1974
  }
1946
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
+ }
1947
1999
  //# sourceMappingURL=index.cjs.map