@moonbase.sh/storefront-api 0.4.74 → 1.0.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/dist/index.cjs +6 -23
- package/dist/index.js +4 -11
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -347,9 +337,6 @@ var ActivationRequestEndpoints = class {
|
|
|
347
337
|
}
|
|
348
338
|
};
|
|
349
339
|
|
|
350
|
-
// src/identity/endpoints.ts
|
|
351
|
-
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
352
|
-
|
|
353
340
|
// src/utils/errors.ts
|
|
354
341
|
var NotAuthorizedError = class extends Error {
|
|
355
342
|
constructor() {
|
|
@@ -492,7 +479,7 @@ var IdentityEndpoints = class {
|
|
|
492
479
|
return response.data;
|
|
493
480
|
}
|
|
494
481
|
async signIn(email, password) {
|
|
495
|
-
const response = await (
|
|
482
|
+
const response = await fetch(`${this.api.baseUrl}/api/customer/identity/sign-in?email=${encodeURIComponent(email)}&scheme=JWT`, {
|
|
496
483
|
method: "POST",
|
|
497
484
|
headers: {
|
|
498
485
|
"Accept": "application/json",
|
|
@@ -562,7 +549,7 @@ var IdentityEndpoints = class {
|
|
|
562
549
|
await this.api.fetch(`/api/customer/identity/forgot-password?email=${encodeURIComponent(email)}`, null, { method: "POST" });
|
|
563
550
|
}
|
|
564
551
|
async resetPassword(email, newPassword, code) {
|
|
565
|
-
const response = await (
|
|
552
|
+
const response = await fetch(`${this.api.baseUrl}/api/customer/identity/reset-password?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code.replaceAll(" ", "+"))}`, {
|
|
566
553
|
method: "POST",
|
|
567
554
|
headers: {
|
|
568
555
|
"Accept": "application/json",
|
|
@@ -726,7 +713,6 @@ var ProductEndpoints = class {
|
|
|
726
713
|
};
|
|
727
714
|
|
|
728
715
|
// src/utils/api.ts
|
|
729
|
-
var import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
|
|
730
716
|
function objectToQuery(obj) {
|
|
731
717
|
return Object.entries(obj != null ? obj : {}).filter(([_, value]) => value !== void 0).map(([key, value]) => `${key}=${encodeURIComponent(value instanceof Date ? value.toISOString() : value)}`).join("&");
|
|
732
718
|
}
|
|
@@ -765,7 +751,7 @@ var MoonbaseApi = class {
|
|
|
765
751
|
signal: options == null ? void 0 : options.abort,
|
|
766
752
|
redirect: "manual"
|
|
767
753
|
};
|
|
768
|
-
const response = await (
|
|
754
|
+
const response = await fetch(this.baseUrl + path, request);
|
|
769
755
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
770
756
|
this.logger.debug("Received response from Moonbase", {
|
|
771
757
|
path,
|
|
@@ -803,7 +789,7 @@ var MoonbaseApi = class {
|
|
|
803
789
|
}
|
|
804
790
|
async reportParsingProblem(path, err, body) {
|
|
805
791
|
try {
|
|
806
|
-
await (
|
|
792
|
+
await fetch(`${this.baseUrl}/api/customer/insights/error`, {
|
|
807
793
|
mode: "cors",
|
|
808
794
|
method: "POST",
|
|
809
795
|
headers: {
|
|
@@ -825,7 +811,7 @@ var MoonbaseApi = class {
|
|
|
825
811
|
}
|
|
826
812
|
async reportRequestProblem(path, request, response, err) {
|
|
827
813
|
try {
|
|
828
|
-
await (
|
|
814
|
+
await fetch(`${this.baseUrl}/api/customer/insights/warn`, {
|
|
829
815
|
mode: "cors",
|
|
830
816
|
method: "POST",
|
|
831
817
|
headers: {
|
|
@@ -1180,9 +1166,6 @@ var StorefrontEndpoints = class {
|
|
|
1180
1166
|
}
|
|
1181
1167
|
};
|
|
1182
1168
|
|
|
1183
|
-
// src/utils/tokenStore.ts
|
|
1184
|
-
var import_cross_fetch3 = __toESM(require("cross-fetch"), 1);
|
|
1185
|
-
|
|
1186
1169
|
// src/utils/store.ts
|
|
1187
1170
|
var LocalStorageStore = class {
|
|
1188
1171
|
get(key) {
|
|
@@ -1311,7 +1294,7 @@ var _TokenStore = class _TokenStore {
|
|
|
1311
1294
|
async refreshTokens() {
|
|
1312
1295
|
if (!this.tokens)
|
|
1313
1296
|
throw new Error("No tokens found to refresh");
|
|
1314
|
-
const response = await (
|
|
1297
|
+
const response = await fetch(`${this.configuration.endpoint}/api/customer/identity/refresh?token=${this.tokens.refreshToken}`, {
|
|
1315
1298
|
method: "POST",
|
|
1316
1299
|
headers: {
|
|
1317
1300
|
"Accept": "application/json",
|
package/dist/index.js
CHANGED
|
@@ -290,9 +290,6 @@ var ActivationRequestEndpoints = class {
|
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
-
// src/identity/endpoints.ts
|
|
294
|
-
import fetch from "cross-fetch";
|
|
295
|
-
|
|
296
293
|
// src/utils/errors.ts
|
|
297
294
|
var NotAuthorizedError = class extends Error {
|
|
298
295
|
constructor() {
|
|
@@ -669,7 +666,6 @@ var ProductEndpoints = class {
|
|
|
669
666
|
};
|
|
670
667
|
|
|
671
668
|
// src/utils/api.ts
|
|
672
|
-
import fetch2 from "cross-fetch";
|
|
673
669
|
function objectToQuery(obj) {
|
|
674
670
|
return Object.entries(obj != null ? obj : {}).filter(([_, value]) => value !== void 0).map(([key, value]) => `${key}=${encodeURIComponent(value instanceof Date ? value.toISOString() : value)}`).join("&");
|
|
675
671
|
}
|
|
@@ -708,7 +704,7 @@ var MoonbaseApi = class {
|
|
|
708
704
|
signal: options == null ? void 0 : options.abort,
|
|
709
705
|
redirect: "manual"
|
|
710
706
|
};
|
|
711
|
-
const response = await
|
|
707
|
+
const response = await fetch(this.baseUrl + path, request);
|
|
712
708
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
713
709
|
this.logger.debug("Received response from Moonbase", {
|
|
714
710
|
path,
|
|
@@ -746,7 +742,7 @@ var MoonbaseApi = class {
|
|
|
746
742
|
}
|
|
747
743
|
async reportParsingProblem(path, err, body) {
|
|
748
744
|
try {
|
|
749
|
-
await
|
|
745
|
+
await fetch(`${this.baseUrl}/api/customer/insights/error`, {
|
|
750
746
|
mode: "cors",
|
|
751
747
|
method: "POST",
|
|
752
748
|
headers: {
|
|
@@ -768,7 +764,7 @@ var MoonbaseApi = class {
|
|
|
768
764
|
}
|
|
769
765
|
async reportRequestProblem(path, request, response, err) {
|
|
770
766
|
try {
|
|
771
|
-
await
|
|
767
|
+
await fetch(`${this.baseUrl}/api/customer/insights/warn`, {
|
|
772
768
|
mode: "cors",
|
|
773
769
|
method: "POST",
|
|
774
770
|
headers: {
|
|
@@ -1123,9 +1119,6 @@ var StorefrontEndpoints = class {
|
|
|
1123
1119
|
}
|
|
1124
1120
|
};
|
|
1125
1121
|
|
|
1126
|
-
// src/utils/tokenStore.ts
|
|
1127
|
-
import fetch3 from "cross-fetch";
|
|
1128
|
-
|
|
1129
1122
|
// src/utils/store.ts
|
|
1130
1123
|
var LocalStorageStore = class {
|
|
1131
1124
|
get(key) {
|
|
@@ -1254,7 +1247,7 @@ var _TokenStore = class _TokenStore {
|
|
|
1254
1247
|
async refreshTokens() {
|
|
1255
1248
|
if (!this.tokens)
|
|
1256
1249
|
throw new Error("No tokens found to refresh");
|
|
1257
|
-
const response = await
|
|
1250
|
+
const response = await fetch(`${this.configuration.endpoint}/api/customer/identity/refresh?token=${this.tokens.refreshToken}`, {
|
|
1258
1251
|
method: "POST",
|
|
1259
1252
|
headers: {
|
|
1260
1253
|
"Accept": "application/json",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"dist/**"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"cross-fetch": "^4.0.0",
|
|
17
16
|
"zod": "^3.23.8"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|