@imtbl/sdk 0.28.10 → 0.29.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.
@@ -554,16 +554,25 @@ declare class ImmutableConfiguration {
554
554
  readonly environment: Environment;
555
555
  readonly rateLimitingKey?: string;
556
556
  readonly apiKey?: string;
557
- readonly clientAppId?: string;
557
+ readonly publishableKey?: string;
558
558
  constructor(options: {
559
559
  environment: Environment;
560
- rateLimitingKey?: string;
561
- apiKey?: string;
562
- clientAppId?: string;
563
560
  });
564
561
  }
562
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
563
+ apiKey: 'required';
564
+ } ? Required<{
565
+ apiKey: string;
566
+ }> : {}) & (T extends {
567
+ publishableKey: 'required';
568
+ } ? Required<{
569
+ publishableKey: string;
570
+ }> : {});
571
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
572
+ apiKey: 'omit';
573
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
565
574
  interface ModuleConfiguration<T> {
566
- baseConfig: ImmutableConfiguration;
575
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
567
576
  overrides?: T;
568
577
  }
569
578
 
@@ -20,27 +20,9 @@ class ImmutableConfiguration {
20
20
  environment;
21
21
  rateLimitingKey;
22
22
  apiKey;
23
- clientAppId;
23
+ publishableKey;
24
24
  constructor(options) {
25
25
  this.environment = options.environment;
26
- if (options.rateLimitingKey) {
27
- this.rateLimitingKey = options.rateLimitingKey;
28
- globalAxios.defaults.headers.common['x-api-key'] = this.rateLimitingKey;
29
- }
30
- if (options.apiKey) {
31
- if (!options.apiKey.startsWith('sk_imapik-')) {
32
- throw new Error('Invalid API key');
33
- }
34
- this.apiKey = options.apiKey;
35
- globalAxios.defaults.headers.common['x-immutable-api-key'] = this.apiKey;
36
- }
37
- if (options.clientAppId) {
38
- if (!options.clientAppId.startsWith('cai_imapik-')) {
39
- throw new Error('Invalid Client App Id');
40
- }
41
- this.clientAppId = options.clientAppId;
42
- globalAxios.defaults.headers.common['x-immutable-client-app-id'] = this.clientAppId;
43
- }
44
26
  }
45
27
  }
46
28
 
@@ -20790,7 +20772,7 @@ class APIError extends Error {
20790
20772
 
20791
20773
  /* eslint-disable implicit-arrow-linebreak */
20792
20774
  const defaultHeaders = {
20793
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.10',
20775
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.29.0',
20794
20776
  };
20795
20777
  /**
20796
20778
  * createAPIConfiguration to create a custom Configuration
@@ -8,16 +8,25 @@ declare class ImmutableConfiguration {
8
8
  readonly environment: Environment;
9
9
  readonly rateLimitingKey?: string;
10
10
  readonly apiKey?: string;
11
- readonly clientAppId?: string;
11
+ readonly publishableKey?: string;
12
12
  constructor(options: {
13
13
  environment: Environment;
14
- rateLimitingKey?: string;
15
- apiKey?: string;
16
- clientAppId?: string;
17
14
  });
18
15
  }
16
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
17
+ apiKey: 'required';
18
+ } ? Required<{
19
+ apiKey: string;
20
+ }> : {}) & (T extends {
21
+ publishableKey: 'required';
22
+ } ? Required<{
23
+ publishableKey: string;
24
+ }> : {});
25
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
26
+ apiKey: 'omit';
27
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
19
28
  interface ModuleConfiguration<T> {
20
- baseConfig: ImmutableConfiguration;
29
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
21
30
  overrides?: T;
22
31
  }
23
32
 
@@ -25,7 +25,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
25
25
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
26
26
 
27
27
 
28
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.28.10";
28
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.29.0";
29
29
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
30
30
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
31
31
 
package/dist/config.d.ts CHANGED
@@ -6,17 +6,29 @@ declare class ImmutableConfiguration {
6
6
  readonly environment: Environment;
7
7
  readonly rateLimitingKey?: string;
8
8
  readonly apiKey?: string;
9
- readonly clientAppId?: string;
9
+ readonly publishableKey?: string;
10
10
  constructor(options: {
11
11
  environment: Environment;
12
- rateLimitingKey?: string;
13
- apiKey?: string;
14
- clientAppId?: string;
15
12
  });
16
13
  }
14
+ declare const addApiKeyToAxiosHeader: (apiKey: string) => void;
15
+ declare const addPublishableKeyToAxiosHeader: (publishableKey: string) => void;
16
+ declare const addRateLimitingKeyToAxiosHeader: (rateLimitingKey: string) => void;
17
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
18
+ apiKey: 'required';
19
+ } ? Required<{
20
+ apiKey: string;
21
+ }> : {}) & (T extends {
22
+ publishableKey: 'required';
23
+ } ? Required<{
24
+ publishableKey: string;
25
+ }> : {});
26
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
27
+ apiKey: 'omit';
28
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
17
29
  interface ModuleConfiguration<T> {
18
- baseConfig: ImmutableConfiguration;
30
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
19
31
  overrides?: T;
20
32
  }
21
33
 
22
- export { Environment, ImmutableConfiguration, ModuleConfiguration };
34
+ export { Environment, ImmutableConfiguration, ModuleConfiguration, addApiKeyToAxiosHeader, addPublishableKeyToAxiosHeader, addRateLimitingKeyToAxiosHeader };
package/dist/config.js CHANGED
@@ -9,28 +9,29 @@ class ImmutableConfiguration {
9
9
  environment;
10
10
  rateLimitingKey;
11
11
  apiKey;
12
- clientAppId;
12
+ publishableKey;
13
13
  constructor(options) {
14
14
  this.environment = options.environment;
15
- if (options.rateLimitingKey) {
16
- this.rateLimitingKey = options.rateLimitingKey;
17
- axios.defaults.headers.common['x-api-key'] = this.rateLimitingKey;
18
- }
19
- if (options.apiKey) {
20
- if (!options.apiKey.startsWith('sk_imapik-')) {
21
- throw new Error('Invalid API key');
22
- }
23
- this.apiKey = options.apiKey;
24
- axios.defaults.headers.common['x-immutable-api-key'] = this.apiKey;
25
- }
26
- if (options.clientAppId) {
27
- if (!options.clientAppId.startsWith('cai_imapik-')) {
28
- throw new Error('Invalid Client App Id');
29
- }
30
- this.clientAppId = options.clientAppId;
31
- axios.defaults.headers.common['x-immutable-client-app-id'] = this.clientAppId;
32
- }
33
15
  }
34
16
  }
17
+ const API_KEY_PREFIX = 'sk_imapik-';
18
+ const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
19
+ const PUBLISHABLE_KEY_LENGTH = 30;
20
+ const addApiKeyToAxiosHeader = (apiKey) => {
21
+ if (!apiKey.startsWith(API_KEY_PREFIX)) {
22
+ throw new Error('Invalid API key. Create your api key in Immutable developer hub. https://hub.immutable.com');
23
+ }
24
+ axios.defaults.headers.common['x-immutable-api-key'] = apiKey;
25
+ };
26
+ const addPublishableKeyToAxiosHeader = (publishableKey) => {
27
+ if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX) || publishableKey.length !== PUBLISHABLE_KEY_LENGTH) {
28
+ throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
29
+ + ' https://hub.immutable.com');
30
+ }
31
+ axios.defaults.headers.common['x-immutable-publishable-key'] = publishableKey;
32
+ };
33
+ const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
34
+ axios.defaults.headers.common['x-api-key'] = rateLimitingKey;
35
+ };
35
36
 
36
- export { Environment, ImmutableConfiguration };
37
+ export { Environment, ImmutableConfiguration, addApiKeyToAxiosHeader, addPublishableKeyToAxiosHeader, addRateLimitingKeyToAxiosHeader };
@@ -9742,16 +9742,25 @@ declare class ImmutableConfiguration {
9742
9742
  readonly environment: Environment;
9743
9743
  readonly rateLimitingKey?: string;
9744
9744
  readonly apiKey?: string;
9745
- readonly clientAppId?: string;
9745
+ readonly publishableKey?: string;
9746
9746
  constructor(options: {
9747
9747
  environment: Environment;
9748
- rateLimitingKey?: string;
9749
- apiKey?: string;
9750
- clientAppId?: string;
9751
9748
  });
9752
9749
  }
9750
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
9751
+ apiKey: 'required';
9752
+ } ? Required<{
9753
+ apiKey: string;
9754
+ }> : {}) & (T extends {
9755
+ publishableKey: 'required';
9756
+ } ? Required<{
9757
+ publishableKey: string;
9758
+ }> : {});
9759
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
9760
+ apiKey: 'omit';
9761
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
9753
9762
  interface ModuleConfiguration<T> {
9754
- baseConfig: ImmutableConfiguration;
9763
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
9755
9764
  overrides?: T;
9756
9765
  }
9757
9766
 
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
17
17
  chainID,
18
18
  coreContractAddress,
19
19
  registrationContractAddress,
20
- sdkVersion: 'ts-immutable-sdk-0.28.10',
20
+ sdkVersion: 'ts-immutable-sdk-0.29.0',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build