@unchainedshop/platform 3.1.10 → 3.1.13

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.
@@ -0,0 +1,4 @@
1
+ import { Context } from '@unchainedshop/types/api.js';
2
+ declare const _default: (fn?: (context: Context) => any) => any;
3
+ export default _default;
4
+ //# sourceMappingURL=withAccessToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAccessToken.d.ts","sourceRoot":"","sources":["../../src/context/withAccessToken.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;8BAOlC,CAAC,OAAO,EAAE,OAAO,KAAK,GAAG,KAAqB,GAAG;AAArE,wBAmCE"}
@@ -0,0 +1,42 @@
1
+ import { createLogger } from '@unchainedshop/logger';
2
+ import { timingSafeEqual } from 'crypto';
3
+ const logger = createLogger('unchained:platform');
4
+ const contextIdentity = (params) => params;
5
+ export default (fn = contextIdentity) => {
6
+ return async (params, unchainedContextFn) => {
7
+ const unchainedContext = await unchainedContextFn(params);
8
+ const newContext = {
9
+ userId: unchainedContext.userId,
10
+ user: unchainedContext.user,
11
+ };
12
+ if (!unchainedContext.userId && params.req.headers.authorization) {
13
+ const [type, userToken] = params.req.headers.authorization.split(' ');
14
+ if (type === 'Bearer' && userToken) {
15
+ const [username, secret] = userToken.split(':');
16
+ const user = await unchainedContext.modules.users.findUser({
17
+ username,
18
+ });
19
+ if (secret && user?.services.token?.secret) {
20
+ try {
21
+ if (timingSafeEqual(Buffer.from(secret), Buffer.from(user?.services.token?.secret))) {
22
+ newContext.userId = user._id;
23
+ newContext.user = user;
24
+ logger.debug('Token login success');
25
+ }
26
+ else {
27
+ throw new Error('Access Token not valid');
28
+ }
29
+ }
30
+ catch (e) {
31
+ logger.warn(`Token login failed: ${e.message}`);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ return fn({
37
+ ...unchainedContext,
38
+ ...newContext,
39
+ });
40
+ };
41
+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AI,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;4BACpF,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;4BAC7B,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;4BACvB,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;wBACtC,CAAC;6BAAM,CAAC;4BACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;wBAC5C,CAAC;oBACH,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;oBAClD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;YACR,GAAG,gBAAgB;YACnB,GAAG,UAAU;SACd,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Address } from '@unchainedshop/types/common.js';
2
+ export declare const formatAddress: (address: Address) => string;
3
+ //# sourceMappingURL=formatAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatAddress.d.ts","sourceRoot":"","sources":["../../../src/templates/order-parser/formatAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,eAAO,MAAM,aAAa,YAAa,OAAO,WAY7C,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const formatAddress = (address) => {
2
+ return [
3
+ [address.firstName, address.lastName].filter(Boolean).join(' '),
4
+ address.company,
5
+ address.addressLine,
6
+ address.addressLine2,
7
+ [address.postalCode, address.city].filter(Boolean).join(' '),
8
+ address.regionCode,
9
+ [address.countryCode].filter(Boolean).join(''),
10
+ ]
11
+ .filter(Boolean)
12
+ .join('\n');
13
+ };
14
+ //# sourceMappingURL=formatAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatAddress.js","sourceRoot":"","sources":["../../../src/templates/order-parser/formatAddress.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,EAAE;IAChD,OAAO;QACL,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/D,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,WAAW;QACnB,OAAO,CAAC,YAAY;QACpB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5D,OAAO,CAAC,UAAU;QAClB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KAC/C;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const formatPrice: ({ amount, currency }: {
2
+ amount: number;
3
+ currency: string;
4
+ }) => string;
5
+ export default formatPrice;
6
+ //# sourceMappingURL=formatPrice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatPrice.d.ts","sourceRoot":"","sources":["../../../src/templates/order-parser/formatPrice.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,yBAA0B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,WAGrF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const formatPrice = ({ amount, currency }) => {
2
+ const fixedPrice = amount / 100;
3
+ return `${currency} ${fixedPrice}`;
4
+ };
5
+ export default formatPrice;
6
+ //# sourceMappingURL=formatPrice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatPrice.js","sourceRoot":"","sources":["../../../src/templates/order-parser/formatPrice.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAwC,EAAE,EAAE;IACxF,MAAM,UAAU,GAAG,MAAM,GAAG,GAAG,CAAC;IAChC,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/platform",
3
- "version": "3.1.10",
3
+ "version": "3.1.13",
4
4
  "main": "lib/platform-index.js",
5
5
  "types": "lib/platform-index.d.ts",
6
6
  "type": "module",
@@ -31,25 +31,26 @@
31
31
  },
32
32
  "homepage": "https://github.com/unchainedshop/unchained#readme",
33
33
  "engines": {
34
- "node": ">=22.0.0"
34
+ "node": ">=22.0.0",
35
+ "npm": ">=10.0.0"
35
36
  },
36
37
  "dependencies": {
37
- "@unchainedshop/api": "^3.1.7",
38
- "@unchainedshop/core": "^3.1.7",
39
- "@unchainedshop/events": "^3.1.7",
40
- "@unchainedshop/file-upload": "^3.1.7",
41
- "@unchainedshop/logger": "^3.1.7",
42
- "@unchainedshop/mongodb": "^3.1.7",
43
- "@unchainedshop/plugins": "^3.1.7",
44
- "@unchainedshop/roles": "^3.1.7",
45
- "@unchainedshop/utils": "^3.1.7",
38
+ "@unchainedshop/api": "^3.1.12",
39
+ "@unchainedshop/core": "^3.1.13",
40
+ "@unchainedshop/events": "^3.1.13",
41
+ "@unchainedshop/file-upload": "^3.1.13",
42
+ "@unchainedshop/logger": "^3.1.13",
43
+ "@unchainedshop/mongodb": "^3.1.12",
44
+ "@unchainedshop/plugins": "^3.1.13",
45
+ "@unchainedshop/roles": "^3.1.13",
46
+ "@unchainedshop/utils": "^3.1.13",
46
47
  "mustache": "^4.2.0",
47
48
  "safe-stable-stringify": "^2.5.0"
48
49
  },
49
50
  "devDependencies": {
50
- "@types/mustache": "^4.2.5",
51
- "@types/node": "^22.13.14",
52
- "tsx": "^4.19.3",
53
- "typescript": "^5.8.2"
51
+ "@types/mustache": "^4.2.6",
52
+ "@types/node": "^24.0.4",
53
+ "tsx": "^4.20.3",
54
+ "typescript": "^5.8.3"
54
55
  }
55
56
  }