@bedrock/validation 7.1.1 → 7.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,11 +8,11 @@ jobs:
8
8
  timeout-minutes: 10
9
9
  strategy:
10
10
  matrix:
11
- node-version: [22.x]
11
+ node-version: [24.x]
12
12
  steps:
13
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v6
14
14
  - name: Use Node.js ${{ matrix.node-version }}
15
- uses: actions/setup-node@v4
15
+ uses: actions/setup-node@v6
16
16
  with:
17
17
  node-version: ${{ matrix.node-version }}
18
18
  - run: npm install
@@ -24,11 +24,11 @@ jobs:
24
24
  timeout-minutes: 10
25
25
  strategy:
26
26
  matrix:
27
- node-version: [18.x, 20.x, 22.x]
27
+ node-version: [22.x, 24.x, 26.x]
28
28
  steps:
29
- - uses: actions/checkout@v4
29
+ - uses: actions/checkout@v6
30
30
  - name: Use Node.js ${{ matrix.node-version }}
31
- uses: actions/setup-node@v4
31
+ uses: actions/setup-node@v6
32
32
  with:
33
33
  node-version: ${{ matrix.node-version }}
34
34
  - run: |
@@ -45,11 +45,11 @@ jobs:
45
45
  timeout-minutes: 10
46
46
  strategy:
47
47
  matrix:
48
- node-version: [22.x]
48
+ node-version: [24.x]
49
49
  steps:
50
- - uses: actions/checkout@v4
50
+ - uses: actions/checkout@v6
51
51
  - name: Use Node.js ${{ matrix.node-version }}
52
- uses: actions/setup-node@v4
52
+ uses: actions/setup-node@v6
53
53
  with:
54
54
  node-version: ${{ matrix.node-version }}
55
55
  - run: |
@@ -61,8 +61,8 @@ jobs:
61
61
  cd test
62
62
  npm run coverage-ci
63
63
  - name: Upload coverage to Codecov
64
- uses: codecov/codecov-action@v4
64
+ uses: codecov/codecov-action@v6
65
65
  with:
66
- file: ./test/coverage/lcov.info
66
+ files: ./test/coverage/lcov.info
67
67
  fail_ci_if_error: true
68
68
  token: ${{ secrets.CODECOV_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # bedrock-validation ChangeLog
2
2
 
3
+ ## 7.2.0 - 2026-06-04
4
+
5
+ ### Changed
6
+ - Update dependencies:
7
+ - `ajv@8`
8
+ - remove `klona` dependency.
9
+
3
10
  ## 7.1.1 - 2024-11-14
4
11
 
5
12
  ### Changed
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright 2022 - 2026 Digital Bazaar, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * SPDX-License-Identifier: Apache-2.0
17
+ */
18
+
19
+ import config from '@digitalbazaar/eslint-config/node-recommended';
20
+
21
+ export default [
22
+ ...config
23
+ ];
package/lib/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import * as bedrock from '@bedrock/core';
5
5
  import Ajv from 'ajv';
6
- import {Cache} from './Cache.js';
7
6
  import {promises as fs} from 'node:fs';
8
7
  import {logger} from './logger.js';
9
8
  import PATH from 'node:path';
10
9
 
11
- const ajv = new Ajv({cache: new Cache(), serialize: false, verbose: true});
10
+ // strict=false for backwards compatibility with ajv v6
11
+ const ajv = new Ajv({strict: false, verbose: true});
12
12
  const {util: {BedrockError}} = bedrock;
13
13
 
14
14
  // load config defaults
@@ -203,9 +203,10 @@ function _createError({schema, instance}) {
203
203
  const details = {
204
204
  instance,
205
205
  params: error.params,
206
- path: error.dataPath,
206
+ instancePath: error.instancePath,
207
+ path: _jsonPointerToJsPath(error.instancePath),
207
208
  public: true,
208
- schemaPath: error.schemaPath,
209
+ schemaPath: error.schemaPath
209
210
  };
210
211
  let title;
211
212
  if(Array.isArray(error.schema)) {
@@ -214,7 +215,7 @@ function _createError({schema, instance}) {
214
215
  title = title || error.parentSchema.title || '',
215
216
  details.schema = {
216
217
  description: error.parentSchema.description || '',
217
- title,
218
+ title
218
219
  };
219
220
  // include custom errors or use default
220
221
  // FIXME: enable if ajv supports this parentSchema.errors property
@@ -248,3 +249,27 @@ function _createError({schema, instance}) {
248
249
 
249
250
  return error;
250
251
  }
252
+
253
+ function _jsonPointerToJsPath(pointer) {
254
+ let path = '';
255
+ const [, ...segments] = pointer.split('/');
256
+ for(const segment of segments) {
257
+ // decode JSON pointer escape chars
258
+ const decoded = segment.replace(/~1/g, '/').replace(/~0/g, '~');
259
+
260
+ // handle integer index
261
+ if(/^\d+$/.test(decoded)) {
262
+ path += `[${decoded}]`;
263
+ continue;
264
+ }
265
+
266
+ // use dot notation for valid keys and bracket notation otherwise
267
+ if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(decoded)) {
268
+ path += `.${decoded}`;
269
+ } else {
270
+ path += `["${decoded}"]`;
271
+ }
272
+ }
273
+
274
+ return path;
275
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@bedrock/validation",
3
- "version": "7.1.1",
3
+ "version": "7.2.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock validation",
6
6
  "main": "./lib/index.js",
7
7
  "scripts": {
8
- "lint": "eslint --ext .cjs,.js ."
8
+ "lint": "eslint"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
@@ -24,8 +24,7 @@
24
24
  },
25
25
  "homepage": "https://github.com/digitalbazaar/bedrock-validation",
26
26
  "dependencies": {
27
- "ajv": "^6.12.6",
28
- "klona": "^2.0.6"
27
+ "ajv": "^8.20.0"
29
28
  },
30
29
  "peerDependencies": {
31
30
  "@bedrock/core": "^6.2.0"
@@ -34,9 +33,7 @@
34
33
  "lib": "./lib"
35
34
  },
36
35
  "devDependencies": {
37
- "eslint": "^8.57.1",
38
- "eslint-config-digitalbazaar": "^5.2.0",
39
- "eslint-plugin-jsdoc": "^50.5.0",
40
- "eslint-plugin-unicorn": "^56.0.0"
36
+ "@digitalbazaar/eslint-config": "^8.0.1",
37
+ "eslint": "^9.39.4"
41
38
  }
42
39
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Comment',
@@ -19,7 +18,7 @@ const schema = {
19
18
 
20
19
  export default function(extend) {
21
20
  if(extend) {
22
- return _extend(true, klona(schema), extend);
21
+ return _extend(true, structuredClone(schema), extend);
23
22
  }
24
23
  return schema;
25
24
  }
@@ -1,10 +1,9 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
5
  import identifier from './identifier.js';
6
6
  import jsonldContext from './jsonldContext.js';
7
- import {klona} from 'klona';
8
7
  import w3cDateTime from './w3cDateTime.js';
9
8
 
10
9
  // TODO: Improve this schema
@@ -24,7 +23,7 @@ const schema = {
24
23
  required: ['id'],
25
24
  properties: {
26
25
  id: identifier()
27
- },
26
+ }
28
27
  }
29
28
  },
30
29
  required: ['issuer', 'issued', 'claim']
@@ -32,7 +31,7 @@ const schema = {
32
31
 
33
32
  export default function(extend) {
34
33
  if(extend) {
35
- return _extend(true, klona(schema), extend);
34
+ return _extend(true, structuredClone(schema), extend);
36
35
  }
37
36
  return schema;
38
37
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Description',
@@ -19,7 +18,7 @@ const schema = {
19
18
 
20
19
  export default function(extend) {
21
20
  if(extend) {
22
- return _extend(true, klona(schema), extend);
21
+ return _extend(true, structuredClone(schema), extend);
23
22
  }
24
23
  return schema;
25
24
  }
package/schemas/email.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  // RFC 1034 - All labels have a max length of 63 octets.
8
7
  // https://tools.ietf.org/html/rfc1034#section-3.1
@@ -10,8 +9,8 @@ const schema = {
10
9
  title: 'Email',
11
10
  description: 'An email address.',
12
11
  type: 'string',
13
- // eslint-disable-next-line max-len
14
- pattern: '^[-a-z0-9~!$%^&*_=+}{\\\'?]+(\\.[-a-z0-9~!$%^&*_=+}{\\\'?]+)*@(((([a-z0-9]{1}[a-z0-9\\-]{0,63}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,63})$',
12
+ // eslint-disable-next-line @stylistic/max-len
13
+ pattern: `^[-a-z0-9~!$%^&*_=+}{'?]+(\\.[-a-z0-9~!$%^&*_=+}{'?]+)*@(((([a-z0-9]{1}[a-z0-9\\-]{0,63}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,63})$`,
15
14
  minLength: 1,
16
15
  maxLength: 100,
17
16
  errors: {
@@ -24,12 +23,12 @@ export default function(extend, options) {
24
23
  if(options && options.lowerCaseOnly) {
25
24
  extend = extend || {};
26
25
  if(!('pattern' in extend)) {
27
- // eslint-disable-next-line max-len
28
- extend.pattern = '^[-a-z0-9~!$%^&*_=+}{\\\'?]+(\\.[-a-z0-9~!$%^&*_=+}{\\\'?]+)*@(((([a-z0-9]{1}[a-z0-9\\-]{0,63}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,63})$';
26
+ // eslint-disable-next-line @stylistic/max-len
27
+ extend.pattern = `^[-a-z0-9~!$%^&*_=+}{'?]+(\\.[-a-z0-9~!$%^&*_=+}{'?]+)*@(((([a-z0-9]{1}[a-z0-9\\-]{0,63}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,63})$`;
29
28
  }
30
29
  }
31
30
  if(extend) {
32
- return _extend(true, klona(schema), extend);
31
+ return _extend(true, structuredClone(schema), extend);
33
32
  }
34
33
  return schema;
35
34
  }
@@ -1,9 +1,8 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../../lib/helpers.js';
5
5
  import identifier from '../identifier.js';
6
- import {klona} from 'klona';
7
6
 
8
7
  const schema = {
9
8
  title: 'identifier or an object with an id',
@@ -20,7 +19,7 @@ const schema = {
20
19
 
21
20
  export default function(extend) {
22
21
  if(extend) {
23
- return _extend(true, klona(schema), extend);
22
+ return _extend(true, structuredClone(schema), extend);
24
23
  }
25
24
  return schema;
26
25
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'ID',
@@ -17,7 +16,7 @@ const schema = {
17
16
 
18
17
  export default function(extend) {
19
18
  if(extend) {
20
- return _extend(true, klona(schema), extend);
19
+ return _extend(true, structuredClone(schema), extend);
21
20
  }
22
21
  return schema;
23
22
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2019-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'JSON Patch',
@@ -18,10 +17,10 @@ const schema = {
18
17
  enum: ['add', 'copy', 'move', 'remove', 'replace', 'test']
19
18
  },
20
19
  from: {
21
- type: 'string',
20
+ type: 'string'
22
21
  },
23
22
  path: {
24
- type: 'string',
23
+ type: 'string'
25
24
  },
26
25
  value: {
27
26
  //type: ['number', 'string', 'boolean', 'object', 'array'],
@@ -33,7 +32,7 @@ const schema = {
33
32
 
34
33
  export default function(extend) {
35
34
  if(extend) {
36
- return _extend(true, klona(schema), extend);
35
+ return _extend(true, structuredClone(schema), extend);
37
36
  }
38
37
  return schema;
39
38
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  export default function(context, extend) {
8
7
  const schema = {
@@ -17,7 +16,7 @@ export default function(context, extend) {
17
16
  type: 'object'
18
17
  // FIXME: improve context object validator
19
18
  }, {
20
- type: 'array',
19
+ type: 'array'
21
20
  // items added below if context param truthy
22
21
  }];
23
22
  if(context) {
@@ -49,7 +48,7 @@ export default function(context, extend) {
49
48
  }
50
49
  }
51
50
  if(extend) {
52
- return _extend(true, klona(schema), extend);
51
+ return _extend(true, structuredClone(schema), extend);
53
52
  }
54
53
  return schema;
55
54
  }
package/schemas/label.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Label',
@@ -20,7 +19,7 @@ const schema = {
20
19
 
21
20
  export default function(extend) {
22
21
  if(extend) {
23
- return _extend(true, klona(schema), extend);
22
+ return _extend(true, structuredClone(schema), extend);
24
23
  }
25
24
  return schema;
26
25
  }
@@ -1,9 +1,8 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
5
  import identifier from './identifier.js';
6
- import {klona} from 'klona';
7
6
  import w3cDateTime from './w3cDateTime.js';
8
7
 
9
8
  const signature = {
@@ -24,7 +23,7 @@ const signature = {
24
23
  description: 'The Base64 encoding of the result of the signature ' +
25
24
  'algorithm.',
26
25
  type: 'string'
27
- },
26
+ }
28
27
  },
29
28
  // NOTE: id is not required
30
29
  required: ['type', 'creator', 'created', 'signatureValue']
@@ -35,13 +34,13 @@ const schema = {
35
34
  anyOf: [{
36
35
  type: 'array',
37
36
  items: signature,
38
- minItems: 1,
37
+ minItems: 1
39
38
  }, signature]
40
39
  };
41
40
 
42
41
  export default function(extend) {
43
42
  if(extend) {
44
- return _extend(true, klona(schema), extend);
43
+ return _extend(true, structuredClone(schema), extend);
45
44
  }
46
45
  return schema;
47
46
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import identifier from './identifier.js';
5
5
  import w3cDateTime from './w3cDateTime.js';
@@ -25,8 +25,8 @@ const baseSignature = {
25
25
  'algorithm.',
26
26
  type: 'string'
27
27
  },
28
- verificationMethod: identifier(),
29
- },
28
+ verificationMethod: identifier()
29
+ }
30
30
  };
31
31
 
32
32
  const signature = {
@@ -35,10 +35,10 @@ const signature = {
35
35
  // only one of `creator` or `verificationMethod`
36
36
  anyOf: [{
37
37
  required: ['creator'],
38
- not: {required: ['verificationMethod']},
38
+ not: {required: ['verificationMethod']}
39
39
  }, {
40
40
  required: ['verificationMethod'],
41
- not: {required: ['creator']},
41
+ not: {required: ['creator']}
42
42
  }]
43
43
  }
44
44
  ]
@@ -49,7 +49,7 @@ const schema = {
49
49
  oneOf: [{
50
50
  type: 'array',
51
51
  items: signature,
52
- minItems: 1,
52
+ minItems: 1
53
53
  }, signature]
54
54
  };
55
55
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright (c) 2021-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2021-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import identifier from './identifier.js';
5
5
  import w3cDateTime from './w3cDateTime.js';
@@ -24,8 +24,8 @@ const signature = {
24
24
  'the signature algorithm.',
25
25
  type: 'string'
26
26
  },
27
- verificationMethod: identifier(),
28
- },
27
+ verificationMethod: identifier()
28
+ }
29
29
  };
30
30
 
31
31
  const schema = {
@@ -33,7 +33,7 @@ const schema = {
33
33
  oneOf: [{
34
34
  type: 'array',
35
35
  items: signature,
36
- minItems: 1,
36
+ minItems: 1
37
37
  }, signature]
38
38
  };
39
39
 
package/schemas/nonce.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Nonce',
@@ -20,7 +19,7 @@ const schema = {
20
19
 
21
20
  export default function(extend) {
22
21
  if(extend) {
23
- return _extend(true, klona(schema), extend);
22
+ return _extend(true, structuredClone(schema), extend);
24
23
  }
25
24
  return schema;
26
25
  }
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Person Name',
@@ -20,7 +19,7 @@ const schema = {
20
19
 
21
20
  export default function(extend) {
22
21
  if(extend) {
23
- return _extend(true, klona(schema), extend);
22
+ return _extend(true, structuredClone(schema), extend);
24
23
  }
25
24
  return schema;
26
25
  }
@@ -1,14 +1,13 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Private Key PEM',
9
8
  description: 'A cryptographic Private Key in PEM format.',
10
9
  type: 'string',
11
- // eslint-disable-next-line max-len
10
+ // eslint-disable-next-line @stylistic/max-len
12
11
  pattern: '^\\s*-----BEGIN RSA PRIVATE KEY-----[a-zA-Z0-9/+=\\s]*-----END RSA PRIVATE KEY-----\\s*$',
13
12
  errors: {
14
13
  invalid: 'The private key is not formatted correctly.',
@@ -18,7 +17,7 @@ const schema = {
18
17
 
19
18
  export default function(extend) {
20
19
  if(extend) {
21
- return _extend(true, klona(schema), extend);
20
+ return _extend(true, structuredClone(schema), extend);
22
21
  }
23
22
  return schema;
24
23
  }
package/schemas/proof.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  // schema for a proof on a VerifiableCredential or Presentation
8
7
  const schema = {
@@ -15,7 +14,7 @@ const schema = {
15
14
 
16
15
  export default function(extend) {
17
16
  if(extend) {
18
- return _extend(true, klona(schema), extend);
17
+ return _extend(true, structuredClone(schema), extend);
19
18
  }
20
19
  return schema;
21
20
  }
@@ -1,14 +1,13 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Public Key PEM',
9
8
  description: 'A cryptographic Public Key in PEM format.',
10
9
  type: 'string',
11
- // eslint-disable-next-line max-len
10
+ // eslint-disable-next-line @stylistic/max-len
12
11
  pattern: '^\\s*-----BEGIN (RSA\\s)?PUBLIC KEY-----[a-zA-Z0-9/+=\\s]*-----END (RSA\\s)?PUBLIC KEY-----\\s*$',
13
12
  errors: {
14
13
  invalid: 'The public key is not formatted correctly.',
@@ -18,7 +17,7 @@ const schema = {
18
17
 
19
18
  export default function(extend) {
20
19
  if(extend) {
21
- return _extend(true, klona(schema), extend);
20
+ return _extend(true, structuredClone(schema), extend);
22
21
  }
23
22
  return schema;
24
23
  }
@@ -1,9 +1,8 @@
1
1
  /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2019-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
5
  import jsonPatch from './jsonPatch.js';
6
- import {klona} from 'klona';
7
6
 
8
7
  const schema = {
9
8
  required: ['patch', 'sequence', 'target'],
@@ -11,7 +10,7 @@ const schema = {
11
10
  type: 'object',
12
11
  properties: {
13
12
  target: {
14
- type: 'string',
13
+ type: 'string'
15
14
  },
16
15
  // FIXME: also support `frame` property later
17
16
  patch: jsonPatch(),
@@ -26,7 +25,7 @@ const schema = {
26
25
 
27
26
  export default function(extend) {
28
27
  if(extend) {
29
- return _extend(true, klona(schema), extend);
28
+ return _extend(true, structuredClone(schema), extend);
30
29
  }
31
30
  return schema;
32
31
  }
package/schemas/slug.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Slug',
@@ -22,7 +21,7 @@ const schema = {
22
21
 
23
22
  export default function(extend) {
24
23
  if(extend) {
25
- return _extend(true, klona(schema), extend);
24
+ return _extend(true, structuredClone(schema), extend);
26
25
  }
27
26
  return schema;
28
27
  }
package/schemas/title.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'Title',
@@ -20,7 +19,7 @@ const schema = {
20
19
 
21
20
  export default function(extend) {
22
21
  if(extend) {
23
- return _extend(true, klona(schema), extend);
22
+ return _extend(true, structuredClone(schema), extend);
24
23
  }
25
24
  return schema;
26
25
  }
package/schemas/url.js CHANGED
@@ -1,8 +1,7 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'URL',
@@ -17,7 +16,7 @@ const schema = {
17
16
 
18
17
  export default function(extend) {
19
18
  if(extend) {
20
- return _extend(true, klona(schema), extend);
19
+ return _extend(true, structuredClone(schema), extend);
21
20
  }
22
21
  return schema;
23
22
  }
@@ -1,9 +1,8 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
5
  import idOrObjectWithId from './helpers/idOrObjectWithId.js';
6
- import {klona} from 'klona';
7
6
  import proof from './proof.js';
8
7
  import w3cDateTime from './w3cDateTime.js';
9
8
 
@@ -42,7 +41,7 @@ const schema = {
42
41
  minItems: 1,
43
42
  // this first type must be VerifiableCredential
44
43
  items: [
45
- {type: 'string', const: 'VerifiableCredential'},
44
+ {type: 'string', const: 'VerifiableCredential'}
46
45
  ],
47
46
  // additional types must be strings
48
47
  additionalItems: {
@@ -61,7 +60,7 @@ const schema = {
61
60
 
62
61
  export default function(extend) {
63
62
  if(extend) {
64
- return _extend(true, klona(schema), extend);
63
+ return _extend(true, structuredClone(schema), extend);
65
64
  }
66
65
  return schema;
67
66
  }
@@ -1,9 +1,8 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
5
  import idOrObjectWithId from './helpers/idOrObjectWithId.js';
6
- import {klona} from 'klona';
7
6
  import proof from './proof.js';
8
7
  import verifiableCredential from './verifiableCredential.js';
9
8
 
@@ -31,7 +30,7 @@ const schema = {
31
30
  minItems: 1,
32
31
  // this first type must be VerifiablePresentation
33
32
  items: [
34
- {type: 'string', const: 'VerifiablePresentation'},
33
+ {type: 'string', const: 'VerifiablePresentation'}
35
34
  ],
36
35
  // additional types must be strings
37
36
  additionalItems: {
@@ -52,7 +51,7 @@ const schema = {
52
51
 
53
52
  export default function(extend) {
54
53
  if(extend) {
55
- return _extend(true, klona(schema), extend);
54
+ return _extend(true, structuredClone(schema), extend);
56
55
  }
57
56
  return schema;
58
57
  }
@@ -1,17 +1,16 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import {extend as _extend} from '../lib/helpers.js';
5
- import {klona} from 'klona';
6
5
 
7
6
  const schema = {
8
7
  title: 'W3C Date/Time',
9
8
  description: 'A W3C-formatted date and time combination.',
10
9
  type: 'string',
11
- // eslint-disable-next-line max-len
10
+ // eslint-disable-next-line @stylistic/max-len
12
11
  pattern: '^[1-9][0-9]{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3]):([0-5][0-9]):(([0-5][0-9])|60)(\\.[0-9]+)?(Z|((\\+|-)([0-1][0-9]|2[0-3]):([0-5][0-9])))?$',
13
12
  errors: {
14
- // eslint-disable-next-line max-len
13
+ // eslint-disable-next-line @stylistic/max-len
15
14
  invalid: 'The date/time must be of the W3C date/time format "YYYY-MM-DD( |T)HH:MM:SS.s(Z|(+|-)TZOFFSET)".',
16
15
  missing: 'Please enter a date/time.'
17
16
  }
@@ -19,7 +18,7 @@ const schema = {
19
18
 
20
19
  export default function(extend) {
21
20
  if(extend) {
22
- return _extend(true, klona(schema), extend);
21
+ return _extend(true, structuredClone(schema), extend);
23
22
  }
24
23
  return schema;
25
24
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2
+ * Copyright (c) 2012-2026 Digital Bazaar, Inc.
3
3
  */
4
4
  import * as validation from '@bedrock/validation';
5
5
  import {mock} from './mock.data.js';
@@ -822,7 +822,7 @@ describe('bedrock-validation', function() {
822
822
  type: 'LinkedDataSignature2015',
823
823
  created: '2016-01-01T01:00:00Z',
824
824
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
825
- // eslint-disable-next-line max-len
825
+ // eslint-disable-next-line @stylistic/max-len
826
826
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
827
827
  };
828
828
  const result = validateInstance({instance: signature, schema});
@@ -834,7 +834,7 @@ describe('bedrock-validation', function() {
834
834
  type: 'LinkedDataSignature2016',
835
835
  created: '2016-01-01T01:00:00Z',
836
836
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
837
- // eslint-disable-next-line max-len
837
+ // eslint-disable-next-line @stylistic/max-len
838
838
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
839
839
  };
840
840
  const result = validateInstance({instance: signature, schema});
@@ -846,7 +846,7 @@ describe('bedrock-validation', function() {
846
846
  type: 'LinkedDataSignature2015',
847
847
  created: '2016-01-01T01:00:00Z',
848
848
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
849
- // eslint-disable-next-line max-len
849
+ // eslint-disable-next-line @stylistic/max-len
850
850
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
851
851
  };
852
852
  const extend = {name: 'test'};
@@ -861,7 +861,7 @@ describe('bedrock-validation', function() {
861
861
  type: 'GraphSignature2012',
862
862
  created: '2016-01-01T01:00:00Z',
863
863
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
864
- // eslint-disable-next-line max-len
864
+ // eslint-disable-next-line @stylistic/max-len
865
865
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
866
866
  };
867
867
  const result = validateInstance({instance: signature, schema});
@@ -872,38 +872,38 @@ describe('bedrock-validation', function() {
872
872
  const signature = {
873
873
  created: '2016-01-01T01:00:00Z',
874
874
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
875
- // eslint-disable-next-line max-len
875
+ // eslint-disable-next-line @stylistic/max-len
876
876
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
877
877
  };
878
878
  const result = validateInstance({instance: signature, schema});
879
879
  result.valid.should.be.false;
880
880
  });
881
881
 
882
- // eslint-disable-next-line max-len
882
+ // eslint-disable-next-line @stylistic/max-len
883
883
  it('should NOT validate a LinkedDataSignature2015 signature w/missing created', function() {
884
884
  const signature = {
885
885
  type: 'LinkedDataSignature2015',
886
886
  creator: 'urn:5dd6a7e2-4c32-4a21-60b3-2385e5b6bcd4/keys/1',
887
- // eslint-disable-next-line max-len
887
+ // eslint-disable-next-line @stylistic/max-len
888
888
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
889
889
  };
890
890
  const result = validateInstance({instance: signature, schema});
891
891
  result.valid.should.be.false;
892
892
  });
893
893
 
894
- // eslint-disable-next-line max-len
894
+ // eslint-disable-next-line @stylistic/max-len
895
895
  it('should NOT validate a LinkedDataSignature2015 signature w/missing creator', function() {
896
896
  const signature = {
897
897
  type: 'LinkedDataSignature2015',
898
898
  created: '2016-01-01T01:00:00Z',
899
- // eslint-disable-next-line max-len
899
+ // eslint-disable-next-line @stylistic/max-len
900
900
  signatureValue: 'Lc6l7gxEPV1lKTj4KADaER52CiMBpvsHg7eZZJXzRK3U8N/eUYxITlenu3svj4KPrdnaBfMXGo3U/vAVaQNF5Er0g/SXC2KpUmRN4uyMYgQ5NwWklS2JqjJ/0Y3hio4GOgdMDiqrlZJvfQdtRaJjKoskc7F3bZtDVsX6Sr95erfOeobHOIMcbNIC0a96oYOaQlOeOC45BqQaUaczYKPayGEeQN2lfD+qR6b1MR4xtWNrx5pzzPpAPkjj3I91wiVQER43s/nq5XZKkDk8V8eD7xEURoDUcu3rA1qHLfrpRHJGCErXNc784O4R4Oqm5zQlkyB1mWJxnz3qSqzgqVG0sQ=='
901
901
  };
902
902
  const result = validateInstance({instance: signature, schema});
903
903
  result.valid.should.be.false;
904
904
  });
905
905
 
906
- // eslint-disable-next-line max-len
906
+ // eslint-disable-next-line @stylistic/max-len
907
907
  it('should NOT validate a LinkedDataSignature2015 signature w/missing signature', function() {
908
908
  const signature = {
909
909
  type: 'LinkedDataSignature2015',
@@ -973,7 +973,6 @@ describe('bedrock-validation', function() {
973
973
  result.valid.should.be.false;
974
974
  });
975
975
 
976
- // eslint-disable-next-line max-len
977
976
  it('should NOT validate a signature w/missing proofValue', function() {
978
977
  const signature = {
979
978
  type: 'Ed25519Signature2020',
@@ -1098,7 +1097,7 @@ describe('bedrock-validation', function() {
1098
1097
  result.valid.should.be.true;
1099
1098
  });
1100
1099
 
1101
- // eslint-disable-next-line max-len
1100
+ // eslint-disable-next-line @stylistic/max-len
1102
1101
  it('should NOT validate a sequenced JSON patch without a sequence', function() {
1103
1102
  const doc = {
1104
1103
  target: 'some-identifier',
@@ -1110,7 +1109,7 @@ describe('bedrock-validation', function() {
1110
1109
  result.valid.should.be.false;
1111
1110
  });
1112
1111
 
1113
- // eslint-disable-next-line max-len
1112
+ // eslint-disable-next-line @stylistic/max-len
1114
1113
  it('should NOT validate a sequenced JSON patch without a target', function() {
1115
1114
  const doc = {
1116
1115
  patch: [
@@ -1122,7 +1121,7 @@ describe('bedrock-validation', function() {
1122
1121
  result.valid.should.be.false;
1123
1122
  });
1124
1123
 
1125
- // eslint-disable-next-line max-len
1124
+ // eslint-disable-next-line @stylistic/max-len
1126
1125
  it('should NOT validate a sequenced JSON patch with a negative sequence', function() {
1127
1126
  const doc = {
1128
1127
  target: 'some-identifier',
package/.eslintrc.cjs DELETED
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: {
4
- node: true
5
- },
6
- extends: [
7
- 'digitalbazaar',
8
- 'digitalbazaar/jsdoc',
9
- 'digitalbazaar/module'
10
- ],
11
- ignorePatterns: ['node_modules/'],
12
- rules: {
13
- 'unicorn/prefer-node-protocol': 'error'
14
- }
15
- };
package/lib/Cache.js DELETED
@@ -1,24 +0,0 @@
1
- /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- export class Cache {
5
- constructor() {
6
- this._cache = new Map();
7
- }
8
-
9
- put(key, value) {
10
- this._cache.set(key, value);
11
- }
12
-
13
- get(key) {
14
- return this._cache.get(key);
15
- }
16
-
17
- del(key) {
18
- this._cache.delete(key);
19
- }
20
-
21
- clear() {
22
- this._cache.clear();
23
- }
24
- }
@@ -1,9 +0,0 @@
1
- {
2
- "env": {
3
- "mocha": true
4
- },
5
- "globals": {
6
- "assertNoError": true,
7
- "should": true
8
- }
9
- }