@unchainedshop/plugins 3.1.0 → 3.1.2

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.
@@ -1,20 +1,23 @@
1
1
  import { setEmitAdapter } from '@unchainedshop/events';
2
- import { EventBridgeClient, PutEventsCommand } from '@aws-sdk/client-eventbridge';
3
2
  import { createLogger } from '@unchainedshop/logger';
4
3
  const logger = createLogger('unchained:eventbridge');
5
- const EventBridgeEventEmitter = ({ region, source, busName }) => {
4
+ const EventBridgeEventEmitter = async ({ region, source, busName }) => {
5
+ // eslint-disable-next-line
6
+ // @ts-expect-error
7
+ const { EventBridgeClient, PutEventsCommand } = await import('@aws-sdk/client-eventbridge');
6
8
  const ebClient = new EventBridgeClient({ region });
7
9
  return {
8
10
  publish: (eventName, payload) => {
9
- const entry = {
10
- Source: source,
11
- DetailType: eventName,
12
- EventBusName: busName,
13
- Detail: JSON.stringify(payload),
14
- };
15
11
  ebClient
16
12
  .send(new PutEventsCommand({
17
- Entries: [entry],
13
+ Entries: [
14
+ {
15
+ Source: source,
16
+ DetailType: eventName,
17
+ EventBusName: busName,
18
+ Detail: JSON.stringify(payload),
19
+ },
20
+ ],
18
21
  }))
19
22
  .catch((e) => {
20
23
  logger.warn(e);
@@ -27,10 +30,11 @@ const EventBridgeEventEmitter = ({ region, source, busName }) => {
27
30
  };
28
31
  const { EVENT_BRIDGE_REGION, EVENT_BRIDGE_SOURCE, EVENT_BRIDGE_BUS_NAME } = process.env;
29
32
  if (EVENT_BRIDGE_REGION && EVENT_BRIDGE_SOURCE && EVENT_BRIDGE_BUS_NAME) {
30
- setEmitAdapter(EventBridgeEventEmitter({
33
+ const eventBridgeAdapter = await EventBridgeEventEmitter({
31
34
  source: EVENT_BRIDGE_SOURCE,
32
35
  region: EVENT_BRIDGE_REGION,
33
36
  busName: EVENT_BRIDGE_BUS_NAME,
34
- }));
37
+ });
38
+ setEmitAdapter(eventBridgeAdapter);
35
39
  }
36
40
  //# sourceMappingURL=aws-eventbridge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aws-eventbridge.js","sourceRoot":"","sources":["../../src/events/aws-eventbridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAyB,MAAM,6BAA6B,CAAC;AACzG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,uBAAuB,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAe,EAAE;IAC3E,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEnD,OAAO;QACL,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;YAC9B,MAAM,KAAK,GAA0B;gBACnC,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,SAAS;gBACrB,YAAY,EAAE,OAAO;gBACrB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAChC,CAAC;YACF,QAAQ;iBACL,IAAI,CACH,IAAI,gBAAgB,CAAC;gBACnB,OAAO,EAAE,CAAC,KAAK,CAAC;aACjB,CAAC,CACH;iBACA,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACP,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AACxF,IAAI,mBAAmB,IAAI,mBAAmB,IAAI,qBAAq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,CAAC,CAAC;AAEF,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AACxF,IAAI,mBAAmB,IAAI,mBAAmB,IAAI,qBAAqB,EAAE,CAAC;IACxE,MAAM,kBAAkB,GAAG,MAAM,uBAAuB,CAAC;QACvD,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,mBAAmB;QAC3B,OAAO,EAAE,qBAAqB;KAC/B,CAAC,CAAC;IACH,cAAc,CAAC,kBAAkB,CAAC,CAAC;AACrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/payment/cryptopay/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,eAAe,EAKhB,MAAM,qBAAqB,CAAC;AAsC7B,QAAA,MAAM,SAAS,EAAE,eAgPhB,CAAC;AAIF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/payment/cryptopay/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EAKhB,MAAM,qBAAqB,CAAC;AAgD7B,QAAA,MAAM,SAAS,EAAE,eA6OhB,CAAC;AAIF,eAAe,SAAS,CAAC"}
@@ -1,28 +1,50 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { BIP32Factory } from 'bip32';
3
+ import bs58check from 'bs58check';
3
4
  import * as ecc from 'tiny-secp256k1';
4
5
  import { networks, payments } from 'bitcoinjs-lib';
5
6
  import { createLogger } from '@unchainedshop/logger';
6
7
  import { PaymentAdapter, PaymentDirector, PaymentError, OrderPricingSheet, } from '@unchainedshop/core';
7
8
  const logger = createLogger('unchained:core-payment:cryptopay');
8
- const { CRYPTOPAY_SECRET, CRYPTOPAY_BTC_XPUB, CRYPTOPAY_ETH_XPUB, CRYPTOPAY_BTC_TESTNET, CRYPTOPAY_DERIVATION_START = '0', } = process.env;
9
+ const { CRYPTOPAY_SECRET, CRYPTOPAY_BTC_XPUB, CRYPTOPAY_ETH_XPUB } = process.env;
10
+ const resolvePath = (prefix) => {
11
+ if (prefix === 'x')
12
+ return `m/44'/0'`;
13
+ if (prefix === 'y')
14
+ return `m/49'/0'`;
15
+ if (prefix === 'z')
16
+ return `m/84'/0'`;
17
+ if (prefix === 't')
18
+ return `m/44'/1'`;
19
+ if (prefix === 'u')
20
+ return `m/49'/1'`;
21
+ if (prefix === 'v')
22
+ return `m/84'/1'`;
23
+ return `m`;
24
+ };
25
+ const resolveNetwork = (prefix) => {
26
+ if (['x', 'y', 'z'].includes(prefix))
27
+ return networks.bitcoin;
28
+ return networks.testnet;
29
+ };
30
+ function convertExtendedPublicKey(z) {
31
+ const derivationPath = resolvePath(z.slice(0, 1));
32
+ const network = resolveNetwork(z.slice(0, 1));
33
+ // https://github.com/satoshilabs/slips/blob/master/slip-0132.md
34
+ let data = bs58check.decode(z);
35
+ data = data.slice(4);
36
+ data = Buffer.concat([Buffer.from('0488b21e', 'hex'), data]);
37
+ return {
38
+ xpub: bs58check.encode(data),
39
+ network,
40
+ derivationPath,
41
+ };
42
+ }
9
43
  var CryptopayCurrencies;
10
44
  (function (CryptopayCurrencies) {
11
45
  CryptopayCurrencies["BTC"] = "BTC";
12
46
  CryptopayCurrencies["ETH"] = "ETH";
13
47
  })(CryptopayCurrencies || (CryptopayCurrencies = {}));
14
- const getDerivationPath = (currency, index) => {
15
- const address = `${(parseInt(CRYPTOPAY_DERIVATION_START, 10) || 0) + index}`;
16
- if (currency === CryptopayCurrencies.ETH) {
17
- const pathComponents = ethers.defaultPath.split('/');
18
- pathComponents[pathComponents.length - 1] = address;
19
- return pathComponents.join('/');
20
- }
21
- if (currency === CryptopayCurrencies.BTC) {
22
- return `m/44'/0'/0'/0/${address}`;
23
- }
24
- return `0/${address}`;
25
- };
26
48
  const Cryptopay = {
27
49
  ...PaymentAdapter,
28
50
  key: 'shop.unchained.payment.cryptopay',
@@ -101,15 +123,14 @@ const Cryptopay = {
101
123
  }
102
124
  const cryptoAddresses = [];
103
125
  if (CRYPTOPAY_BTC_XPUB) {
104
- const network = CRYPTOPAY_BTC_TESTNET ? networks.testnet : networks.bitcoin;
126
+ const { xpub, network } = convertExtendedPublicKey(CRYPTOPAY_BTC_XPUB);
105
127
  const bip32 = BIP32Factory(ecc);
106
- const hardenedMaster = bip32.fromBase58(CRYPTOPAY_BTC_XPUB, network);
128
+ const hardenedMaster = bip32.fromBase58(xpub, network);
107
129
  const btcDerivationNumber = await modules.cryptopay.getNextDerivationNumber(CryptopayCurrencies.BTC);
108
- const derivationPath = getDerivationPath(CryptopayCurrencies.BTC, btcDerivationNumber);
109
- const child = hardenedMaster.derivePath(derivationPath);
130
+ const child = hardenedMaster.derivePath(`0/${btcDerivationNumber}`);
110
131
  cryptoAddresses.push({
111
132
  currency: CryptopayCurrencies.BTC,
112
- address: payments.p2pkh({
133
+ address: payments.p2wpkh({
113
134
  pubkey: child.publicKey,
114
135
  network,
115
136
  }).address,
@@ -121,11 +142,9 @@ const Cryptopay = {
121
142
  const hdWallet = ethers.HDNodeWallet.fromExtendedKey(CRYPTOPAY_ETH_XPUB);
122
143
  const hardenedMaster = 'neuter' in hdWallet ? hdWallet.neuter() : hdWallet;
123
144
  const ethDerivationNumber = await modules.cryptopay.getNextDerivationNumber(CryptopayCurrencies.ETH);
124
- const derivationPath = getDerivationPath(CryptopayCurrencies.ETH, ethDerivationNumber);
125
- const cleanedForHD = derivationPath.split('/').slice(-2).join('/');
126
145
  cryptoAddresses.push({
127
146
  currency: CryptopayCurrencies.ETH,
128
- address: hardenedMaster.derivePath(cleanedForHD).address,
147
+ address: hardenedMaster.derivePath(`0/${ethDerivationNumber}`).address,
129
148
  });
130
149
  }
131
150
  const cryptoAddressesWithExpiration = await setConversionRates(order.currency, cryptoAddresses);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/payment/cryptopay/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AAG,KAAK,CAAC;oBAEvE,IAAI,SAAS,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;wBAC1C,cAAc;wBACd,OAAO;4BACL,aAAa,EAAE,qBAAqB,CAAC,GAAG;yBACzC,CAAC;oBACJ,CAAC;oBACD,MAAM,CAAC,IAAI,CACT,4BAA4B,qBAAqB,CAAC,GAAG,2BAA2B,SAAS,MAAM,WAAW,EAAE,CAC7G,CAAC;gBACJ,CAAC;gBAED,IAAI,qBAAqB,EAAE,CAAC;oBAC1B,gCAAgC;oBAChC,MAAM,eAAe,GACnB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;wBAC/C,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,mDAAmD;oBAE3G,IAAI,eAAe,IAAI,eAAe,IAAI,WAAW,EAAE,CAAC;wBACtD,OAAO;4BACL,aAAa,EAAE,qBAAqB,CAAC,GAAG;yBACzC,CAAC;oBACJ,CAAC;oBACD,MAAM,CAAC,IAAI,CACT,4BAA4B,qBAAqB,CAAC,GAAG,2BAA2B,eAAe,MAAM,WAAW,EAAE,CACnH,CAAC;gBACJ,CAAC;gBAED,MAAM,CAAC,IAAI,CACT,8DACE,KAAK,CAAC,QACR,kBAAkB,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAAE,CAC7D,CAAC;gBAEF;;;;;;;;;;;;;;;;;kBAiBE;gBAEF,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;QAEF,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAC;AAEF,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAE3C,eAAe,SAAS,CAAC"}
@@ -5,6 +5,7 @@ try {
5
5
  // eslint-disable-next-line
6
6
  // @ts-ignore
7
7
  checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
8
+ // TODO: npm warn deprecated @paypal/checkout-server-sdk@1.0.3: Package no longer supported. The author suggests using the @paypal/paypal-server-sdk package instead: https://www.npmjs.com/package/@paypal/paypal-server-sdk. Contact Support at https://www.npmjs.com/support for more info.
8
9
  }
9
10
  catch {
10
11
  /* */
@@ -1 +1 @@
1
- {"version":3,"file":"paypal-checkout.js","sourceRoot":"","sources":["../../src/payment/paypal-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,IAAI,iBAAiB,CAAC;AACtB,IAAI,CAAC;IACH,2BAA2B;IAC3B,aAAa;IACb,iBAAiB,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAClE,CAAC;AAAC,MAAM,CAAC;IACP,KAAK;AACP,CAAC;AAED,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAEtD,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,MAAM,QAAQ,GAAG,gBAAgB,CAAC;IAClC,MAAM,YAAY,GAAG,aAAa,CAAC;IAEnC,OAAO,kBAAkB,KAAK,MAAM;QAClC,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC;QACvE,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,cAAc,GAAoB;IACtC,GAAG,cAAc;IAEjB,GAAG,EAAE,+BAA+B;IACpC,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,OAAO;IAEhB,oBAAoB,EAAE,EAAE;IAExB,aAAa,E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K,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBACjF,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAEtE,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;wBAC7B,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;wBACjD,OAAO,KAAK,CAAC;oBACf,CAAC;oBAED,MAAM,CAAC,IAAI,CACT,8CAA8C,EAC9C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAC5C,CAAC;oBAEF,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;oBACvD,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;oBAEzD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;gBACtC,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC;oBAC/C,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;SACF,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC;AAEF,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "main": "lib/plugins-index.js",
5
5
  "types": "lib/plugins-index.d.ts",
6
6
  "exports": {
@@ -12,8 +12,8 @@
12
12
  "build": "tsc -b",
13
13
  "prepublishOnly": "npm run clean && npm run build",
14
14
  "watch": "tsc -w",
15
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
16
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --detectOpenHandles --forceExit"
15
+ "test": "tsx --test",
16
+ "test:watch": "tsx --test --watch"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -54,8 +54,9 @@
54
54
  "@aws-sdk/client-eventbridge": ">= 3.714 < 4",
55
55
  "@paypal/checkout-server-sdk": "1.x",
56
56
  "@redis/client": "1.x",
57
- "bip32": "4.x",
57
+ "bip32": "^5.0.0-rc.0",
58
58
  "bitcoinjs-lib": ">= 6.1 <7",
59
+ "bs58check": "^4.0.0",
59
60
  "ethers": ">= 6.13 < 7",
60
61
  "expiry-map": "2.x",
61
62
  "express": "5.x",
@@ -88,6 +89,9 @@
88
89
  "bitcoinjs-lib": {
89
90
  "optional": true
90
91
  },
92
+ "bs58check": {
93
+ "optional": true
94
+ },
91
95
  "ethers": {
92
96
  "optional": true
93
97
  },
@@ -135,19 +139,18 @@
135
139
  }
136
140
  },
137
141
  "devDependencies": {
138
- "@aws-sdk/client-eventbridge": "^3.743.0",
139
142
  "@breejs/later": "^4.2.0",
140
143
  "@paypal/checkout-server-sdk": "^1.0.3",
141
144
  "@redis/client": "^1.6.0",
142
145
  "@types/express": "^5.0.0",
143
- "@types/node": "^22.13.1",
144
- "bip32": "^4.0.0",
146
+ "@types/node": "^22.13.4",
147
+ "bip32": "^5.0.0-rc.0",
145
148
  "bitcoinjs-lib": "^6.1.7",
149
+ "bs58check": "^4.0.0",
146
150
  "ethers": "^6.13.5",
147
151
  "expiry-map": "^2.0.0",
148
152
  "express": "^5.0.1",
149
153
  "fastify": "^5.2.1",
150
- "jest": "^29.7.0",
151
154
  "mime-types": "^2.1.35",
152
155
  "minio": "^8.0.4",
153
156
  "nodemailer": "^6.10.0",
@@ -156,8 +159,8 @@
156
159
  "postfinancecheckout": "^4.5.0",
157
160
  "stripe": "^17.6.0",
158
161
  "tiny-secp256k1": "^2.2.3",
159
- "ts-jest": "^29.2.5",
160
- "twilio": "^5.4.3",
162
+ "tsx": "^4.19.2",
163
+ "twilio": "^5.4.4",
161
164
  "typescript": "^5.7.3",
162
165
  "web-push": "^3.6.7",
163
166
  "xml-js": "^1.6.11"
@@ -1,24 +1,27 @@
1
1
  import { EmitAdapter, setEmitAdapter } from '@unchainedshop/events';
2
- import { EventBridgeClient, PutEventsCommand, PutEventsRequestEntry } from '@aws-sdk/client-eventbridge';
3
2
  import { createLogger } from '@unchainedshop/logger';
4
3
 
5
4
  const logger = createLogger('unchained:eventbridge');
6
5
 
7
- const EventBridgeEventEmitter = ({ region, source, busName }): EmitAdapter => {
6
+ const EventBridgeEventEmitter = async ({ region, source, busName }): Promise<EmitAdapter> => {
7
+ // eslint-disable-next-line
8
+ // @ts-expect-error
9
+ const { EventBridgeClient, PutEventsCommand } = await import('@aws-sdk/client-eventbridge');
8
10
  const ebClient = new EventBridgeClient({ region });
9
11
 
10
12
  return {
11
13
  publish: (eventName, payload) => {
12
- const entry: PutEventsRequestEntry = {
13
- Source: source,
14
- DetailType: eventName,
15
- EventBusName: busName,
16
- Detail: JSON.stringify(payload),
17
- };
18
14
  ebClient
19
15
  .send(
20
16
  new PutEventsCommand({
21
- Entries: [entry],
17
+ Entries: [
18
+ {
19
+ Source: source,
20
+ DetailType: eventName,
21
+ EventBusName: busName,
22
+ Detail: JSON.stringify(payload),
23
+ },
24
+ ],
22
25
  }),
23
26
  )
24
27
  .catch((e) => {
@@ -33,11 +36,10 @@ const EventBridgeEventEmitter = ({ region, source, busName }): EmitAdapter => {
33
36
 
34
37
  const { EVENT_BRIDGE_REGION, EVENT_BRIDGE_SOURCE, EVENT_BRIDGE_BUS_NAME } = process.env;
35
38
  if (EVENT_BRIDGE_REGION && EVENT_BRIDGE_SOURCE && EVENT_BRIDGE_BUS_NAME) {
36
- setEmitAdapter(
37
- EventBridgeEventEmitter({
38
- source: EVENT_BRIDGE_SOURCE,
39
- region: EVENT_BRIDGE_REGION,
40
- busName: EVENT_BRIDGE_BUS_NAME,
41
- }),
42
- );
39
+ const eventBridgeAdapter = await EventBridgeEventEmitter({
40
+ source: EVENT_BRIDGE_SOURCE,
41
+ region: EVENT_BRIDGE_REGION,
42
+ busName: EVENT_BRIDGE_BUS_NAME,
43
+ });
44
+ setEmitAdapter(eventBridgeAdapter);
43
45
  }
@@ -1,5 +1,6 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { BIP32Factory } from 'bip32';
3
+ import bs58check from 'bs58check';
3
4
  import * as ecc from 'tiny-secp256k1';
4
5
  import { networks, payments } from 'bitcoinjs-lib';
5
6
  import { createLogger } from '@unchainedshop/logger';
@@ -14,13 +15,36 @@ import { CryptopayModule } from './module.js';
14
15
 
15
16
  const logger = createLogger('unchained:core-payment:cryptopay');
16
17
 
17
- const {
18
- CRYPTOPAY_SECRET,
19
- CRYPTOPAY_BTC_XPUB,
20
- CRYPTOPAY_ETH_XPUB,
21
- CRYPTOPAY_BTC_TESTNET,
22
- CRYPTOPAY_DERIVATION_START = '0',
23
- } = process.env;
18
+ const { CRYPTOPAY_SECRET, CRYPTOPAY_BTC_XPUB, CRYPTOPAY_ETH_XPUB } = process.env;
19
+
20
+ const resolvePath = (prefix) => {
21
+ if (prefix === 'x') return `m/44'/0'`;
22
+ if (prefix === 'y') return `m/49'/0'`;
23
+ if (prefix === 'z') return `m/84'/0'`;
24
+ if (prefix === 't') return `m/44'/1'`;
25
+ if (prefix === 'u') return `m/49'/1'`;
26
+ if (prefix === 'v') return `m/84'/1'`;
27
+ return `m`;
28
+ };
29
+
30
+ const resolveNetwork = (prefix) => {
31
+ if (['x', 'y', 'z'].includes(prefix)) return networks.bitcoin;
32
+ return networks.testnet;
33
+ };
34
+
35
+ function convertExtendedPublicKey(z) {
36
+ const derivationPath = resolvePath(z.slice(0, 1));
37
+ const network = resolveNetwork(z.slice(0, 1));
38
+ // https://github.com/satoshilabs/slips/blob/master/slip-0132.md
39
+ let data = bs58check.decode(z);
40
+ data = data.slice(4);
41
+ data = Buffer.concat([Buffer.from('0488b21e', 'hex'), data]);
42
+ return {
43
+ xpub: bs58check.encode(data),
44
+ network,
45
+ derivationPath,
46
+ };
47
+ }
24
48
 
25
49
  enum CryptopayCurrencies { // eslint-disable-line
26
50
  BTC = 'BTC',
@@ -34,19 +58,6 @@ type CryptopayAddress = {
34
58
  currencyConversionExpiryDate?: Date;
35
59
  };
36
60
 
37
- const getDerivationPath = (currency: CryptopayCurrencies, index: number): string => {
38
- const address = `${(parseInt(CRYPTOPAY_DERIVATION_START, 10) || 0) + index}`;
39
- if (currency === CryptopayCurrencies.ETH) {
40
- const pathComponents = ethers.defaultPath.split('/');
41
- pathComponents[pathComponents.length - 1] = address;
42
- return pathComponents.join('/');
43
- }
44
- if (currency === CryptopayCurrencies.BTC) {
45
- return `m/44'/0'/0'/0/${address}`;
46
- }
47
- return `0/${address}`;
48
- };
49
-
50
61
  const Cryptopay: IPaymentAdapter = {
51
62
  ...PaymentAdapter,
52
63
 
@@ -154,18 +165,17 @@ const Cryptopay: IPaymentAdapter = {
154
165
 
155
166
  const cryptoAddresses: CryptopayAddress[] = [];
156
167
  if (CRYPTOPAY_BTC_XPUB) {
157
- const network = CRYPTOPAY_BTC_TESTNET ? networks.testnet : networks.bitcoin;
168
+ const { xpub, network } = convertExtendedPublicKey(CRYPTOPAY_BTC_XPUB);
158
169
  const bip32 = BIP32Factory(ecc);
159
- const hardenedMaster = bip32.fromBase58(CRYPTOPAY_BTC_XPUB, network);
170
+ const hardenedMaster = bip32.fromBase58(xpub, network);
160
171
  const btcDerivationNumber = await modules.cryptopay.getNextDerivationNumber(
161
172
  CryptopayCurrencies.BTC,
162
173
  );
163
- const derivationPath = getDerivationPath(CryptopayCurrencies.BTC, btcDerivationNumber);
164
- const child = hardenedMaster.derivePath(derivationPath);
174
+ const child = hardenedMaster.derivePath(`0/${btcDerivationNumber}`);
165
175
  cryptoAddresses.push({
166
176
  currency: CryptopayCurrencies.BTC,
167
- address: payments.p2pkh({
168
- pubkey: child.publicKey,
177
+ address: payments.p2wpkh({
178
+ pubkey: child.publicKey as Buffer,
169
179
  network,
170
180
  }).address,
171
181
  });
@@ -179,11 +189,9 @@ const Cryptopay: IPaymentAdapter = {
179
189
  const ethDerivationNumber = await modules.cryptopay.getNextDerivationNumber(
180
190
  CryptopayCurrencies.ETH,
181
191
  );
182
- const derivationPath = getDerivationPath(CryptopayCurrencies.ETH, ethDerivationNumber);
183
- const cleanedForHD = derivationPath.split('/').slice(-2).join('/');
184
192
  cryptoAddresses.push({
185
193
  currency: CryptopayCurrencies.ETH,
186
- address: hardenedMaster.derivePath(cleanedForHD).address,
194
+ address: hardenedMaster.derivePath(`0/${ethDerivationNumber}`).address,
187
195
  });
188
196
  }
189
197
 
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import generateSignature from './generateSignature';
2
4
 
3
5
  describe('Datatrans Signature', () => {
@@ -8,7 +10,8 @@ describe('Datatrans Signature', () => {
8
10
  timestamp: '12424123412',
9
11
  body: '{"card":{"3D":{"authenticationResponse":"D"},"alias":"70119122433810042","expiryMonth":"12","expiryYear":"21","info":{"brand":"VISA CREDIT","country":"GB","issuer":"DATATRANS","type":"credit","usage":"consumer"},"masked":"424242xxxxxx4242"},"currency":"CHF","detail":{"authorize":{"acquirerAuthorizationCode":"100055"}},"history":[{"action":"init","date":"2021-09-03T08:00:32Z","ip":"212.232.234.26","source":"api","success":true},{"action":"authorize","date":"2021-09-03T08:00:55Z","ip":"212.232.234.26","source":"redirect","success":true}],"language":"de","paymentMethod":"VIS","refno":"1NTU1NQ=","refno2":"user","status":"authorized","transactionId":"card_check_authorized","type":"card_check"}',
10
12
  };
11
- expect(await generateSignature({ security, signKey })(timestamp, body)).toEqual(
13
+ assert.strictEqual(
14
+ await generateSignature({ security, signKey })(timestamp, body),
12
15
  '5118c93025fdb16a110cdde3aa7669422da320cfe9478e35b531f45c4619d4db',
13
16
  );
14
17
  });
@@ -12,6 +12,7 @@ try {
12
12
  // eslint-disable-next-line
13
13
  // @ts-ignore
14
14
  checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
15
+ // TODO: npm warn deprecated @paypal/checkout-server-sdk@1.0.3: Package no longer supported. The author suggests using the @paypal/paypal-server-sdk package instead: https://www.npmjs.com/package/@paypal/paypal-server-sdk. Contact Support at https://www.npmjs.com/support for more info.
15
16
  } catch {
16
17
  /* */
17
18
  }
@@ -1,37 +1,41 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HundredOff } from './discount-100-off.js';
2
4
 
3
5
  describe('HundredOff', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
7
  let x;
6
- expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
8
+ assert.strictEqual(await HundredOff.isManualAdditionAllowed(x), true);
7
9
  });
8
10
  it('isManualRemovalAllowed', async () => {
9
- expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
11
+ assert.strictEqual(await HundredOff.isManualRemovalAllowed(), true);
10
12
  });
11
13
  it('isValidForSystemTriggering', async () => {
12
14
  const context = {};
13
15
  const actions = await HundredOff.actions({ context } as any);
14
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
16
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
15
17
  });
16
18
  it('isValidForCodeTriggering', async () => {
17
19
  const context = {};
18
20
  const actions = await HundredOff.actions({ context } as any);
19
- expect(await actions.isValidForCodeTriggering({ code: '100OFF' })).toBeTruthy();
20
- expect(await actions.isValidForCodeTriggering({ code: 'wrongcode' })).toBeFalsy();
21
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: '100OFF' }), true);
22
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'wrongcode' }), false);
21
23
  });
22
24
 
23
25
  it('discountForPricingAdapterKey', async () => {
24
26
  const context = {};
25
27
  const actions = await HundredOff.actions({ context } as any);
26
- expect(
28
+ assert.deepStrictEqual(
27
29
  actions.discountForPricingAdapterKey({
28
30
  pricingAdapterKey: 'shop.unchained.pricing.order-discount',
29
31
  } as any),
30
- ).toEqual({ fixedRate: 10000 });
31
- expect(
32
+ { fixedRate: 10000 },
33
+ );
34
+ assert.strictEqual(
32
35
  actions.discountForPricingAdapterKey({
33
36
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
34
37
  } as any),
35
- ).toBeNull();
38
+ null,
39
+ );
36
40
  });
37
41
  });
@@ -1,48 +1,52 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HalfPriceManual } from './discount-half-price-manual.js';
2
4
 
3
5
  describe('HalfPriceManual', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
7
  let x;
6
- expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
8
+ assert.strictEqual(await HalfPriceManual.isManualAdditionAllowed(x), true);
7
9
  });
8
10
 
9
11
  it('isManualRemovalAllowed', async () => {
10
- expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
12
+ assert.strictEqual(await HalfPriceManual.isManualRemovalAllowed(), true);
11
13
  });
12
14
 
13
15
  it('isValidForSystemTriggering', async () => {
14
16
  const context = {};
15
17
  const actions = await HalfPriceManual.actions({ context } as any);
16
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
18
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
17
19
  });
18
20
 
19
21
  it('isValidForCodeTriggering', async () => {
20
22
  const context = {};
21
23
  const actions = await HalfPriceManual.actions({ context } as any);
22
- expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
23
- expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
24
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' }), true);
25
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'othercode' }), false);
24
26
  });
25
27
 
26
28
  it('discountForPricingAdapterKey', async () => {
27
29
  const context = {};
28
30
  const actions = await HalfPriceManual.actions({ context } as any);
29
- expect(
31
+ assert.deepStrictEqual(
30
32
  actions.discountForPricingAdapterKey({
31
33
  pricingAdapterKey: 'shop.unchained.pricing.product-discount',
32
34
  } as any),
33
- ).toEqual({ rate: 0.5 });
34
- expect(
35
+ { rate: 0.5 },
36
+ );
37
+ assert.strictEqual(
35
38
  actions.discountForPricingAdapterKey({
36
39
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
37
40
  } as any),
38
- ).toBeNull();
41
+ null,
42
+ );
39
43
  });
40
44
 
41
45
  it('Actions', async () => {
42
46
  const context = {};
43
47
  const actions = await HalfPriceManual.actions({ context } as any);
44
- expect(typeof actions.isValidForSystemTriggering).toBe('function');
45
- expect(typeof actions.isValidForCodeTriggering).toBe('function');
46
- expect(typeof actions.discountForPricingAdapterKey).toBe('function');
48
+ assert.strictEqual(typeof actions.isValidForSystemTriggering, 'function');
49
+ assert.strictEqual(typeof actions.isValidForCodeTriggering, 'function');
50
+ assert.strictEqual(typeof actions.discountForPricingAdapterKey, 'function');
47
51
  });
48
52
  });
@@ -1,48 +1,52 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HalfPrice } from './discount-half-price.js';
2
4
 
3
5
  describe('HalfPrice', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
- expect(await HalfPrice.isManualAdditionAllowed('')).toBeFalsy();
7
+ assert.strictEqual(await HalfPrice.isManualAdditionAllowed(''), false);
6
8
  });
7
9
 
8
10
  it('isManualRemovalAllowed', async () => {
9
- expect(await HalfPrice.isManualRemovalAllowed()).toBeFalsy();
11
+ assert.strictEqual(await HalfPrice.isManualRemovalAllowed(), false);
10
12
  });
11
13
 
12
14
  it('isValidForSystemTriggering', async () => {
13
15
  const context = {
14
16
  modules: {
15
17
  users: {
16
- findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] })),
18
+ findUserById: async () => ({ tags: ['half-price'] }),
17
19
  },
18
20
  },
19
21
  order: { userId: 'user-id' },
20
22
  };
21
23
  const actions = await HalfPrice.actions({ context } as any);
22
- expect(await actions.isValidForSystemTriggering()).toBeTruthy();
24
+ assert.strictEqual(await actions.isValidForSystemTriggering(), true);
23
25
 
24
- context.modules.users.findUserById.mockImplementationOnce(() => Promise.resolve({ tags: [] }));
25
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
26
+ context.modules.users.findUserById = async () => ({ tags: [] });
27
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
26
28
  });
29
+
27
30
  it('discountForPricingAdapterKey', async () => {
28
31
  const context = {};
29
32
  const actions = await HalfPrice.actions({ context } as any);
30
- expect(
33
+ assert.deepStrictEqual(
31
34
  actions.discountForPricingAdapterKey({
32
35
  pricingAdapterKey: 'shop.unchained.pricing.product-discount',
33
36
  } as any),
34
- ).toEqual({ rate: 0.5 });
35
- expect(
37
+ { rate: 0.5 },
38
+ );
39
+ assert.strictEqual(
36
40
  actions.discountForPricingAdapterKey({
37
41
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
38
42
  } as any),
39
- ).toBeNull();
43
+ null,
44
+ );
40
45
  });
41
46
 
42
47
  it('isValidForCodeTriggering', async () => {
43
48
  const context = {};
44
49
  const actions = await HalfPrice.actions({ context } as any);
45
-
46
- expect(await actions.isValidForCodeTriggering({ code: '' })).toBeFalsy();
50
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: '' }), false);
47
51
  });
48
52
  });
@@ -1,7 +1,10 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { DeliveryFreePrice } from './free-delivery.js';
2
5
 
3
6
  describe('DeliveryFreePrice', () => {
4
7
  it('should return true', () => {
5
- expect(DeliveryFreePrice.isActivatedFor(undefined as any)).toBeTruthy();
8
+ assert.strictEqual(DeliveryFreePrice.isActivatedFor(undefined as any), true);
6
9
  });
7
10
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { rangeMatcher } from '../enrollments/licensed.js';
2
4
 
3
5
  describe('rangeMatcher', () => {
@@ -13,24 +15,24 @@ describe('rangeMatcher', () => {
13
15
  it('matches correctly when the date is within the range', () => {
14
16
  const range = { start: yesterday, end: tomorrow };
15
17
  const matcher = rangeMatcher(now);
16
- expect(matcher(range)).toBe(true);
18
+ assert.strictEqual(matcher(range), true);
17
19
  });
18
20
 
19
21
  it('does not match when the date is before the start of the range', () => {
20
22
  const range = { start: tomorrow, end: tomorrow };
21
23
  const matcher = rangeMatcher(yesterday);
22
- expect(matcher(range)).toBe(false);
24
+ assert.strictEqual(matcher(range), false);
23
25
  });
24
26
 
25
27
  it('does not match when the date is after the end of the range', () => {
26
28
  const range = { start: yesterday, end: yesterday };
27
29
  const matcher = rangeMatcher(tomorrow);
28
- expect(matcher(range)).toBe(false);
30
+ assert.strictEqual(matcher(range), false);
29
31
  });
30
32
 
31
33
  it('matches correctly when the date is not provided', () => {
32
34
  const range = { start: yesterdayTimestamp, end: tomorrowTimestamp };
33
35
  const matcher = rangeMatcher();
34
- expect(matcher(range)).toBe(true);
36
+ assert.strictEqual(matcher(range), true);
35
37
  });
36
38
  });
@@ -1,7 +1,9 @@
1
1
  import { OrderDelivery } from './order-delivery.js';
2
+ import { describe, it } from 'node:test';
3
+ import assert from 'node:assert';
2
4
 
3
5
  describe('OrderDelivery ', () => {
4
6
  it('isActivatedFor', () => {
5
- expect(OrderDelivery.isActivatedFor({} as any)).toBeTruthy();
7
+ assert.equal(OrderDelivery.isActivatedFor({} as any), true);
6
8
  });
7
9
  });
@@ -1,7 +1,10 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { OrderDiscount } from './order-discount.js';
2
5
 
3
6
  describe('OrderDelivery ', () => {
4
7
  it('isActivatedFor', () => {
5
- expect(OrderDiscount.isActivatedFor({} as any)).toBeTruthy();
8
+ assert.equal(OrderDiscount.isActivatedFor({} as any), true);
6
9
  });
7
10
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+
1
3
  describe('Plugins', () => {
2
4
  it.todo('Plugins Tests');
3
5
  });
@@ -1,47 +1,54 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { getTaxRate, isDeliveryAddressInSwitzerland } from './product-swiss-tax.js';
2
5
 
3
6
  describe('ProductSwissTax', () => {
4
7
  describe('getTaxRate', () => {
5
8
  it('default rate', () => {
6
- expect(
9
+ assert.strictEqual(
7
10
  getTaxRate({
8
11
  product: {} as any,
9
12
  order: {} as any,
10
13
  } as any),
11
- ).toBe(0.081);
14
+ 0.081,
15
+ );
12
16
  });
13
17
 
14
18
  it('reduced rate', () => {
15
- expect(
19
+ assert.strictEqual(
16
20
  getTaxRate({
17
21
  product: {
18
22
  tags: ['swiss-tax-category:reduced'],
19
23
  },
20
24
  order: {},
21
25
  } as any),
22
- ).toBe(0.026);
26
+ 0.026,
27
+ );
23
28
  });
24
29
 
25
30
  it('special rate', () => {
26
- expect(
31
+ assert.strictEqual(
27
32
  getTaxRate({
28
33
  product: {
29
34
  tags: ['swiss-tax-category:special'],
30
35
  },
31
36
  order: {},
32
37
  } as any),
33
- ).toBe(0.038);
38
+ 0.038,
39
+ );
34
40
  });
35
41
 
36
42
  it('default rate', () => {
37
- expect(
43
+ assert.strictEqual(
38
44
  getTaxRate({
39
45
  product: {
40
46
  tags: ['swiss-tax-category:default'],
41
47
  },
42
48
  order: {},
43
49
  } as any),
44
- ).toBe(0.081);
50
+ 0.081,
51
+ );
45
52
  });
46
53
  });
47
54
 
@@ -50,12 +57,12 @@ describe('ProductSwissTax', () => {
50
57
  modules: {
51
58
  orders: {
52
59
  deliveries: {
53
- findDelivery: import.meta.jest.fn(async ({ orderDeliveryId }) => {
60
+ findDelivery: async ({ orderDeliveryId }) => {
54
61
  if (orderDeliveryId === 'CH' || orderDeliveryId === 'LI')
55
62
  return { context: { address: { countryCode: 'CH' } } };
56
63
  if (orderDeliveryId === null) return { context: { address: null } };
57
64
  return { context: { address: { countryCode: 'RT' } } };
58
- }),
65
+ },
59
66
  },
60
67
  },
61
68
  },
@@ -66,26 +73,29 @@ describe('ProductSwissTax', () => {
66
73
  country: 'CH',
67
74
  };
68
75
  it('Should return true when passed country code CH', async () => {
69
- expect(
76
+ assert.strictEqual(
70
77
  await isDeliveryAddressInSwitzerland({ ...context, country: 'ch', order: null } as any),
71
- ).toBe(true);
78
+ true,
79
+ );
72
80
  });
73
81
 
74
82
  it('Should return true when passed country code LI', async () => {
75
- expect(
83
+ assert.strictEqual(
76
84
  await isDeliveryAddressInSwitzerland({ ...context, country: 'LI', order: null } as any),
77
- ).toBe(true);
85
+ true,
86
+ );
78
87
  });
79
88
 
80
89
  it('Should return false when country is neither CH nor LI and order is null', async () => {
81
- expect(
90
+ assert.strictEqual(
82
91
  await isDeliveryAddressInSwitzerland({ ...context, country: 'ET', order: null } as any),
83
- ).toBe(false);
92
+ false,
93
+ );
84
94
  });
85
95
 
86
96
  it('Order should take precedence over country parameter', async () => {
87
97
  // not CH or LI order so returns false
88
- expect(
98
+ assert.strictEqual(
89
99
  await isDeliveryAddressInSwitzerland({
90
100
  ...context,
91
101
  country: 'CH',
@@ -94,11 +104,12 @@ describe('ProductSwissTax', () => {
94
104
  billingAddress: { countryCode: 'ET' },
95
105
  },
96
106
  } as any),
97
- ).toBe(false);
107
+ false,
108
+ );
98
109
  });
99
110
 
100
111
  it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
101
- expect(
112
+ assert.strictEqual(
102
113
  await isDeliveryAddressInSwitzerland({
103
114
  ...context,
104
115
  country: 'IT',
@@ -107,11 +118,12 @@ describe('ProductSwissTax', () => {
107
118
  billingAddress: { countryCode: 'CH' },
108
119
  },
109
120
  } as any),
110
- ).toBe(true);
121
+ true,
122
+ );
111
123
  });
112
124
 
113
125
  it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
114
- expect(
126
+ assert.strictEqual(
115
127
  await isDeliveryAddressInSwitzerland({
116
128
  ...context,
117
129
  country: null,
@@ -120,7 +132,8 @@ describe('ProductSwissTax', () => {
120
132
  billingAddress: { countryCode: 'HH' },
121
133
  },
122
134
  } as any),
123
- ).toBe(false);
135
+ false,
136
+ );
124
137
  });
125
138
  });
126
139
  });
@@ -1,18 +1,20 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { SwissTaxCategories } from './ch';
2
4
 
3
5
  describe('SwissTaxCategories', () => {
4
6
  it('DEFAULT rate', () => {
5
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1))).toBe(0.077);
6
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1))).toBe(0.081);
7
+ assert.strictEqual(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1)), 0.077);
8
+ assert.strictEqual(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1)), 0.081);
7
9
  });
8
10
 
9
11
  it('REDUCED rate', () => {
10
- expect(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1))).toBe(0.025);
11
- expect(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1))).toBe(0.026);
12
+ assert.strictEqual(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1)), 0.025);
13
+ assert.strictEqual(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1)), 0.026);
12
14
  });
13
15
 
14
16
  it('SPECIAL rate', () => {
15
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1))).toBe(0.037);
16
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1))).toBe(0.038);
17
+ assert.strictEqual(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1)), 0.037);
18
+ assert.strictEqual(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1)), 0.038);
17
19
  });
18
20
  });
package/jest.config.js DELETED
@@ -1,17 +0,0 @@
1
- /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
- export default {
3
- preset: 'ts-jest/presets/default-esm', // or other ESM presets
4
- testEnvironment: 'node',
5
- extensionsToTreatAsEsm: ['.ts'],
6
- transform: {
7
- '^.+\\.tsx?$': [
8
- 'ts-jest',
9
- {
10
- useESM: true,
11
- },
12
- ],
13
- },
14
- moduleNameMapper: {
15
- '^(\\.{1,2}/.*)\\.js$': '$1',
16
- },
17
- };