@calimero-network/mero-js 1.2.1 → 1.4.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
+ CloudClient: () => CloudClient,
24
25
  HTTPError: () => HTTPError,
25
26
  LocalStorageTokenStore: () => LocalStorageTokenStore,
26
27
  MemoryTokenStore: () => MemoryTokenStore,
@@ -720,6 +721,16 @@ var AdminApiClient = class {
720
721
  return unwrap(await this.httpClient.get(`/admin-api/applications/${appId}`));
721
722
  }
722
723
  // ---- Package Management ----
724
+ async listPackages() {
725
+ return unwrap(await this.httpClient.get("/admin-api/packages"));
726
+ }
727
+ async listPackageVersions(packageName) {
728
+ return unwrap(
729
+ await this.httpClient.get(
730
+ `/admin-api/packages/${encodeURIComponent(packageName)}/versions`
731
+ )
732
+ );
733
+ }
723
734
  async getLatestPackageVersion(packageName) {
724
735
  return this.httpClient.get(
725
736
  `/admin-api/packages/${encodeURIComponent(packageName)}/latest`
@@ -729,7 +740,16 @@ var AdminApiClient = class {
729
740
  async createContext(request) {
730
741
  return unwrap(await this.httpClient.post("/admin-api/contexts", request));
731
742
  }
732
- async deleteContext(contextId) {
743
+ async deleteContext(contextId, request) {
744
+ if (request) {
745
+ return unwrap(
746
+ await this.httpClient.request(`/admin-api/contexts/${contextId}`, {
747
+ method: "DELETE",
748
+ body: JSON.stringify(request),
749
+ headers: { "Content-Type": "application/json" }
750
+ })
751
+ );
752
+ }
733
753
  return unwrap(await this.httpClient.delete(`/admin-api/contexts/${contextId}`));
734
754
  }
735
755
  async getContexts() {
@@ -751,12 +771,39 @@ var AdminApiClient = class {
751
771
  async getContextIdentitiesOwned(contextId) {
752
772
  return unwrap(await this.httpClient.get(`/admin-api/contexts/${contextId}/identities-owned`));
753
773
  }
754
- // ---- Context Invite / Join ----
755
- async inviteToContext(request) {
756
- return unwrap(await this.httpClient.post("/admin-api/contexts/invite", request));
774
+ // ---- Context join (group membership) ----
775
+ async joinContext(contextId) {
776
+ return unwrap(
777
+ await this.httpClient.post(`/admin-api/contexts/${contextId}/join`, {})
778
+ );
779
+ }
780
+ // ---- Context group / storage / sync ----
781
+ async getContextGroup(contextId) {
782
+ return unwrap(await this.httpClient.get(`/admin-api/contexts/${contextId}/group`));
783
+ }
784
+ async getContextStorage(contextId) {
785
+ return unwrap(await this.httpClient.get(`/admin-api/contexts/${contextId}/storage`));
786
+ }
787
+ async syncContext(contextId) {
788
+ await this.httpClient.post(`/admin-api/contexts/sync/${contextId ?? ""}`, {});
789
+ }
790
+ async inviteSpecializedNode(request) {
791
+ return unwrap(
792
+ await this.httpClient.post(
793
+ "/admin-api/contexts/invite-specialized-node",
794
+ request
795
+ )
796
+ );
797
+ }
798
+ async updateContextApplication(contextId, request) {
799
+ await this.httpClient.post(`/admin-api/contexts/${contextId}/application`, request);
757
800
  }
758
- async joinContext(request) {
759
- return unwrap(await this.httpClient.post("/admin-api/contexts/join", request));
801
+ async getContextsWithExecutorsForApplication(applicationId) {
802
+ return unwrap(
803
+ await this.httpClient.get(
804
+ `/admin-api/contexts/with-executors/for-application/${applicationId}`
805
+ )
806
+ );
760
807
  }
761
808
  // ---- Blob Management ----
762
809
  async uploadBlob(data) {
@@ -772,24 +819,43 @@ var AdminApiClient = class {
772
819
  return unwrap(await this.httpClient.get(`/admin-api/blobs/${blobId}`));
773
820
  }
774
821
  // ---- Alias Management ----
775
- // Server uses type-specific alias routes: /admin-api/alias/{create,lookup,delete,list}/{context,application}
776
822
  async createContextAlias(request) {
777
- return this.httpClient.post("/admin-api/alias/create/context", request);
823
+ return unwrap(await this.httpClient.post("/admin-api/alias/create/context", request));
778
824
  }
779
825
  async createApplicationAlias(request) {
780
- return this.httpClient.post("/admin-api/alias/create/application", request);
826
+ return unwrap(await this.httpClient.post("/admin-api/alias/create/application", request));
781
827
  }
782
828
  async lookupContextAlias(name) {
783
- return this.httpClient.post(`/admin-api/alias/lookup/context/${encodeURIComponent(name)}`, {});
829
+ return unwrap(
830
+ await this.httpClient.post(
831
+ `/admin-api/alias/lookup/context/${encodeURIComponent(name)}`,
832
+ {}
833
+ )
834
+ );
784
835
  }
785
836
  async lookupApplicationAlias(name) {
786
- return this.httpClient.post(`/admin-api/alias/lookup/application/${encodeURIComponent(name)}`, {});
837
+ return unwrap(
838
+ await this.httpClient.post(
839
+ `/admin-api/alias/lookup/application/${encodeURIComponent(name)}`,
840
+ {}
841
+ )
842
+ );
787
843
  }
788
844
  async deleteContextAlias(name) {
789
- return this.httpClient.post(`/admin-api/alias/delete/context/${encodeURIComponent(name)}`, {});
845
+ return unwrap(
846
+ await this.httpClient.post(
847
+ `/admin-api/alias/delete/context/${encodeURIComponent(name)}`,
848
+ {}
849
+ )
850
+ );
790
851
  }
791
852
  async deleteApplicationAlias(name) {
792
- return this.httpClient.post(`/admin-api/alias/delete/application/${encodeURIComponent(name)}`, {});
853
+ return unwrap(
854
+ await this.httpClient.post(
855
+ `/admin-api/alias/delete/application/${encodeURIComponent(name)}`,
856
+ {}
857
+ )
858
+ );
793
859
  }
794
860
  async listContextAliases() {
795
861
  return unwrap(await this.httpClient.get("/admin-api/alias/list/context"));
@@ -797,6 +863,215 @@ var AdminApiClient = class {
797
863
  async listApplicationAliases() {
798
864
  return unwrap(await this.httpClient.get("/admin-api/alias/list/application"));
799
865
  }
866
+ // ---- Context Identity Aliases ----
867
+ async listContextIdentityAliases(contextId) {
868
+ return unwrap(
869
+ await this.httpClient.get(
870
+ `/admin-api/alias/list/identity/${contextId}`
871
+ )
872
+ );
873
+ }
874
+ async createContextIdentityAlias(contextId, request) {
875
+ return unwrap(
876
+ await this.httpClient.post(
877
+ `/admin-api/alias/create/identity/${contextId}`,
878
+ request
879
+ )
880
+ );
881
+ }
882
+ async lookupContextIdentityAlias(contextId, name) {
883
+ return unwrap(
884
+ await this.httpClient.post(
885
+ `/admin-api/alias/lookup/identity/${contextId}/${encodeURIComponent(name)}`,
886
+ {}
887
+ )
888
+ );
889
+ }
890
+ async deleteContextIdentityAlias(contextId, name) {
891
+ return unwrap(
892
+ await this.httpClient.post(
893
+ `/admin-api/alias/delete/identity/${contextId}/${encodeURIComponent(name)}`,
894
+ {}
895
+ )
896
+ );
897
+ }
898
+ // ---- Namespace Management ----
899
+ async listNamespaces() {
900
+ return unwrap(await this.httpClient.get("/admin-api/namespaces"));
901
+ }
902
+ async getNamespace(namespaceId) {
903
+ return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}`));
904
+ }
905
+ async getNamespaceIdentity(namespaceId) {
906
+ return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}/identity`));
907
+ }
908
+ async listNamespacesForApplication(applicationId) {
909
+ return unwrap(await this.httpClient.get(`/admin-api/namespaces/for-application/${applicationId}`));
910
+ }
911
+ async createNamespace(request) {
912
+ return unwrap(await this.httpClient.post("/admin-api/namespaces", request));
913
+ }
914
+ async deleteNamespace(namespaceId, request) {
915
+ return unwrap(
916
+ await this.httpClient.request(`/admin-api/namespaces/${namespaceId}`, {
917
+ method: "DELETE",
918
+ body: request ? JSON.stringify(request) : void 0,
919
+ headers: request ? { "Content-Type": "application/json" } : void 0
920
+ })
921
+ );
922
+ }
923
+ async createNamespaceInvitation(namespaceId, request) {
924
+ return unwrap(
925
+ await this.httpClient.post(
926
+ `/admin-api/namespaces/${namespaceId}/invite`,
927
+ request ?? {}
928
+ )
929
+ );
930
+ }
931
+ async joinNamespace(namespaceId, request) {
932
+ return unwrap(
933
+ await this.httpClient.post(
934
+ `/admin-api/namespaces/${namespaceId}/join`,
935
+ request,
936
+ { timeoutMs: 65e3 }
937
+ )
938
+ );
939
+ }
940
+ async createGroupInNamespace(namespaceId, request) {
941
+ return unwrap(
942
+ await this.httpClient.post(
943
+ `/admin-api/namespaces/${namespaceId}/groups`,
944
+ request ?? {}
945
+ )
946
+ );
947
+ }
948
+ async listNamespaceGroups(namespaceId) {
949
+ return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}/groups`));
950
+ }
951
+ // ---- Group Management ----
952
+ async getGroupInfo(groupId) {
953
+ return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}`));
954
+ }
955
+ async deleteGroup(groupId, request) {
956
+ if (request) {
957
+ return unwrap(
958
+ await this.httpClient.request(`/admin-api/groups/${groupId}`, {
959
+ method: "DELETE",
960
+ body: JSON.stringify(request),
961
+ headers: { "Content-Type": "application/json" }
962
+ })
963
+ );
964
+ }
965
+ return unwrap(await this.httpClient.delete(`/admin-api/groups/${groupId}`));
966
+ }
967
+ async listGroupMembers(groupId) {
968
+ return this.httpClient.get(`/admin-api/groups/${groupId}/members`);
969
+ }
970
+ async listGroupContexts(groupId) {
971
+ return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}/contexts`));
972
+ }
973
+ async addGroupMembers(groupId, request) {
974
+ await this.httpClient.post(`/admin-api/groups/${groupId}/members`, request);
975
+ }
976
+ async removeGroupMembers(groupId, request) {
977
+ await this.httpClient.post(`/admin-api/groups/${groupId}/members/remove`, request);
978
+ }
979
+ async updateMemberRole(groupId, identity, request) {
980
+ await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/role`, request);
981
+ }
982
+ async getMemberCapabilities(groupId, identity) {
983
+ return unwrap(
984
+ await this.httpClient.get(
985
+ `/admin-api/groups/${groupId}/members/${identity}/capabilities`
986
+ )
987
+ );
988
+ }
989
+ async setMemberCapabilities(groupId, identity, request) {
990
+ await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/capabilities`, request);
991
+ }
992
+ async setDefaultCapabilities(groupId, request) {
993
+ await this.httpClient.put(`/admin-api/groups/${groupId}/settings/default-capabilities`, request);
994
+ }
995
+ async setDefaultVisibility(groupId, request) {
996
+ await this.httpClient.put(`/admin-api/groups/${groupId}/settings/default-visibility`, request);
997
+ }
998
+ async setTeeAdmissionPolicy(groupId, request) {
999
+ await this.httpClient.put(`/admin-api/groups/${groupId}/settings/tee-admission-policy`, request);
1000
+ }
1001
+ async updateGroupSettings(groupId, request) {
1002
+ await this.httpClient.patch(`/admin-api/groups/${groupId}`, request);
1003
+ }
1004
+ async setGroupAlias(groupId, request) {
1005
+ await this.httpClient.put(`/admin-api/groups/${groupId}/alias`, request);
1006
+ }
1007
+ async setMemberAlias(groupId, identity, request) {
1008
+ await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/alias`, request);
1009
+ }
1010
+ async syncGroup(groupId, request) {
1011
+ return unwrap(await this.httpClient.post(`/admin-api/groups/${groupId}/sync`, request ?? {}));
1012
+ }
1013
+ async registerGroupSigningKey(groupId, request) {
1014
+ return unwrap(
1015
+ await this.httpClient.post(
1016
+ `/admin-api/groups/${groupId}/signing-key`,
1017
+ request
1018
+ )
1019
+ );
1020
+ }
1021
+ async upgradeGroup(groupId, request) {
1022
+ return unwrap(await this.httpClient.post(`/admin-api/groups/${groupId}/upgrade`, request));
1023
+ }
1024
+ async getGroupUpgradeStatus(groupId) {
1025
+ return unwrap(
1026
+ await this.httpClient.get(`/admin-api/groups/${groupId}/upgrade/status`)
1027
+ );
1028
+ }
1029
+ async retryGroupUpgrade(groupId, request) {
1030
+ return unwrap(
1031
+ await this.httpClient.post(
1032
+ `/admin-api/groups/${groupId}/upgrade/retry`,
1033
+ request ?? {}
1034
+ )
1035
+ );
1036
+ }
1037
+ async nestGroup(parentGroupId, request) {
1038
+ await this.httpClient.post(`/admin-api/groups/${parentGroupId}/nest`, request);
1039
+ }
1040
+ async unnestGroup(parentGroupId, request) {
1041
+ await this.httpClient.post(`/admin-api/groups/${parentGroupId}/unnest`, request);
1042
+ }
1043
+ async listSubgroups(groupId) {
1044
+ return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}/subgroups`));
1045
+ }
1046
+ async detachContextFromGroup(groupId, contextId, request) {
1047
+ await this.httpClient.post(`/admin-api/groups/${groupId}/contexts/${contextId}/remove`, request ?? {});
1048
+ }
1049
+ // ---- Group Invitation & Join ----
1050
+ async createGroupInvitation(groupId, request) {
1051
+ return unwrap(
1052
+ await this.httpClient.post(
1053
+ `/admin-api/groups/${groupId}/invite`,
1054
+ request ?? {}
1055
+ )
1056
+ );
1057
+ }
1058
+ async joinGroup(request) {
1059
+ return unwrap(
1060
+ await this.httpClient.post("/admin-api/groups/join", request)
1061
+ );
1062
+ }
1063
+ // ---- TEE ----
1064
+ async getTeeInfo() {
1065
+ return unwrap(await this.httpClient.get("/admin-api/tee/info"));
1066
+ }
1067
+ async teeAttest(request) {
1068
+ return unwrap(await this.httpClient.post("/admin-api/tee/attest", request));
1069
+ }
1070
+ async teeVerifyQuote(request) {
1071
+ return unwrap(
1072
+ await this.httpClient.post("/admin-api/tee/verify-quote", request)
1073
+ );
1074
+ }
800
1075
  // ---- Network ----
801
1076
  async getPeersCount() {
802
1077
  return this.httpClient.get("/admin-api/peers");
@@ -920,8 +1195,7 @@ var RpcClient = class {
920
1195
  params: {
921
1196
  contextId: params.contextId,
922
1197
  method: params.method,
923
- argsJson: params.argsJson ?? {},
924
- executorPublicKey: params.executorPublicKey
1198
+ argsJson: params.argsJson ?? {}
925
1199
  }
926
1200
  };
927
1201
  const response = await this.httpClient.post(
@@ -1634,4 +1908,31 @@ var LocalStorageTokenStore = class {
1634
1908
  }
1635
1909
  }
1636
1910
  };
1911
+
1912
+ // src/cloud/cloud-client.ts
1913
+ var CloudClient = class {
1914
+ constructor(config = {}) {
1915
+ this.baseUrl = (config.cloudBaseUrl || "https://cloud.calimero.network").replace(/\/+$/, "");
1916
+ }
1917
+ enableHA(options) {
1918
+ const params = new URLSearchParams({
1919
+ group_id: options.groupId,
1920
+ context_id: options.contextId
1921
+ });
1922
+ if (options.redirectUrl) {
1923
+ params.set("redirect_url", options.redirectUrl);
1924
+ }
1925
+ window.open(`${this.baseUrl}/enable-ha?${params.toString()}`);
1926
+ }
1927
+ disableHA(options) {
1928
+ const params = new URLSearchParams({
1929
+ group_id: options.groupId,
1930
+ context_id: options.contextId
1931
+ });
1932
+ if (options.redirectUrl) {
1933
+ params.set("redirect_url", options.redirectUrl);
1934
+ }
1935
+ window.open(`${this.baseUrl}/disable-ha?${params.toString()}`);
1936
+ }
1937
+ };
1637
1938
  //# sourceMappingURL=index.cjs.map