@imtbl/sdk 1.41.3 → 1.42.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/passport.js CHANGED
@@ -11460,7 +11460,7 @@ class MultiRollupApiClients {
11460
11460
  }
11461
11461
 
11462
11462
  // eslint-disable-next-line @typescript-eslint/naming-convention
11463
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.41.3' };
11463
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.42.0' };
11464
11464
  const createConfig$1 = ({ basePath, headers, }) => {
11465
11465
  if (!basePath.trim()) {
11466
11466
  throw Error('basePath can not be empty');
@@ -11639,7 +11639,7 @@ const flattenProperties = (properties) => {
11639
11639
  };
11640
11640
 
11641
11641
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
11642
- const SDK_VERSION = '1.41.3';
11642
+ const SDK_VERSION = '1.42.0';
11643
11643
  const getFrameParentDomain = () => {
11644
11644
  if (isNode()) {
11645
11645
  return '';
@@ -12029,7 +12029,7 @@ const addKeysToHeadersOverride = (baseConfig, overrides) => {
12029
12029
  /* eslint-disable @typescript-eslint/naming-convention */
12030
12030
  class ApiConfiguration extends index$2.Configuration {
12031
12031
  }
12032
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.41.3' };
12032
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.42.0' };
12033
12033
  /**
12034
12034
  * @dev use createImmutableXConfiguration instead
12035
12035
  */
@@ -12070,7 +12070,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
12070
12070
  coreContractAddress,
12071
12071
  registrationContractAddress,
12072
12072
  registrationV4ContractAddress,
12073
- sdkVersion: 'ts-immutable-sdk-1.41.3',
12073
+ sdkVersion: 'ts-immutable-sdk-1.42.0',
12074
12074
  baseConfig,
12075
12075
  });
12076
12076
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -18970,9 +18970,7 @@ var globalAxios = axios;
18970
18970
  * https://openapi-generator.tech
18971
18971
  * Do not edit the class manually.
18972
18972
  */
18973
- // Some imports not used depending on template conditions
18974
- // @ts-ignore
18975
- const BASE_PATH = "https://guardian.sandbox.imtbl.com".replace(/\/+$/, "");
18973
+ const BASE_PATH = "https://api.immutable.com".replace(/\/+$/, "");
18976
18974
  /**
18977
18975
  *
18978
18976
  * @export
@@ -18987,7 +18985,7 @@ class BaseAPI {
18987
18985
  this.axios = axios;
18988
18986
  if (configuration) {
18989
18987
  this.configuration = configuration;
18990
- this.basePath = configuration.basePath || this.basePath;
18988
+ this.basePath = configuration.basePath ?? basePath;
18991
18989
  }
18992
18990
  }
18993
18991
  }
@@ -18999,12 +18997,17 @@ class BaseAPI {
18999
18997
  */
19000
18998
  class RequiredError extends Error {
19001
18999
  field;
19002
- name = "RequiredError";
19003
19000
  constructor(field, msg) {
19004
19001
  super(msg);
19005
19002
  this.field = field;
19003
+ this.name = "RequiredError";
19006
19004
  }
19007
19005
  }
19006
+ /**
19007
+ *
19008
+ * @export
19009
+ */
19010
+ const operationServerMap = {};
19008
19011
 
19009
19012
  /* tslint:disable */
19010
19013
  /* eslint-disable */
@@ -19047,6 +19050,8 @@ const setBearerAuthToObject = async function (object, configuration) {
19047
19050
  }
19048
19051
  };
19049
19052
  function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
19053
+ if (parameter == null)
19054
+ return;
19050
19055
  if (typeof parameter === "object") {
19051
19056
  if (Array.isArray(parameter)) {
19052
19057
  parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
@@ -19099,7 +19104,7 @@ const toPathString = function (url) {
19099
19104
  */
19100
19105
  const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
19101
19106
  return (axios = globalAxios, basePath = BASE_PATH) => {
19102
- const axiosRequestArgs = { ...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url };
19107
+ const axiosRequestArgs = { ...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url };
19103
19108
  return axios.request(axiosRequestArgs);
19104
19109
  };
19105
19110
  };
@@ -19123,6 +19128,38 @@ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, confi
19123
19128
  */
19124
19129
  const MessagesApiAxiosParamCreator = function (configuration) {
19125
19130
  return {
19131
+ /**
19132
+ * Approve a pending erc191 message
19133
+ * @summary Approve a pending erc191 message
19134
+ * @param {string} messageID id for the message
19135
+ * @param {*} [options] Override http request option.
19136
+ * @throws {RequiredError}
19137
+ */
19138
+ approvePendingERC191Message: async (messageID, options = {}) => {
19139
+ // verify required parameter 'messageID' is not null or undefined
19140
+ assertParamExists('approvePendingERC191Message', 'messageID', messageID);
19141
+ const localVarPath = `/guardian/v1/erc191-messages/{messageID}/approve`
19142
+ .replace(`{${"messageID"}}`, encodeURIComponent(String(messageID)));
19143
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
19144
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
19145
+ let baseOptions;
19146
+ if (configuration) {
19147
+ baseOptions = configuration.baseOptions;
19148
+ }
19149
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
19150
+ const localVarHeaderParameter = {};
19151
+ const localVarQueryParameter = {};
19152
+ // authentication BearerAuth required
19153
+ // http bearer authentication required
19154
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
19155
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
19156
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
19157
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
19158
+ return {
19159
+ url: toPathString(localVarUrlObj),
19160
+ options: localVarRequestOptions,
19161
+ };
19162
+ },
19126
19163
  /**
19127
19164
  * Approve a pending evm message
19128
19165
  * @summary Approve a pending evm message
@@ -19155,6 +19192,39 @@ const MessagesApiAxiosParamCreator = function (configuration) {
19155
19192
  options: localVarRequestOptions,
19156
19193
  };
19157
19194
  },
19195
+ /**
19196
+ * Check if a given erc191 message is valid
19197
+ * @summary Evaluate an erc191 message to sign
19198
+ * @param {ERC191MessageEvaluationRequest} eRC191MessageEvaluationRequest Specifies the kind of transaction
19199
+ * @param {*} [options] Override http request option.
19200
+ * @throws {RequiredError}
19201
+ */
19202
+ evaluateErc191Message: async (eRC191MessageEvaluationRequest, options = {}) => {
19203
+ // verify required parameter 'eRC191MessageEvaluationRequest' is not null or undefined
19204
+ assertParamExists('evaluateErc191Message', 'eRC191MessageEvaluationRequest', eRC191MessageEvaluationRequest);
19205
+ const localVarPath = `/guardian/v1/erc191-messages/evaluate`;
19206
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
19207
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
19208
+ let baseOptions;
19209
+ if (configuration) {
19210
+ baseOptions = configuration.baseOptions;
19211
+ }
19212
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
19213
+ const localVarHeaderParameter = {};
19214
+ const localVarQueryParameter = {};
19215
+ // authentication BearerAuth required
19216
+ // http bearer authentication required
19217
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
19218
+ localVarHeaderParameter['Content-Type'] = 'application/json';
19219
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
19220
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
19221
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
19222
+ localVarRequestOptions.data = serializeDataIfNeeded(eRC191MessageEvaluationRequest, localVarRequestOptions, configuration);
19223
+ return {
19224
+ url: toPathString(localVarUrlObj),
19225
+ options: localVarRequestOptions,
19226
+ };
19227
+ },
19158
19228
  /**
19159
19229
  * Check if a given message is valid for EVM
19160
19230
  * @summary Evaluate an evm message to sign
@@ -19188,6 +19258,38 @@ const MessagesApiAxiosParamCreator = function (configuration) {
19188
19258
  options: localVarRequestOptions,
19189
19259
  };
19190
19260
  },
19261
+ /**
19262
+ * Get an erc191 message by id
19263
+ * @summary Info for a specific erc191 message
19264
+ * @param {string} messageID The id of the erc191 message
19265
+ * @param {*} [options] Override http request option.
19266
+ * @throws {RequiredError}
19267
+ */
19268
+ getErc191MessageByID: async (messageID, options = {}) => {
19269
+ // verify required parameter 'messageID' is not null or undefined
19270
+ assertParamExists('getErc191MessageByID', 'messageID', messageID);
19271
+ const localVarPath = `/guardian/v1/erc191-messages/{messageID}`
19272
+ .replace(`{${"messageID"}}`, encodeURIComponent(String(messageID)));
19273
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
19274
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
19275
+ let baseOptions;
19276
+ if (configuration) {
19277
+ baseOptions = configuration.baseOptions;
19278
+ }
19279
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
19280
+ const localVarHeaderParameter = {};
19281
+ const localVarQueryParameter = {};
19282
+ // authentication BearerAuth required
19283
+ // http bearer authentication required
19284
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
19285
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
19286
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
19287
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
19288
+ return {
19289
+ url: toPathString(localVarUrlObj),
19290
+ options: localVarRequestOptions,
19291
+ };
19292
+ },
19191
19293
  /**
19192
19294
  * Get an evm message by id
19193
19295
  * @summary Info for a specific evm message
@@ -19229,6 +19331,19 @@ const MessagesApiAxiosParamCreator = function (configuration) {
19229
19331
  const MessagesApiFp = function (configuration) {
19230
19332
  const localVarAxiosParamCreator = MessagesApiAxiosParamCreator(configuration);
19231
19333
  return {
19334
+ /**
19335
+ * Approve a pending erc191 message
19336
+ * @summary Approve a pending erc191 message
19337
+ * @param {string} messageID id for the message
19338
+ * @param {*} [options] Override http request option.
19339
+ * @throws {RequiredError}
19340
+ */
19341
+ async approvePendingERC191Message(messageID, options) {
19342
+ const localVarAxiosArgs = await localVarAxiosParamCreator.approvePendingERC191Message(messageID, options);
19343
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19344
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.approvePendingERC191Message']?.[localVarOperationServerIndex]?.url;
19345
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19346
+ },
19232
19347
  /**
19233
19348
  * Approve a pending evm message
19234
19349
  * @summary Approve a pending evm message
@@ -19238,7 +19353,22 @@ const MessagesApiFp = function (configuration) {
19238
19353
  */
19239
19354
  async approvePendingMessage(messageID, options) {
19240
19355
  const localVarAxiosArgs = await localVarAxiosParamCreator.approvePendingMessage(messageID, options);
19241
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19356
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19357
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.approvePendingMessage']?.[localVarOperationServerIndex]?.url;
19358
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19359
+ },
19360
+ /**
19361
+ * Check if a given erc191 message is valid
19362
+ * @summary Evaluate an erc191 message to sign
19363
+ * @param {ERC191MessageEvaluationRequest} eRC191MessageEvaluationRequest Specifies the kind of transaction
19364
+ * @param {*} [options] Override http request option.
19365
+ * @throws {RequiredError}
19366
+ */
19367
+ async evaluateErc191Message(eRC191MessageEvaluationRequest, options) {
19368
+ const localVarAxiosArgs = await localVarAxiosParamCreator.evaluateErc191Message(eRC191MessageEvaluationRequest, options);
19369
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19370
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.evaluateErc191Message']?.[localVarOperationServerIndex]?.url;
19371
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19242
19372
  },
19243
19373
  /**
19244
19374
  * Check if a given message is valid for EVM
@@ -19249,7 +19379,22 @@ const MessagesApiFp = function (configuration) {
19249
19379
  */
19250
19380
  async evaluateMessage(messageEvaluationRequest, options) {
19251
19381
  const localVarAxiosArgs = await localVarAxiosParamCreator.evaluateMessage(messageEvaluationRequest, options);
19252
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19382
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19383
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.evaluateMessage']?.[localVarOperationServerIndex]?.url;
19384
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19385
+ },
19386
+ /**
19387
+ * Get an erc191 message by id
19388
+ * @summary Info for a specific erc191 message
19389
+ * @param {string} messageID The id of the erc191 message
19390
+ * @param {*} [options] Override http request option.
19391
+ * @throws {RequiredError}
19392
+ */
19393
+ async getErc191MessageByID(messageID, options) {
19394
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getErc191MessageByID(messageID, options);
19395
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19396
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.getErc191MessageByID']?.[localVarOperationServerIndex]?.url;
19397
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19253
19398
  },
19254
19399
  /**
19255
19400
  * Get an evm message by id
@@ -19260,7 +19405,9 @@ const MessagesApiFp = function (configuration) {
19260
19405
  */
19261
19406
  async getMessageByID(messageID, options) {
19262
19407
  const localVarAxiosArgs = await localVarAxiosParamCreator.getMessageByID(messageID, options);
19263
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19408
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19409
+ const localVarOperationServerBasePath = operationServerMap['MessagesApi.getMessageByID']?.[localVarOperationServerIndex]?.url;
19410
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19264
19411
  },
19265
19412
  };
19266
19413
  };
@@ -19271,6 +19418,17 @@ const MessagesApiFp = function (configuration) {
19271
19418
  * @extends {BaseAPI}
19272
19419
  */
19273
19420
  class MessagesApi extends BaseAPI {
19421
+ /**
19422
+ * Approve a pending erc191 message
19423
+ * @summary Approve a pending erc191 message
19424
+ * @param {MessagesApiApprovePendingERC191MessageRequest} requestParameters Request parameters.
19425
+ * @param {*} [options] Override http request option.
19426
+ * @throws {RequiredError}
19427
+ * @memberof MessagesApi
19428
+ */
19429
+ approvePendingERC191Message(requestParameters, options) {
19430
+ return MessagesApiFp(this.configuration).approvePendingERC191Message(requestParameters.messageID, options).then((request) => request(this.axios, this.basePath));
19431
+ }
19274
19432
  /**
19275
19433
  * Approve a pending evm message
19276
19434
  * @summary Approve a pending evm message
@@ -19282,6 +19440,17 @@ class MessagesApi extends BaseAPI {
19282
19440
  approvePendingMessage(requestParameters, options) {
19283
19441
  return MessagesApiFp(this.configuration).approvePendingMessage(requestParameters.messageID, options).then((request) => request(this.axios, this.basePath));
19284
19442
  }
19443
+ /**
19444
+ * Check if a given erc191 message is valid
19445
+ * @summary Evaluate an erc191 message to sign
19446
+ * @param {MessagesApiEvaluateErc191MessageRequest} requestParameters Request parameters.
19447
+ * @param {*} [options] Override http request option.
19448
+ * @throws {RequiredError}
19449
+ * @memberof MessagesApi
19450
+ */
19451
+ evaluateErc191Message(requestParameters, options) {
19452
+ return MessagesApiFp(this.configuration).evaluateErc191Message(requestParameters.eRC191MessageEvaluationRequest, options).then((request) => request(this.axios, this.basePath));
19453
+ }
19285
19454
  /**
19286
19455
  * Check if a given message is valid for EVM
19287
19456
  * @summary Evaluate an evm message to sign
@@ -19293,6 +19462,17 @@ class MessagesApi extends BaseAPI {
19293
19462
  evaluateMessage(requestParameters, options) {
19294
19463
  return MessagesApiFp(this.configuration).evaluateMessage(requestParameters.messageEvaluationRequest, options).then((request) => request(this.axios, this.basePath));
19295
19464
  }
19465
+ /**
19466
+ * Get an erc191 message by id
19467
+ * @summary Info for a specific erc191 message
19468
+ * @param {MessagesApiGetErc191MessageByIDRequest} requestParameters Request parameters.
19469
+ * @param {*} [options] Override http request option.
19470
+ * @throws {RequiredError}
19471
+ * @memberof MessagesApi
19472
+ */
19473
+ getErc191MessageByID(requestParameters, options) {
19474
+ return MessagesApiFp(this.configuration).getErc191MessageByID(requestParameters.messageID, options).then((request) => request(this.axios, this.basePath));
19475
+ }
19296
19476
  /**
19297
19477
  * Get an evm message by id
19298
19478
  * @summary Info for a specific evm message
@@ -19403,7 +19583,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
19403
19583
  * Get a transaction by payload hash
19404
19584
  * @summary Info for a specific transaction
19405
19585
  * @param {string} transactionID The id of the starkex transaction to retrieve
19406
- * @param {'starkex' | 'evm'} chainType roll up type
19586
+ * @param {GetTransactionByIDChainTypeEnum} chainType roll up type
19407
19587
  * @param {string} [chainID] ID of evm chain
19408
19588
  * @param {*} [options] Override http request option.
19409
19589
  * @throws {RequiredError}
@@ -19460,7 +19640,9 @@ const TransactionsApiFp = function (configuration) {
19460
19640
  */
19461
19641
  async approvePendingTransaction(payloadHash, transactionApprovalRequest, options) {
19462
19642
  const localVarAxiosArgs = await localVarAxiosParamCreator.approvePendingTransaction(payloadHash, transactionApprovalRequest, options);
19463
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19643
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19644
+ const localVarOperationServerBasePath = operationServerMap['TransactionsApi.approvePendingTransaction']?.[localVarOperationServerIndex]?.url;
19645
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19464
19646
  },
19465
19647
  /**
19466
19648
  * Check if the transaction is valid by transaction ID for both StarkEx and EVM
@@ -19472,20 +19654,24 @@ const TransactionsApiFp = function (configuration) {
19472
19654
  */
19473
19655
  async evaluateTransaction(id, transactionEvaluationRequest, options) {
19474
19656
  const localVarAxiosArgs = await localVarAxiosParamCreator.evaluateTransaction(id, transactionEvaluationRequest, options);
19475
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19657
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19658
+ const localVarOperationServerBasePath = operationServerMap['TransactionsApi.evaluateTransaction']?.[localVarOperationServerIndex]?.url;
19659
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19476
19660
  },
19477
19661
  /**
19478
19662
  * Get a transaction by payload hash
19479
19663
  * @summary Info for a specific transaction
19480
19664
  * @param {string} transactionID The id of the starkex transaction to retrieve
19481
- * @param {'starkex' | 'evm'} chainType roll up type
19665
+ * @param {GetTransactionByIDChainTypeEnum} chainType roll up type
19482
19666
  * @param {string} [chainID] ID of evm chain
19483
19667
  * @param {*} [options] Override http request option.
19484
19668
  * @throws {RequiredError}
19485
19669
  */
19486
19670
  async getTransactionByID(transactionID, chainType, chainID, options) {
19487
19671
  const localVarAxiosArgs = await localVarAxiosParamCreator.getTransactionByID(transactionID, chainType, chainID, options);
19488
- return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
19672
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
19673
+ const localVarOperationServerBasePath = operationServerMap['TransactionsApi.getTransactionByID']?.[localVarOperationServerIndex]?.url;
19674
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19489
19675
  },
19490
19676
  };
19491
19677
  };
@@ -19579,6 +19765,13 @@ class Configuration {
19579
19765
  * @memberof Configuration
19580
19766
  */
19581
19767
  basePath;
19768
+ /**
19769
+ * override server index
19770
+ *
19771
+ * @type {number}
19772
+ * @memberof Configuration
19773
+ */
19774
+ serverIndex;
19582
19775
  /**
19583
19776
  * base options for axios calls
19584
19777
  *
@@ -19600,6 +19793,7 @@ class Configuration {
19600
19793
  this.password = param.password;
19601
19794
  this.accessToken = param.accessToken;
19602
19795
  this.basePath = param.basePath;
19796
+ this.serverIndex = param.serverIndex;
19603
19797
  this.baseOptions = param.baseOptions;
19604
19798
  this.formDataCtor = param.formDataCtor;
19605
19799
  }
@@ -21468,7 +21662,7 @@ class ConfirmationScreen {
21468
21662
  this.showConfirmationScreen(href, messageHandler, resolve);
21469
21663
  });
21470
21664
  }
21471
- requestMessageConfirmation(messageID, etherAddress) {
21665
+ requestMessageConfirmation(messageID, etherAddress, messageType) {
21472
21666
  return new Promise((resolve, reject) => {
21473
21667
  const messageHandler = ({ data, origin }) => {
21474
21668
  if (origin !== this.config.passportDomain
@@ -21504,7 +21698,11 @@ class ConfirmationScreen {
21504
21698
  }
21505
21699
  };
21506
21700
  window.addEventListener('message', messageHandler);
21507
- const href = this.getHref('zkevm/message', { messageID, etherAddress });
21701
+ const href = this.getHref('zkevm/message', {
21702
+ messageID,
21703
+ etherAddress,
21704
+ ...(messageType ? { messageType } : {}),
21705
+ });
21508
21706
  this.showConfirmationScreen(href, messageHandler, resolve);
21509
21707
  });
21510
21708
  }
@@ -21619,7 +21817,7 @@ class TypedEventEmitter {
21619
21817
 
21620
21818
  const SIGNATURE_WEIGHT = 1; // Weight of a single signature in the multi-sig
21621
21819
  const TRANSACTION_SIGNATURE_THRESHOLD = 1; // Total required weight in the multi-sig for a transaction
21622
- const EIP712_SIGNATURE_THRESHOLD = 2; // Total required weight in the multi-sig for data signing
21820
+ const PACKED_SIGNATURE_THRESHOLD = 2; // Total required weight in the multi-sig for data signing
21623
21821
  const ETH_SIGN_FLAG = '02';
21624
21822
  const ETH_SIGN_PREFIX = '\x19\x01';
21625
21823
  const META_TRANSACTIONS_TYPE = `tuple(
@@ -21664,7 +21862,7 @@ const getNonce = async (rpcProvider, smartContractWalletAddress) => {
21664
21862
  throw new Error('Unexpected result from contract.nonce() call.');
21665
21863
  };
21666
21864
  const encodeMessageSubDigest = (chainId, walletAddress, digest) => (utils$2.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]));
21667
- const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
21865
+ const signMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
21668
21866
  const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
21669
21867
  // Get the hash
21670
21868
  const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
@@ -21697,29 +21895,14 @@ const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walle
21697
21895
  encodedSignature,
21698
21896
  ]);
21699
21897
  };
21700
- const decodeRelayerTypedDataSignature = (relayerSignature) => {
21898
+ const decodeRelayerSignature = (relayerSignature) => {
21701
21899
  const signatureWithThreshold = `0x0000${relayerSignature}`;
21702
21900
  return v1.signature.decodeSignature(signatureWithThreshold);
21703
21901
  };
21704
- const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAddress, signer) => {
21705
- // Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
21706
- const types = { ...typedData.types };
21707
- // @ts-ignore
21708
- delete types.EIP712Domain;
21709
- // Hash the EIP712 payload and generate the complete payload
21710
- const { _TypedDataEncoder: typedDataEncoder } = utils$2;
21711
- const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
21712
- const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
21713
- const hash = utils$2.keccak256(messageSubDigest);
21714
- // Sign the sub digest
21715
- // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
21716
- const hashArray = utils$2.arrayify(hash);
21717
- const startTime = performance.now();
21718
- const ethsigNoType = await signer.signMessage(hashArray);
21719
- trackDuration('passport', 'magicSignMessageTypedData', Math.round(performance.now() - startTime));
21720
- const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
21902
+ const packSignatures = (EOASignature, EOAAddress, relayerSignature) => {
21903
+ const signedDigest = `${EOASignature}${ETH_SIGN_FLAG}`;
21721
21904
  // Combine the relayer and user signatures; sort by address to match the imageHash order
21722
- const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
21905
+ const { signers: relayerSigners } = decodeRelayerSignature(relayerSignature);
21723
21906
  const combinedSigners = [
21724
21907
  ...relayerSigners,
21725
21908
  {
@@ -21727,7 +21910,7 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
21727
21910
  unrecovered: true,
21728
21911
  weight: SIGNATURE_WEIGHT,
21729
21912
  signature: signedDigest,
21730
- address: await signer.getAddress(),
21913
+ address: EOAAddress,
21731
21914
  },
21732
21915
  ];
21733
21916
  const sortedSigners = combinedSigners.sort((a, b) => {
@@ -21743,10 +21926,38 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
21743
21926
  });
21744
21927
  return v1.signature.encodeSignature({
21745
21928
  version: 1,
21746
- threshold: EIP712_SIGNATURE_THRESHOLD,
21929
+ threshold: PACKED_SIGNATURE_THRESHOLD,
21747
21930
  signers: sortedSigners,
21748
21931
  });
21749
21932
  };
21933
+ const signAndPackTypedData = async (typedData, relayerSignature, chainId, walletAddress, signer) => {
21934
+ // Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
21935
+ const types = { ...typedData.types };
21936
+ // @ts-ignore
21937
+ delete types.EIP712Domain;
21938
+ // Hash the EIP712 payload and generate the complete payload
21939
+ const { _TypedDataEncoder: typedDataEncoder } = utils$2;
21940
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
21941
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
21942
+ const hash = utils$2.keccak256(messageSubDigest);
21943
+ // Sign the sub digest
21944
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
21945
+ const hashArray = utils$2.arrayify(hash);
21946
+ const startTime = performance.now();
21947
+ const eoaSignature = await signer.signMessage(hashArray);
21948
+ trackDuration('passport', 'magicSignMessageTypedData', Math.round(performance.now() - startTime));
21949
+ const eoaAddress = await signer.getAddress();
21950
+ return packSignatures(eoaSignature, eoaAddress, relayerSignature);
21951
+ };
21952
+ const signERC191Message = async (chainId, payload, signer, walletAddress) => {
21953
+ // Generate digest
21954
+ const digest = utils$2.keccak256(utils$2.toUtf8Bytes(payload));
21955
+ // Generate subDigest
21956
+ const subDigest = encodeMessageSubDigest(chainId, walletAddress, digest);
21957
+ const subDigestHash = utils$2.keccak256(subDigest);
21958
+ const subDigestHashArray = utils$2.arrayify(subDigestHash);
21959
+ return signer.signMessage(subDigestHashArray);
21960
+ };
21750
21961
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
21751
21962
 
21752
21963
  class RelayerClient {
@@ -21828,6 +22039,19 @@ class RelayerClient {
21828
22039
  const { result } = await this.postToRelayer(payload);
21829
22040
  return result;
21830
22041
  }
22042
+ async imSign(address, message) {
22043
+ const { chainId } = await this.rpcProvider.detectNetwork();
22044
+ const payload = {
22045
+ method: 'im_sign',
22046
+ params: [{
22047
+ address,
22048
+ message,
22049
+ chainId: getEip155ChainId(chainId),
22050
+ }],
22051
+ };
22052
+ const { result } = await this.postToRelayer(payload);
22053
+ return result;
22054
+ }
21831
22055
  }
21832
22056
 
21833
22057
  /**
@@ -21996,7 +22220,7 @@ class GuardianClient {
21996
22220
  const headers = { Authorization: `Bearer ${user.accessToken}` };
21997
22221
  const guardianTransactions = transformGuardianTransactions(metaTransactions);
21998
22222
  try {
21999
- const transactionEvaluationResponseAxiosResponse = await this.transactionAPI.evaluateTransaction({
22223
+ const response = await this.transactionAPI.evaluateTransaction({
22000
22224
  id: 'evm',
22001
22225
  transactionEvaluationRequest: {
22002
22226
  chainType: 'evm',
@@ -22008,7 +22232,7 @@ class GuardianClient {
22008
22232
  },
22009
22233
  },
22010
22234
  }, { headers });
22011
- return transactionEvaluationResponseAxiosResponse.data;
22235
+ return response.data;
22012
22236
  }
22013
22237
  catch (error) {
22014
22238
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -22036,11 +22260,11 @@ class GuardianClient {
22036
22260
  this.confirmationScreen.closeWindow();
22037
22261
  }
22038
22262
  }
22039
- async evaluateMessage({ chainID, payload }) {
22263
+ async handleEIP712MessageEvaluation({ chainID, payload }) {
22040
22264
  try {
22041
22265
  const user = await this.authManager.getUserZkEvm();
22042
22266
  if (user === null) {
22043
- throw new PassportError('evaluateMessage requires a valid ID token or refresh token. Please log in first', PassportErrorType.NOT_LOGGED_IN_ERROR);
22267
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'User not logged in. Please log in first.');
22044
22268
  }
22045
22269
  const messageEvalResponse = await this.messageAPI.evaluateMessage({ messageEvaluationRequest: { chainID, payload } }, { headers: { Authorization: `Bearer ${user.accessToken}` } });
22046
22270
  return messageEvalResponse.data;
@@ -22050,14 +22274,49 @@ class GuardianClient {
22050
22274
  throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Message failed to validate with error: ${errorMessage}`);
22051
22275
  }
22052
22276
  }
22053
- async validateMessage({ chainID, payload }) {
22054
- const { messageId, confirmationRequired } = await this.evaluateMessage({ chainID, payload });
22277
+ async evaluateEIP712Message({ chainID, payload }) {
22278
+ const { messageId, confirmationRequired } = await this.handleEIP712MessageEvaluation({ chainID, payload });
22279
+ if (confirmationRequired && this.crossSdkBridgeEnabled) {
22280
+ throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
22281
+ }
22282
+ if (confirmationRequired && !!messageId) {
22283
+ const user = await this.authManager.getUserZkEvm();
22284
+ const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress, 'eip712');
22285
+ if (!confirmationResult.confirmed) {
22286
+ throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
22287
+ }
22288
+ }
22289
+ else {
22290
+ this.confirmationScreen.closeWindow();
22291
+ }
22292
+ }
22293
+ async handleERC191MessageEvaluation({ chainID, payload }) {
22294
+ try {
22295
+ const user = await this.authManager.getUserZkEvm();
22296
+ if (user === null) {
22297
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'User not logged in. Please log in first.');
22298
+ }
22299
+ const messageEvalResponse = await this.messageAPI.evaluateErc191Message({
22300
+ eRC191MessageEvaluationRequest: {
22301
+ chainID: getEip155ChainId(chainID),
22302
+ payload,
22303
+ },
22304
+ }, { headers: { Authorization: `Bearer ${user.accessToken}` } });
22305
+ return messageEvalResponse.data;
22306
+ }
22307
+ catch (error) {
22308
+ const errorMessage = error instanceof Error ? error.message : String(error);
22309
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Message failed to validate with error: ${errorMessage}`);
22310
+ }
22311
+ }
22312
+ async evaluateERC191Message({ chainID, payload }) {
22313
+ const { messageId, confirmationRequired } = await this.handleERC191MessageEvaluation({ chainID, payload });
22055
22314
  if (confirmationRequired && this.crossSdkBridgeEnabled) {
22056
22315
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
22057
22316
  }
22058
22317
  if (confirmationRequired && !!messageId) {
22059
22318
  const user = await this.authManager.getUserZkEvm();
22060
- const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress);
22319
+ const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress, 'erc191');
22061
22320
  if (!confirmationResult.confirmed) {
22062
22321
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
22063
22322
  }
@@ -22138,7 +22397,7 @@ const sendTransaction = async ({ params, ethSigner, rpcProvider, relayerClient,
22138
22397
  validateEVMTransactionPromise.then(() => flow.addEvent('endValidateEVMTransaction'));
22139
22398
  // NOTE: We sign again because we now are adding the fee transaction, so the
22140
22399
  // whole payload is different and needs a new signature.
22141
- const getSignedMetaTransactionsPromise = getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress, ethSigner);
22400
+ const getSignedMetaTransactionsPromise = signMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress, ethSigner);
22142
22401
  getSignedMetaTransactionsPromise.then(() => flow.addEvent('endGetSignedMetaTransactions'));
22143
22402
  const [, signedTransactions] = await Promise.all([
22144
22403
  validateEVMTransactionPromise,
@@ -22223,15 +22482,57 @@ const signTypedDataV4 = async ({ params, method, ethSigner, rpcProvider, relayer
22223
22482
  const { chainId } = await rpcProvider.detectNetwork();
22224
22483
  const typedData = transformTypedData(typedDataParam, chainId);
22225
22484
  flow.addEvent('endDetectNetwork');
22226
- await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData });
22485
+ await guardianClient.evaluateEIP712Message({ chainID: String(chainId), payload: typedData });
22227
22486
  flow.addEvent('endValidateMessage');
22228
22487
  const relayerSignature = await relayerClient.imSignTypedData(fromAddress, typedData);
22229
22488
  flow.addEvent('endRelayerSignTypedData');
22230
- const signature = await getSignedTypedData(typedData, relayerSignature, BigNumber.from(chainId), fromAddress, ethSigner);
22489
+ const signature = await signAndPackTypedData(typedData, relayerSignature, BigNumber.from(chainId), fromAddress, ethSigner);
22231
22490
  flow.addEvent('getSignedTypedData');
22232
22491
  return signature;
22233
22492
  };
22234
22493
 
22494
+ const hexToString = (hex) => {
22495
+ if (!hex)
22496
+ return hex;
22497
+ try {
22498
+ const stripped = utils$2.stripZeros(utils$2.arrayify(hex));
22499
+ const buff = Buffer.from(stripped);
22500
+ return buff.length === 32 ? hex : utils$2.toUtf8String(stripped);
22501
+ }
22502
+ catch (e) {
22503
+ return hex;
22504
+ }
22505
+ };
22506
+
22507
+ const personalSign = async ({ params, ethSigner, zkEvmAddress, rpcProvider, guardianClient, relayerClient, flow, }) => {
22508
+ const message = params[0];
22509
+ const fromAddress = params[1];
22510
+ if (!fromAddress || !message) {
22511
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'personal_sign requires an address and a message');
22512
+ }
22513
+ if (fromAddress.toLowerCase() !== zkEvmAddress.toLowerCase()) {
22514
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'personal_sign requires the signer to be the from address');
22515
+ }
22516
+ // Convert message into a string if it's a hex
22517
+ const payload = hexToString(message);
22518
+ const { chainId } = await rpcProvider.detectNetwork();
22519
+ flow.addEvent('endDetectNetwork');
22520
+ const chainIdBigNumber = BigNumber.from(chainId);
22521
+ // Sign the message with the EOA without blocking
22522
+ const eoaSignaturePromise = signERC191Message(chainIdBigNumber, payload, ethSigner, fromAddress);
22523
+ eoaSignaturePromise.then(() => flow.addEvent('endEOASignature'));
22524
+ await guardianClient.evaluateERC191Message({ chainID: chainId, payload });
22525
+ flow.addEvent('endEvaluateERC191Message');
22526
+ const [eoaSignature, relayerSignature] = await Promise.all([
22527
+ eoaSignaturePromise,
22528
+ relayerClient.imSign(fromAddress, payload),
22529
+ ]);
22530
+ flow.addEvent('endRelayerSign');
22531
+ const eoaAddress = await ethSigner.getAddress();
22532
+ flow.addEvent('endGetEOAAddress');
22533
+ return packSignatures(eoaSignature, eoaAddress, relayerSignature);
22534
+ };
22535
+
22235
22536
  const isZkEvmUser = (user) => 'zkEvm' in user;
22236
22537
  class ZkEvmProvider {
22237
22538
  #authManager;
@@ -22407,6 +22708,38 @@ class ZkEvmProvider {
22407
22708
  case 'eth_accounts': {
22408
22709
  return this.#zkEvmAddress ? [this.#zkEvmAddress] : [];
22409
22710
  }
22711
+ case 'personal_sign': {
22712
+ if (!this.#zkEvmAddress) {
22713
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
22714
+ }
22715
+ const flow = trackFlow('passport', 'personalSign');
22716
+ try {
22717
+ return await this.#guardianClient.withConfirmationScreen({ width: 480, height: 720 })(async () => {
22718
+ const ethSigner = await this.#getSigner();
22719
+ flow.addEvent('endGetSigner');
22720
+ return await personalSign({
22721
+ params: request.params || [],
22722
+ ethSigner,
22723
+ zkEvmAddress: this.#zkEvmAddress,
22724
+ rpcProvider: this.#rpcProvider,
22725
+ guardianClient: this.#guardianClient,
22726
+ relayerClient: this.#relayerClient,
22727
+ flow,
22728
+ });
22729
+ });
22730
+ }
22731
+ catch (error) {
22732
+ let errorMessage = 'Unknown error';
22733
+ if (error instanceof Error) {
22734
+ errorMessage = error.message;
22735
+ }
22736
+ flow.addEvent('error', { errorMessage });
22737
+ throw error;
22738
+ }
22739
+ finally {
22740
+ flow.end();
22741
+ }
22742
+ }
22410
22743
  case 'eth_signTypedData':
22411
22744
  case 'eth_signTypedData_v4': {
22412
22745
  if (!this.#zkEvmAddress) {