@scayle/storefront-core 8.3.2 → 8.5.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/CHANGELOG.md +22 -0
- package/dist/api/customer.d.ts +19 -13
- package/dist/api/customer.mjs +16 -10
- package/dist/api/oauth.d.ts +45 -11
- package/dist/api/oauth.mjs +43 -10
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/search.d.ts +22 -0
- package/dist/types/user.d.ts +1 -1
- package/package.json +9 -19
- package/dist/api/customer.cjs +0 -158
- package/dist/api/oauth.cjs +0 -205
- package/dist/cache/cache.cjs +0 -1
- package/dist/cache/cached.cjs +0 -90
- package/dist/cache/index.cjs +0 -27
- package/dist/cache/providers/unstorage.cjs +0 -55
- package/dist/constants/basket.cjs +0 -26
- package/dist/constants/cache.cjs +0 -7
- package/dist/constants/hash.cjs +0 -11
- package/dist/constants/httpStatus.cjs +0 -634
- package/dist/constants/index.cjs +0 -93
- package/dist/constants/product.cjs +0 -10
- package/dist/constants/promotion.cjs +0 -12
- package/dist/constants/sorting.cjs +0 -22
- package/dist/constants/withParameters.cjs +0 -132
- package/dist/errors/errorResponse.cjs +0 -27
- package/dist/errors/index.cjs +0 -16
- package/dist/helpers/advancedAttributeHelpers.cjs +0 -30
- package/dist/helpers/arrayHelpers.cjs +0 -10
- package/dist/helpers/attributeHelpers.cjs +0 -24
- package/dist/helpers/basketHelpers.cjs +0 -12
- package/dist/helpers/categoryHelper.cjs +0 -61
- package/dist/helpers/filterHelper.cjs +0 -185
- package/dist/helpers/formHelpers.cjs +0 -114
- package/dist/helpers/imageHelpers.cjs +0 -20
- package/dist/helpers/index.cjs +0 -181
- package/dist/helpers/localization.cjs +0 -13
- package/dist/helpers/objectHelpers.cjs +0 -19
- package/dist/helpers/orderHelpers.cjs +0 -10
- package/dist/helpers/product.fixture.cjs +0 -766
- package/dist/helpers/productDisruptorHelper.cjs +0 -37
- package/dist/helpers/productHelpers.cjs +0 -156
- package/dist/helpers/sanitizationHelpers.cjs +0 -35
- package/dist/helpers/sortingHelper.cjs +0 -68
- package/dist/helpers/stringHelpers.cjs +0 -8
- package/dist/index.cjs +0 -100
- package/dist/rpc/methods/basket/basket.cjs +0 -270
- package/dist/rpc/methods/brands.cjs +0 -33
- package/dist/rpc/methods/categories.cjs +0 -129
- package/dist/rpc/methods/cbd.cjs +0 -38
- package/dist/rpc/methods/checkout/checkout.cjs +0 -48
- package/dist/rpc/methods/checkout/index.cjs +0 -49
- package/dist/rpc/methods/checkout/order.cjs +0 -42
- package/dist/rpc/methods/checkout/shopUser.cjs +0 -110
- package/dist/rpc/methods/checkout/shopUserAddresses.cjs +0 -12
- package/dist/rpc/methods/index.cjs +0 -225
- package/dist/rpc/methods/navigationTrees.cjs +0 -54
- package/dist/rpc/methods/oauth/idp.cjs +0 -59
- package/dist/rpc/methods/products.cjs +0 -309
- package/dist/rpc/methods/promotion.cjs +0 -51
- package/dist/rpc/methods/search.cjs +0 -40
- package/dist/rpc/methods/session.cjs +0 -257
- package/dist/rpc/methods/shopConfiguration.cjs +0 -15
- package/dist/rpc/methods/user.cjs +0 -103
- package/dist/rpc/methods/variants.cjs +0 -29
- package/dist/rpc/methods/wishlist.cjs +0 -104
- package/dist/server.cjs +0 -47
- package/dist/test/factories/index.cjs +0 -16
- package/dist/types/api/auth.cjs +0 -1
- package/dist/types/api/context.cjs +0 -15
- package/dist/types/api/rpc.cjs +0 -1
- package/dist/types/breadcrumb.cjs +0 -1
- package/dist/types/index.cjs +0 -267
- package/dist/types/promises.cjs +0 -1
- package/dist/types/sapi/basket.cjs +0 -1
- package/dist/types/sapi/brand.cjs +0 -1
- package/dist/types/sapi/campaign.cjs +0 -1
- package/dist/types/sapi/category.cjs +0 -1
- package/dist/types/sapi/filter.cjs +0 -1
- package/dist/types/sapi/navigation.cjs +0 -1
- package/dist/types/sapi/order.cjs +0 -1
- package/dist/types/sapi/product.cjs +0 -1
- package/dist/types/sapi/productFilter.cjs +0 -1
- package/dist/types/sapi/promotion.cjs +0 -1
- package/dist/types/sapi/redirects.cjs +0 -1
- package/dist/types/sapi/router.cjs +0 -1
- package/dist/types/sapi/search.cjs +0 -1
- package/dist/types/sapi/sorting.cjs +0 -1
- package/dist/types/sapi/variant.cjs +0 -1
- package/dist/types/sapi/wishlist.cjs +0 -1
- package/dist/types/user.cjs +0 -1
- package/dist/utils/basket.cjs +0 -14
- package/dist/utils/fetch.cjs +0 -19
- package/dist/utils/hash.cjs +0 -72
- package/dist/utils/index.cjs +0 -49
- package/dist/utils/keys.cjs +0 -67
- package/dist/utils/log.cjs +0 -93
- package/dist/utils/response.cjs +0 -13
- package/dist/utils/sapi.cjs +0 -26
- package/dist/utils/timeout.cjs +0 -18
- package/dist/utils/user.cjs +0 -90
- /package/dist/api/{README.md → INFO.md} +0 -0
package/dist/types/index.cjs
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
StorefrontAPIClient: true
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "StorefrontAPIClient", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return _storefrontApi.StorefrontAPIClient;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
var _promises = require("./promises.cjs");
|
|
16
|
-
Object.keys(_promises).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _promises[key]) return;
|
|
20
|
-
Object.defineProperty(exports, key, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _promises[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _user = require("./user.cjs");
|
|
28
|
-
Object.keys(_user).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _user[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _user[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _breadcrumb = require("./breadcrumb.cjs");
|
|
40
|
-
Object.keys(_breadcrumb).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
-
if (key in exports && exports[key] === _breadcrumb[key]) return;
|
|
44
|
-
Object.defineProperty(exports, key, {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _breadcrumb[key];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
var _rpc = require("./api/rpc.cjs");
|
|
52
|
-
Object.keys(_rpc).forEach(function (key) {
|
|
53
|
-
if (key === "default" || key === "__esModule") return;
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
55
|
-
if (key in exports && exports[key] === _rpc[key]) return;
|
|
56
|
-
Object.defineProperty(exports, key, {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return _rpc[key];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
var _context = require("./api/context.cjs");
|
|
64
|
-
Object.keys(_context).forEach(function (key) {
|
|
65
|
-
if (key === "default" || key === "__esModule") return;
|
|
66
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
67
|
-
if (key in exports && exports[key] === _context[key]) return;
|
|
68
|
-
Object.defineProperty(exports, key, {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return _context[key];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
var _auth = require("./api/auth.cjs");
|
|
76
|
-
Object.keys(_auth).forEach(function (key) {
|
|
77
|
-
if (key === "default" || key === "__esModule") return;
|
|
78
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
79
|
-
if (key in exports && exports[key] === _auth[key]) return;
|
|
80
|
-
Object.defineProperty(exports, key, {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function () {
|
|
83
|
-
return _auth[key];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
var _storefrontApi = require("@scayle/storefront-api");
|
|
88
|
-
var _basket = require("./sapi/basket.cjs");
|
|
89
|
-
Object.keys(_basket).forEach(function (key) {
|
|
90
|
-
if (key === "default" || key === "__esModule") return;
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
-
if (key in exports && exports[key] === _basket[key]) return;
|
|
93
|
-
Object.defineProperty(exports, key, {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function () {
|
|
96
|
-
return _basket[key];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
var _brand = require("./sapi/brand.cjs");
|
|
101
|
-
Object.keys(_brand).forEach(function (key) {
|
|
102
|
-
if (key === "default" || key === "__esModule") return;
|
|
103
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
104
|
-
if (key in exports && exports[key] === _brand[key]) return;
|
|
105
|
-
Object.defineProperty(exports, key, {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function () {
|
|
108
|
-
return _brand[key];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
var _campaign = require("./sapi/campaign.cjs");
|
|
113
|
-
Object.keys(_campaign).forEach(function (key) {
|
|
114
|
-
if (key === "default" || key === "__esModule") return;
|
|
115
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
116
|
-
if (key in exports && exports[key] === _campaign[key]) return;
|
|
117
|
-
Object.defineProperty(exports, key, {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
get: function () {
|
|
120
|
-
return _campaign[key];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
var _category = require("./sapi/category.cjs");
|
|
125
|
-
Object.keys(_category).forEach(function (key) {
|
|
126
|
-
if (key === "default" || key === "__esModule") return;
|
|
127
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
128
|
-
if (key in exports && exports[key] === _category[key]) return;
|
|
129
|
-
Object.defineProperty(exports, key, {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
get: function () {
|
|
132
|
-
return _category[key];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
var _filter = require("./sapi/filter.cjs");
|
|
137
|
-
Object.keys(_filter).forEach(function (key) {
|
|
138
|
-
if (key === "default" || key === "__esModule") return;
|
|
139
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
140
|
-
if (key in exports && exports[key] === _filter[key]) return;
|
|
141
|
-
Object.defineProperty(exports, key, {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get: function () {
|
|
144
|
-
return _filter[key];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
var _navigation = require("./sapi/navigation.cjs");
|
|
149
|
-
Object.keys(_navigation).forEach(function (key) {
|
|
150
|
-
if (key === "default" || key === "__esModule") return;
|
|
151
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
152
|
-
if (key in exports && exports[key] === _navigation[key]) return;
|
|
153
|
-
Object.defineProperty(exports, key, {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function () {
|
|
156
|
-
return _navigation[key];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
var _order = require("./sapi/order.cjs");
|
|
161
|
-
Object.keys(_order).forEach(function (key) {
|
|
162
|
-
if (key === "default" || key === "__esModule") return;
|
|
163
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
164
|
-
if (key in exports && exports[key] === _order[key]) return;
|
|
165
|
-
Object.defineProperty(exports, key, {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
get: function () {
|
|
168
|
-
return _order[key];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
var _product = require("./sapi/product.cjs");
|
|
173
|
-
Object.keys(_product).forEach(function (key) {
|
|
174
|
-
if (key === "default" || key === "__esModule") return;
|
|
175
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
176
|
-
if (key in exports && exports[key] === _product[key]) return;
|
|
177
|
-
Object.defineProperty(exports, key, {
|
|
178
|
-
enumerable: true,
|
|
179
|
-
get: function () {
|
|
180
|
-
return _product[key];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
var _productFilter = require("./sapi/productFilter.cjs");
|
|
185
|
-
Object.keys(_productFilter).forEach(function (key) {
|
|
186
|
-
if (key === "default" || key === "__esModule") return;
|
|
187
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
188
|
-
if (key in exports && exports[key] === _productFilter[key]) return;
|
|
189
|
-
Object.defineProperty(exports, key, {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function () {
|
|
192
|
-
return _productFilter[key];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
var _redirects = require("./sapi/redirects.cjs");
|
|
197
|
-
Object.keys(_redirects).forEach(function (key) {
|
|
198
|
-
if (key === "default" || key === "__esModule") return;
|
|
199
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
200
|
-
if (key in exports && exports[key] === _redirects[key]) return;
|
|
201
|
-
Object.defineProperty(exports, key, {
|
|
202
|
-
enumerable: true,
|
|
203
|
-
get: function () {
|
|
204
|
-
return _redirects[key];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
var _router = require("./sapi/router.cjs");
|
|
209
|
-
Object.keys(_router).forEach(function (key) {
|
|
210
|
-
if (key === "default" || key === "__esModule") return;
|
|
211
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
212
|
-
if (key in exports && exports[key] === _router[key]) return;
|
|
213
|
-
Object.defineProperty(exports, key, {
|
|
214
|
-
enumerable: true,
|
|
215
|
-
get: function () {
|
|
216
|
-
return _router[key];
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
var _search = require("./sapi/search.cjs");
|
|
221
|
-
Object.keys(_search).forEach(function (key) {
|
|
222
|
-
if (key === "default" || key === "__esModule") return;
|
|
223
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
224
|
-
if (key in exports && exports[key] === _search[key]) return;
|
|
225
|
-
Object.defineProperty(exports, key, {
|
|
226
|
-
enumerable: true,
|
|
227
|
-
get: function () {
|
|
228
|
-
return _search[key];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
var _sorting = require("./sapi/sorting.cjs");
|
|
233
|
-
Object.keys(_sorting).forEach(function (key) {
|
|
234
|
-
if (key === "default" || key === "__esModule") return;
|
|
235
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
236
|
-
if (key in exports && exports[key] === _sorting[key]) return;
|
|
237
|
-
Object.defineProperty(exports, key, {
|
|
238
|
-
enumerable: true,
|
|
239
|
-
get: function () {
|
|
240
|
-
return _sorting[key];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
var _wishlist = require("./sapi/wishlist.cjs");
|
|
245
|
-
Object.keys(_wishlist).forEach(function (key) {
|
|
246
|
-
if (key === "default" || key === "__esModule") return;
|
|
247
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
248
|
-
if (key in exports && exports[key] === _wishlist[key]) return;
|
|
249
|
-
Object.defineProperty(exports, key, {
|
|
250
|
-
enumerable: true,
|
|
251
|
-
get: function () {
|
|
252
|
-
return _wishlist[key];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
var _promotion = require("./sapi/promotion.cjs");
|
|
257
|
-
Object.keys(_promotion).forEach(function (key) {
|
|
258
|
-
if (key === "default" || key === "__esModule") return;
|
|
259
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
260
|
-
if (key in exports && exports[key] === _promotion[key]) return;
|
|
261
|
-
Object.defineProperty(exports, key, {
|
|
262
|
-
enumerable: true,
|
|
263
|
-
get: function () {
|
|
264
|
-
return _promotion[key];
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
});
|
package/dist/types/promises.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/types/user.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/utils/basket.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wasAddedWithReducedQuantity = void 0;
|
|
7
|
-
var _constants = require("../constants/index.cjs");
|
|
8
|
-
const wasAddedWithReducedQuantity = errors => {
|
|
9
|
-
if (!errors) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return errors.every(error => error.operation === "add" && error.kind === _constants.AddToBasketFailureKind.ItemAddedWithReducedQuantity || error.operation === "update" && error.kind === _constants.UpdateBasketItemFailureKind.ItemAddedWithReducedQuantity);
|
|
13
|
-
};
|
|
14
|
-
exports.wasAddedWithReducedQuantity = wasAddedWithReducedQuantity;
|
package/dist/utils/fetch.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FetchError = void 0;
|
|
7
|
-
class FetchError extends Error {
|
|
8
|
-
response;
|
|
9
|
-
data;
|
|
10
|
-
constructor(response, data) {
|
|
11
|
-
const message = `Failed to fetch ${response.url}. ${response.status} ${response.statusText}`;
|
|
12
|
-
super(message);
|
|
13
|
-
this.response = response;
|
|
14
|
-
this.data = data;
|
|
15
|
-
this.name = "FetchError";
|
|
16
|
-
this.message = message;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.FetchError = FetchError;
|
package/dist/utils/hash.cjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.verifyOrderSuccessToken = exports.sha256 = exports.md5 = exports.hmac = exports.encodeBase64 = exports.decodeBase64 = exports.buildSignature = exports.buildHashPayload = void 0;
|
|
7
|
-
var _uncrypto = require("uncrypto");
|
|
8
|
-
function stringToBoolean(value, defaultValue = false) {
|
|
9
|
-
return value ? value.toLowerCase() === "true" : defaultValue;
|
|
10
|
-
}
|
|
11
|
-
const md5 = async value => {
|
|
12
|
-
if (!stringToBoolean(process.env.SFC_OMIT_MD5)) {
|
|
13
|
-
const md5EncryptImport = await Promise.resolve().then(() => require("crypto-js/md5.js"));
|
|
14
|
-
const hexImport = await Promise.resolve().then(() => require("crypto-js/enc-hex.js"));
|
|
15
|
-
const md5Encrypt = md5EncryptImport.default && (typeof md5EncryptImport.default === "function" || typeof md5EncryptImport.default === "object") ? md5EncryptImport.default : md5EncryptImport;
|
|
16
|
-
const hex = hexImport.default && (typeof hexImport.default === "function" || typeof hexImport.default === "object") ? hexImport.default : hexImport;
|
|
17
|
-
return hex.stringify(md5Encrypt(value));
|
|
18
|
-
} else {
|
|
19
|
-
throw Error("SFC was built without support for MD5");
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.md5 = md5;
|
|
23
|
-
const sha256 = async value => Array.from(new Uint8Array(await _uncrypto.subtle.digest("SHA-256", new TextEncoder().encode(value)))).map(b => b.toString(16).padStart(2, "0")).join("");
|
|
24
|
-
exports.sha256 = sha256;
|
|
25
|
-
const hmac = async (value, secret, algorithm = "SHA-256") => {
|
|
26
|
-
const encoder = new TextEncoder();
|
|
27
|
-
const messageUint8Array = encoder.encode(value);
|
|
28
|
-
const keyUint8Array = encoder.encode(secret);
|
|
29
|
-
const cryptoKey = await _uncrypto.subtle.importKey("raw", keyUint8Array, {
|
|
30
|
-
name: "HMAC",
|
|
31
|
-
hash: algorithm
|
|
32
|
-
}, false, ["sign"]);
|
|
33
|
-
const signature = await _uncrypto.subtle.sign("HMAC", cryptoKey, messageUint8Array);
|
|
34
|
-
const hashArray = Array.from(new Uint8Array(signature));
|
|
35
|
-
return hashArray.map(b => b.toString(16).padStart(2, "0")).join("");
|
|
36
|
-
};
|
|
37
|
-
exports.hmac = hmac;
|
|
38
|
-
function base64ToBytes(base64) {
|
|
39
|
-
const binString = atob(base64);
|
|
40
|
-
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
41
|
-
}
|
|
42
|
-
function bytesToBase64(bytes) {
|
|
43
|
-
const binString = Array.from(bytes, x => String.fromCodePoint(x)).join("");
|
|
44
|
-
return btoa(binString);
|
|
45
|
-
}
|
|
46
|
-
const encodeBase64 = string => {
|
|
47
|
-
if (typeof Buffer === "function") {
|
|
48
|
-
return Buffer.from(string).toString("base64");
|
|
49
|
-
}
|
|
50
|
-
return bytesToBase64(new TextEncoder().encode(string));
|
|
51
|
-
};
|
|
52
|
-
exports.encodeBase64 = encodeBase64;
|
|
53
|
-
const decodeBase64 = string => {
|
|
54
|
-
if (typeof Buffer === "function") {
|
|
55
|
-
return Buffer.from(string, "base64").toString("utf-8");
|
|
56
|
-
}
|
|
57
|
-
return new TextDecoder().decode(base64ToBytes(string));
|
|
58
|
-
};
|
|
59
|
-
exports.decodeBase64 = decodeBase64;
|
|
60
|
-
const verifyOrderSuccessToken = async (token, secret) => {
|
|
61
|
-
const [encodedPayload, signature] = token.split(".", 2);
|
|
62
|
-
const expectedSignature = encodeBase64(await hmac(encodedPayload, secret));
|
|
63
|
-
if (expectedSignature === signature) {
|
|
64
|
-
return JSON.parse(decodeBase64(encodedPayload));
|
|
65
|
-
}
|
|
66
|
-
return void 0;
|
|
67
|
-
};
|
|
68
|
-
exports.verifyOrderSuccessToken = verifyOrderSuccessToken;
|
|
69
|
-
const buildHashPayload = payload => encodeBase64(JSON.stringify(payload));
|
|
70
|
-
exports.buildHashPayload = buildHashPayload;
|
|
71
|
-
const buildSignature = async (payloadHash, secret) => encodeBase64(await hmac(payloadHash, secret));
|
|
72
|
-
exports.buildSignature = buildSignature;
|
package/dist/utils/index.cjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _timeout = require("./timeout.cjs");
|
|
7
|
-
Object.keys(_timeout).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _timeout[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _timeout[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _log = require("./log.cjs");
|
|
18
|
-
Object.keys(_log).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _log[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _log[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _fetch = require("./fetch.cjs");
|
|
29
|
-
Object.keys(_fetch).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _fetch[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _fetch[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _basket = require("./basket.cjs");
|
|
40
|
-
Object.keys(_basket).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _basket[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _basket[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
package/dist/utils/keys.cjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateWishlistKey = exports.generateKey = exports.generateBasketKey = void 0;
|
|
7
|
-
var _hash = require("../constants/hash.cjs");
|
|
8
|
-
var _hash2 = require("./hash.cjs");
|
|
9
|
-
const generateKey = async ({
|
|
10
|
-
keyTemplate,
|
|
11
|
-
hashAlgorithm = _hash.HashAlgorithm.SHA256,
|
|
12
|
-
shopId,
|
|
13
|
-
userId,
|
|
14
|
-
log
|
|
15
|
-
}) => {
|
|
16
|
-
if (!shopId) {
|
|
17
|
-
log?.warn("No shopId provided", {
|
|
18
|
-
shopId
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (!userId) {
|
|
22
|
-
log?.warn("No userId provided", {
|
|
23
|
-
userId
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const key = String(keyTemplate.replace("{shopId}", shopId).replace("{userId}", userId));
|
|
27
|
-
if (hashAlgorithm === _hash.HashAlgorithm.MD5) {
|
|
28
|
-
return await (0, _hash2.md5)(key);
|
|
29
|
-
}
|
|
30
|
-
if (hashAlgorithm === _hash.HashAlgorithm.SHA256) {
|
|
31
|
-
return await (0, _hash2.sha256)(key);
|
|
32
|
-
}
|
|
33
|
-
return key;
|
|
34
|
-
};
|
|
35
|
-
exports.generateKey = generateKey;
|
|
36
|
-
const generateWishlistKey = async ({
|
|
37
|
-
keyTemplate,
|
|
38
|
-
hashAlgorithm = _hash.HashAlgorithm.SHA256,
|
|
39
|
-
shopId,
|
|
40
|
-
userId,
|
|
41
|
-
log
|
|
42
|
-
}) => {
|
|
43
|
-
return await generateKey({
|
|
44
|
-
log: log?.space("core.generateWishlistKey"),
|
|
45
|
-
keyTemplate,
|
|
46
|
-
hashAlgorithm,
|
|
47
|
-
shopId,
|
|
48
|
-
userId
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
exports.generateWishlistKey = generateWishlistKey;
|
|
52
|
-
const generateBasketKey = async ({
|
|
53
|
-
keyTemplate,
|
|
54
|
-
hashAlgorithm = _hash.HashAlgorithm.SHA256,
|
|
55
|
-
shopId,
|
|
56
|
-
userId,
|
|
57
|
-
log
|
|
58
|
-
}) => {
|
|
59
|
-
return await generateKey({
|
|
60
|
-
log: log?.space("core.generateBasketKey"),
|
|
61
|
-
keyTemplate,
|
|
62
|
-
hashAlgorithm,
|
|
63
|
-
shopId,
|
|
64
|
-
userId
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
exports.generateBasketKey = generateBasketKey;
|
package/dist/utils/log.cjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Log = void 0;
|
|
7
|
-
class Log {
|
|
8
|
-
static default = new this({
|
|
9
|
-
space: "global",
|
|
10
|
-
handler: consoleLogHandler
|
|
11
|
-
});
|
|
12
|
-
_handler;
|
|
13
|
-
_space;
|
|
14
|
-
_type = "log";
|
|
15
|
-
constructor(options) {
|
|
16
|
-
this._handler = options?.handler || Log.default._handler;
|
|
17
|
-
this._space = options?.space || Log.default._space;
|
|
18
|
-
}
|
|
19
|
-
debug(message, data) {
|
|
20
|
-
this.write("debug", message, data);
|
|
21
|
-
}
|
|
22
|
-
info(message, data) {
|
|
23
|
-
this.write("info", message, data);
|
|
24
|
-
}
|
|
25
|
-
warn(message, data) {
|
|
26
|
-
this.write("warn", message, data);
|
|
27
|
-
}
|
|
28
|
-
error(message, data) {
|
|
29
|
-
const error = message instanceof Error ? message : null;
|
|
30
|
-
if (error) {
|
|
31
|
-
data = {
|
|
32
|
-
error: message,
|
|
33
|
-
...data
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
this.write("error", error?.message ?? message, data);
|
|
37
|
-
}
|
|
38
|
-
write(level, message, data) {
|
|
39
|
-
if (typeof data !== "undefined") {
|
|
40
|
-
data = typeof data !== "object" ? {
|
|
41
|
-
data
|
|
42
|
-
} : data;
|
|
43
|
-
}
|
|
44
|
-
if (this._handler) {
|
|
45
|
-
this._handler({
|
|
46
|
-
level,
|
|
47
|
-
message,
|
|
48
|
-
data,
|
|
49
|
-
space: this._space
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
const logFunc = console[level] || console.log;
|
|
53
|
-
logFunc.apply(console, data ? [message, data] : [message]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Create a new sub-space.
|
|
58
|
-
* All spaces are being separated by a dot. E.g. `global.api` and `global.api.getUser`
|
|
59
|
-
* @param subSpace The name of the sub-space in camel-case (e.g. `api` and `api.getUser`)
|
|
60
|
-
*/
|
|
61
|
-
space(subSpace) {
|
|
62
|
-
return new Log({
|
|
63
|
-
space: `${this._space}.${subSpace}`,
|
|
64
|
-
handler: this._handler
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Measure the time of a function.
|
|
69
|
-
*/
|
|
70
|
-
async time(message, func) {
|
|
71
|
-
const start = Date.now();
|
|
72
|
-
const result = await func();
|
|
73
|
-
const end = Date.now();
|
|
74
|
-
this.debug(`${message} took ${end - start}ms`);
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Attach the log to the request object: `req.$log`.
|
|
79
|
-
* This function should be called in a server middleware before storefront-core is initialized.
|
|
80
|
-
*/
|
|
81
|
-
static attachToRequest(req, log) {
|
|
82
|
-
req.$log = log;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.Log = Log;
|
|
86
|
-
function consoleLogHandler({
|
|
87
|
-
level,
|
|
88
|
-
message,
|
|
89
|
-
data
|
|
90
|
-
}) {
|
|
91
|
-
const logFunc = console[level] || console.log;
|
|
92
|
-
logFunc.apply(console, data ? [message, data] : [message]);
|
|
93
|
-
}
|
package/dist/utils/response.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.unwrap = unwrap;
|
|
7
|
-
async function unwrap(res) {
|
|
8
|
-
const response = await res;
|
|
9
|
-
if (response instanceof Response) {
|
|
10
|
-
return await response.json();
|
|
11
|
-
}
|
|
12
|
-
return response;
|
|
13
|
-
}
|
package/dist/utils/sapi.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mapSAPIFetchErrorToResponse = mapSAPIFetchErrorToResponse;
|
|
7
|
-
var _storefrontApi = require("@scayle/storefront-api");
|
|
8
|
-
function mapSAPIFetchErrorToResponse(func) {
|
|
9
|
-
return async (...args) => {
|
|
10
|
-
try {
|
|
11
|
-
return await func(...args);
|
|
12
|
-
} catch (e) {
|
|
13
|
-
if (e instanceof _storefrontApi.FetchError) {
|
|
14
|
-
const response = e.response;
|
|
15
|
-
return Response.json({
|
|
16
|
-
statusCode: response.status,
|
|
17
|
-
statusMessage: response.statusText
|
|
18
|
-
}, {
|
|
19
|
-
status: response.status,
|
|
20
|
-
statusText: response.statusText
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|