cryptique-sdk 1.2.0 → 1.2.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/lib/cjs/index.js +27 -17
- package/lib/esm/index.js +27 -17
- package/lib/umd/index.js +27 -17
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -161,7 +161,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
161
161
|
timer: null, // Session tracking interval timer
|
|
162
162
|
countryName: null, // Cached country name
|
|
163
163
|
isInitialized: false, // Prevents API calls during initialization
|
|
164
|
-
eip6963Providers: []
|
|
164
|
+
eip6963Providers: [], // EIP-6963 discovered wallet providers
|
|
165
|
+
reportedWalletAddress: null // Last wallet address reported to backend (prevents duplicate calls)
|
|
165
166
|
};
|
|
166
167
|
|
|
167
168
|
// Ready promise - resolves when SDK is fully initialized (allows consumers to await init)
|
|
@@ -2873,11 +2874,16 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2873
2874
|
console.error('Error updating UTM event with wallet:', error);
|
|
2874
2875
|
});
|
|
2875
2876
|
|
|
2876
|
-
// Automatic wallet address matching -
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2877
|
+
// Automatic wallet address matching - only call once per address per session
|
|
2878
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2879
|
+
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2880
|
+
runtimeState.reportedWalletAddress = walletAddress;
|
|
2881
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2882
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2883
|
+
// Reset so it retries next time wallet info is updated
|
|
2884
|
+
runtimeState.reportedWalletAddress = null;
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2881
2887
|
}
|
|
2882
2888
|
|
|
2883
2889
|
return {
|
|
@@ -5312,12 +5318,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5312
5318
|
*/
|
|
5313
5319
|
startNetworkTracking() {
|
|
5314
5320
|
try {
|
|
5315
|
-
// Track fetch errors
|
|
5321
|
+
// Track fetch errors - only intercept calls to our own backend
|
|
5316
5322
|
const originalFetch = window.fetch;
|
|
5317
5323
|
window.fetch = function(...args) {
|
|
5318
5324
|
const startTime = Date.now();
|
|
5319
|
-
const url = args[0];
|
|
5320
|
-
|
|
5325
|
+
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
5326
|
+
|
|
5327
|
+
// Pass third-party requests through completely untouched — no interception,
|
|
5328
|
+
// no involvement of our SDK in their call stack or error handling
|
|
5329
|
+
if (!url.includes('backend.cryptique.io')) {
|
|
5330
|
+
return originalFetch.apply(this, args);
|
|
5331
|
+
}
|
|
5332
|
+
|
|
5321
5333
|
return originalFetch.apply(this, args).then(response => {
|
|
5322
5334
|
// Only track error status codes (4xx, 5xx)
|
|
5323
5335
|
if (response.status >= 400) {
|
|
@@ -5352,7 +5364,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5352
5364
|
});
|
|
5353
5365
|
};
|
|
5354
5366
|
|
|
5355
|
-
// Track XMLHttpRequest errors
|
|
5367
|
+
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5356
5368
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5357
5369
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
5358
5370
|
|
|
@@ -5365,6 +5377,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5365
5377
|
XMLHttpRequest.prototype.send = function(...args) {
|
|
5366
5378
|
const startTime = Date.now();
|
|
5367
5379
|
const xhr = this;
|
|
5380
|
+
|
|
5381
|
+
// Pass third-party XHR requests through completely untouched
|
|
5382
|
+
if (!xhr._cryptiqueUrl || !xhr._cryptiqueUrl.includes('backend.cryptique.io')) {
|
|
5383
|
+
return originalXHRSend.apply(this, args);
|
|
5384
|
+
}
|
|
5368
5385
|
|
|
5369
5386
|
xhr.addEventListener('load', function() {
|
|
5370
5387
|
if (xhr.status >= 400) {
|
|
@@ -5623,13 +5640,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5623
5640
|
try {
|
|
5624
5641
|
// Update session duration
|
|
5625
5642
|
DurationManager.updateSessionDuration();
|
|
5626
|
-
|
|
5627
|
-
// Update wallet info (non-blocking)
|
|
5628
|
-
try {
|
|
5629
|
-
await WalletManager.updateWalletInfo();
|
|
5630
|
-
} catch (walletError) {
|
|
5631
|
-
console.warn('Error updating wallet info:', walletError);
|
|
5632
|
-
}
|
|
5633
5643
|
|
|
5634
5644
|
// Update session activity
|
|
5635
5645
|
StorageManager.updateSessionActivity();
|
package/lib/esm/index.js
CHANGED
|
@@ -159,7 +159,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
159
159
|
timer: null, // Session tracking interval timer
|
|
160
160
|
countryName: null, // Cached country name
|
|
161
161
|
isInitialized: false, // Prevents API calls during initialization
|
|
162
|
-
eip6963Providers: []
|
|
162
|
+
eip6963Providers: [], // EIP-6963 discovered wallet providers
|
|
163
|
+
reportedWalletAddress: null // Last wallet address reported to backend (prevents duplicate calls)
|
|
163
164
|
};
|
|
164
165
|
|
|
165
166
|
// Ready promise - resolves when SDK is fully initialized (allows consumers to await init)
|
|
@@ -2871,11 +2872,16 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
2871
2872
|
console.error('Error updating UTM event with wallet:', error);
|
|
2872
2873
|
});
|
|
2873
2874
|
|
|
2874
|
-
// Automatic wallet address matching -
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2875
|
+
// Automatic wallet address matching - only call once per address per session
|
|
2876
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2877
|
+
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2878
|
+
runtimeState.reportedWalletAddress = walletAddress;
|
|
2879
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2880
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2881
|
+
// Reset so it retries next time wallet info is updated
|
|
2882
|
+
runtimeState.reportedWalletAddress = null;
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2879
2885
|
}
|
|
2880
2886
|
|
|
2881
2887
|
return {
|
|
@@ -5310,12 +5316,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5310
5316
|
*/
|
|
5311
5317
|
startNetworkTracking() {
|
|
5312
5318
|
try {
|
|
5313
|
-
// Track fetch errors
|
|
5319
|
+
// Track fetch errors - only intercept calls to our own backend
|
|
5314
5320
|
const originalFetch = window.fetch;
|
|
5315
5321
|
window.fetch = function(...args) {
|
|
5316
5322
|
const startTime = Date.now();
|
|
5317
|
-
const url = args[0];
|
|
5318
|
-
|
|
5323
|
+
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
5324
|
+
|
|
5325
|
+
// Pass third-party requests through completely untouched — no interception,
|
|
5326
|
+
// no involvement of our SDK in their call stack or error handling
|
|
5327
|
+
if (!url.includes('backend.cryptique.io')) {
|
|
5328
|
+
return originalFetch.apply(this, args);
|
|
5329
|
+
}
|
|
5330
|
+
|
|
5319
5331
|
return originalFetch.apply(this, args).then(response => {
|
|
5320
5332
|
// Only track error status codes (4xx, 5xx)
|
|
5321
5333
|
if (response.status >= 400) {
|
|
@@ -5350,7 +5362,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5350
5362
|
});
|
|
5351
5363
|
};
|
|
5352
5364
|
|
|
5353
|
-
// Track XMLHttpRequest errors
|
|
5365
|
+
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5354
5366
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5355
5367
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
5356
5368
|
|
|
@@ -5363,6 +5375,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5363
5375
|
XMLHttpRequest.prototype.send = function(...args) {
|
|
5364
5376
|
const startTime = Date.now();
|
|
5365
5377
|
const xhr = this;
|
|
5378
|
+
|
|
5379
|
+
// Pass third-party XHR requests through completely untouched
|
|
5380
|
+
if (!xhr._cryptiqueUrl || !xhr._cryptiqueUrl.includes('backend.cryptique.io')) {
|
|
5381
|
+
return originalXHRSend.apply(this, args);
|
|
5382
|
+
}
|
|
5366
5383
|
|
|
5367
5384
|
xhr.addEventListener('load', function() {
|
|
5368
5385
|
if (xhr.status >= 400) {
|
|
@@ -5621,13 +5638,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5621
5638
|
try {
|
|
5622
5639
|
// Update session duration
|
|
5623
5640
|
DurationManager.updateSessionDuration();
|
|
5624
|
-
|
|
5625
|
-
// Update wallet info (non-blocking)
|
|
5626
|
-
try {
|
|
5627
|
-
await WalletManager.updateWalletInfo();
|
|
5628
|
-
} catch (walletError) {
|
|
5629
|
-
console.warn('Error updating wallet info:', walletError);
|
|
5630
|
-
}
|
|
5631
5641
|
|
|
5632
5642
|
// Update session activity
|
|
5633
5643
|
StorageManager.updateSessionActivity();
|
package/lib/umd/index.js
CHANGED
|
@@ -165,7 +165,8 @@
|
|
|
165
165
|
timer: null, // Session tracking interval timer
|
|
166
166
|
countryName: null, // Cached country name
|
|
167
167
|
isInitialized: false, // Prevents API calls during initialization
|
|
168
|
-
eip6963Providers: []
|
|
168
|
+
eip6963Providers: [], // EIP-6963 discovered wallet providers
|
|
169
|
+
reportedWalletAddress: null // Last wallet address reported to backend (prevents duplicate calls)
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
// Ready promise - resolves when SDK is fully initialized (allows consumers to await init)
|
|
@@ -2877,11 +2878,16 @@
|
|
|
2877
2878
|
console.error('Error updating UTM event with wallet:', error);
|
|
2878
2879
|
});
|
|
2879
2880
|
|
|
2880
|
-
// Automatic wallet address matching -
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2881
|
+
// Automatic wallet address matching - only call once per address per session
|
|
2882
|
+
// Prevents repeated calls to /api/sdk/wallet-address on every interval tick
|
|
2883
|
+
if (walletAddress !== runtimeState.reportedWalletAddress) {
|
|
2884
|
+
runtimeState.reportedWalletAddress = walletAddress;
|
|
2885
|
+
IdentityManager.walletAddress(walletAddress).catch((error) => {
|
|
2886
|
+
console.warn('Error in automatic wallet address matching:', error);
|
|
2887
|
+
// Reset so it retries next time wallet info is updated
|
|
2888
|
+
runtimeState.reportedWalletAddress = null;
|
|
2889
|
+
});
|
|
2890
|
+
}
|
|
2885
2891
|
}
|
|
2886
2892
|
|
|
2887
2893
|
return {
|
|
@@ -5316,12 +5322,18 @@
|
|
|
5316
5322
|
*/
|
|
5317
5323
|
startNetworkTracking() {
|
|
5318
5324
|
try {
|
|
5319
|
-
// Track fetch errors
|
|
5325
|
+
// Track fetch errors - only intercept calls to our own backend
|
|
5320
5326
|
const originalFetch = window.fetch;
|
|
5321
5327
|
window.fetch = function(...args) {
|
|
5322
5328
|
const startTime = Date.now();
|
|
5323
|
-
const url = args[0];
|
|
5324
|
-
|
|
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 originalFetch.apply(this, args);
|
|
5335
|
+
}
|
|
5336
|
+
|
|
5325
5337
|
return originalFetch.apply(this, args).then(response => {
|
|
5326
5338
|
// Only track error status codes (4xx, 5xx)
|
|
5327
5339
|
if (response.status >= 400) {
|
|
@@ -5356,7 +5368,7 @@
|
|
|
5356
5368
|
});
|
|
5357
5369
|
};
|
|
5358
5370
|
|
|
5359
|
-
// Track XMLHttpRequest errors
|
|
5371
|
+
// Track XMLHttpRequest errors - only intercept calls to our own backend
|
|
5360
5372
|
const originalXHROpen = XMLHttpRequest.prototype.open;
|
|
5361
5373
|
const originalXHRSend = XMLHttpRequest.prototype.send;
|
|
5362
5374
|
|
|
@@ -5369,6 +5381,11 @@
|
|
|
5369
5381
|
XMLHttpRequest.prototype.send = function(...args) {
|
|
5370
5382
|
const startTime = Date.now();
|
|
5371
5383
|
const xhr = this;
|
|
5384
|
+
|
|
5385
|
+
// Pass third-party XHR requests through completely untouched
|
|
5386
|
+
if (!xhr._cryptiqueUrl || !xhr._cryptiqueUrl.includes('backend.cryptique.io')) {
|
|
5387
|
+
return originalXHRSend.apply(this, args);
|
|
5388
|
+
}
|
|
5372
5389
|
|
|
5373
5390
|
xhr.addEventListener('load', function() {
|
|
5374
5391
|
if (xhr.status >= 400) {
|
|
@@ -5627,13 +5644,6 @@
|
|
|
5627
5644
|
try {
|
|
5628
5645
|
// Update session duration
|
|
5629
5646
|
DurationManager.updateSessionDuration();
|
|
5630
|
-
|
|
5631
|
-
// Update wallet info (non-blocking)
|
|
5632
|
-
try {
|
|
5633
|
-
await WalletManager.updateWalletInfo();
|
|
5634
|
-
} catch (walletError) {
|
|
5635
|
-
console.warn('Error updating wallet info:', walletError);
|
|
5636
|
-
}
|
|
5637
5647
|
|
|
5638
5648
|
// Update session activity
|
|
5639
5649
|
StorageManager.updateSessionActivity();
|
package/package.json
CHANGED