@eluvio/elv-client-js 3.1.94 → 3.1.97

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.
@@ -2,12 +2,18 @@ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
2
 
3
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
4
 
5
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
+
5
7
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
8
 
7
9
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
8
10
 
9
11
  var _createClass = require("@babel/runtime/helpers/createClass");
10
12
 
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+
11
17
  if (typeof Buffer === "undefined") {
12
18
  Buffer = require("buffer/").Buffer;
13
19
  }
@@ -778,6 +784,113 @@ function () {
778
784
  }
779
785
  }, null, this);
780
786
  }
787
+ /*
788
+ TOKEN 211b PREFIX + BODY | aplsjcJf1HYcDDUuCdXcSZtU86nYK162YmYJeuqwMczEBJVkD5D5EvsBvVwYDRsf4hzDvBWMoe9piBpqx...
789
+ PREFIX 6b aplsjc | apl=plain s=ES256K jc=json-compressed
790
+ BODY 205b base58(SIGNATURE + PAYLOAD)
791
+ SIGNATURE + PAYLOAD 151b 151b * 138 / 100 + 1 = 209b (>= 205b)
792
+ SIGNATURE 66b ES256K_Di9Lu83mz4wMoehCEeQhKpJJ7ApmDZLumAa2Cge48F6EHYnbn8msATGGpjucScwimei1TWGd7aeyQY45AdXd5tT1Z
793
+ PAYLOAD 85b json-compressed
794
+ json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
795
+ */
796
+
797
+ /**
798
+ * Create a signed authorization token that can be used to authorize against the fabric
799
+ *
800
+ * @methodGroup Authorization
801
+ * @namedParams
802
+ * @param {number} duration=86400000 - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000). Default is 24 hours.
803
+ * @param {Object=} spec - Additional attributes for this token
804
+ * @param {string=} address - Address of the signing account - if not specified, the current signer address will be used.
805
+ * @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
806
+ * @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
807
+ */
808
+
809
+ }, {
810
+ key: "CreateFabricToken",
811
+ value: function CreateFabricToken() {
812
+ var _this = this;
813
+
814
+ var _ref12,
815
+ _ref12$duration,
816
+ duration,
817
+ _ref12$spec,
818
+ spec,
819
+ address,
820
+ Sign,
821
+ _ref12$addEthereumPre,
822
+ addEthereumPrefix,
823
+ token,
824
+ message,
825
+ signature,
826
+ compressedToken,
827
+ _args10 = arguments;
828
+
829
+ return _regeneratorRuntime.async(function CreateFabricToken$(_context10) {
830
+ while (1) {
831
+ switch (_context10.prev = _context10.next) {
832
+ case 0:
833
+ _ref12 = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {}, _ref12$duration = _ref12.duration, duration = _ref12$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref12$duration, _ref12$spec = _ref12.spec, spec = _ref12$spec === void 0 ? {} : _ref12$spec, address = _ref12.address, Sign = _ref12.Sign, _ref12$addEthereumPre = _ref12.addEthereumPrefix, addEthereumPrefix = _ref12$addEthereumPre === void 0 ? true : _ref12$addEthereumPre;
834
+ address = address || this.CurrentAccountAddress();
835
+ _context10.t0 = _objectSpread;
836
+ _context10.t1 = {};
837
+ _context10.t2 = spec;
838
+ _context10.t3 = "iusr".concat(Utils.AddressToHash(address));
839
+ _context10.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
840
+ _context10.next = 9;
841
+ return _regeneratorRuntime.awrap(this.ContentSpaceId());
842
+
843
+ case 9:
844
+ _context10.t5 = _context10.sent;
845
+ _context10.t6 = Date.now();
846
+ _context10.t7 = Date.now() + duration;
847
+ _context10.t8 = {
848
+ sub: _context10.t3,
849
+ adr: _context10.t4,
850
+ spc: _context10.t5,
851
+ iat: _context10.t6,
852
+ exp: _context10.t7
853
+ };
854
+ token = (0, _context10.t0)(_context10.t1, _context10.t2, _context10.t8);
855
+
856
+ if (!Sign) {
857
+ Sign = function Sign(message) {
858
+ return _regeneratorRuntime.async(function Sign$(_context9) {
859
+ while (1) {
860
+ switch (_context9.prev = _context9.next) {
861
+ case 0:
862
+ return _context9.abrupt("return", _this.authClient.Sign(message));
863
+
864
+ case 1:
865
+ case "end":
866
+ return _context9.stop();
867
+ }
868
+ }
869
+ });
870
+ };
871
+ }
872
+
873
+ message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
874
+
875
+ if (addEthereumPrefix) {
876
+ message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
877
+ }
878
+
879
+ _context10.next = 19;
880
+ return _regeneratorRuntime.awrap(Sign(message));
881
+
882
+ case 19:
883
+ signature = _context10.sent;
884
+ compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
885
+ return _context10.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
886
+
887
+ case 22:
888
+ case "end":
889
+ return _context10.stop();
890
+ }
891
+ }
892
+ }, null, this);
893
+ }
781
894
  /**
782
895
  * Issue a self-signed authorization token
783
896
  *
@@ -789,7 +902,7 @@ function () {
789
902
  * @param {string=} policyId - The object ID of the policy for this token
790
903
  * @param {string=} subject - The subject of the token
791
904
  * @param {string} grantType=read - Permissions to grant for this token. Options: "access", "read", "create", "update", "read-crypt"
792
- * @param {number} duration - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000)
905
+ * @param {number} duration - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000)
793
906
  * @param {boolean} allowDecryption=false - If specified, the re-encryption key will be included in the token,
794
907
  * enabling the user of this token to download encrypted content from the specified object
795
908
  * @param {Object=} context - Additional JSON context
@@ -797,60 +910,60 @@ function () {
797
910
 
798
911
  }, {
799
912
  key: "CreateSignedToken",
800
- value: function CreateSignedToken(_ref12) {
801
- var libraryId, objectId, versionHash, policyId, subject, _ref12$grantType, grantType, _ref12$allowDecryptio, allowDecryption, duration, _ref12$context, context, token, cap, compressedToken, signature;
913
+ value: function CreateSignedToken(_ref13) {
914
+ var libraryId, objectId, versionHash, policyId, subject, _ref13$grantType, grantType, _ref13$allowDecryptio, allowDecryption, duration, _ref13$context, context, token, cap, compressedToken, signature;
802
915
 
803
- return _regeneratorRuntime.async(function CreateSignedToken$(_context9) {
916
+ return _regeneratorRuntime.async(function CreateSignedToken$(_context11) {
804
917
  while (1) {
805
- switch (_context9.prev = _context9.next) {
918
+ switch (_context11.prev = _context11.next) {
806
919
  case 0:
807
- libraryId = _ref12.libraryId, objectId = _ref12.objectId, versionHash = _ref12.versionHash, policyId = _ref12.policyId, subject = _ref12.subject, _ref12$grantType = _ref12.grantType, grantType = _ref12$grantType === void 0 ? "read" : _ref12$grantType, _ref12$allowDecryptio = _ref12.allowDecryption, allowDecryption = _ref12$allowDecryptio === void 0 ? false : _ref12$allowDecryptio, duration = _ref12.duration, _ref12$context = _ref12.context, context = _ref12$context === void 0 ? {} : _ref12$context;
920
+ libraryId = _ref13.libraryId, objectId = _ref13.objectId, versionHash = _ref13.versionHash, policyId = _ref13.policyId, subject = _ref13.subject, _ref13$grantType = _ref13.grantType, grantType = _ref13$grantType === void 0 ? "read" : _ref13$grantType, _ref13$allowDecryptio = _ref13.allowDecryption, allowDecryption = _ref13$allowDecryptio === void 0 ? false : _ref13$allowDecryptio, duration = _ref13.duration, _ref13$context = _ref13.context, context = _ref13$context === void 0 ? {} : _ref13$context;
808
921
 
809
922
  if (subject) {
810
- _context9.next = 9;
923
+ _context11.next = 9;
811
924
  break;
812
925
  }
813
926
 
814
- _context9.t0 = "iusr";
815
- _context9.t1 = this.utils;
816
- _context9.next = 6;
927
+ _context11.t0 = "iusr";
928
+ _context11.t1 = this.utils;
929
+ _context11.next = 6;
817
930
  return _regeneratorRuntime.awrap(this.CurrentAccountAddress());
818
931
 
819
932
  case 6:
820
- _context9.t2 = _context9.sent;
821
- _context9.t3 = _context9.t1.AddressToHash.call(_context9.t1, _context9.t2);
822
- subject = _context9.t0.concat.call(_context9.t0, _context9.t3);
933
+ _context11.t2 = _context11.sent;
934
+ _context11.t3 = _context11.t1.AddressToHash.call(_context11.t1, _context11.t2);
935
+ subject = _context11.t0.concat.call(_context11.t0, _context11.t3);
823
936
 
824
937
  case 9:
825
938
  if (policyId) {
826
939
  context["elv:delegation-id"] = policyId;
827
940
  }
828
941
 
829
- _context9.t4 = Buffer;
830
- _context9.next = 13;
942
+ _context11.t4 = Buffer;
943
+ _context11.next = 13;
831
944
  return _regeneratorRuntime.awrap(this.CurrentAccountAddress().replace(/^0x/, ""));
832
945
 
833
946
  case 13:
834
- _context9.t5 = _context9.sent;
835
- _context9.t6 = _context9.t4.from.call(_context9.t4, _context9.t5, "hex").toString("base64");
836
- _context9.t7 = subject;
837
- _context9.next = 18;
947
+ _context11.t5 = _context11.sent;
948
+ _context11.t6 = _context11.t4.from.call(_context11.t4, _context11.t5, "hex").toString("base64");
949
+ _context11.t7 = subject;
950
+ _context11.next = 18;
838
951
  return _regeneratorRuntime.awrap(this.ContentSpaceId());
839
952
 
840
953
  case 18:
841
- _context9.t8 = _context9.sent;
842
- _context9.t9 = Date.now();
843
- _context9.t10 = Date.now() + duration;
844
- _context9.t11 = grantType;
845
- _context9.t12 = context;
954
+ _context11.t8 = _context11.sent;
955
+ _context11.t9 = Date.now();
956
+ _context11.t10 = Date.now() + duration;
957
+ _context11.t11 = grantType;
958
+ _context11.t12 = context;
846
959
  token = {
847
- adr: _context9.t6,
848
- sub: _context9.t7,
849
- spc: _context9.t8,
850
- iat: _context9.t9,
851
- exp: _context9.t10,
852
- gra: _context9.t11,
853
- ctx: _context9.t12
960
+ adr: _context11.t6,
961
+ sub: _context11.t7,
962
+ spc: _context11.t8,
963
+ iat: _context11.t9,
964
+ exp: _context11.t10,
965
+ gra: _context11.t11,
966
+ ctx: _context11.t12
854
967
  };
855
968
 
856
969
  if (versionHash) {
@@ -858,24 +971,24 @@ function () {
858
971
  }
859
972
 
860
973
  if (!objectId) {
861
- _context9.next = 31;
974
+ _context11.next = 31;
862
975
  break;
863
976
  }
864
977
 
865
978
  token.qid = objectId;
866
979
 
867
980
  if (libraryId) {
868
- _context9.next = 31;
981
+ _context11.next = 31;
869
982
  break;
870
983
  }
871
984
 
872
- _context9.next = 30;
985
+ _context11.next = 30;
873
986
  return _regeneratorRuntime.awrap(this.ContentObjectLibraryId({
874
987
  objectId: objectId
875
988
  }));
876
989
 
877
990
  case 30:
878
- libraryId = _context9.sent;
991
+ libraryId = _context11.sent;
879
992
 
880
993
  case 31:
881
994
  if (libraryId) {
@@ -883,32 +996,32 @@ function () {
883
996
  }
884
997
 
885
998
  if (!allowDecryption) {
886
- _context9.next = 37;
999
+ _context11.next = 37;
887
1000
  break;
888
1001
  }
889
1002
 
890
- _context9.next = 35;
1003
+ _context11.next = 35;
891
1004
  return _regeneratorRuntime.awrap(this.authClient.ReEncryptionConk({
892
1005
  libraryId: libraryId,
893
1006
  objectId: objectId
894
1007
  }));
895
1008
 
896
1009
  case 35:
897
- cap = _context9.sent;
1010
+ cap = _context11.sent;
898
1011
  token.apk = cap.public_key;
899
1012
 
900
1013
  case 37:
901
1014
  compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
902
- _context9.next = 40;
1015
+ _context11.next = 40;
903
1016
  return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(compressedToken)));
904
1017
 
905
1018
  case 40:
906
- signature = _context9.sent;
907
- return _context9.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
1019
+ signature = _context11.sent;
1020
+ return _context11.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
908
1021
 
909
1022
  case 42:
910
1023
  case "end":
911
- return _context9.stop();
1024
+ return _context11.stop();
912
1025
  }
913
1026
  }
914
1027
  }, null, this);
@@ -935,13 +1048,13 @@ function () {
935
1048
 
936
1049
  }, {
937
1050
  key: "SetOauthToken",
938
- value: function SetOauthToken(_ref13) {
1051
+ value: function SetOauthToken(_ref14) {
939
1052
  var token, wallet, signer;
940
- return _regeneratorRuntime.async(function SetOauthToken$(_context10) {
1053
+ return _regeneratorRuntime.async(function SetOauthToken$(_context12) {
941
1054
  while (1) {
942
- switch (_context10.prev = _context10.next) {
1055
+ switch (_context12.prev = _context12.next) {
943
1056
  case 0:
944
- token = _ref13.token;
1057
+ token = _ref14.token;
945
1058
  this.oauthToken = token;
946
1059
  wallet = this.GenerateWallet();
947
1060
  signer = wallet.AddAccountFromMnemonic({
@@ -953,7 +1066,7 @@ function () {
953
1066
 
954
1067
  case 5:
955
1068
  case "end":
956
- return _context10.stop();
1069
+ return _context12.stop();
957
1070
  }
958
1071
  }
959
1072
  }, null, this);
@@ -971,17 +1084,17 @@ function () {
971
1084
 
972
1085
  }, {
973
1086
  key: "SetSignerFromOauthToken",
974
- value: function SetSignerFromOauthToken(_ref14) {
975
- var token, wallet, client, _ref15, urls, path, httpClient, response, privateKey;
1087
+ value: function SetSignerFromOauthToken(_ref15) {
1088
+ var token, wallet, client, _ref16, urls, path, httpClient, response, privateKey;
976
1089
 
977
- return _regeneratorRuntime.async(function SetSignerFromOauthToken$(_context11) {
1090
+ return _regeneratorRuntime.async(function SetSignerFromOauthToken$(_context13) {
978
1091
  while (1) {
979
- switch (_context11.prev = _context11.next) {
1092
+ switch (_context13.prev = _context13.next) {
980
1093
  case 0:
981
- token = _ref14.token;
1094
+ token = _ref15.token;
982
1095
 
983
1096
  if (this.trustAuthorityId) {
984
- _context11.next = 3;
1097
+ _context13.next = 3;
985
1098
  break;
986
1099
  }
987
1100
 
@@ -989,36 +1102,36 @@ function () {
989
1102
 
990
1103
  case 3:
991
1104
  wallet = this.GenerateWallet();
992
- _context11.prev = 4;
1105
+ _context13.prev = 4;
993
1106
 
994
1107
  if (this.kmsURIs) {
995
- _context11.next = 17;
1108
+ _context13.next = 17;
996
1109
  break;
997
1110
  }
998
1111
 
999
- _context11.next = 8;
1112
+ _context13.next = 8;
1000
1113
  return _regeneratorRuntime.awrap(ElvClient.FromConfigurationUrl({
1001
1114
  configUrl: this.configUrl
1002
1115
  }));
1003
1116
 
1004
1117
  case 8:
1005
- client = _context11.sent;
1118
+ client = _context13.sent;
1006
1119
  client.SetSigner({
1007
1120
  signer: wallet.AddAccountFromMnemonic({
1008
1121
  mnemonic: wallet.GenerateMnemonic()
1009
1122
  })
1010
1123
  });
1011
- _context11.next = 12;
1124
+ _context13.next = 12;
1012
1125
  return _regeneratorRuntime.awrap(client.authClient.KMSInfo({
1013
1126
  kmsId: this.trustAuthorityId
1014
1127
  }));
1015
1128
 
1016
1129
  case 12:
1017
- _ref15 = _context11.sent;
1018
- urls = _ref15.urls;
1130
+ _ref16 = _context13.sent;
1131
+ urls = _ref16.urls;
1019
1132
 
1020
1133
  if (!(!urls || urls.length === 0)) {
1021
- _context11.next = 16;
1134
+ _context13.next = 16;
1022
1135
  break;
1023
1136
  }
1024
1137
 
@@ -1034,7 +1147,7 @@ function () {
1034
1147
  uris: this.kmsURIs,
1035
1148
  debug: this.debug
1036
1149
  });
1037
- _context11.next = 22;
1150
+ _context13.next = 22;
1038
1151
  return _regeneratorRuntime.awrap(this.utils.ResponseToJson(httpClient.Request({
1039
1152
  headers: {
1040
1153
  Authorization: "Bearer ".concat(token)
@@ -1045,7 +1158,7 @@ function () {
1045
1158
  })));
1046
1159
 
1047
1160
  case 22:
1048
- response = _context11.sent;
1161
+ response = _context13.sent;
1049
1162
  privateKey = response["UserSKHex"];
1050
1163
  this.SetSigner({
1051
1164
  signer: wallet.AddAccount({
@@ -1053,27 +1166,27 @@ function () {
1053
1166
  })
1054
1167
  }); // Ensure wallet is initialized
1055
1168
 
1056
- _context11.next = 27;
1169
+ _context13.next = 27;
1057
1170
  return _regeneratorRuntime.awrap(this.userProfileClient.WalletAddress());
1058
1171
 
1059
1172
  case 27:
1060
- _context11.next = 36;
1173
+ _context13.next = 36;
1061
1174
  break;
1062
1175
 
1063
1176
  case 29:
1064
- _context11.prev = 29;
1065
- _context11.t0 = _context11["catch"](4);
1177
+ _context13.prev = 29;
1178
+ _context13.t0 = _context13["catch"](4);
1066
1179
  this.Log("Failed to set signer from OAuth token:", true);
1067
- this.Log(_context11.t0, true);
1068
- _context11.next = 35;
1180
+ this.Log(_context13.t0, true);
1181
+ _context13.next = 35;
1069
1182
  return _regeneratorRuntime.awrap(this.ClearSigner());
1070
1183
 
1071
1184
  case 35:
1072
- throw _context11.t0;
1185
+ throw _context13.t0;
1073
1186
 
1074
1187
  case 36:
1075
1188
  case "end":
1076
- return _context11.stop();
1189
+ return _context13.stop();
1077
1190
  }
1078
1191
  }
1079
1192
  }, null, this, [[4, 29]]);
@@ -1089,8 +1202,8 @@ function () {
1089
1202
  }, {
1090
1203
  key: "SetStaticToken",
1091
1204
  value: function SetStaticToken() {
1092
- var _ref16 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1093
- token = _ref16.token;
1205
+ var _ref17 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1206
+ token = _ref17.token;
1094
1207
 
1095
1208
  if (!token) {
1096
1209
  token = this.utils.B64(JSON.stringify({
@@ -1121,30 +1234,30 @@ function () {
1121
1234
 
1122
1235
  }, {
1123
1236
  key: "SetPolicyAuthorization",
1124
- value: function SetPolicyAuthorization(_ref17) {
1237
+ value: function SetPolicyAuthorization(_ref18) {
1125
1238
  var objectId;
1126
- return _regeneratorRuntime.async(function SetPolicyAuthorization$(_context12) {
1239
+ return _regeneratorRuntime.async(function SetPolicyAuthorization$(_context14) {
1127
1240
  while (1) {
1128
- switch (_context12.prev = _context12.next) {
1241
+ switch (_context14.prev = _context14.next) {
1129
1242
  case 0:
1130
- objectId = _ref17.objectId;
1131
- _context12.t0 = this;
1132
- _context12.next = 4;
1243
+ objectId = _ref18.objectId;
1244
+ _context14.t0 = this;
1245
+ _context14.next = 4;
1133
1246
  return _regeneratorRuntime.awrap(this.GenerateStateChannelToken({
1134
1247
  objectId: objectId
1135
1248
  }));
1136
1249
 
1137
1250
  case 4:
1138
- _context12.t1 = _context12.sent;
1139
- _context12.t2 = {
1140
- token: _context12.t1
1251
+ _context14.t1 = _context14.sent;
1252
+ _context14.t2 = {
1253
+ token: _context14.t1
1141
1254
  };
1142
1255
 
1143
- _context12.t0.SetStaticToken.call(_context12.t0, _context12.t2);
1256
+ _context14.t0.SetStaticToken.call(_context14.t0, _context14.t2);
1144
1257
 
1145
1258
  case 7:
1146
1259
  case "end":
1147
- return _context12.stop();
1260
+ return _context14.stop();
1148
1261
  }
1149
1262
  }
1150
1263
  }, null, this);
@@ -1160,20 +1273,20 @@ function () {
1160
1273
  key: "Sign",
1161
1274
  value: function Sign(string) {
1162
1275
  var signature;
1163
- return _regeneratorRuntime.async(function Sign$(_context13) {
1276
+ return _regeneratorRuntime.async(function Sign$(_context15) {
1164
1277
  while (1) {
1165
- switch (_context13.prev = _context13.next) {
1278
+ switch (_context15.prev = _context15.next) {
1166
1279
  case 0:
1167
- _context13.next = 2;
1280
+ _context15.next = 2;
1168
1281
  return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string))));
1169
1282
 
1170
1283
  case 2:
1171
- signature = _context13.sent;
1172
- return _context13.abrupt("return", this.utils.FormatSignature(signature));
1284
+ signature = _context15.sent;
1285
+ return _context15.abrupt("return", this.utils.FormatSignature(signature));
1173
1286
 
1174
1287
  case 4:
1175
1288
  case "end":
1176
- return _context13.stop();
1289
+ return _context15.stop();
1177
1290
  }
1178
1291
  }
1179
1292
  }, null, this);
@@ -1190,16 +1303,16 @@ function () {
1190
1303
 
1191
1304
  }, {
1192
1305
  key: "EncryptECIES",
1193
- value: function EncryptECIES(_ref18) {
1306
+ value: function EncryptECIES(_ref19) {
1194
1307
  var message, publicKey;
1195
- return _regeneratorRuntime.async(function EncryptECIES$(_context14) {
1308
+ return _regeneratorRuntime.async(function EncryptECIES$(_context16) {
1196
1309
  while (1) {
1197
- switch (_context14.prev = _context14.next) {
1310
+ switch (_context16.prev = _context16.next) {
1198
1311
  case 0:
1199
- message = _ref18.message, publicKey = _ref18.publicKey;
1312
+ message = _ref19.message, publicKey = _ref19.publicKey;
1200
1313
 
1201
1314
  if (this.signer) {
1202
- _context14.next = 3;
1315
+ _context16.next = 3;
1203
1316
  break;
1204
1317
  }
1205
1318
 
@@ -1207,15 +1320,15 @@ function () {
1207
1320
 
1208
1321
  case 3:
1209
1322
  ValidatePresence("message", message);
1210
- _context14.next = 6;
1323
+ _context16.next = 6;
1211
1324
  return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(message, publicKey || this.signer.signingKey.keyPair.publicKey));
1212
1325
 
1213
1326
  case 6:
1214
- return _context14.abrupt("return", _context14.sent);
1327
+ return _context16.abrupt("return", _context16.sent);
1215
1328
 
1216
1329
  case 7:
1217
1330
  case "end":
1218
- return _context14.stop();
1331
+ return _context16.stop();
1219
1332
  }
1220
1333
  }
1221
1334
  }, null, this);
@@ -1231,16 +1344,16 @@ function () {
1231
1344
 
1232
1345
  }, {
1233
1346
  key: "DecryptECIES",
1234
- value: function DecryptECIES(_ref19) {
1347
+ value: function DecryptECIES(_ref20) {
1235
1348
  var message;
1236
- return _regeneratorRuntime.async(function DecryptECIES$(_context15) {
1349
+ return _regeneratorRuntime.async(function DecryptECIES$(_context17) {
1237
1350
  while (1) {
1238
- switch (_context15.prev = _context15.next) {
1351
+ switch (_context17.prev = _context17.next) {
1239
1352
  case 0:
1240
- message = _ref19.message;
1353
+ message = _ref20.message;
1241
1354
 
1242
1355
  if (this.signer) {
1243
- _context15.next = 3;
1356
+ _context17.next = 3;
1244
1357
  break;
1245
1358
  }
1246
1359
 
@@ -1248,15 +1361,15 @@ function () {
1248
1361
 
1249
1362
  case 3:
1250
1363
  ValidatePresence("message", message);
1251
- _context15.next = 6;
1364
+ _context17.next = 6;
1252
1365
  return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(message, this.signer.signingKey.privateKey));
1253
1366
 
1254
1367
  case 6:
1255
- return _context15.abrupt("return", _context15.sent);
1368
+ return _context17.abrupt("return", _context17.sent);
1256
1369
 
1257
1370
  case 7:
1258
1371
  case "end":
1259
- return _context15.stop();
1372
+ return _context17.stop();
1260
1373
  }
1261
1374
  }
1262
1375
  }, null, this);
@@ -1275,15 +1388,15 @@ function () {
1275
1388
 
1276
1389
  }, {
1277
1390
  key: "Request",
1278
- value: function Request(_ref20) {
1279
- var url, _ref20$format, format, _ref20$method, method, _ref20$headers, headers, body;
1391
+ value: function Request(_ref21) {
1392
+ var url, _ref21$format, format, _ref21$method, method, _ref21$headers, headers, body;
1280
1393
 
1281
- return _regeneratorRuntime.async(function Request$(_context16) {
1394
+ return _regeneratorRuntime.async(function Request$(_context18) {
1282
1395
  while (1) {
1283
- switch (_context16.prev = _context16.next) {
1396
+ switch (_context18.prev = _context18.next) {
1284
1397
  case 0:
1285
- url = _ref20.url, _ref20$format = _ref20.format, format = _ref20$format === void 0 ? "json" : _ref20$format, _ref20$method = _ref20.method, method = _ref20$method === void 0 ? "GET" : _ref20$method, _ref20$headers = _ref20.headers, headers = _ref20$headers === void 0 ? {} : _ref20$headers, body = _ref20.body;
1286
- return _context16.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
1398
+ url = _ref21.url, _ref21$format = _ref21.format, format = _ref21$format === void 0 ? "json" : _ref21$format, _ref21$method = _ref21.method, method = _ref21$method === void 0 ? "GET" : _ref21$method, _ref21$headers = _ref21.headers, headers = _ref21$headers === void 0 ? {} : _ref21$headers, body = _ref21.body;
1399
+ return _context18.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
1287
1400
  method: method,
1288
1401
  headers: headers,
1289
1402
  body: body
@@ -1291,7 +1404,7 @@ function () {
1291
1404
 
1292
1405
  case 2:
1293
1406
  case "end":
1294
- return _context16.stop();
1407
+ return _context18.stop();
1295
1408
  }
1296
1409
  }
1297
1410
  }, null, this);
@@ -1302,35 +1415,35 @@ function () {
1302
1415
  }, {
1303
1416
  key: "FrameAllowedMethods",
1304
1417
  value: function FrameAllowedMethods() {
1305
- var _this = this;
1418
+ var _this2 = this;
1306
1419
 
1307
1420
  var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
1308
1421
  return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
1309
- return typeof _this[method] === "function" && !forbiddenMethods.includes(method);
1422
+ return typeof _this2[method] === "function" && !forbiddenMethods.includes(method);
1310
1423
  });
1311
1424
  } // Call a method specified in a message from a frame
1312
1425
 
1313
1426
  }, {
1314
1427
  key: "CallFromFrameMessage",
1315
1428
  value: function CallFromFrameMessage(message, Respond) {
1316
- var _this2 = this;
1429
+ var _this3 = this;
1317
1430
 
1318
1431
  var callback, method, methodResults, responseError;
1319
- return _regeneratorRuntime.async(function CallFromFrameMessage$(_context17) {
1432
+ return _regeneratorRuntime.async(function CallFromFrameMessage$(_context19) {
1320
1433
  while (1) {
1321
- switch (_context17.prev = _context17.next) {
1434
+ switch (_context19.prev = _context19.next) {
1322
1435
  case 0:
1323
1436
  if (!(message.type !== "ElvFrameRequest")) {
1324
- _context17.next = 2;
1437
+ _context19.next = 2;
1325
1438
  break;
1326
1439
  }
1327
1440
 
1328
- return _context17.abrupt("return");
1441
+ return _context19.abrupt("return");
1329
1442
 
1330
1443
  case 2:
1331
1444
  if (message.callbackId) {
1332
1445
  callback = function callback(result) {
1333
- Respond(_this2.utils.MakeClonable({
1446
+ Respond(_this3.utils.MakeClonable({
1334
1447
  type: "ElvFrameResponse",
1335
1448
  requestId: message.callbackId,
1336
1449
  response: result
@@ -1340,44 +1453,44 @@ function () {
1340
1453
  message.args.callback = callback;
1341
1454
  }
1342
1455
 
1343
- _context17.prev = 3;
1456
+ _context19.prev = 3;
1344
1457
  method = message.calledMethod;
1345
1458
 
1346
1459
  if (!(message.module === "userProfileClient")) {
1347
- _context17.next = 13;
1460
+ _context19.next = 13;
1348
1461
  break;
1349
1462
  }
1350
1463
 
1351
1464
  if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
1352
- _context17.next = 8;
1465
+ _context19.next = 8;
1353
1466
  break;
1354
1467
  }
1355
1468
 
1356
1469
  throw Error("Invalid user profile method: " + method);
1357
1470
 
1358
1471
  case 8:
1359
- _context17.next = 10;
1472
+ _context19.next = 10;
1360
1473
  return _regeneratorRuntime.awrap(this.userProfileClient[method](message.args));
1361
1474
 
1362
1475
  case 10:
1363
- methodResults = _context17.sent;
1364
- _context17.next = 18;
1476
+ methodResults = _context19.sent;
1477
+ _context19.next = 18;
1365
1478
  break;
1366
1479
 
1367
1480
  case 13:
1368
1481
  if (this.FrameAllowedMethods().includes(method)) {
1369
- _context17.next = 15;
1482
+ _context19.next = 15;
1370
1483
  break;
1371
1484
  }
1372
1485
 
1373
1486
  throw Error("Invalid method: " + method);
1374
1487
 
1375
1488
  case 15:
1376
- _context17.next = 17;
1489
+ _context19.next = 17;
1377
1490
  return _regeneratorRuntime.awrap(this[method](message.args));
1378
1491
 
1379
1492
  case 17:
1380
- methodResults = _context17.sent;
1493
+ methodResults = _context19.sent;
1381
1494
 
1382
1495
  case 18:
1383
1496
  Respond(this.utils.MakeClonable({
@@ -1385,17 +1498,17 @@ function () {
1385
1498
  requestId: message.requestId,
1386
1499
  response: methodResults
1387
1500
  }));
1388
- _context17.next = 27;
1501
+ _context19.next = 27;
1389
1502
  break;
1390
1503
 
1391
1504
  case 21:
1392
- _context17.prev = 21;
1393
- _context17.t0 = _context17["catch"](3);
1505
+ _context19.prev = 21;
1506
+ _context19.t0 = _context19["catch"](3);
1394
1507
  // eslint-disable-next-line no-console
1395
- this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context17.t0) === "object" ? JSON.stringify(_context17.t0, null, 2) : _context17.t0), true); // eslint-disable-next-line no-console
1508
+ this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context19.t0) === "object" ? JSON.stringify(_context19.t0, null, 2) : _context19.t0), true); // eslint-disable-next-line no-console
1396
1509
 
1397
- console.error(_context17.t0);
1398
- responseError = _context17.t0 instanceof Error ? _context17.t0.message : _context17.t0;
1510
+ console.error(_context19.t0);
1511
+ responseError = _context19.t0 instanceof Error ? _context19.t0.message : _context19.t0;
1399
1512
  Respond(this.utils.MakeClonable({
1400
1513
  type: "ElvFrameResponse",
1401
1514
  requestId: message.requestId,
@@ -1404,22 +1517,22 @@ function () {
1404
1517
 
1405
1518
  case 27:
1406
1519
  case "end":
1407
- return _context17.stop();
1520
+ return _context19.stop();
1408
1521
  }
1409
1522
  }
1410
1523
  }, null, this, [[3, 21]]);
1411
1524
  }
1412
1525
  }], [{
1413
1526
  key: "Configuration",
1414
- value: function Configuration(_ref21) {
1415
- var configUrl, _ref21$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion;
1527
+ value: function Configuration(_ref22) {
1528
+ var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion;
1416
1529
 
1417
- return _regeneratorRuntime.async(function Configuration$(_context18) {
1530
+ return _regeneratorRuntime.async(function Configuration$(_context20) {
1418
1531
  while (1) {
1419
- switch (_context18.prev = _context18.next) {
1532
+ switch (_context20.prev = _context20.next) {
1420
1533
  case 0:
1421
- configUrl = _ref21.configUrl, _ref21$kmsUrls = _ref21.kmsUrls, kmsUrls = _ref21$kmsUrls === void 0 ? [] : _ref21$kmsUrls, region = _ref21.region;
1422
- _context18.prev = 1;
1534
+ configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
1535
+ _context20.prev = 1;
1423
1536
  uri = new URI(configUrl);
1424
1537
  uri.pathname("/config");
1425
1538
 
@@ -1427,11 +1540,11 @@ function () {
1427
1540
  uri.addSearch("elvgeo", region);
1428
1541
  }
1429
1542
 
1430
- _context18.next = 7;
1543
+ _context20.next = 7;
1431
1544
  return _regeneratorRuntime.awrap(Utils.ResponseToJson(HttpClient.Fetch(uri.toString())));
1432
1545
 
1433
1546
  case 7:
1434
- fabricInfo = _context18.sent;
1547
+ fabricInfo = _context20.sent;
1435
1548
 
1436
1549
  // If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
1437
1550
  filterHTTPS = function filterHTTPS(uri) {
@@ -1457,7 +1570,7 @@ function () {
1457
1570
  }
1458
1571
 
1459
1572
  fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
1460
- return _context18.abrupt("return", {
1573
+ return _context20.abrupt("return", {
1461
1574
  nodeId: fabricInfo.node_id,
1462
1575
  contentSpaceId: fabricInfo.qspace.id,
1463
1576
  networkId: (fabricInfo.qspace.ethereum || {}).network_id,
@@ -1470,17 +1583,17 @@ function () {
1470
1583
  });
1471
1584
 
1472
1585
  case 19:
1473
- _context18.prev = 19;
1474
- _context18.t0 = _context18["catch"](1);
1586
+ _context20.prev = 19;
1587
+ _context20.t0 = _context20["catch"](1);
1475
1588
  // eslint-disable-next-line no-console
1476
1589
  console.error("Error retrieving fabric configuration:"); // eslint-disable-next-line no-console
1477
1590
 
1478
- console.error(_context18.t0);
1479
- throw _context18.t0;
1591
+ console.error(_context20.t0);
1592
+ throw _context20.t0;
1480
1593
 
1481
1594
  case 24:
1482
1595
  case "end":
1483
- return _context18.stop();
1596
+ return _context20.stop();
1484
1597
  }
1485
1598
  }
1486
1599
  }, null, null, [[1, 19]]);
@@ -1503,25 +1616,25 @@ function () {
1503
1616
 
1504
1617
  }, {
1505
1618
  key: "FromNetworkName",
1506
- value: function FromNetworkName(_ref22) {
1507
- var networkName, region, trustAuthorityId, staticToken, _ref22$ethereumContra, ethereumContractTimeout, _ref22$noCache, noCache, _ref22$noAuth, noAuth, assumeV3, configUrl;
1619
+ value: function FromNetworkName(_ref23) {
1620
+ var networkName, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
1508
1621
 
1509
- return _regeneratorRuntime.async(function FromNetworkName$(_context19) {
1622
+ return _regeneratorRuntime.async(function FromNetworkName$(_context21) {
1510
1623
  while (1) {
1511
- switch (_context19.prev = _context19.next) {
1624
+ switch (_context21.prev = _context21.next) {
1512
1625
  case 0:
1513
- networkName = _ref22.networkName, region = _ref22.region, trustAuthorityId = _ref22.trustAuthorityId, staticToken = _ref22.staticToken, _ref22$ethereumContra = _ref22.ethereumContractTimeout, ethereumContractTimeout = _ref22$ethereumContra === void 0 ? 10 : _ref22$ethereumContra, _ref22$noCache = _ref22.noCache, noCache = _ref22$noCache === void 0 ? false : _ref22$noCache, _ref22$noAuth = _ref22.noAuth, noAuth = _ref22$noAuth === void 0 ? false : _ref22$noAuth, assumeV3 = _ref22.assumeV3;
1626
+ networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
1514
1627
  configUrl = networks[networkName];
1515
1628
 
1516
1629
  if (configUrl) {
1517
- _context19.next = 4;
1630
+ _context21.next = 4;
1518
1631
  break;
1519
1632
  }
1520
1633
 
1521
1634
  throw Error("Invalid network name: " + networkName);
1522
1635
 
1523
1636
  case 4:
1524
- _context19.next = 6;
1637
+ _context21.next = 6;
1525
1638
  return _regeneratorRuntime.awrap(this.FromConfigurationUrl({
1526
1639
  configUrl: configUrl,
1527
1640
  region: region,
@@ -1534,11 +1647,11 @@ function () {
1534
1647
  }));
1535
1648
 
1536
1649
  case 6:
1537
- return _context19.abrupt("return", _context19.sent);
1650
+ return _context21.abrupt("return", _context21.sent);
1538
1651
 
1539
1652
  case 7:
1540
1653
  case "end":
1541
- return _context19.stop();
1654
+ return _context21.stop();
1542
1655
  }
1543
1656
  }
1544
1657
  }, null, this);
@@ -1561,29 +1674,29 @@ function () {
1561
1674
 
1562
1675
  }, {
1563
1676
  key: "FromConfigurationUrl",
1564
- value: function FromConfigurationUrl(_ref23) {
1565
- var configUrl, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, _ref23$assumeV, assumeV3, _ref24, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion, client;
1677
+ value: function FromConfigurationUrl(_ref24) {
1678
+ var configUrl, region, trustAuthorityId, staticToken, _ref24$ethereumContra, ethereumContractTimeout, _ref24$noCache, noCache, _ref24$noAuth, noAuth, _ref24$assumeV, assumeV3, _ref25, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion, client;
1566
1679
 
1567
- return _regeneratorRuntime.async(function FromConfigurationUrl$(_context20) {
1680
+ return _regeneratorRuntime.async(function FromConfigurationUrl$(_context22) {
1568
1681
  while (1) {
1569
- switch (_context20.prev = _context20.next) {
1682
+ switch (_context22.prev = _context22.next) {
1570
1683
  case 0:
1571
- configUrl = _ref23.configUrl, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, _ref23$assumeV = _ref23.assumeV3, assumeV3 = _ref23$assumeV === void 0 ? false : _ref23$assumeV;
1572
- _context20.next = 3;
1684
+ configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
1685
+ _context22.next = 3;
1573
1686
  return _regeneratorRuntime.awrap(ElvClient.Configuration({
1574
1687
  configUrl: configUrl,
1575
1688
  region: region
1576
1689
  }));
1577
1690
 
1578
1691
  case 3:
1579
- _ref24 = _context20.sent;
1580
- contentSpaceId = _ref24.contentSpaceId;
1581
- networkId = _ref24.networkId;
1582
- networkName = _ref24.networkName;
1583
- fabricURIs = _ref24.fabricURIs;
1584
- ethereumURIs = _ref24.ethereumURIs;
1585
- authServiceURIs = _ref24.authServiceURIs;
1586
- fabricVersion = _ref24.fabricVersion;
1692
+ _ref25 = _context22.sent;
1693
+ contentSpaceId = _ref25.contentSpaceId;
1694
+ networkId = _ref25.networkId;
1695
+ networkName = _ref25.networkName;
1696
+ fabricURIs = _ref25.fabricURIs;
1697
+ ethereumURIs = _ref25.ethereumURIs;
1698
+ authServiceURIs = _ref25.authServiceURIs;
1699
+ fabricVersion = _ref25.fabricVersion;
1587
1700
  client = new ElvClient({
1588
1701
  contentSpaceId: contentSpaceId,
1589
1702
  networkId: networkId,
@@ -1600,11 +1713,11 @@ function () {
1600
1713
  assumeV3: assumeV3
1601
1714
  });
1602
1715
  client.configUrl = configUrl;
1603
- return _context20.abrupt("return", client);
1716
+ return _context22.abrupt("return", client);
1604
1717
 
1605
1718
  case 14:
1606
1719
  case "end":
1607
- return _context20.stop();
1720
+ return _context22.stop();
1608
1721
  }
1609
1722
  }
1610
1723
  });