@imtbl/sdk 0.28.10 → 0.29.0-alpha.1

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/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-alpha.1',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build