glitch-javascript-sdk 2.6.6 → 2.6.7
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 +52 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Communities.d.ts +10 -0
- package/dist/esm/api/Subscriptions.d.ts +8 -0
- package/dist/esm/index.js +52 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/package.json +1 -1
- package/src/api/Communities.ts +10 -0
- package/src/api/Subscriptions.ts +27 -17
- package/src/config/Config.ts +6 -9
- package/src/routes/CommunitiesRoute.ts +5 -0
- package/src/routes/SubscriptionsRoute.ts +5 -0
- package/src/util/Storage.ts +21 -3
package/dist/cjs/index.js
CHANGED
|
@@ -18827,10 +18827,26 @@ var Storage = /** @class */ (function () {
|
|
|
18827
18827
|
}
|
|
18828
18828
|
};
|
|
18829
18829
|
Storage.setAuthToken = function (token) {
|
|
18830
|
+
// Always set the cookie if we have a root domain to ensure cross-subdomain sync
|
|
18831
|
+
if (Storage.rootDomain) {
|
|
18832
|
+
if (token) {
|
|
18833
|
+
this.setCookie('glitch_auth_token', token, 31);
|
|
18834
|
+
}
|
|
18835
|
+
else {
|
|
18836
|
+
this.eraseCookie('glitch_auth_token');
|
|
18837
|
+
}
|
|
18838
|
+
}
|
|
18839
|
+
// Still set localStorage for the current domain
|
|
18830
18840
|
Storage.set('glitch_auth_token', token);
|
|
18831
18841
|
};
|
|
18832
18842
|
Storage.getAuthToken = function () {
|
|
18833
|
-
|
|
18843
|
+
// 1. Try Cookie first (best for cross-subdomain)
|
|
18844
|
+
var token = Storage.getCookie('glitch_auth_token');
|
|
18845
|
+
// 2. Fallback to LocalStorage
|
|
18846
|
+
if (!token || token === 'null') {
|
|
18847
|
+
token = Storage.get('glitch_auth_token');
|
|
18848
|
+
}
|
|
18849
|
+
return (token === 'null' || !token) ? null : token;
|
|
18834
18850
|
};
|
|
18835
18851
|
Storage.eraseCookie = function (name) {
|
|
18836
18852
|
if (document) {
|
|
@@ -18846,7 +18862,8 @@ var Storage = /** @class */ (function () {
|
|
|
18846
18862
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
18847
18863
|
expires = '; expires=' + date.toUTCString();
|
|
18848
18864
|
}
|
|
18849
|
-
if (document) {
|
|
18865
|
+
if (typeof document !== 'undefined') {
|
|
18866
|
+
// If rootDomain is .glitch.fun, this works for all subdomains
|
|
18850
18867
|
document.cookie =
|
|
18851
18868
|
name +
|
|
18852
18869
|
'=' +
|
|
@@ -18854,7 +18871,7 @@ var Storage = /** @class */ (function () {
|
|
|
18854
18871
|
expires +
|
|
18855
18872
|
'; path=/; domain=' +
|
|
18856
18873
|
Storage.rootDomain +
|
|
18857
|
-
';
|
|
18874
|
+
'; SameSite=Lax; Secure';
|
|
18858
18875
|
}
|
|
18859
18876
|
};
|
|
18860
18877
|
Storage.getCookie = function (name) {
|
|
@@ -18942,12 +18959,11 @@ var Config = /** @class */ (function () {
|
|
|
18942
18959
|
console.error("setRootDomain: domain is undefined or null");
|
|
18943
18960
|
return;
|
|
18944
18961
|
}
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
18949
|
-
|
|
18950
|
-
formattedDomain = formattedDomain.replace(/^\./, '');
|
|
18962
|
+
// If the domain already starts with a dot, keep it.
|
|
18963
|
+
// If not, and it's a standard domain, we usually want the dot for subdomains.
|
|
18964
|
+
var formattedDomain = domain;
|
|
18965
|
+
// REMOVE THIS LINE: formattedDomain = formattedDomain.replace(/^\./, '');
|
|
18966
|
+
// We WANT the dot.
|
|
18951
18967
|
this._rootDomain = formattedDomain;
|
|
18952
18968
|
Storage.setRootDomain(formattedDomain);
|
|
18953
18969
|
};
|
|
@@ -21011,6 +21027,10 @@ var CommunitiesRoute = /** @class */ (function () {
|
|
|
21011
21027
|
deleteNewsletterSubscriber: { url: '/communities/{community_id}/newsletters/{newsletter_id}/subscribers/{subscriber_id}', method: HTTP_METHODS.DELETE },
|
|
21012
21028
|
// Subscriber registration (open route)
|
|
21013
21029
|
registerNewsletterSubscriber: { url: '/communities/{community_id}/newsletters/{newsletter_id}/subscribers', method: HTTP_METHODS.POST },
|
|
21030
|
+
createOneTimeInvoice: {
|
|
21031
|
+
url: '/communities/{community_id}/invoice-once',
|
|
21032
|
+
method: HTTP_METHODS.POST
|
|
21033
|
+
},
|
|
21014
21034
|
};
|
|
21015
21035
|
return CommunitiesRoute;
|
|
21016
21036
|
}());
|
|
@@ -21792,6 +21812,15 @@ var Communities = /** @class */ (function () {
|
|
|
21792
21812
|
Communities.deleteInvite = function (community_id, invite_id, params) {
|
|
21793
21813
|
return Requests.processRoute(CommunitiesRoute.routes.deleteInvite, {}, { community_id: community_id, invite_id: invite_id }, params);
|
|
21794
21814
|
};
|
|
21815
|
+
/**
|
|
21816
|
+
* Create a one-time immediate invoice for a business account.
|
|
21817
|
+
*
|
|
21818
|
+
* @param community_id The ID of the community.
|
|
21819
|
+
* @param data { amount: number, description: string }
|
|
21820
|
+
*/
|
|
21821
|
+
Communities.createOneTimeInvoice = function (community_id, data, params) {
|
|
21822
|
+
return Requests.processRoute(CommunitiesRoute.routes.createOneTimeInvoice, data, { community_id: community_id }, params);
|
|
21823
|
+
};
|
|
21795
21824
|
return Communities;
|
|
21796
21825
|
}());
|
|
21797
21826
|
|
|
@@ -26398,6 +26427,10 @@ var SubscriptionsRoute = /** @class */ (function () {
|
|
|
26398
26427
|
cancelCommunityInfluencerSubscription: { url: '/subscriptions/communities/influencers/{community_id}/{stripe_subscription_id}', method: HTTP_METHODS.DELETE },
|
|
26399
26428
|
listCommunityInfluencerSubscriptions: { url: '/subscriptions/communities/influencers/{community_id}', method: HTTP_METHODS.GET },
|
|
26400
26429
|
changeCommunityInfluencerSubscription: { url: '/subscriptions/communities/influencers/change/{community_id}', method: HTTP_METHODS.POST },
|
|
26430
|
+
createCustomCommunitySubscription: {
|
|
26431
|
+
url: '/subscriptions/communities/custom/{community_id}',
|
|
26432
|
+
method: HTTP_METHODS.POST
|
|
26433
|
+
},
|
|
26401
26434
|
};
|
|
26402
26435
|
return SubscriptionsRoute;
|
|
26403
26436
|
}());
|
|
@@ -26495,6 +26528,16 @@ var Subscriptions = /** @class */ (function () {
|
|
|
26495
26528
|
Subscriptions.changeCommunityInfluencerSubscription = function (community_id, data, params) {
|
|
26496
26529
|
return Requests.processRoute(SubscriptionsRoute.routes.changeCommunityInfluencerSubscription, data, { community_id: community_id }, params);
|
|
26497
26530
|
};
|
|
26531
|
+
/**
|
|
26532
|
+
* Create a custom tailored subscription for a business/community.
|
|
26533
|
+
* Only accessible by Glitch administrators.
|
|
26534
|
+
*
|
|
26535
|
+
* @param community_id The ID of the community.
|
|
26536
|
+
* @param data { priceId, paymentMethod, custom_name, limits: { posts, enrichments, invites, ads }, metered_prices: [] }
|
|
26537
|
+
*/
|
|
26538
|
+
Subscriptions.createCustomCommunitySubscription = function (community_id, data, params) {
|
|
26539
|
+
return Requests.processRoute(SubscriptionsRoute.routes.createCustomCommunitySubscription, data, { community_id: community_id }, params);
|
|
26540
|
+
};
|
|
26498
26541
|
return Subscriptions;
|
|
26499
26542
|
}());
|
|
26500
26543
|
|