glitch-javascript-sdk 3.10.8 → 4.0.0
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/README.md +7 -1
- package/dist/browser/hosting-runtime.js +13 -3
- package/dist/browser/hosting-runtime.js.map +1 -1
- package/dist/cjs/index.js +8348 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/FestivalNetworking.d.ts +286 -0
- package/dist/esm/api/Messages.d.ts +4 -1
- package/dist/esm/api/Microtransactions.d.ts +776 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8272 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/FestivalNetworkingRoute.d.ts +7 -0
- package/dist/esm/routes/MicrotransactionsRoute.d.ts +8 -0
- package/dist/esm/util/MicrotransactionBridge.d.ts +93 -0
- package/dist/esm/util/MicrotransactionOverlay.d.ts +59 -0
- package/dist/esm/util/Requests.d.ts +7 -3
- package/dist/index.d.ts +1227 -5
- package/guides/commerce-delivery-receiver.mjs +117 -0
- package/guides/microtransactions.md +466 -0
- package/package.json +7 -4
- package/src/api/FestivalNetworking.ts +216 -0
- package/src/api/Messages.ts +4 -1
- package/src/api/Microtransactions.ts +699 -0
- package/src/api/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/routes/FestivalNetworkingRoute.ts +33 -0
- package/src/routes/MicrotransactionsRoute.ts +57 -0
- package/src/util/MicrotransactionBridge.ts +193 -0
- package/src/util/MicrotransactionOverlay.ts +302 -0
- package/src/util/Requests.ts +15 -3
- package/src/util/Session.ts +3 -2
package/src/util/Requests.ts
CHANGED
|
@@ -226,7 +226,8 @@ class Requests {
|
|
|
226
226
|
file: File | Blob,
|
|
227
227
|
data?: any,
|
|
228
228
|
params?: Record<string, any>,
|
|
229
|
-
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void
|
|
229
|
+
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
|
|
230
|
+
options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'> & { excludeCommunityContext?: boolean }
|
|
230
231
|
): AxiosPromise<Response<T>> {
|
|
231
232
|
// Process URL and params
|
|
232
233
|
if (params && Object.keys(params).length > 0) {
|
|
@@ -240,7 +241,7 @@ class Requests {
|
|
|
240
241
|
const formData = new FormData();
|
|
241
242
|
formData.append(filename, file);
|
|
242
243
|
|
|
243
|
-
if (Requests.community_id) {
|
|
244
|
+
if (Requests.community_id && !options?.excludeCommunityContext) {
|
|
244
245
|
data = {
|
|
245
246
|
...data,
|
|
246
247
|
communities: [Requests.community_id],
|
|
@@ -268,6 +269,8 @@ class Requests {
|
|
|
268
269
|
data: formData,
|
|
269
270
|
headers,
|
|
270
271
|
onUploadProgress,
|
|
272
|
+
signal: options?.signal,
|
|
273
|
+
timeout: options?.timeout,
|
|
271
274
|
});
|
|
272
275
|
}
|
|
273
276
|
|
|
@@ -435,7 +438,7 @@ class Requests {
|
|
|
435
438
|
|
|
436
439
|
|
|
437
440
|
|
|
438
|
-
public static processRoute<T>(route: Route, data?: object, routeReplace?: { [key: string]: any }, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
441
|
+
public static processRoute<T>(route: Route, data?: object, routeReplace?: { [key: string]: any }, params?: Record<string, any>, options?: Pick<AxiosRequestConfig, 'signal' | 'timeout' | 'headers'> & { excludeCommunityContext?: boolean }): AxiosPromise<Response<T>> {
|
|
439
442
|
let url = route.url;
|
|
440
443
|
|
|
441
444
|
if (routeReplace) {
|
|
@@ -444,6 +447,15 @@ class Requests {
|
|
|
444
447
|
}
|
|
445
448
|
}
|
|
446
449
|
|
|
450
|
+
if (options) {
|
|
451
|
+
const query = { ...params, ...(Requests.community_id && !options.excludeCommunityContext ? { community_id: Requests.community_id } : {}) };
|
|
452
|
+
return axios({
|
|
453
|
+
method: route.method, url: Requests.buildUrl(url, query), data,
|
|
454
|
+
headers: { 'Content-Type': 'application/json', ...(Requests.authToken ? { Authorization: `Bearer ${Requests.authToken}` } : {}), ...options.headers },
|
|
455
|
+
signal: options.signal, timeout: options.timeout,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
447
459
|
if (route.method == HTTP_METHODS.GET) {
|
|
448
460
|
return Requests.get(url, params);
|
|
449
461
|
} else if (route.method == HTTP_METHODS.POST) {
|
package/src/util/Session.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config } from "../config";
|
|
2
2
|
import Storage from "./Storage";
|
|
3
|
+
import CryptoJS from 'crypto-js';
|
|
3
4
|
|
|
4
5
|
// Type declarations for crypto functionality
|
|
5
6
|
interface HmacInterface {
|
|
@@ -16,7 +17,7 @@ class BrowserCrypto implements CryptoInterface {
|
|
|
16
17
|
private CryptoJS: any;
|
|
17
18
|
|
|
18
19
|
constructor() {
|
|
19
|
-
this.CryptoJS =
|
|
20
|
+
this.CryptoJS = CryptoJS;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
createHmac(algorithm: string, secret: string): HmacInterface {
|
|
@@ -188,4 +189,4 @@ class Session {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
export default Session;
|
|
192
|
+
export default Session;
|