glitch-javascript-sdk 1.8.2 → 1.8.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/cjs/index.js +50 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Titles.d.ts +10 -0
- package/dist/esm/index.js +50 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/package.json +1 -1
- package/src/api/Titles.ts +21 -0
- package/src/routes/TitlesRoute.ts +5 -0
- package/src/util/Session.ts +45 -22
package/dist/cjs/index.js
CHANGED
|
@@ -23348,6 +23348,10 @@ var TitlesRoute = /** @class */ (function () {
|
|
|
23348
23348
|
url: "/titles/{title_id}/utm",
|
|
23349
23349
|
method: HTTP_METHODS.GET,
|
|
23350
23350
|
},
|
|
23351
|
+
getWebTrackingToken: {
|
|
23352
|
+
url: "/titles/{title_id}/webTrackingToken",
|
|
23353
|
+
method: HTTP_METHODS.GET,
|
|
23354
|
+
},
|
|
23351
23355
|
/**
|
|
23352
23356
|
* 3) Analyze UTM data with optional group_by / dimension-based aggregates
|
|
23353
23357
|
* GET /titles/{title_id}/utm/analysis
|
|
@@ -23687,6 +23691,18 @@ var Titles = /** @class */ (function () {
|
|
|
23687
23691
|
Titles.getUtmAnalytics = function (title_id, params) {
|
|
23688
23692
|
return Requests.processRoute(TitlesRoute.routes.getUtmAnalytics, {}, { title_id: title_id }, params);
|
|
23689
23693
|
};
|
|
23694
|
+
/**
|
|
23695
|
+
* Get the web tracking token used for websites.
|
|
23696
|
+
*
|
|
23697
|
+
* GET /titles/{title_id}/webTrackingToken
|
|
23698
|
+
*
|
|
23699
|
+
* @param title_id The UUID of the title
|
|
23700
|
+
* @param params Optional query params:
|
|
23701
|
+
* @returns AxiosPromise
|
|
23702
|
+
*/
|
|
23703
|
+
Titles.getWebTrackingToken = function (title_id, params) {
|
|
23704
|
+
return Requests.processRoute(TitlesRoute.routes.getWebTrackingToken, {}, { title_id: title_id }, params);
|
|
23705
|
+
};
|
|
23690
23706
|
/**
|
|
23691
23707
|
* Analyze UTM data with optional group_by (source, campaign, medium, device_type, etc.)
|
|
23692
23708
|
*
|
|
@@ -26482,9 +26498,10 @@ var Parser = /** @class */ (function () {
|
|
|
26482
26498
|
// Browser implementation using crypto-js
|
|
26483
26499
|
var BrowserCrypto = /** @class */ (function () {
|
|
26484
26500
|
function BrowserCrypto() {
|
|
26501
|
+
this.CryptoJS = require('crypto-js');
|
|
26485
26502
|
}
|
|
26486
26503
|
BrowserCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
26487
|
-
var
|
|
26504
|
+
var _this = this;
|
|
26488
26505
|
var data = '';
|
|
26489
26506
|
var hmac = {
|
|
26490
26507
|
update: function (updateData) {
|
|
@@ -26495,38 +26512,58 @@ var BrowserCrypto = /** @class */ (function () {
|
|
|
26495
26512
|
if (encoding !== 'hex') {
|
|
26496
26513
|
throw new Error('Only hex encoding is supported in browser implementation');
|
|
26497
26514
|
}
|
|
26498
|
-
return CryptoJS.HmacSHA256(data, secret).toString(CryptoJS.enc.Hex);
|
|
26515
|
+
return _this.CryptoJS.HmacSHA256(data, secret).toString(_this.CryptoJS.enc.Hex);
|
|
26499
26516
|
}
|
|
26500
26517
|
};
|
|
26501
26518
|
return hmac;
|
|
26502
26519
|
};
|
|
26503
26520
|
return BrowserCrypto;
|
|
26504
26521
|
}());
|
|
26505
|
-
// Node.js implementation
|
|
26522
|
+
// Node.js implementation that maintains sync interface
|
|
26506
26523
|
var NodeCrypto = /** @class */ (function () {
|
|
26507
26524
|
function NodeCrypto() {
|
|
26508
|
-
|
|
26525
|
+
// Use dynamic import but handle it synchronously for interface compliance
|
|
26526
|
+
try {
|
|
26527
|
+
// This will throw in browser environments
|
|
26528
|
+
this.crypto = require('crypto');
|
|
26529
|
+
}
|
|
26530
|
+
catch (e) {
|
|
26531
|
+
this.crypto = undefined;
|
|
26532
|
+
}
|
|
26509
26533
|
}
|
|
26510
26534
|
NodeCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
26535
|
+
if (!this.crypto) {
|
|
26536
|
+
throw new Error('Node.js crypto module not available');
|
|
26537
|
+
}
|
|
26511
26538
|
return this.crypto.createHmac(algorithm, secret);
|
|
26512
26539
|
};
|
|
26513
26540
|
return NodeCrypto;
|
|
26514
26541
|
}());
|
|
26515
26542
|
// Determine which crypto implementation to use
|
|
26516
26543
|
var getCrypto = function () {
|
|
26544
|
+
var _a;
|
|
26517
26545
|
try {
|
|
26518
|
-
// Check if we're in Node.js environment
|
|
26519
|
-
if (typeof process !== 'undefined' && process.versions
|
|
26520
|
-
|
|
26546
|
+
// Check if we're in Node.js environment and crypto is available
|
|
26547
|
+
if (typeof process !== 'undefined' && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
|
|
26548
|
+
var nodeCrypto = new NodeCrypto();
|
|
26549
|
+
// Verify crypto was actually loaded
|
|
26550
|
+
try {
|
|
26551
|
+
nodeCrypto.createHmac('sha256', 'test');
|
|
26552
|
+
return nodeCrypto;
|
|
26553
|
+
}
|
|
26554
|
+
catch (e) {
|
|
26555
|
+
console.warn('Node.js crypto not available, falling back to browser implementation');
|
|
26556
|
+
}
|
|
26521
26557
|
}
|
|
26522
|
-
// Fall back to browser implementation
|
|
26523
|
-
return new BrowserCrypto();
|
|
26524
26558
|
}
|
|
26525
26559
|
catch (e) {
|
|
26526
|
-
|
|
26560
|
+
console.warn('Node.js environment detection failed, falling back to browser implementation');
|
|
26527
26561
|
}
|
|
26562
|
+
// Fall back to browser implementation
|
|
26563
|
+
return new BrowserCrypto();
|
|
26528
26564
|
};
|
|
26529
|
-
|
|
26565
|
+
// Singleton crypto instance
|
|
26566
|
+
var cryptoInstance = getCrypto();
|
|
26530
26567
|
var Session = /** @class */ (function () {
|
|
26531
26568
|
function Session() {
|
|
26532
26569
|
}
|
|
@@ -26551,10 +26588,7 @@ var Session = /** @class */ (function () {
|
|
|
26551
26588
|
};
|
|
26552
26589
|
Session.hasJoinedCommunity = function () {
|
|
26553
26590
|
var community = Storage.get('community');
|
|
26554
|
-
|
|
26555
|
-
return false;
|
|
26556
|
-
}
|
|
26557
|
-
return (community === null || community === void 0 ? void 0 : community.me) ? true : false;
|
|
26591
|
+
return !!(community === null || community === void 0 ? void 0 : community.me);
|
|
26558
26592
|
};
|
|
26559
26593
|
Session.end = function () {
|
|
26560
26594
|
Storage.setAuthToken(null);
|
|
@@ -26588,7 +26622,7 @@ var Session = /** @class */ (function () {
|
|
|
26588
26622
|
if (!secret) {
|
|
26589
26623
|
throw new Error('secret is required');
|
|
26590
26624
|
}
|
|
26591
|
-
return
|
|
26625
|
+
return cryptoInstance
|
|
26592
26626
|
.createHmac('sha256', secret)
|
|
26593
26627
|
.update(titleId)
|
|
26594
26628
|
.digest('hex');
|