@bedrock/kms 9.0.0 → 10.2.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.
@@ -8,7 +8,7 @@ jobs:
8
8
  timeout-minutes: 10
9
9
  strategy:
10
10
  matrix:
11
- node-version: [14.x]
11
+ node-version: [16.x]
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
14
  - name: Use Node.js ${{ matrix.node-version }}
@@ -24,12 +24,12 @@ jobs:
24
24
  timeout-minutes: 10
25
25
  services:
26
26
  mongodb:
27
- image: mongo:4.2
27
+ image: mongo:4.4
28
28
  ports:
29
29
  - 27017:27017
30
30
  strategy:
31
31
  matrix:
32
- node-version: [14.x]
32
+ node-version: [14.x, 16.x]
33
33
  steps:
34
34
  - uses: actions/checkout@v2
35
35
  - name: Use Node.js ${{ matrix.node-version }}
@@ -50,12 +50,12 @@ jobs:
50
50
  timeout-minutes: 10
51
51
  services:
52
52
  mongodb:
53
- image: mongo:4.2
53
+ image: mongo:4.4
54
54
  ports:
55
55
  - 27017:27017
56
56
  strategy:
57
57
  matrix:
58
- node-version: [14.x]
58
+ node-version: [16.x]
59
59
  steps:
60
60
  - uses: actions/checkout@v2
61
61
  - name: Use Node.js ${{ matrix.node-version }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # bedrock-kms ChangeLog
2
2
 
3
+ ## 10.2.0 - 2022-05-13
4
+
5
+ ### Added
6
+ - Expose `_disableClearCacheOnUpdate` for testing cache busting only; do not use in
7
+ production.
8
+
9
+ ## 10.1.0 - 2022-05-13
10
+
11
+ ### Added
12
+ - Add `fresh` option to `keystores.get()` API to allow for retrieving a fresh
13
+ (not previously cached) keystore config record.
14
+
15
+ ## 10.0.0 - 2022-04-29
16
+
17
+ ### Changed
18
+ - **BREAKING**: Update peer deps:
19
+ - `@bedrock/core@6`.
20
+ - `@bedrock/did-context@4`
21
+ - `@bedrock/did-io@8`
22
+ - `@bedrock/jsonld-document-loader@3`
23
+ - `@bedrock/mongodb@10`
24
+ - `@bedrock/package-manager@3`
25
+ - `@bedrock/security-context@7`
26
+ - `@bedrock/veres-one-context@14`.
27
+
3
28
  ## 9.0.0 - 2022-04-05
4
29
 
5
30
  ### Changed
package/lib/keystores.js CHANGED
@@ -5,7 +5,7 @@ import * as bedrock from '@bedrock/core';
5
5
  import * as database from '@bedrock/mongodb';
6
6
  import assert from 'assert-plus';
7
7
  import pAll from 'p-all';
8
- import {createRequire} from 'module';
8
+ import {createRequire} from 'node:module';
9
9
  const require = createRequire(import.meta.url);
10
10
  const {LruCache} = require('@digitalbazaar/lru-memoize');
11
11
 
@@ -16,6 +16,10 @@ import './config.js';
16
16
 
17
17
  const USAGE_COUNTER_MAX_CONCURRENCY = 100;
18
18
  let KEYSTORE_CONFIG_CACHE;
19
+ let DISABLE_CLEAR_CACHE_ON_UPDATE = false;
20
+
21
+ // cache only exported for testing purposes
22
+ export {KEYSTORE_CONFIG_CACHE as _KEYSTORE_CONFIG_CACHE};
19
23
 
20
24
  bedrock.events.on('bedrock.init', async () => {
21
25
  const cfg = bedrock.config.kms;
@@ -100,8 +104,7 @@ export async function insert({config} = {}) {
100
104
  config
101
105
  };
102
106
  try {
103
- const result = await database.collections['kms-keystore'].insertOne(
104
- record, database.writeOptions);
107
+ const result = await database.collections['kms-keystore'].insertOne(record);
105
108
  return result.ops[0];
106
109
  } catch(e) {
107
110
  if(!database.isDuplicateError(e)) {
@@ -180,7 +183,7 @@ export async function update({config, explain = false} = {}) {
180
183
  config,
181
184
  'meta.updated': Date.now()
182
185
  }
183
- }, database.writeOptions);
186
+ });
184
187
 
185
188
  if(result.result.n === 0) {
186
189
  // no records changed...
@@ -196,8 +199,10 @@ export async function update({config, explain = false} = {}) {
196
199
  });
197
200
  }
198
201
 
199
- // delete record from cache
200
- KEYSTORE_CONFIG_CACHE.delete(config.id);
202
+ if(!DISABLE_CLEAR_CACHE_ON_UPDATE) {
203
+ // delete record from cache
204
+ KEYSTORE_CONFIG_CACHE.delete(config.id);
205
+ }
201
206
 
202
207
  return true;
203
208
  }
@@ -207,11 +212,16 @@ export async function update({config, explain = false} = {}) {
207
212
  *
208
213
  * @param {object} options - The options to use.
209
214
  * @param {string} options.id - The ID of the keystore.
215
+ * @param {boolean} [options.fresh=false] - False if it is safe to use a
216
+ * potentially cached value, true to always get a fresh value.
210
217
  *
211
218
  * @returns {Promise<object>} Resolves to `{config, meta}`.
212
219
  */
213
- export async function get({id} = {}) {
220
+ export async function get({id, fresh = false} = {}) {
214
221
  assert.string(id, 'id');
222
+ if(fresh) {
223
+ KEYSTORE_CONFIG_CACHE.delete(id);
224
+ }
215
225
  const fn = () => _getUncachedRecord({id});
216
226
  return KEYSTORE_CONFIG_CACHE.memoize({key: id, fn});
217
227
  }
@@ -328,3 +338,8 @@ export async function _getUncachedRecord({id, explain = false} = {}) {
328
338
  }
329
339
  return record;
330
340
  }
341
+
342
+ // exported for testing purposes
343
+ export function _disableClearCacheOnUpdate(disable) {
344
+ DISABLE_CLEAR_CACHE_ON_UPDATE = disable;
345
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/kms",
3
- "version": "9.0.0",
3
+ "version": "10.2.0",
4
4
  "type": "module",
5
5
  "description": "Key management for Bedrock applications",
6
6
  "main": "./lib/index.js",
@@ -31,14 +31,14 @@
31
31
  "p-all": "^4.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@bedrock/core": "^5.0.0",
35
- "@bedrock/did-context": "^3.0.0",
36
- "@bedrock/did-io": "^7.0.0",
37
- "@bedrock/jsonld-document-loader": "^2.0.0",
38
- "@bedrock/mongodb": "^9.0.0",
39
- "@bedrock/package-manager": "^2.0.0",
40
- "@bedrock/security-context": "^6.0.0",
41
- "@bedrock/veres-one-context": "^13.0.0"
34
+ "@bedrock/core": "^6.0.0",
35
+ "@bedrock/did-context": "^4.0.0",
36
+ "@bedrock/did-io": "^8.0.0",
37
+ "@bedrock/jsonld-document-loader": "^3.0.0",
38
+ "@bedrock/mongodb": "^10.0.0",
39
+ "@bedrock/package-manager": "^3.0.0",
40
+ "@bedrock/security-context": "^7.0.0",
41
+ "@bedrock/veres-one-context": "^14.0.0"
42
42
  },
43
43
  "directories": {
44
44
  "lib": "./lib"
@@ -1,9 +1,8 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
5
4
  import {keystores} from '@bedrock/kms';
6
- const {util: {clone}} = bedrock;
5
+ import {klona} from 'klona';
7
6
 
8
7
  describe('keystores APIs', () => {
9
8
  const mockConfigAlpha = {
@@ -25,6 +24,12 @@ describe('keystores APIs', () => {
25
24
  controller: 'f2da13ee-50d2-46ab-865d-ee23d609edbd',
26
25
  sequence: 0,
27
26
  };
27
+ const mockConfigDelta = {
28
+ id: 'https://example.com/keystores/f9da6f23-6e13-42e9-88d3-5c03011ecbbf',
29
+ kmsModule: 'ssm-v1',
30
+ controller: '17e77da1-bb7e-4fe2-b4dd-1c4bba933d7c',
31
+ sequence: 0,
32
+ };
28
33
 
29
34
  before(async () => {
30
35
  let err;
@@ -32,6 +37,7 @@ describe('keystores APIs', () => {
32
37
  await keystores.insert({config: mockConfigAlpha});
33
38
  await keystores.insert({config: mockConfigBeta});
34
39
  await keystores.insert({config: mockConfigGamma});
40
+ await keystores.insert({config: mockConfigDelta});
35
41
  } catch(e) {
36
42
  err = e;
37
43
  }
@@ -53,7 +59,7 @@ describe('keystores APIs', () => {
53
59
  it('successfully updates a keystore', async () => {
54
60
  let err;
55
61
  let result;
56
- const config = clone(mockConfigAlpha);
62
+ const config = klona(mockConfigAlpha);
57
63
  config.sequence++;
58
64
  config.controller = 'someOtherController';
59
65
  try {
@@ -68,7 +74,7 @@ describe('keystores APIs', () => {
68
74
  it('successfully updates a keystore twice', async () => {
69
75
  let err;
70
76
  let result;
71
- const config = clone(mockConfigBeta);
77
+ const config = klona(mockConfigBeta);
72
78
  config.sequence++;
73
79
  config.controller = 'someOtherController';
74
80
  try {
@@ -94,10 +100,43 @@ describe('keystores APIs', () => {
94
100
  result.should.be.a('boolean');
95
101
  result.should.be.true;
96
102
  });
103
+ it('successfully updates a keystore and gets a fresh value', async () => {
104
+ const config = klona(mockConfigDelta);
105
+
106
+ // get keystore config to prime cache
107
+ await keystores.get({id: config.id});
108
+
109
+ // now update config
110
+ let err;
111
+ let result;
112
+ config.sequence++;
113
+ config.controller = 'someOtherController';
114
+ const oldDelete = keystores._KEYSTORE_CONFIG_CACHE.delete;
115
+ try {
116
+ // remove cache delete functionality to test fresh API
117
+ keystores._KEYSTORE_CONFIG_CACHE.delete = () => {};
118
+ result = await keystores.update({config});
119
+ } catch(e) {
120
+ err = e;
121
+ } finally {
122
+ keystores._KEYSTORE_CONFIG_CACHE.delete = oldDelete;
123
+ }
124
+ assertNoError(err);
125
+ result.should.be.a('boolean');
126
+ result.should.be.true;
127
+
128
+ // get keystore config, should be stale
129
+ const stale = await keystores.get({id: config.id});
130
+ stale.config.controller.should.not.equal(config.controller);
131
+
132
+ // get fresh config
133
+ const fresh = await keystores.get({id: config.id, fresh: true});
134
+ fresh.config.controller.should.equal(config.controller);
135
+ });
97
136
  it('fails to updates a keystore using wrong sequence number', async () => {
98
137
  let err;
99
138
  let result;
100
- const config = clone(mockConfigGamma);
139
+ const config = klona(mockConfigGamma);
101
140
  config.sequence++;
102
141
  config.controller = 'someOtherController';
103
142
  try {
@@ -129,7 +168,7 @@ describe('keystores APIs', () => {
129
168
  it('successfully updates a keystore and invalidates cache', async () => {
130
169
  let err;
131
170
  let result;
132
- const config = clone(mockConfigBeta);
171
+ const config = klona(mockConfigBeta);
133
172
  config.sequence = 3;
134
173
  config.controller = 'someOtherController';
135
174
  try {
@@ -147,7 +186,7 @@ describe('keystores APIs', () => {
147
186
  it('throws error on unknown keystore id', async () => {
148
187
  let err;
149
188
  let result;
150
- const config = clone(mockConfigBeta);
189
+ const config = klona(mockConfigBeta);
151
190
  config.sequence++;
152
191
  config.id = 'someOtherId';
153
192
  try {
@@ -1,16 +1,15 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
5
4
  import * as helpers from './helpers.js';
6
- import {createRequire} from 'module';
5
+ import {createRequire} from 'node:module';
7
6
  import {defaultModuleManager as moduleManager} from '@bedrock/kms';
7
+ import {klona} from 'klona';
8
8
  import {mockData} from './mock.data.js';
9
+ import {v4 as uuid} from 'uuid';
9
10
  const require = createRequire(import.meta.url);
10
11
  const {runOperation} = require('@digitalbazaar/webkms-switch');
11
12
 
12
- const {util: {clone, uuid}} = bedrock;
13
-
14
13
  describe('bedrock-kms', () => {
15
14
  describe('integration with runOperation API', () => {
16
15
  describe('GenerateKeyOperation', () => {
@@ -20,7 +19,7 @@ describe('bedrock-kms', () => {
20
19
  controller: 'urn:uuid:baa943d2-7338-11ec-b1c4-10bf48838a41',
21
20
  kmsModule: 'ssm-v1'
22
21
  };
23
- const operation = clone(
22
+ const operation = klona(
24
23
  mockData.operations.generate({type: 'Ed25519VerificationKey2018'}));
25
24
  operation.invocationTarget.type = 'Ed25519VerificationKey2018';
26
25
  let error;
@@ -46,7 +45,7 @@ describe('bedrock-kms', () => {
46
45
  controller: 'urn:uuid:baa943d2-7338-11ec-b1c4-10bf48838a41',
47
46
  kmsModule: 'ssm-v1'
48
47
  };
49
- const operation = clone(
48
+ const operation = klona(
50
49
  mockData.operations.generate({type: 'Ed25519VerificationKey2020'}));
51
50
  operation.invocationTarget.type = 'Ed25519VerificationKey2020';
52
51
  let error;
@@ -72,7 +71,7 @@ describe('bedrock-kms', () => {
72
71
  controller: 'urn:uuid:baa943d2-7338-11ec-b1c4-10bf48838a41',
73
72
  kmsModule: 'ssm-v1'
74
73
  };
75
- const operation = clone(
74
+ const operation = klona(
76
75
  mockData.operations.generate({type: 'Sha256HmacKey2019'}));
77
76
  operation.invocationTarget.type = 'Sha256HmacKey2019';
78
77
  let error;
@@ -97,7 +96,7 @@ describe('bedrock-kms', () => {
97
96
  controller: 'urn:uuid:baa943d2-7338-11ec-b1c4-10bf48838a41',
98
97
  kmsModule: 'ssm-v1'
99
98
  };
100
- const operation = clone(
99
+ const operation = klona(
101
100
  mockData.operations.generate({type: 'AesKeyWrappingKey2019'}));
102
101
  operation.invocationTarget.type = 'AesKeyWrappingKey2019';
103
102
  let error;
@@ -122,7 +121,7 @@ describe('bedrock-kms', () => {
122
121
  controller: 'urn:uuid:baa943d2-7338-11ec-b1c4-10bf48838a41',
123
122
  kmsModule: 'ssm-v1'
124
123
  };
125
- const operation = clone(
124
+ const operation = klona(
126
125
  mockData.operations.generate({type: 'AesKeyWrappingKey2019'}));
127
126
  operation.invocationTarget.type = 'UnknownKeyType';
128
127
  let error;
@@ -142,7 +141,7 @@ describe('bedrock-kms', () => {
142
141
  it('signs a string using Ed25519VerificationKey2018', async () => {
143
142
  const {keystore, key: {id: keyId}} = await helpers.generateKey(
144
143
  {mockData, type: 'Ed25519VerificationKey2018'});
145
- const operation = clone(mockData.operations.sign);
144
+ const operation = klona(mockData.operations.sign);
146
145
  operation.invocationTarget = keyId;
147
146
  operation.verifyData = uuid();
148
147
  let result;
@@ -164,7 +163,7 @@ describe('bedrock-kms', () => {
164
163
  it('signs a string using Ed25519VerificationKey2020', async () => {
165
164
  const {keystore, key: {id: keyId}} = await helpers.generateKey(
166
165
  {mockData, type: 'Ed25519VerificationKey2020'});
167
- const operation = clone(mockData.operations.sign);
166
+ const operation = klona(mockData.operations.sign);
168
167
  operation.invocationTarget = keyId;
169
168
  operation.verifyData = uuid();
170
169
  let result;
@@ -186,7 +185,7 @@ describe('bedrock-kms', () => {
186
185
  it('signs a string using Sha256HmacKey2019', async () => {
187
186
  const {keystore, key: {id: keyId}} = await helpers.generateKey(
188
187
  {mockData, type: 'Sha256HmacKey2019'});
189
- const operation = clone(mockData.operations.sign);
188
+ const operation = klona(mockData.operations.sign);
190
189
  operation.invocationTarget = keyId;
191
190
  operation.verifyData = uuid();
192
191
  let result;
@@ -212,12 +211,12 @@ describe('bedrock-kms', () => {
212
211
  const verifyData = uuid();
213
212
  const {keystore, key: {id: keyId}} = await helpers.generateKey(
214
213
  {mockData, type: 'Sha256HmacKey2019'});
215
- const signOperation = clone(mockData.operations.sign);
214
+ const signOperation = klona(mockData.operations.sign);
216
215
  signOperation.invocationTarget = keyId;
217
216
  signOperation.verifyData = verifyData;
218
217
  const {result: {signatureValue}} = await runOperation(
219
218
  {operation: signOperation, keystore, moduleManager});
220
- const verifyOperation = clone(mockData.operations.verify);
219
+ const verifyOperation = klona(mockData.operations.verify);
221
220
  verifyOperation.invocationTarget = keyId;
222
221
  verifyOperation.verifyData = verifyData;
223
222
  verifyOperation.signatureValue = signatureValue;
@@ -1,16 +1,15 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
5
4
  import * as helpers from './helpers.js';
6
5
  import {createRequire} from 'module';
7
6
  import {defaultModuleManager as moduleManager} from '@bedrock/kms';
7
+ import {klona} from 'klona';
8
8
  import {mockData} from './mock.data.js';
9
+ import {v4 as uuid} from 'uuid';
9
10
  const require = createRequire(import.meta.url);
10
11
  const {runOperation} = require('@digitalbazaar/webkms-switch');
11
12
 
12
- const {util: {clone, uuid}} = bedrock;
13
-
14
13
  describe('bulk operations', () => {
15
14
  describe('Ed25519VerificationKey2020', () => {
16
15
  let mockKeyId;
@@ -40,7 +39,7 @@ describe('bulk operations', () => {
40
39
  this.timeout(0);
41
40
  const promises = [];
42
41
  for(let i = 0; i < operationCount; ++i) {
43
- const operation = clone(mockData.operations.sign);
42
+ const operation = klona(mockData.operations.sign);
44
43
  operation.invocationTarget = mockKeyId;
45
44
  operation.verifyData = vData[i];
46
45
  promises.push(runOperation({
@@ -88,7 +87,7 @@ describe('bulk operations', () => {
88
87
  this.timeout(0);
89
88
  const promises = [];
90
89
  for(let i = 0; i < operationCount; ++i) {
91
- const operation = clone(mockData.operations.sign);
90
+ const operation = klona(mockData.operations.sign);
92
91
  operation.invocationTarget = mockKeyId;
93
92
  operation.verifyData = vData[i];
94
93
  promises.push(runOperation({
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Copyright (c) 2021-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import {createRequire} from 'module';
4
+ import {createRequire} from 'node:module';
5
5
  const require = createRequire(import.meta.url);
6
6
  const {CryptoLD} = require('crypto-ld');
7
7
  const {Ed25519VerificationKey2018} =
@@ -1,16 +1,14 @@
1
1
  /*!
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
- import * as bedrock from '@bedrock/core';
5
4
  import * as brKms from '@bedrock/kms';
6
5
  import * as database from '@bedrock/mongodb';
7
- import {createRequire} from 'module';
6
+ import {createRequire} from 'node:module';
7
+ import {klona} from 'klona';
8
8
  const require = createRequire(import.meta.url);
9
9
  const {runOperation} = require('@digitalbazaar/webkms-switch');
10
10
  const {generateId} = require('bnid');
11
11
 
12
- const {util: {clone}} = bedrock;
13
-
14
12
  export async function generateKey({mockData, type}) {
15
13
  // create a keystore
16
14
  const mockKeystoreId = `https://example.com/keystore/${await generateId()}`;
@@ -23,7 +21,7 @@ export async function generateKey({mockData, type}) {
23
21
  await brKms.keystores.insert({config: keystore});
24
22
 
25
23
  const keyId = `${mockKeystoreId}/keys/${await generateId()}`;
26
- const operation = clone(mockData.operations.generate({type}));
24
+ const operation = klona(mockData.operations.generate({type}));
27
25
  operation.invocationTarget.id = keyId;
28
26
  operation.invocationTarget.type = type;
29
27
  const moduleManager = brKms.defaultModuleManager;
package/test/package.json CHANGED
@@ -11,19 +11,19 @@
11
11
  "coverage-report": "c8 report"
12
12
  },
13
13
  "dependencies": {
14
- "@bedrock/core": "^5.0.0",
15
- "@bedrock/did-context": "^3.0.0",
16
- "@bedrock/did-io": "^7.0.0",
17
- "@bedrock/https-agent": "^3.0.0",
18
- "@bedrock/jsonld-document-loader": "^2.0.0",
14
+ "@bedrock/core": "^6.0.0",
15
+ "@bedrock/did-context": "^4.0.0",
16
+ "@bedrock/did-io": "^8.0.0",
17
+ "@bedrock/https-agent": "^4.0.0",
18
+ "@bedrock/jsonld-document-loader": "^3.0.0",
19
19
  "@bedrock/kms": "file:..",
20
- "@bedrock/ledger-context": "^22.0.0",
21
- "@bedrock/mongodb": "^9.0.0",
22
- "@bedrock/package-manager": "^2.0.0",
23
- "@bedrock/security-context": "^6.0.0",
24
- "@bedrock/ssm-mongodb": "^8.0.1",
25
- "@bedrock/test": "^7.0.0",
26
- "@bedrock/veres-one-context": "^13.0.0",
20
+ "@bedrock/ledger-context": "^23.0.0",
21
+ "@bedrock/mongodb": "^10.0.0",
22
+ "@bedrock/package-manager": "^3.0.0",
23
+ "@bedrock/security-context": "^7.0.0",
24
+ "@bedrock/ssm-mongodb": "^9.0.0",
25
+ "@bedrock/test": "^8.0.0",
26
+ "@bedrock/veres-one-context": "^14.0.0",
27
27
  "@digitalbazaar/ed25519-verification-key-2018": "^3.1.1",
28
28
  "@digitalbazaar/ed25519-verification-key-2020": "^3.1.0",
29
29
  "@digitalbazaar/webkms-context": "^2.0.0",
@@ -35,7 +35,9 @@
35
35
  "c8": "^7.11.0",
36
36
  "cross-env": "^7.0.3",
37
37
  "crypto-ld": "^6.0.0",
38
- "sha256-hmac-key-2019-context": "^1.0.3"
38
+ "klona": "^2.0.5",
39
+ "sha256-hmac-key-2019-context": "^1.0.3",
40
+ "uuid": "^8.3.2"
39
41
  },
40
42
  "c8": {
41
43
  "excludeNodeModules": false,
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
3
  */
4
4
  import {config} from '@bedrock/core';
5
- import {fileURLToPath} from 'url';
6
- import path from 'path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import path from 'node:path';
7
7
  import '@bedrock/mongodb';
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));