@imtbl/sdk 1.43.3 → 1.43.4
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.d-011d5035.d.ts +224 -0
- package/dist/blockchain-data.d-1634b683.d.ts +3406 -0
- package/dist/blockchain_data-d989298c.js +1 -0
- package/dist/blockchain_data.d-d538f8d4.d.ts +4543 -0
- package/dist/blockchain_data.d.ts +3 -7950
- package/dist/blockchain_data.js +1 -6058
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/checkout-68675dd1.js +16 -0
- package/dist/checkout.d-ae9ca847.d.ts +3392 -0
- package/dist/checkout.d.ts +7 -16882
- package/dist/checkout.js +1 -37189
- package/dist/config-53a9a4ca.js +1 -0
- package/dist/config.d-65420620.d.ts +18 -0
- package/dist/config.d.ts +1 -30
- package/dist/config.js +1 -394
- package/dist/event-types.d-42520276.d.ts +332 -0
- package/dist/imxProvider.d-cac9e315.d.ts +12538 -0
- package/dist/index-14aad537.js +1 -0
- package/dist/index-3951cdf0.js +1 -0
- package/dist/index-3f40d7f6.js +1 -0
- package/dist/index-58a79c29.js +1 -0
- package/dist/index-96599707.js +1 -0
- package/dist/index-e7002486.js +1 -0
- package/dist/index.browser.js +4 -4
- package/dist/index.cjs +7 -7
- package/dist/index.d-c4a4c17d.d.ts +277 -0
- package/dist/index.d-f0845744.d.ts +30 -0
- package/dist/index.d-f1471830.d.ts +376 -0
- package/dist/index.d.ts +18 -32627
- package/dist/index.js +1 -64124
- package/dist/json-rpc-provider.d-5c038bd9.d.ts +249 -0
- package/dist/minting_backend-04aef147.js +1 -0
- package/dist/minting_backend.d-4754ffee.d.ts +104 -0
- package/dist/minting_backend.d.ts +5 -3535
- package/dist/minting_backend.js +1 -6756
- package/dist/orderbook-e71036df.js +1 -0
- package/dist/orderbook.d-77162c6c.d.ts +1257 -0
- package/dist/orderbook.d.ts +5 -1713
- package/dist/orderbook.js +1 -2479
- package/dist/passport-0f45e532.js +1 -0
- package/dist/passport.d-d3f44798.d.ts +67 -0
- package/dist/passport.d.ts +6 -13703
- package/dist/passport.js +1 -23137
- package/dist/transfer.d-87728423.d.ts +898 -0
- package/dist/webhook-a16541bb.js +1 -0
- package/dist/webhook.d-4c3cb340.d.ts +75 -0
- package/dist/webhook.d.ts +4 -1265
- package/dist/webhook.js +1 -488
- package/dist/x-a5b39578.js +1 -0
- package/dist/x.d-1b51f0c3.d.ts +4879 -0
- package/dist/x.d.ts +6 -18663
- package/dist/x.js +1 -19242
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,I as r,K as a,a as t}from"./index-14aad537.js";var n=Object.freeze({__proto__:null,get Environment(){return e},ImmutableConfiguration:r,get KeyHeaders(){return a},addKeysToHeadersOverride:t});export{n as c};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, M as ModuleConfiguration, a as addKeysToHeadersOverride } from './index.d-f0845744.js';
|
|
2
|
+
|
|
3
|
+
declare const config_d_Environment: typeof Environment;
|
|
4
|
+
declare const config_d_ImmutableConfiguration: typeof ImmutableConfiguration;
|
|
5
|
+
declare const config_d_KeyHeaders: typeof KeyHeaders;
|
|
6
|
+
declare const config_d_ModuleConfiguration: typeof ModuleConfiguration;
|
|
7
|
+
declare const config_d_addKeysToHeadersOverride: typeof addKeysToHeadersOverride;
|
|
8
|
+
declare namespace config_d {
|
|
9
|
+
export {
|
|
10
|
+
config_d_Environment as Environment,
|
|
11
|
+
config_d_ImmutableConfiguration as ImmutableConfiguration,
|
|
12
|
+
config_d_KeyHeaders as KeyHeaders,
|
|
13
|
+
config_d_ModuleConfiguration as ModuleConfiguration,
|
|
14
|
+
config_d_addKeysToHeadersOverride as addKeysToHeadersOverride,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { config_d as c };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
PRODUCTION = "production",
|
|
3
|
-
SANDBOX = "sandbox"
|
|
4
|
-
}
|
|
5
|
-
declare enum KeyHeaders {
|
|
6
|
-
API_KEY = "x-immutable-api-key",
|
|
7
|
-
PUBLISHABLE_KEY = "x-immutable-publishable-key",
|
|
8
|
-
RATE_LIMITING_KEY = "x-api-key"
|
|
9
|
-
}
|
|
10
|
-
declare class ImmutableConfiguration {
|
|
11
|
-
readonly environment: Environment;
|
|
12
|
-
readonly rateLimitingKey?: string;
|
|
13
|
-
readonly apiKey?: string;
|
|
14
|
-
readonly publishableKey?: string;
|
|
15
|
-
constructor(options: {
|
|
16
|
-
environment: Environment;
|
|
17
|
-
rateLimitingKey?: string;
|
|
18
|
-
apiKey?: string;
|
|
19
|
-
publishableKey?: string;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
declare const addKeysToHeadersOverride: <T extends {
|
|
23
|
-
headers?: Record<string, string> | undefined;
|
|
24
|
-
}>(baseConfig: ImmutableConfiguration | undefined, overrides: T | undefined) => T | undefined;
|
|
25
|
-
interface ModuleConfiguration<T> {
|
|
26
|
-
baseConfig: ImmutableConfiguration;
|
|
27
|
-
overrides?: T;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Environment, ImmutableConfiguration, KeyHeaders, ModuleConfiguration, addKeysToHeadersOverride };
|
|
1
|
+
export { E as Environment, I as ImmutableConfiguration, K as KeyHeaders, M as ModuleConfiguration, a as addKeysToHeadersOverride } from './index.d-f0845744.js';
|
package/dist/config.js
CHANGED
|
@@ -1,394 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { memorise } from 'lru-memorise';
|
|
3
|
-
import { getGlobalisedValue as getGlobalisedValue$1 } from 'global-const';
|
|
4
|
-
|
|
5
|
-
const isNode = () => typeof window === 'undefined';
|
|
6
|
-
const isBrowser = () => !isNode();
|
|
7
|
-
|
|
8
|
-
var Detail;
|
|
9
|
-
(function (Detail) {
|
|
10
|
-
Detail["RUNTIME_ID"] = "rid";
|
|
11
|
-
Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
|
|
12
|
-
Detail["ENVIRONMENT"] = "env";
|
|
13
|
-
Detail["PUBLISHABLE_API_KEY"] = "pak";
|
|
14
|
-
Detail["IDENTITY"] = "uid";
|
|
15
|
-
Detail["DOMAIN"] = "domain";
|
|
16
|
-
Detail["SDK_VERSION"] = "sdkVersion";
|
|
17
|
-
})(Detail || (Detail = {}));
|
|
18
|
-
|
|
19
|
-
const IMTBL_API = 'https://api.immutable.com';
|
|
20
|
-
async function post(path, data) {
|
|
21
|
-
const client = axios.create({
|
|
22
|
-
baseURL: IMTBL_API,
|
|
23
|
-
});
|
|
24
|
-
const payload = JSON.stringify(data);
|
|
25
|
-
const body = {
|
|
26
|
-
payload: Buffer.from(payload).toString('base64'),
|
|
27
|
-
};
|
|
28
|
-
const response = await client.post(path, body);
|
|
29
|
-
return response.data;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Abstraction on localstorage
|
|
34
|
-
*/
|
|
35
|
-
const localStoragePrefix = '__IMX-';
|
|
36
|
-
const hasLocalstorage = () => isBrowser() && window.localStorage;
|
|
37
|
-
const parseItem = (payload) => {
|
|
38
|
-
// Try to parse, if can't be parsed assume string
|
|
39
|
-
// and return string
|
|
40
|
-
if (payload === null)
|
|
41
|
-
return undefined;
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(payload);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
// Assumes it's a string.
|
|
47
|
-
return payload;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const serialiseItem = (payload) => {
|
|
51
|
-
if (typeof payload === 'string') {
|
|
52
|
-
return payload;
|
|
53
|
-
}
|
|
54
|
-
return JSON.stringify(payload);
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* GenKey will take into account the namespace
|
|
58
|
-
* as well as if being run in the Link, it will tap into the link
|
|
59
|
-
* @param {string} key
|
|
60
|
-
* @returns key
|
|
61
|
-
*/
|
|
62
|
-
const genKey = (key) => `${localStoragePrefix}${key}`;
|
|
63
|
-
function getItem(key) {
|
|
64
|
-
if (hasLocalstorage()) {
|
|
65
|
-
return parseItem(window.localStorage.getItem(genKey(key)));
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
const setItem = (key, payload) => {
|
|
70
|
-
if (hasLocalstorage()) {
|
|
71
|
-
window.localStorage.setItem(genKey(key), serialiseItem(payload));
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var Store;
|
|
78
|
-
(function (Store) {
|
|
79
|
-
Store["EVENTS"] = "events";
|
|
80
|
-
Store["RUNTIME"] = "runtime";
|
|
81
|
-
})(Store || (Store = {}));
|
|
82
|
-
// In memory storage for events and other data
|
|
83
|
-
let EVENT_STORE;
|
|
84
|
-
let RUNTIME_DETAILS;
|
|
85
|
-
// Initialise store and runtime
|
|
86
|
-
const initialise$1 = () => {
|
|
87
|
-
EVENT_STORE = getItem(Store.EVENTS) || [];
|
|
88
|
-
RUNTIME_DETAILS = getItem(Store.RUNTIME) || {};
|
|
89
|
-
};
|
|
90
|
-
initialise$1();
|
|
91
|
-
// Runtime Details
|
|
92
|
-
const storeDetail = (key, value) => {
|
|
93
|
-
RUNTIME_DETAILS = {
|
|
94
|
-
...RUNTIME_DETAILS,
|
|
95
|
-
[key]: value,
|
|
96
|
-
};
|
|
97
|
-
setItem(Store.RUNTIME, RUNTIME_DETAILS);
|
|
98
|
-
};
|
|
99
|
-
const getDetail$1 = (key) => {
|
|
100
|
-
// Handle the scenario where detail is a falsy value
|
|
101
|
-
if (RUNTIME_DETAILS[key] === undefined) {
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
return RUNTIME_DETAILS[key];
|
|
105
|
-
};
|
|
106
|
-
const getAllDetails = () => RUNTIME_DETAILS;
|
|
107
|
-
// Events
|
|
108
|
-
const getEvents = () => EVENT_STORE;
|
|
109
|
-
const addEvent = (event) => {
|
|
110
|
-
EVENT_STORE.push(event);
|
|
111
|
-
setItem(Store.EVENTS, EVENT_STORE);
|
|
112
|
-
};
|
|
113
|
-
const removeSentEvents = (numberOfEvents) => {
|
|
114
|
-
EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
|
|
115
|
-
setItem(Store.EVENTS, EVENT_STORE);
|
|
116
|
-
};
|
|
117
|
-
const flattenProperties = (properties) => {
|
|
118
|
-
const propertyMap = [];
|
|
119
|
-
Object.entries(properties).forEach(([key, value]) => {
|
|
120
|
-
if (typeof key === 'string'
|
|
121
|
-
|| typeof value === 'string'
|
|
122
|
-
|| typeof value === 'number'
|
|
123
|
-
|| typeof value === 'boolean') {
|
|
124
|
-
propertyMap.push([key, value.toString()]);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return propertyMap;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
131
|
-
const SDK_VERSION = '1.43.3';
|
|
132
|
-
const getFrameParentDomain = () => {
|
|
133
|
-
if (isNode()) {
|
|
134
|
-
return '';
|
|
135
|
-
}
|
|
136
|
-
// If available for supported browsers (all except Firefox)
|
|
137
|
-
if (window.location.ancestorOrigins
|
|
138
|
-
&& window.location.ancestorOrigins.length > 0) {
|
|
139
|
-
return new URL(window.location.ancestorOrigins[0]).hostname;
|
|
140
|
-
}
|
|
141
|
-
// Fallback to using the referrer
|
|
142
|
-
return document.referrer ? new URL(window.document.referrer).hostname : '';
|
|
143
|
-
};
|
|
144
|
-
const runtimeHost = () => {
|
|
145
|
-
if (isNode()) {
|
|
146
|
-
return '';
|
|
147
|
-
}
|
|
148
|
-
let domain;
|
|
149
|
-
try {
|
|
150
|
-
if (window.self !== window.top) {
|
|
151
|
-
domain = getFrameParentDomain();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
// Do nothing
|
|
156
|
-
}
|
|
157
|
-
// Fallback to current domain if can't detect parent domain
|
|
158
|
-
if (!domain) {
|
|
159
|
-
domain = window.location.hostname;
|
|
160
|
-
}
|
|
161
|
-
return domain;
|
|
162
|
-
};
|
|
163
|
-
const getRuntimeDetails = () => {
|
|
164
|
-
storeDetail(Detail.SDK_VERSION, SDK_VERSION);
|
|
165
|
-
if (isNode()) {
|
|
166
|
-
return { browser: 'nodejs', sdkVersion: SDK_VERSION };
|
|
167
|
-
}
|
|
168
|
-
const domain = runtimeHost();
|
|
169
|
-
if (domain) {
|
|
170
|
-
storeDetail(Detail.DOMAIN, domain);
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
sdkVersion: SDK_VERSION,
|
|
174
|
-
browser: window.navigator.userAgent,
|
|
175
|
-
domain,
|
|
176
|
-
tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
177
|
-
screen: `${window.screen.width}x${window.screen.height}`,
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
let initialised = false;
|
|
181
|
-
const isInitialised = () => initialised;
|
|
182
|
-
const initialise = async () => {
|
|
183
|
-
initialised = true;
|
|
184
|
-
try {
|
|
185
|
-
const runtimeDetails = flattenProperties(getRuntimeDetails());
|
|
186
|
-
const existingRuntimeId = getDetail$1(Detail.RUNTIME_ID);
|
|
187
|
-
const body = {
|
|
188
|
-
version: 1,
|
|
189
|
-
data: {
|
|
190
|
-
runtimeDetails,
|
|
191
|
-
runtimeId: existingRuntimeId,
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
const response = await post('/v1/sdk/initialise', body);
|
|
195
|
-
// Get runtimeId and store it
|
|
196
|
-
const { runtimeId } = response;
|
|
197
|
-
storeDetail(Detail.RUNTIME_ID, runtimeId);
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
initialised = false;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
function errorBoundary(fn, fallbackResult) {
|
|
205
|
-
return (...args) => {
|
|
206
|
-
try {
|
|
207
|
-
// Execute the original function
|
|
208
|
-
const result = fn(...args);
|
|
209
|
-
if (result instanceof Promise) {
|
|
210
|
-
// Silent fail for now, in future
|
|
211
|
-
// we can send errors to a logging service
|
|
212
|
-
return result.catch(() => fallbackResult);
|
|
213
|
-
}
|
|
214
|
-
return result;
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
// As above, fail silently for now
|
|
218
|
-
return fallbackResult;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function isTestEnvironmentFn() {
|
|
224
|
-
if (isBrowser()) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
if (typeof process === 'undefined') {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
// Consider using `ci-info` package for better results, though might fail as not browser safe.
|
|
231
|
-
// Just use process.env.CI for now.
|
|
232
|
-
return process.env.JEST_WORKER_ID !== undefined;
|
|
233
|
-
}
|
|
234
|
-
const isTestEnvironment = errorBoundary(isTestEnvironmentFn, false);
|
|
235
|
-
|
|
236
|
-
const GLOBALISE_KEY = 'imtbl__metrics';
|
|
237
|
-
const MEMORISE_TIMEFRAME = 5000;
|
|
238
|
-
const MEMORISE_MAX = 1000;
|
|
239
|
-
const getGlobalisedValue = (key, value) => getGlobalisedValue$1(GLOBALISE_KEY, key, value);
|
|
240
|
-
const getGlobalisedCachedFunction = (key, fn) => {
|
|
241
|
-
// Some applications (esp backend, or frontends using the split bundles) can sometimes
|
|
242
|
-
// initialise the same request multiple times. This will prevent multiple of the
|
|
243
|
-
// same event,value from being reported in a 1 second period.
|
|
244
|
-
const memorisedFn = memorise(fn, {
|
|
245
|
-
lruOptions: { ttl: MEMORISE_TIMEFRAME, max: MEMORISE_MAX },
|
|
246
|
-
});
|
|
247
|
-
return getGlobalisedValue$1(GLOBALISE_KEY, key, memorisedFn);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
const POLLING_FREQUENCY = 5000;
|
|
251
|
-
const trackFn = (moduleName, eventName, properties) => {
|
|
252
|
-
const event = {
|
|
253
|
-
event: `${moduleName}.${eventName}`,
|
|
254
|
-
time: new Date().toISOString(),
|
|
255
|
-
...(properties && { properties: flattenProperties(properties) }),
|
|
256
|
-
};
|
|
257
|
-
addEvent(event);
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Track an event completion.
|
|
261
|
-
* @param moduleName Name of the module being tracked (for namespacing purposes), e.g. `passport`
|
|
262
|
-
* @param eventName Name of the event, use camelCase e.g. `clickItem`
|
|
263
|
-
* @param properties Other properties to be sent with the event
|
|
264
|
-
*
|
|
265
|
-
* e.g.
|
|
266
|
-
*
|
|
267
|
-
* ```ts
|
|
268
|
-
* track("passport", "performTransaction");
|
|
269
|
-
* track("passport", "performTransaction", { transationType: "transfer" });
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
const track = errorBoundary(getGlobalisedCachedFunction('track', trackFn));
|
|
273
|
-
// Sending events to the server
|
|
274
|
-
const flushFn = async () => {
|
|
275
|
-
// Don't flush if not initialised
|
|
276
|
-
if (isInitialised() === false) {
|
|
277
|
-
await initialise();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const events = getEvents();
|
|
281
|
-
if (events.length === 0) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
// Track events length here, incase
|
|
285
|
-
const numEvents = events.length;
|
|
286
|
-
// Get details and send it with the track request
|
|
287
|
-
const details = getAllDetails();
|
|
288
|
-
const metricsPayload = {
|
|
289
|
-
version: 1,
|
|
290
|
-
data: {
|
|
291
|
-
events,
|
|
292
|
-
details,
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
const response = await post('/v1/sdk/metrics', metricsPayload);
|
|
296
|
-
if (response instanceof Error) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
// Clear events if successfully posted
|
|
300
|
-
removeSentEvents(numEvents);
|
|
301
|
-
};
|
|
302
|
-
const flush = errorBoundary(flushFn);
|
|
303
|
-
// Flush events every 5 seconds
|
|
304
|
-
const flushPoll = async () => {
|
|
305
|
-
await flush();
|
|
306
|
-
setTimeout(flushPoll, POLLING_FREQUENCY);
|
|
307
|
-
};
|
|
308
|
-
let flushingStarted = false;
|
|
309
|
-
const startFlushing = () => {
|
|
310
|
-
if (flushingStarted) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
flushingStarted = true;
|
|
314
|
-
flushPoll();
|
|
315
|
-
};
|
|
316
|
-
// This will get initialised when module is imported.
|
|
317
|
-
if (!isTestEnvironment()) {
|
|
318
|
-
errorBoundary(getGlobalisedValue('startFlushing', startFlushing))();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const setEnvironmentFn = (env) => {
|
|
322
|
-
storeDetail(Detail.ENVIRONMENT, env);
|
|
323
|
-
};
|
|
324
|
-
const setEnvironment = errorBoundary(getGlobalisedValue('setEnvironment', setEnvironmentFn));
|
|
325
|
-
const setPassportClientIdFn = (passportClientId) => {
|
|
326
|
-
storeDetail(Detail.PASSPORT_CLIENT_ID, passportClientId);
|
|
327
|
-
};
|
|
328
|
-
errorBoundary(getGlobalisedValue('setPassportClientId', setPassportClientIdFn));
|
|
329
|
-
const setPublishableApiKeyFn = (publishableApiKey) => {
|
|
330
|
-
storeDetail(Detail.PUBLISHABLE_API_KEY, publishableApiKey);
|
|
331
|
-
};
|
|
332
|
-
const setPublishableApiKey = errorBoundary(getGlobalisedValue('setPublishableApiKey', setPublishableApiKeyFn));
|
|
333
|
-
errorBoundary(getGlobalisedValue('getDetail', getDetail$1));
|
|
334
|
-
|
|
335
|
-
var Environment;
|
|
336
|
-
(function (Environment) {
|
|
337
|
-
Environment["PRODUCTION"] = "production";
|
|
338
|
-
Environment["SANDBOX"] = "sandbox";
|
|
339
|
-
})(Environment || (Environment = {}));
|
|
340
|
-
var KeyHeaders;
|
|
341
|
-
(function (KeyHeaders) {
|
|
342
|
-
KeyHeaders["API_KEY"] = "x-immutable-api-key";
|
|
343
|
-
KeyHeaders["PUBLISHABLE_KEY"] = "x-immutable-publishable-key";
|
|
344
|
-
KeyHeaders["RATE_LIMITING_KEY"] = "x-api-key";
|
|
345
|
-
})(KeyHeaders || (KeyHeaders = {}));
|
|
346
|
-
class ImmutableConfiguration {
|
|
347
|
-
environment;
|
|
348
|
-
rateLimitingKey;
|
|
349
|
-
apiKey;
|
|
350
|
-
publishableKey;
|
|
351
|
-
constructor(options) {
|
|
352
|
-
this.environment = options.environment;
|
|
353
|
-
this.publishableKey = options.publishableKey;
|
|
354
|
-
this.apiKey = options.apiKey;
|
|
355
|
-
this.rateLimitingKey = options.rateLimitingKey;
|
|
356
|
-
setEnvironment(options.environment);
|
|
357
|
-
track('config', 'created_imtbl_config');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
// Adds publishableKey, apiKey, and rateLimitingKey to the headers of the overrides object
|
|
361
|
-
// if exists in base config. Otherwise returns the overrides object as is.
|
|
362
|
-
// Use this for openapi generated clients with security headers.
|
|
363
|
-
const addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
364
|
-
if (!baseConfig || (!baseConfig.apiKey && !baseConfig.publishableKey && !baseConfig.rateLimitingKey)) {
|
|
365
|
-
return overrides;
|
|
366
|
-
}
|
|
367
|
-
const newHeaders = {};
|
|
368
|
-
if (baseConfig.apiKey) {
|
|
369
|
-
newHeaders[KeyHeaders.API_KEY] = baseConfig.apiKey;
|
|
370
|
-
}
|
|
371
|
-
if (baseConfig.publishableKey) {
|
|
372
|
-
newHeaders[KeyHeaders.PUBLISHABLE_KEY] = baseConfig.publishableKey;
|
|
373
|
-
setPublishableApiKey(baseConfig.publishableKey);
|
|
374
|
-
}
|
|
375
|
-
if (baseConfig.rateLimitingKey) {
|
|
376
|
-
newHeaders[KeyHeaders.RATE_LIMITING_KEY] = baseConfig.rateLimitingKey;
|
|
377
|
-
}
|
|
378
|
-
// If overrides and overrides.headers exist, merge them with newHeaders, giving precedence to existing overrides
|
|
379
|
-
if (overrides && overrides.headers) {
|
|
380
|
-
return {
|
|
381
|
-
...overrides,
|
|
382
|
-
headers: {
|
|
383
|
-
...newHeaders,
|
|
384
|
-
...overrides.headers,
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
return {
|
|
389
|
-
...overrides,
|
|
390
|
-
headers: newHeaders,
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
export { Environment, ImmutableConfiguration, KeyHeaders, addKeysToHeadersOverride };
|
|
1
|
+
export{E as Environment,I as ImmutableConfiguration,K as KeyHeaders,a as addKeysToHeadersOverride}from"./index-14aad537.js";import"axios";import"lru-memorise";import"global-const";
|