@imtbl/sdk 0.45.3-alpha → 0.45.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/blockchain_data.d.ts +2 -2
- package/dist/blockchain_data.js +1 -239
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +61 -61
- package/dist/checkout.d.ts +2 -2
- package/dist/checkout.js +2 -500
- package/dist/config.d.ts +2 -2
- package/dist/config.js +0 -265
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -507
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -507
- package/dist/orderbook.d.ts +2 -2
- package/dist/orderbook.js +0 -238
- package/dist/passport.d.ts +2 -2
- package/dist/passport.js +2 -240
- package/dist/x.d.ts +2 -2
- package/dist/x.js +2 -240
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,268 +46,6 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
|
46
46
|
var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
|
|
47
47
|
var Uniswap__namespace = /*#__PURE__*/_interopNamespaceDefault(Uniswap);
|
|
48
48
|
|
|
49
|
-
const isNode$1 = () => typeof window === 'undefined';
|
|
50
|
-
const isBrowser$1 = () => !isNode$1();
|
|
51
|
-
|
|
52
|
-
var Detail$1;
|
|
53
|
-
(function (Detail) {
|
|
54
|
-
Detail["RUNTIME_ID"] = "rid";
|
|
55
|
-
Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
|
|
56
|
-
Detail["ENVIRONMENT"] = "env";
|
|
57
|
-
Detail["PUBLISHABLE_API_KEY"] = "pak";
|
|
58
|
-
Detail["IDENTITY"] = "uid";
|
|
59
|
-
Detail["DOMAIN"] = "domain";
|
|
60
|
-
})(Detail$1 || (Detail$1 = {}));
|
|
61
|
-
var Store$1;
|
|
62
|
-
(function (Store) {
|
|
63
|
-
Store["EVENTS"] = "events";
|
|
64
|
-
Store["RUNTIME"] = "runtime";
|
|
65
|
-
})(Store$1 || (Store$1 = {}));
|
|
66
|
-
const POLLING_FREQUENCY$1 = 5000;
|
|
67
|
-
|
|
68
|
-
const IMTBL_API$1 = 'https://api.x.immutable.com';
|
|
69
|
-
async function post$1(path, data) {
|
|
70
|
-
const client = globalAxios$1.create({
|
|
71
|
-
baseURL: IMTBL_API$1,
|
|
72
|
-
});
|
|
73
|
-
const payload = JSON.stringify(data);
|
|
74
|
-
const body = {
|
|
75
|
-
payload: btoa(payload),
|
|
76
|
-
};
|
|
77
|
-
const response = await client.post(path, body);
|
|
78
|
-
return response.data;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Abstraction on localstorage
|
|
83
|
-
*/
|
|
84
|
-
const localStoragePrefix$1 = '__IMX-';
|
|
85
|
-
const hasLocalstorage$1 = () => isBrowser$1() && window.localStorage;
|
|
86
|
-
const parseItem$1 = (payload) => {
|
|
87
|
-
// Try to parse, if can't be parsed assume string
|
|
88
|
-
// and return string
|
|
89
|
-
if (payload === null)
|
|
90
|
-
return undefined;
|
|
91
|
-
try {
|
|
92
|
-
return JSON.parse(payload);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
// Assumes it's a string.
|
|
96
|
-
return payload;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const serialiseItem$1 = (payload) => {
|
|
100
|
-
if (typeof payload === 'string') {
|
|
101
|
-
return payload;
|
|
102
|
-
}
|
|
103
|
-
return JSON.stringify(payload);
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* GenKey will take into account the namespace
|
|
107
|
-
* as well as if being run in the Link, it will tap into the link
|
|
108
|
-
* @param {string} key
|
|
109
|
-
* @returns key
|
|
110
|
-
*/
|
|
111
|
-
const genKey$1 = (key) => `${localStoragePrefix$1}${key}`;
|
|
112
|
-
function getItem$1(key) {
|
|
113
|
-
if (hasLocalstorage$1()) {
|
|
114
|
-
return parseItem$1(window.localStorage.getItem(genKey$1(key)));
|
|
115
|
-
}
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
const setItem$1 = (key, payload) => {
|
|
119
|
-
if (hasLocalstorage$1()) {
|
|
120
|
-
window.localStorage.setItem(genKey$1(key), serialiseItem$1(payload));
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// In memory storage for events and other data
|
|
127
|
-
let EVENT_STORE$1;
|
|
128
|
-
let RUNTIME_DETAILS$1;
|
|
129
|
-
// Initialise store and runtime
|
|
130
|
-
const initialise$1$1 = () => {
|
|
131
|
-
EVENT_STORE$1 = getItem$1(Store$1.EVENTS) || [];
|
|
132
|
-
RUNTIME_DETAILS$1 = getItem$1(Store$1.RUNTIME) || {};
|
|
133
|
-
};
|
|
134
|
-
initialise$1$1();
|
|
135
|
-
// Runtime Details
|
|
136
|
-
const storeDetail$1 = (key, value) => {
|
|
137
|
-
RUNTIME_DETAILS$1 = {
|
|
138
|
-
...RUNTIME_DETAILS$1,
|
|
139
|
-
[key]: value,
|
|
140
|
-
};
|
|
141
|
-
setItem$1(Store$1.RUNTIME, RUNTIME_DETAILS$1);
|
|
142
|
-
};
|
|
143
|
-
const getDetail$1 = (key) => {
|
|
144
|
-
// Handle the scenario where detail is a falsy value
|
|
145
|
-
if (RUNTIME_DETAILS$1[key] === undefined) {
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
return RUNTIME_DETAILS$1[key];
|
|
149
|
-
};
|
|
150
|
-
const getAllDetails$1 = () => RUNTIME_DETAILS$1;
|
|
151
|
-
// Events
|
|
152
|
-
const getEvents$1 = () => EVENT_STORE$1;
|
|
153
|
-
const addEvent = (event) => {
|
|
154
|
-
EVENT_STORE$1.push(event);
|
|
155
|
-
setItem$1(Store$1.EVENTS, EVENT_STORE$1);
|
|
156
|
-
};
|
|
157
|
-
const removeSentEvents$1 = (numberOfEvents) => {
|
|
158
|
-
EVENT_STORE$1 = EVENT_STORE$1.slice(numberOfEvents);
|
|
159
|
-
setItem$1(Store$1.EVENTS, EVENT_STORE$1);
|
|
160
|
-
};
|
|
161
|
-
const flattenProperties$1 = (properties) => {
|
|
162
|
-
const propertyMap = [];
|
|
163
|
-
Object.entries(properties).forEach(([key, value]) => {
|
|
164
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
165
|
-
propertyMap.push([key, value.toString()]);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return propertyMap;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
let initialised$1 = false;
|
|
172
|
-
const isInitialised$1 = () => initialised$1;
|
|
173
|
-
const getReferrer$1 = () => {
|
|
174
|
-
if (isNode$1()) {
|
|
175
|
-
return '';
|
|
176
|
-
}
|
|
177
|
-
if (window.location.ancestorOrigins
|
|
178
|
-
&& window.location.ancestorOrigins.length > 0) {
|
|
179
|
-
return new URL(window.location.ancestorOrigins[0]).hostname;
|
|
180
|
-
}
|
|
181
|
-
return document.referrer ? new URL(window.document.referrer).hostname : '';
|
|
182
|
-
};
|
|
183
|
-
const runtimeHost$1 = () => {
|
|
184
|
-
if (isNode$1()) {
|
|
185
|
-
return '';
|
|
186
|
-
}
|
|
187
|
-
if (window.opener || window.parent !== window) {
|
|
188
|
-
return getReferrer$1();
|
|
189
|
-
}
|
|
190
|
-
return new URL(window.location.href).hostname;
|
|
191
|
-
};
|
|
192
|
-
const getRuntimeDetails$1 = () => {
|
|
193
|
-
if (isNode$1()) {
|
|
194
|
-
return { browser: 'nodejs' };
|
|
195
|
-
}
|
|
196
|
-
const domain = runtimeHost$1();
|
|
197
|
-
if (domain) {
|
|
198
|
-
storeDetail$1(Detail$1.DOMAIN, domain);
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
browser: window.navigator.userAgent,
|
|
202
|
-
domain,
|
|
203
|
-
tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
204
|
-
screen: `${window.screen.width}x${window.screen.height}`,
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
const initialise$2 = async () => {
|
|
208
|
-
const runtimeDetails = flattenProperties$1(getRuntimeDetails$1());
|
|
209
|
-
// Get any existing runtimeId and send it along with the initialise
|
|
210
|
-
const existingRuntimeId = getDetail$1(Detail$1.RUNTIME_ID);
|
|
211
|
-
const body = {
|
|
212
|
-
version: 1,
|
|
213
|
-
data: {
|
|
214
|
-
runtimeDetails,
|
|
215
|
-
runtimeId: existingRuntimeId,
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
const response = await post$1('/v1/sdk/initialise', body);
|
|
219
|
-
// Get runtimeId and store it
|
|
220
|
-
const { runtimeId } = response;
|
|
221
|
-
storeDetail$1(Detail$1.RUNTIME_ID, runtimeId);
|
|
222
|
-
initialised$1 = true;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
function errorBoundary$1(fn) {
|
|
226
|
-
const wrappedFunction = ((...args) => {
|
|
227
|
-
try {
|
|
228
|
-
// Execute the original function
|
|
229
|
-
const result = fn(...args);
|
|
230
|
-
if (result instanceof Promise) {
|
|
231
|
-
// Silent fail for now, in future
|
|
232
|
-
// we can send errors to a logging service
|
|
233
|
-
return result.catch(() => undefined);
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
// As above, fail silently for now
|
|
239
|
-
return undefined;
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
return wrappedFunction;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function isTestEnvironment$1() {
|
|
246
|
-
if (typeof process === 'undefined') {
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
return process.env.JEST_WORKER_ID !== undefined;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Store the event in the event store
|
|
253
|
-
const trackFn = (moduleName, eventName, properties) => {
|
|
254
|
-
const event = {
|
|
255
|
-
event: `${moduleName}.${eventName}`,
|
|
256
|
-
time: new Date().toISOString(),
|
|
257
|
-
...(properties && { properties: flattenProperties$1(properties) }),
|
|
258
|
-
};
|
|
259
|
-
addEvent(event);
|
|
260
|
-
};
|
|
261
|
-
const track = errorBoundary$1(trackFn);
|
|
262
|
-
// Sending events to the server
|
|
263
|
-
const flushFn$1 = async () => {
|
|
264
|
-
// Don't flush if not initialised
|
|
265
|
-
if (isInitialised$1() === false) {
|
|
266
|
-
await initialise$2();
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const events = getEvents$1();
|
|
270
|
-
if (events.length === 0) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
// Track events length here, incase
|
|
274
|
-
const numEvents = events.length;
|
|
275
|
-
// Get details and send it with the track request
|
|
276
|
-
const details = getAllDetails$1();
|
|
277
|
-
const metricsPayload = {
|
|
278
|
-
version: 1,
|
|
279
|
-
data: {
|
|
280
|
-
events,
|
|
281
|
-
details,
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
const response = await post$1('/v1/sdk/metrics', metricsPayload);
|
|
285
|
-
if (response instanceof Error) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
// Clear events if successfully posted
|
|
289
|
-
removeSentEvents$1(numEvents);
|
|
290
|
-
};
|
|
291
|
-
const flush$1 = errorBoundary$1(flushFn$1);
|
|
292
|
-
// Flush events every 5 seconds
|
|
293
|
-
const flushPoll$1 = async () => {
|
|
294
|
-
await flush$1();
|
|
295
|
-
setTimeout(flushPoll$1, POLLING_FREQUENCY$1);
|
|
296
|
-
};
|
|
297
|
-
// This will get initialised when module is imported.
|
|
298
|
-
if (!isTestEnvironment$1()) {
|
|
299
|
-
errorBoundary$1(flushPoll$1)();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const setEnvironmentFn = (env) => {
|
|
303
|
-
storeDetail$1(Detail$1.ENVIRONMENT, env);
|
|
304
|
-
};
|
|
305
|
-
const setEnvironment = errorBoundary$1(setEnvironmentFn);
|
|
306
|
-
const setPublishableApiKeyFn = (publishableApiKey) => {
|
|
307
|
-
storeDetail$1(Detail$1.PUBLISHABLE_API_KEY, publishableApiKey);
|
|
308
|
-
};
|
|
309
|
-
const setPublishableApiKey = errorBoundary$1(setPublishableApiKeyFn);
|
|
310
|
-
|
|
311
49
|
var Environment$1;
|
|
312
50
|
(function (Environment) {
|
|
313
51
|
Environment["PRODUCTION"] = "production";
|
|
@@ -320,8 +58,6 @@ class ImmutableConfiguration {
|
|
|
320
58
|
publishableKey;
|
|
321
59
|
constructor(options) {
|
|
322
60
|
this.environment = options.environment;
|
|
323
|
-
setEnvironment(options.environment);
|
|
324
|
-
track('config', 'load_imtbl_config');
|
|
325
61
|
}
|
|
326
62
|
}
|
|
327
63
|
const API_KEY_PREFIX = 'sk_imapik-';
|
|
@@ -337,7 +73,6 @@ const addPublishableKeyToAxiosHeader = (publishableKey) => {
|
|
|
337
73
|
throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
|
|
338
74
|
+ ' https://hub.immutable.com');
|
|
339
75
|
}
|
|
340
|
-
setPublishableApiKey(publishableKey);
|
|
341
76
|
globalAxios$1.defaults.headers.common['x-immutable-publishable-key'] = publishableKey;
|
|
342
77
|
};
|
|
343
78
|
const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
|
|
@@ -10906,7 +10641,7 @@ class MultiRollupApiClients {
|
|
|
10906
10641
|
}
|
|
10907
10642
|
|
|
10908
10643
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10909
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.
|
|
10644
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.4' };
|
|
10910
10645
|
const createConfig = ({ basePath, headers, }) => {
|
|
10911
10646
|
if (!basePath.trim()) {
|
|
10912
10647
|
throw Error('basePath can not be empty');
|
|
@@ -10978,7 +10713,7 @@ class APIError extends Error {
|
|
|
10978
10713
|
|
|
10979
10714
|
/* eslint-disable implicit-arrow-linebreak */
|
|
10980
10715
|
const defaultHeaders = {
|
|
10981
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.
|
|
10716
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.4',
|
|
10982
10717
|
};
|
|
10983
10718
|
/**
|
|
10984
10719
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11417,7 +11152,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11417
11152
|
chainID,
|
|
11418
11153
|
coreContractAddress,
|
|
11419
11154
|
registrationContractAddress,
|
|
11420
|
-
sdkVersion: 'ts-immutable-sdk-0.45.
|
|
11155
|
+
sdkVersion: 'ts-immutable-sdk-0.45.4',
|
|
11421
11156
|
});
|
|
11422
11157
|
/**
|
|
11423
11158
|
* Sets `sdkVersion` at the time of build
|
|
@@ -36571,244 +36306,6 @@ class TokenBridge {
|
|
|
36571
36306
|
}
|
|
36572
36307
|
}
|
|
36573
36308
|
|
|
36574
|
-
const isNode = () => typeof window === 'undefined';
|
|
36575
|
-
const isBrowser = () => !isNode();
|
|
36576
|
-
|
|
36577
|
-
var Detail;
|
|
36578
|
-
(function (Detail) {
|
|
36579
|
-
Detail["RUNTIME_ID"] = "rid";
|
|
36580
|
-
Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
|
|
36581
|
-
Detail["ENVIRONMENT"] = "env";
|
|
36582
|
-
Detail["PUBLISHABLE_API_KEY"] = "pak";
|
|
36583
|
-
Detail["IDENTITY"] = "uid";
|
|
36584
|
-
Detail["DOMAIN"] = "domain";
|
|
36585
|
-
})(Detail || (Detail = {}));
|
|
36586
|
-
var Store;
|
|
36587
|
-
(function (Store) {
|
|
36588
|
-
Store["EVENTS"] = "events";
|
|
36589
|
-
Store["RUNTIME"] = "runtime";
|
|
36590
|
-
})(Store || (Store = {}));
|
|
36591
|
-
const POLLING_FREQUENCY = 5000;
|
|
36592
|
-
|
|
36593
|
-
const IMTBL_API = 'https://api.x.immutable.com';
|
|
36594
|
-
async function post(path, data) {
|
|
36595
|
-
const client = axios$1.create({
|
|
36596
|
-
baseURL: IMTBL_API,
|
|
36597
|
-
});
|
|
36598
|
-
const payload = JSON.stringify(data);
|
|
36599
|
-
const body = {
|
|
36600
|
-
payload: btoa(payload),
|
|
36601
|
-
};
|
|
36602
|
-
const response = await client.post(path, body);
|
|
36603
|
-
return response.data;
|
|
36604
|
-
}
|
|
36605
|
-
|
|
36606
|
-
/**
|
|
36607
|
-
* Abstraction on localstorage
|
|
36608
|
-
*/
|
|
36609
|
-
const localStoragePrefix = '__IMX-';
|
|
36610
|
-
const hasLocalstorage = () => isBrowser() && window.localStorage;
|
|
36611
|
-
const parseItem = (payload) => {
|
|
36612
|
-
// Try to parse, if can't be parsed assume string
|
|
36613
|
-
// and return string
|
|
36614
|
-
if (payload === null)
|
|
36615
|
-
return undefined;
|
|
36616
|
-
try {
|
|
36617
|
-
return JSON.parse(payload);
|
|
36618
|
-
}
|
|
36619
|
-
catch (error) {
|
|
36620
|
-
// Assumes it's a string.
|
|
36621
|
-
return payload;
|
|
36622
|
-
}
|
|
36623
|
-
};
|
|
36624
|
-
const serialiseItem = (payload) => {
|
|
36625
|
-
if (typeof payload === 'string') {
|
|
36626
|
-
return payload;
|
|
36627
|
-
}
|
|
36628
|
-
return JSON.stringify(payload);
|
|
36629
|
-
};
|
|
36630
|
-
/**
|
|
36631
|
-
* GenKey will take into account the namespace
|
|
36632
|
-
* as well as if being run in the Link, it will tap into the link
|
|
36633
|
-
* @param {string} key
|
|
36634
|
-
* @returns key
|
|
36635
|
-
*/
|
|
36636
|
-
const genKey = (key) => `${localStoragePrefix}${key}`;
|
|
36637
|
-
function getItem(key) {
|
|
36638
|
-
if (hasLocalstorage()) {
|
|
36639
|
-
return parseItem(window.localStorage.getItem(genKey(key)));
|
|
36640
|
-
}
|
|
36641
|
-
return undefined;
|
|
36642
|
-
}
|
|
36643
|
-
const setItem = (key, payload) => {
|
|
36644
|
-
if (hasLocalstorage()) {
|
|
36645
|
-
window.localStorage.setItem(genKey(key), serialiseItem(payload));
|
|
36646
|
-
return true;
|
|
36647
|
-
}
|
|
36648
|
-
return false;
|
|
36649
|
-
};
|
|
36650
|
-
|
|
36651
|
-
// In memory storage for events and other data
|
|
36652
|
-
let EVENT_STORE;
|
|
36653
|
-
let RUNTIME_DETAILS;
|
|
36654
|
-
// Initialise store and runtime
|
|
36655
|
-
const initialise$1 = () => {
|
|
36656
|
-
EVENT_STORE = getItem(Store.EVENTS) || [];
|
|
36657
|
-
RUNTIME_DETAILS = getItem(Store.RUNTIME) || {};
|
|
36658
|
-
};
|
|
36659
|
-
initialise$1();
|
|
36660
|
-
// Runtime Details
|
|
36661
|
-
const storeDetail = (key, value) => {
|
|
36662
|
-
RUNTIME_DETAILS = {
|
|
36663
|
-
...RUNTIME_DETAILS,
|
|
36664
|
-
[key]: value,
|
|
36665
|
-
};
|
|
36666
|
-
setItem(Store.RUNTIME, RUNTIME_DETAILS);
|
|
36667
|
-
};
|
|
36668
|
-
const getDetail = (key) => {
|
|
36669
|
-
// Handle the scenario where detail is a falsy value
|
|
36670
|
-
if (RUNTIME_DETAILS[key] === undefined) {
|
|
36671
|
-
return undefined;
|
|
36672
|
-
}
|
|
36673
|
-
return RUNTIME_DETAILS[key];
|
|
36674
|
-
};
|
|
36675
|
-
const getAllDetails = () => RUNTIME_DETAILS;
|
|
36676
|
-
// Events
|
|
36677
|
-
const getEvents = () => EVENT_STORE;
|
|
36678
|
-
const removeSentEvents = (numberOfEvents) => {
|
|
36679
|
-
EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
|
|
36680
|
-
setItem(Store.EVENTS, EVENT_STORE);
|
|
36681
|
-
};
|
|
36682
|
-
const flattenProperties = (properties) => {
|
|
36683
|
-
const propertyMap = [];
|
|
36684
|
-
Object.entries(properties).forEach(([key, value]) => {
|
|
36685
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
36686
|
-
propertyMap.push([key, value.toString()]);
|
|
36687
|
-
}
|
|
36688
|
-
});
|
|
36689
|
-
return propertyMap;
|
|
36690
|
-
};
|
|
36691
|
-
|
|
36692
|
-
let initialised = false;
|
|
36693
|
-
const isInitialised = () => initialised;
|
|
36694
|
-
const getReferrer = () => {
|
|
36695
|
-
if (isNode()) {
|
|
36696
|
-
return '';
|
|
36697
|
-
}
|
|
36698
|
-
if (window.location.ancestorOrigins
|
|
36699
|
-
&& window.location.ancestorOrigins.length > 0) {
|
|
36700
|
-
return new URL(window.location.ancestorOrigins[0]).hostname;
|
|
36701
|
-
}
|
|
36702
|
-
return document.referrer ? new URL(window.document.referrer).hostname : '';
|
|
36703
|
-
};
|
|
36704
|
-
const runtimeHost = () => {
|
|
36705
|
-
if (isNode()) {
|
|
36706
|
-
return '';
|
|
36707
|
-
}
|
|
36708
|
-
if (window.opener || window.parent !== window) {
|
|
36709
|
-
return getReferrer();
|
|
36710
|
-
}
|
|
36711
|
-
return new URL(window.location.href).hostname;
|
|
36712
|
-
};
|
|
36713
|
-
const getRuntimeDetails = () => {
|
|
36714
|
-
if (isNode()) {
|
|
36715
|
-
return { browser: 'nodejs' };
|
|
36716
|
-
}
|
|
36717
|
-
const domain = runtimeHost();
|
|
36718
|
-
if (domain) {
|
|
36719
|
-
storeDetail(Detail.DOMAIN, domain);
|
|
36720
|
-
}
|
|
36721
|
-
return {
|
|
36722
|
-
browser: window.navigator.userAgent,
|
|
36723
|
-
domain,
|
|
36724
|
-
tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
36725
|
-
screen: `${window.screen.width}x${window.screen.height}`,
|
|
36726
|
-
};
|
|
36727
|
-
};
|
|
36728
|
-
const initialise = async () => {
|
|
36729
|
-
const runtimeDetails = flattenProperties(getRuntimeDetails());
|
|
36730
|
-
// Get any existing runtimeId and send it along with the initialise
|
|
36731
|
-
const existingRuntimeId = getDetail(Detail.RUNTIME_ID);
|
|
36732
|
-
const body = {
|
|
36733
|
-
version: 1,
|
|
36734
|
-
data: {
|
|
36735
|
-
runtimeDetails,
|
|
36736
|
-
runtimeId: existingRuntimeId,
|
|
36737
|
-
},
|
|
36738
|
-
};
|
|
36739
|
-
const response = await post('/v1/sdk/initialise', body);
|
|
36740
|
-
// Get runtimeId and store it
|
|
36741
|
-
const { runtimeId } = response;
|
|
36742
|
-
storeDetail(Detail.RUNTIME_ID, runtimeId);
|
|
36743
|
-
initialised = true;
|
|
36744
|
-
};
|
|
36745
|
-
|
|
36746
|
-
function errorBoundary(fn) {
|
|
36747
|
-
const wrappedFunction = ((...args) => {
|
|
36748
|
-
try {
|
|
36749
|
-
// Execute the original function
|
|
36750
|
-
const result = fn(...args);
|
|
36751
|
-
if (result instanceof Promise) {
|
|
36752
|
-
// Silent fail for now, in future
|
|
36753
|
-
// we can send errors to a logging service
|
|
36754
|
-
return result.catch(() => undefined);
|
|
36755
|
-
}
|
|
36756
|
-
return result;
|
|
36757
|
-
}
|
|
36758
|
-
catch (error) {
|
|
36759
|
-
// As above, fail silently for now
|
|
36760
|
-
return undefined;
|
|
36761
|
-
}
|
|
36762
|
-
});
|
|
36763
|
-
return wrappedFunction;
|
|
36764
|
-
}
|
|
36765
|
-
|
|
36766
|
-
function isTestEnvironment() {
|
|
36767
|
-
if (typeof process === 'undefined') {
|
|
36768
|
-
return false;
|
|
36769
|
-
}
|
|
36770
|
-
return process.env.JEST_WORKER_ID !== undefined;
|
|
36771
|
-
}
|
|
36772
|
-
// Sending events to the server
|
|
36773
|
-
const flushFn = async () => {
|
|
36774
|
-
// Don't flush if not initialised
|
|
36775
|
-
if (isInitialised() === false) {
|
|
36776
|
-
await initialise();
|
|
36777
|
-
return;
|
|
36778
|
-
}
|
|
36779
|
-
const events = getEvents();
|
|
36780
|
-
if (events.length === 0) {
|
|
36781
|
-
return;
|
|
36782
|
-
}
|
|
36783
|
-
// Track events length here, incase
|
|
36784
|
-
const numEvents = events.length;
|
|
36785
|
-
// Get details and send it with the track request
|
|
36786
|
-
const details = getAllDetails();
|
|
36787
|
-
const metricsPayload = {
|
|
36788
|
-
version: 1,
|
|
36789
|
-
data: {
|
|
36790
|
-
events,
|
|
36791
|
-
details,
|
|
36792
|
-
},
|
|
36793
|
-
};
|
|
36794
|
-
const response = await post('/v1/sdk/metrics', metricsPayload);
|
|
36795
|
-
if (response instanceof Error) {
|
|
36796
|
-
return;
|
|
36797
|
-
}
|
|
36798
|
-
// Clear events if successfully posted
|
|
36799
|
-
removeSentEvents(numEvents);
|
|
36800
|
-
};
|
|
36801
|
-
const flush = errorBoundary(flushFn);
|
|
36802
|
-
// Flush events every 5 seconds
|
|
36803
|
-
const flushPoll = async () => {
|
|
36804
|
-
await flush();
|
|
36805
|
-
setTimeout(flushPoll, POLLING_FREQUENCY);
|
|
36806
|
-
};
|
|
36807
|
-
// This will get initialised when module is imported.
|
|
36808
|
-
if (!isTestEnvironment()) {
|
|
36809
|
-
errorBoundary(flushPoll)();
|
|
36810
|
-
}
|
|
36811
|
-
|
|
36812
36309
|
var Environment;
|
|
36813
36310
|
(function (Environment) {
|
|
36814
36311
|
Environment["PRODUCTION"] = "production";
|
|
@@ -41788,7 +41285,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
41788
41285
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
41789
41286
|
};
|
|
41790
41287
|
|
|
41791
|
-
const SDK_VERSION_MARKER = '0.45.
|
|
41288
|
+
const SDK_VERSION_MARKER = '0.45.4';
|
|
41792
41289
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
41793
41290
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
41794
41291
|
|
package/dist/index.d.ts
CHANGED
|
@@ -24,9 +24,9 @@ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (
|
|
|
24
24
|
} ? Required<{
|
|
25
25
|
publishableKey: string;
|
|
26
26
|
}> : {});
|
|
27
|
-
type ImmutableConfigurationWithOmitableFields<T> = T extends {
|
|
27
|
+
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
28
28
|
apiKey: 'omit';
|
|
29
|
-
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T
|
|
29
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
30
30
|
interface ModuleConfiguration<T> {
|
|
31
31
|
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
32
32
|
overrides?: T;
|