cryptique-sdk 1.2.3 → 1.2.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/lib/cjs/index.js +33 -54
- package/lib/esm/index.js +33 -54
- package/lib/umd/index.js +33 -54
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -2880,14 +2880,34 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2880
2880
|
});
|
|
2881
2881
|
|
|
2882
2882
|
// Automatic wallet address matching - only call once per address per session
|
|
2883
|
-
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2883
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
|
|
2884
|
+
// Also guards against the race condition where the wallet is detected before the
|
|
2885
|
+
// initial session POST has completed on the backend (which would return 404).
|
|
2886
|
+
// We wait until isInitialized is true (meaning sendInitialSessionData has run)
|
|
2887
|
+
// plus an extra 1 s buffer to ensure the backend has persisted the session.
|
|
2884
2888
|
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2885
2889
|
runtimeState.reportedWalletAddress = walletAddress;
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2890
|
+
const _sendWalletAddress = () => {
|
|
2891
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2892
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2893
|
+
// Reset so it retries next time wallet info is updated
|
|
2894
|
+
runtimeState.reportedWalletAddress = null;
|
|
2895
|
+
});
|
|
2896
|
+
};
|
|
2897
|
+
if (runtimeState.isInitialized) {
|
|
2898
|
+
// SDK already fully initialised - still give backend 1 s to persist session
|
|
2899
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2900
|
+
} else {
|
|
2901
|
+
// SDK still starting up - poll until initialised then add 1 s buffer
|
|
2902
|
+
const _waitAndSend = () => {
|
|
2903
|
+
if (runtimeState.isInitialized) {
|
|
2904
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2905
|
+
} else {
|
|
2906
|
+
setTimeout(_waitAndSend, 200);
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2909
|
+
setTimeout(_waitAndSend, 200);
|
|
2910
|
+
}
|
|
2891
2911
|
}
|
|
2892
2912
|
}
|
|
2893
2913
|
|
|
@@ -5319,57 +5339,16 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5319
5339
|
},
|
|
5320
5340
|
|
|
5321
5341
|
/**
|
|
5322
|
-
* NetworkTracker - Tracks network errors (
|
|
5342
|
+
* NetworkTracker - Tracks network errors (XHR only)
|
|
5343
|
+
*
|
|
5344
|
+
* NOTE:
|
|
5345
|
+
* We intentionally do NOT wrap window.fetch here, to avoid confusing
|
|
5346
|
+
* browser DevTools attribution for third‑party requests. All SDK
|
|
5347
|
+
* fetch-based calls to backend.cryptique.io are already error-handled
|
|
5348
|
+
* inside APIClient.send(), so fetch wrapping is redundant.
|
|
5323
5349
|
*/
|
|
5324
5350
|
startNetworkTracking() {
|
|
5325
5351
|
try {
|
|
5326
|
-
// Track fetch errors - only intercept calls to our own backend
|
|
5327
|
-
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5328
|
-
// true browser fetch, regardless of what other libraries have patched.
|
|
5329
|
-
window.fetch = function(...args) {
|
|
5330
|
-
const startTime = Date.now();
|
|
5331
|
-
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
5332
|
-
|
|
5333
|
-
// Pass third-party requests through completely untouched — no interception,
|
|
5334
|
-
// no involvement of our SDK in their call stack or error handling
|
|
5335
|
-
if (!url.includes('backend.cryptique.io')) {
|
|
5336
|
-
return _nativeFetch.apply(this, args);
|
|
5337
|
-
}
|
|
5338
|
-
|
|
5339
|
-
return _nativeFetch.apply(this, args).then(response => {
|
|
5340
|
-
// Only track error status codes (4xx, 5xx)
|
|
5341
|
-
if (response.status >= 400) {
|
|
5342
|
-
const networkErrorData = {
|
|
5343
|
-
type: 'api_error',
|
|
5344
|
-
url: url,
|
|
5345
|
-
method: 'GET',
|
|
5346
|
-
status: response.status,
|
|
5347
|
-
error: `HTTP ${response.status} Error`,
|
|
5348
|
-
duration: Date.now() - startTime,
|
|
5349
|
-
path: window.location.pathname
|
|
5350
|
-
};
|
|
5351
|
-
|
|
5352
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5353
|
-
}
|
|
5354
|
-
|
|
5355
|
-
return response;
|
|
5356
|
-
}).catch(error => {
|
|
5357
|
-
// Track actual network errors
|
|
5358
|
-
const networkErrorData = {
|
|
5359
|
-
type: 'api_error',
|
|
5360
|
-
url: url,
|
|
5361
|
-
method: 'GET',
|
|
5362
|
-
status: 0,
|
|
5363
|
-
error: error.message || 'Network Error',
|
|
5364
|
-
duration: Date.now() - startTime,
|
|
5365
|
-
path: window.location.pathname
|
|
5366
|
-
};
|
|
5367
|
-
|
|
5368
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5369
|
-
throw error;
|
|
5370
|
-
});
|
|
5371
|
-
};
|
|
5372
|
-
|
|
5373
5352
|
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5374
5353
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5375
5354
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
package/lib/esm/index.js
CHANGED
|
@@ -2878,14 +2878,34 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2878
2878
|
});
|
|
2879
2879
|
|
|
2880
2880
|
// Automatic wallet address matching - only call once per address per session
|
|
2881
|
-
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2881
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
|
|
2882
|
+
// Also guards against the race condition where the wallet is detected before the
|
|
2883
|
+
// initial session POST has completed on the backend (which would return 404).
|
|
2884
|
+
// We wait until isInitialized is true (meaning sendInitialSessionData has run)
|
|
2885
|
+
// plus an extra 1 s buffer to ensure the backend has persisted the session.
|
|
2882
2886
|
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2883
2887
|
runtimeState.reportedWalletAddress = walletAddress;
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2888
|
+
const _sendWalletAddress = () => {
|
|
2889
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2890
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2891
|
+
// Reset so it retries next time wallet info is updated
|
|
2892
|
+
runtimeState.reportedWalletAddress = null;
|
|
2893
|
+
});
|
|
2894
|
+
};
|
|
2895
|
+
if (runtimeState.isInitialized) {
|
|
2896
|
+
// SDK already fully initialised - still give backend 1 s to persist session
|
|
2897
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2898
|
+
} else {
|
|
2899
|
+
// SDK still starting up - poll until initialised then add 1 s buffer
|
|
2900
|
+
const _waitAndSend = () => {
|
|
2901
|
+
if (runtimeState.isInitialized) {
|
|
2902
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2903
|
+
} else {
|
|
2904
|
+
setTimeout(_waitAndSend, 200);
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
setTimeout(_waitAndSend, 200);
|
|
2908
|
+
}
|
|
2889
2909
|
}
|
|
2890
2910
|
}
|
|
2891
2911
|
|
|
@@ -5317,57 +5337,16 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5317
5337
|
},
|
|
5318
5338
|
|
|
5319
5339
|
/**
|
|
5320
|
-
* NetworkTracker - Tracks network errors (
|
|
5340
|
+
* NetworkTracker - Tracks network errors (XHR only)
|
|
5341
|
+
*
|
|
5342
|
+
* NOTE:
|
|
5343
|
+
* We intentionally do NOT wrap window.fetch here, to avoid confusing
|
|
5344
|
+
* browser DevTools attribution for third‑party requests. All SDK
|
|
5345
|
+
* fetch-based calls to backend.cryptique.io are already error-handled
|
|
5346
|
+
* inside APIClient.send(), so fetch wrapping is redundant.
|
|
5321
5347
|
*/
|
|
5322
5348
|
startNetworkTracking() {
|
|
5323
5349
|
try {
|
|
5324
|
-
// Track fetch errors - only intercept calls to our own backend
|
|
5325
|
-
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5326
|
-
// true browser fetch, regardless of what other libraries have patched.
|
|
5327
|
-
window.fetch = function(...args) {
|
|
5328
|
-
const startTime = Date.now();
|
|
5329
|
-
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
5330
|
-
|
|
5331
|
-
// Pass third-party requests through completely untouched — no interception,
|
|
5332
|
-
// no involvement of our SDK in their call stack or error handling
|
|
5333
|
-
if (!url.includes('backend.cryptique.io')) {
|
|
5334
|
-
return _nativeFetch.apply(this, args);
|
|
5335
|
-
}
|
|
5336
|
-
|
|
5337
|
-
return _nativeFetch.apply(this, args).then(response => {
|
|
5338
|
-
// Only track error status codes (4xx, 5xx)
|
|
5339
|
-
if (response.status >= 400) {
|
|
5340
|
-
const networkErrorData = {
|
|
5341
|
-
type: 'api_error',
|
|
5342
|
-
url: url,
|
|
5343
|
-
method: 'GET',
|
|
5344
|
-
status: response.status,
|
|
5345
|
-
error: `HTTP ${response.status} Error`,
|
|
5346
|
-
duration: Date.now() - startTime,
|
|
5347
|
-
path: window.location.pathname
|
|
5348
|
-
};
|
|
5349
|
-
|
|
5350
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5351
|
-
}
|
|
5352
|
-
|
|
5353
|
-
return response;
|
|
5354
|
-
}).catch(error => {
|
|
5355
|
-
// Track actual network errors
|
|
5356
|
-
const networkErrorData = {
|
|
5357
|
-
type: 'api_error',
|
|
5358
|
-
url: url,
|
|
5359
|
-
method: 'GET',
|
|
5360
|
-
status: 0,
|
|
5361
|
-
error: error.message || 'Network Error',
|
|
5362
|
-
duration: Date.now() - startTime,
|
|
5363
|
-
path: window.location.pathname
|
|
5364
|
-
};
|
|
5365
|
-
|
|
5366
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5367
|
-
throw error;
|
|
5368
|
-
});
|
|
5369
|
-
};
|
|
5370
|
-
|
|
5371
5350
|
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5372
5351
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5373
5352
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
package/lib/umd/index.js
CHANGED
|
@@ -2884,14 +2884,34 @@
|
|
|
2884
2884
|
});
|
|
2885
2885
|
|
|
2886
2886
|
// Automatic wallet address matching - only call once per address per session
|
|
2887
|
-
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2887
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
|
|
2888
|
+
// Also guards against the race condition where the wallet is detected before the
|
|
2889
|
+
// initial session POST has completed on the backend (which would return 404).
|
|
2890
|
+
// We wait until isInitialized is true (meaning sendInitialSessionData has run)
|
|
2891
|
+
// plus an extra 1 s buffer to ensure the backend has persisted the session.
|
|
2888
2892
|
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2889
2893
|
runtimeState.reportedWalletAddress = walletAddress;
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2894
|
+
const _sendWalletAddress = () => {
|
|
2895
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2896
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2897
|
+
// Reset so it retries next time wallet info is updated
|
|
2898
|
+
runtimeState.reportedWalletAddress = null;
|
|
2899
|
+
});
|
|
2900
|
+
};
|
|
2901
|
+
if (runtimeState.isInitialized) {
|
|
2902
|
+
// SDK already fully initialised - still give backend 1 s to persist session
|
|
2903
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2904
|
+
} else {
|
|
2905
|
+
// SDK still starting up - poll until initialised then add 1 s buffer
|
|
2906
|
+
const _waitAndSend = () => {
|
|
2907
|
+
if (runtimeState.isInitialized) {
|
|
2908
|
+
setTimeout(_sendWalletAddress, 1000);
|
|
2909
|
+
} else {
|
|
2910
|
+
setTimeout(_waitAndSend, 200);
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
setTimeout(_waitAndSend, 200);
|
|
2914
|
+
}
|
|
2895
2915
|
}
|
|
2896
2916
|
}
|
|
2897
2917
|
|
|
@@ -5323,57 +5343,16 @@
|
|
|
5323
5343
|
},
|
|
5324
5344
|
|
|
5325
5345
|
/**
|
|
5326
|
-
* NetworkTracker - Tracks network errors (
|
|
5346
|
+
* NetworkTracker - Tracks network errors (XHR only)
|
|
5347
|
+
*
|
|
5348
|
+
* NOTE:
|
|
5349
|
+
* We intentionally do NOT wrap window.fetch here, to avoid confusing
|
|
5350
|
+
* browser DevTools attribution for third‑party requests. All SDK
|
|
5351
|
+
* fetch-based calls to backend.cryptique.io are already error-handled
|
|
5352
|
+
* inside APIClient.send(), so fetch wrapping is redundant.
|
|
5327
5353
|
*/
|
|
5328
5354
|
startNetworkTracking() {
|
|
5329
5355
|
try {
|
|
5330
|
-
// Track fetch errors - only intercept calls to our own backend
|
|
5331
|
-
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5332
|
-
// true browser fetch, regardless of what other libraries have patched.
|
|
5333
|
-
window.fetch = function(...args) {
|
|
5334
|
-
const startTime = Date.now();
|
|
5335
|
-
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
5336
|
-
|
|
5337
|
-
// Pass third-party requests through completely untouched — no interception,
|
|
5338
|
-
// no involvement of our SDK in their call stack or error handling
|
|
5339
|
-
if (!url.includes('backend.cryptique.io')) {
|
|
5340
|
-
return _nativeFetch.apply(this, args);
|
|
5341
|
-
}
|
|
5342
|
-
|
|
5343
|
-
return _nativeFetch.apply(this, args).then(response => {
|
|
5344
|
-
// Only track error status codes (4xx, 5xx)
|
|
5345
|
-
if (response.status >= 400) {
|
|
5346
|
-
const networkErrorData = {
|
|
5347
|
-
type: 'api_error',
|
|
5348
|
-
url: url,
|
|
5349
|
-
method: 'GET',
|
|
5350
|
-
status: response.status,
|
|
5351
|
-
error: `HTTP ${response.status} Error`,
|
|
5352
|
-
duration: Date.now() - startTime,
|
|
5353
|
-
path: window.location.pathname
|
|
5354
|
-
};
|
|
5355
|
-
|
|
5356
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5357
|
-
}
|
|
5358
|
-
|
|
5359
|
-
return response;
|
|
5360
|
-
}).catch(error => {
|
|
5361
|
-
// Track actual network errors
|
|
5362
|
-
const networkErrorData = {
|
|
5363
|
-
type: 'api_error',
|
|
5364
|
-
url: url,
|
|
5365
|
-
method: 'GET',
|
|
5366
|
-
status: 0,
|
|
5367
|
-
error: error.message || 'Network Error',
|
|
5368
|
-
duration: Date.now() - startTime,
|
|
5369
|
-
path: window.location.pathname
|
|
5370
|
-
};
|
|
5371
|
-
|
|
5372
|
-
InteractionManager.add('networkEvents', networkErrorData);
|
|
5373
|
-
throw error;
|
|
5374
|
-
});
|
|
5375
|
-
};
|
|
5376
|
-
|
|
5377
5356
|
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5378
5357
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5379
5358
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
package/package.json
CHANGED