@imtbl/sdk 0.27.3 → 0.27.5

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
@@ -114,8 +114,6 @@ let Configuration$1 = class Configuration {
114
114
  * https://openapi-generator.tech
115
115
  * Do not edit the class manually.
116
116
  */
117
- // Some imports not used depending on template conditions
118
- // @ts-ignore
119
117
  const BASE_PATH$1 = "https://api.sandbox.immutable.com".replace(/\/+$/, "");
120
118
  /**
121
119
  *
@@ -143,10 +141,10 @@ let BaseAPI$1 = class BaseAPI {
143
141
  */
144
142
  let RequiredError$1 = class RequiredError extends Error {
145
143
  field;
146
- name = "RequiredError";
147
144
  constructor(field, msg) {
148
145
  super(msg);
149
146
  this.field = field;
147
+ this.name = "RequiredError";
150
148
  }
151
149
  };
152
150
 
@@ -203,6 +201,8 @@ const setBearerAuthToObject$1 = async function (object, configuration) {
203
201
  }
204
202
  };
205
203
  function setFlattenedQueryParams$1(urlSearchParams, parameter, key = "") {
204
+ if (parameter == null)
205
+ return;
206
206
  if (typeof parameter === "object") {
207
207
  if (Array.isArray(parameter)) {
208
208
  parameter.forEach(item => setFlattenedQueryParams$1(urlSearchParams, item, key));
@@ -255,7 +255,7 @@ const toPathString$1 = function (url) {
255
255
  */
256
256
  const createRequestFunction$1 = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
257
257
  return (axios = globalAxios, basePath = BASE_PATH) => {
258
- const axiosRequestArgs = { ...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url };
258
+ const axiosRequestArgs = { ...axiosArgs.options, url: (configuration?.basePath || axios.defaults.baseURL || basePath) + axiosArgs.url };
259
259
  return axios.request(axiosRequestArgs);
260
260
  };
261
261
  };
@@ -1609,8 +1609,8 @@ const OrdersApiAxiosParamCreator = function (configuration) {
1609
1609
  * @param {string} [buyItemContractAddress] Buy item contract address to filter by
1610
1610
  * @param {string} [sellItemTokenId] Sell item token identifier to filter by
1611
1611
  * @param {number} [pageSize] Maximum number of orders to return per page
1612
- * @param {'created_at' | 'updated_at' | 'buy_item_amount'} [sortBy] Order field to sort by
1613
- * @param {'asc' | 'desc'} [sortDirection] Ascending or descending direction for sort
1612
+ * @param {ListListingsSortByEnum} [sortBy] Order field to sort by
1613
+ * @param {ListListingsSortDirectionEnum} [sortDirection] Ascending or descending direction for sort
1614
1614
  * @param {string} [pageCursor] Page cursor to retrieve previous or next page. Use the value returned in the response.
1615
1615
  * @param {*} [options] Override http request option.
1616
1616
  * @throws {RequiredError}
@@ -1667,8 +1667,8 @@ const OrdersApiAxiosParamCreator = function (configuration) {
1667
1667
  * @param {string} chainName
1668
1668
  * @param {string} [accountAddress]
1669
1669
  * @param {number} [pageSize] Maximum number of trades to return per page
1670
- * @param {'indexed_at'} [sortBy] Trade field to sort by
1671
- * @param {'asc' | 'desc'} [sortDirection] Ascending or descending direction for sort
1670
+ * @param {ListTradesSortByEnum} [sortBy] Trade field to sort by
1671
+ * @param {ListTradesSortDirectionEnum} [sortDirection] Ascending or descending direction for sort
1672
1672
  * @param {string} [pageCursor] Page cursor to retrieve previous or next page. Use the value returned in the response.
1673
1673
  * @param {*} [options] Override http request option.
1674
1674
  * @throws {RequiredError}
@@ -1788,8 +1788,8 @@ const OrdersApiFp = function (configuration) {
1788
1788
  * @param {string} [buyItemContractAddress] Buy item contract address to filter by
1789
1789
  * @param {string} [sellItemTokenId] Sell item token identifier to filter by
1790
1790
  * @param {number} [pageSize] Maximum number of orders to return per page
1791
- * @param {'created_at' | 'updated_at' | 'buy_item_amount'} [sortBy] Order field to sort by
1792
- * @param {'asc' | 'desc'} [sortDirection] Ascending or descending direction for sort
1791
+ * @param {ListListingsSortByEnum} [sortBy] Order field to sort by
1792
+ * @param {ListListingsSortDirectionEnum} [sortDirection] Ascending or descending direction for sort
1793
1793
  * @param {string} [pageCursor] Page cursor to retrieve previous or next page. Use the value returned in the response.
1794
1794
  * @param {*} [options] Override http request option.
1795
1795
  * @throws {RequiredError}
@@ -1804,8 +1804,8 @@ const OrdersApiFp = function (configuration) {
1804
1804
  * @param {string} chainName
1805
1805
  * @param {string} [accountAddress]
1806
1806
  * @param {number} [pageSize] Maximum number of trades to return per page
1807
- * @param {'indexed_at'} [sortBy] Trade field to sort by
1808
- * @param {'asc' | 'desc'} [sortDirection] Ascending or descending direction for sort
1807
+ * @param {ListTradesSortByEnum} [sortBy] Trade field to sort by
1808
+ * @param {ListTradesSortDirectionEnum} [sortDirection] Ascending or descending direction for sort
1809
1809
  * @param {string} [pageCursor] Page cursor to retrieve previous or next page. Use the value returned in the response.
1810
1810
  * @param {*} [options] Override http request option.
1811
1811
  * @throws {RequiredError}
@@ -2072,7 +2072,7 @@ class MultiRollupApiClients {
2072
2072
  }
2073
2073
 
2074
2074
  // eslint-disable-next-line @typescript-eslint/naming-convention
2075
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.3' };
2075
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.5' };
2076
2076
  const createConfig = ({ basePath, headers, }) => {
2077
2077
  if (!basePath.trim()) {
2078
2078
  throw Error('basePath can not be empty');
@@ -2128,7 +2128,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2128
2128
  chainID,
2129
2129
  coreContractAddress,
2130
2130
  registrationContractAddress,
2131
- sdkVersion: 'ts-immutable-sdk-0.27.3',
2131
+ sdkVersion: 'ts-immutable-sdk-0.27.5',
2132
2132
  });
2133
2133
  /**
2134
2134
  * Sets `sdkVersion` at the time of build
@@ -7036,13 +7036,14 @@ class MagicAdapter {
7036
7036
  magicClient;
7037
7037
  constructor(config) {
7038
7038
  this.config = config;
7039
+ this.magicClient = new Magic(this.config.magicPublishableApiKey, {
7040
+ extensions: [new OpenIdExtension()],
7041
+ network: config.network,
7042
+ });
7043
+ this.magicClient.preload();
7039
7044
  }
7040
- async login(idToken, network) {
7045
+ async login(idToken) {
7041
7046
  return withPassportError(async () => {
7042
- this.magicClient = new Magic(this.config.magicPublishableApiKey, {
7043
- extensions: [new OpenIdExtension()],
7044
- network,
7045
- });
7046
7047
  await this.magicClient.openid.loginWithOIDC({
7047
7048
  jwt: idToken,
7048
7049
  providerId: this.config.magicProviderId,
@@ -7051,7 +7052,7 @@ class MagicAdapter {
7051
7052
  }, PassportErrorType.WALLET_CONNECTION_ERROR);
7052
7053
  }
7053
7054
  async logout() {
7054
- if (this.magicClient?.user) {
7055
+ if (this.magicClient.user) {
7055
7056
  await this.magicClient.user.logout();
7056
7057
  }
7057
7058
  }
@@ -7416,8 +7417,10 @@ async function cancelOrder({ user, starkSigner, request, ordersApi, guardianClie
7416
7417
 
7417
7418
  async function registerPassport({ ethSigner, starkSigner, usersApi }, authorization) {
7418
7419
  return withPassportError(async () => {
7419
- const userAddress = await ethSigner.getAddress();
7420
- const starkPublicKey = await starkSigner.getAddress();
7420
+ const [userAddress, starkPublicKey] = await Promise.all([
7421
+ ethSigner.getAddress(),
7422
+ starkSigner.getAddress(),
7423
+ ]);
7421
7424
  const signableResult = await usersApi.getSignableRegistrationOffchain({
7422
7425
  getSignableRegistrationRequest: {
7423
7426
  ether_key: userAddress,
@@ -7425,8 +7428,10 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
7425
7428
  },
7426
7429
  });
7427
7430
  const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
7428
- const ethSignature = await signRaw(signableMessage, ethSigner);
7429
- const starkSignature = await starkSigner.signMessage(payloadHash);
7431
+ const [ethSignature, starkSignature] = await Promise.all([
7432
+ signRaw(signableMessage, ethSigner),
7433
+ starkSigner.signMessage(payloadHash),
7434
+ ]);
7430
7435
  const response = await usersApi.registerPassportUser({
7431
7436
  authorization: `Bearer ${authorization}`,
7432
7437
  registerPassportUserRequest: {
@@ -7751,7 +7756,7 @@ class PassportImxProviderFactory {
7751
7756
  if (!user.idToken) {
7752
7757
  throw new PassportError('Failed to initialise', PassportErrorType.WALLET_CONNECTION_ERROR);
7753
7758
  }
7754
- const magicRpcProvider = await this.magicAdapter.login(user.idToken, this.config.network);
7759
+ const magicRpcProvider = await this.magicAdapter.login(user.idToken);
7755
7760
  const web3Provider = new Web3Provider(magicRpcProvider);
7756
7761
  const ethSigner = web3Provider.getSigner();
7757
7762
  const starkSigner = await getStarkSigner(ethSigner);
@@ -8297,7 +8302,7 @@ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupAp
8297
8302
  if (!user.idToken) {
8298
8303
  throw new Error('User is missing idToken');
8299
8304
  }
8300
- const magicProvider = await magicAdapter.login(user.idToken, config.network);
8305
+ const magicProvider = await magicAdapter.login(user.idToken);
8301
8306
  if (!user.zkEvm) {
8302
8307
  // Generate counterfactual address and retrieve updated Auth0 user
8303
8308
  const userZkevm = await registerZkEvmUser({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.27.3",
4
+ "version": "0.27.5",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",