Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .eslintrc.cjs

This file was deleted.

14 changes: 10 additions & 4 deletions .github/workflows/main.yml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Bedrock Node.js CI
name: Main CI

on: [push]

permissions: {}

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -11,6 +13,8 @@ jobs:
node-version: [24.x]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
Expand All @@ -19,7 +23,6 @@ jobs:
- name: Run eslint
run: npm run lint
test-node:
needs: [lint]
runs-on: ubuntu-latest
timeout-minutes: 10
services:
Expand All @@ -32,6 +35,8 @@ jobs:
node-version: [22.x, 24.x]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
Expand All @@ -45,7 +50,6 @@ jobs:
cd test
npm test
coverage:
needs: [test-node]
runs-on: ubuntu-latest
timeout-minutes: 10
services:
Expand All @@ -58,6 +62,8 @@ jobs:
node-version: [24.x]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
Expand All @@ -73,6 +79,6 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
file: ./test/coverage/lcov.info
files: ./test/coverage/lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# bedrock-tokenization ChangeLog

## 23.3.0 - 2026-06-dd

### Changed
- Expect node >= 22.
- Update dependencies:
- `canonicalize@3`
- `@digitalbazaar/cborld@8.1`
- `@digitalbazaar/minimal-cipher@6.1.1`
- `lru-cache@11.5.1`.

## 23.2.0 - 2026-06-21

### Added
Expand Down
16 changes: 16 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import config from '@digitalbazaar/eslint-config/node-recommended';

export default [
...config,
{
files: [
'test/mocha/**/*.js'
],
languageOptions: {
globals: {
// @bedrock/test global
assertNoError: true
}
}
}
];
4 changes: 2 additions & 2 deletions lib/batchVersions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import * as bedrock from '@bedrock/core';
import * as database from '@bedrock/mongodb';
Expand All @@ -14,7 +14,7 @@ const {util: {BedrockError}} = bedrock;
const CACHE = new LRU({
max: 100,
// 24 hour ttl
ttl: 1000 * 60 * 60 * 24,
ttl: 1000 * 60 * 60 * 24
});

// a special ID, the literal string "NEXT_OPTIONS", is used to identify the
Expand Down
4 changes: 2 additions & 2 deletions lib/tokens/aeskw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import crypto from 'node:crypto';

Expand Down Expand Up @@ -41,7 +41,7 @@ class Kek {
try {
const cipher = crypto.createDecipheriv('id-aes256-wrap', kek, AES_KW_IV);
return Buffer.concat([cipher.update(wrappedKey), cipher.final()]);
} catch(e) {
} catch {
// decryption failed
return null;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/tokens/batches.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*!
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import * as base64url from 'base64url-universal';
import * as batchVersions from '../batchVersions.js';
import * as bedrock from '@bedrock/core';
import * as database from '@bedrock/mongodb';
Expand All @@ -23,7 +22,7 @@ only 100, so it fits within this parameter. The config for this module has
comments that indicate that the max configurable token batch size is 256 and
this is because of this implementation detail. */
const EMPTY_RESOLVED_LIST_FOR_MAX_BATCH_SIZE_256 = Buffer.from(
base64url.decode('H4sIAAAAAAAAA2NgwA8ArVUKGSAAAAA'));
'H4sIAAAAAAAAA2NgwA8ArVUKGSAAAAA', 'base64url');

const INTERNAL_ID_SIZE = 16;
const MAX_TOKEN_COUNT = 100;
Expand Down
8 changes: 4 additions & 4 deletions lib/tokens/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import * as base58 from 'base58-universal';
import * as batchVersions from '../batchVersions.js';
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function create({
// salt
payload.set(salt, offset += 2);
// wrapped
payload.set(wrapped, offset += salt.length);
payload.set(wrapped, offset + salt.length);

// ConcealedIdToken "meta" is "attributes"

Expand All @@ -88,7 +88,7 @@ export async function create({
'@context': CIT_CONTEXT_URL,
type: 'ConcealedIdToken',
meta: `z${base58.encode(attributes)}`,
payload: `z${base58.encode(payload)}`,
payload: `z${base58.encode(payload)}`
};
const token = await cborldEncode({
jsonldDocument,
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function parse({token}) {
let offset = payload.byteOffset + VERSION_SIZE;
const salt = new Uint8Array(payload.buffer, offset, batchSaltSize);
const wrapped = new Uint8Array(
payload.buffer, offset += batchSaltSize, wrappedSize);
payload.buffer, offset + batchSaltSize, wrappedSize);

// get tokenizer associated with version
const tokenizer = await tokenizers.get({id: batchVersion.tokenizerId});
Expand Down
5 changes: 2 additions & 3 deletions lib/tokens/resolve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*!
* Copyright (c) 2020-2025 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2026 Digital Bazaar, Inc.
*/
import * as base64url from 'base64url-universal';
import * as bedrock from '@bedrock/core';
import * as entities from '../entities.js';
import {
Expand Down Expand Up @@ -95,7 +94,7 @@ export async function resolve({
});

// find resolution list for `requester`
const encodedRequester = base64url.encode(requester);
const encodedRequester = Buffer.from(requester).toString('base64url');
const requesterList = resolution[encodedRequester];

// see if token is already resolved
Expand Down
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Bedrock Tokenization Engine",
"main": "./lib/index.js",
"scripts": {
"lint": "eslint ."
"lint": "eslint"
},
"repository": {
"type": "git",
Expand All @@ -26,15 +26,14 @@
"homepage": "https://github.com/digitalbazaar/bedrock-tokenization",
"dependencies": {
"@digitalbazaar/bitstring": "^3.1.0",
"@digitalbazaar/cborld": "^8.0.0",
"@digitalbazaar/minimal-cipher": "^6.0.0",
"@digitalbazaar/cborld": "^8.1.0",
"@digitalbazaar/minimal-cipher": "^6.1.1",
"assert-plus": "^1.0.0",
"base58-universal": "^2.0.0",
"base64url-universal": "^2.0.0",
"bnid": "^3.0.0",
"canonicalize": "^2.1.0",
"canonicalize": "^3.0.0",
"cit-context": "^2.0.1",
"lru-cache": "^11.1.0",
"lru-cache": "^11.5.1",
"p-limit": "^6.2.0"
},
"peerDependencies": {
Expand All @@ -45,15 +44,13 @@
"@bedrock/tokenizer": "^11.0.0"
},
"devDependencies": {
"eslint": "^8.57.1",
"eslint-config-digitalbazaar": "^5.2.0",
"eslint-plugin-jsdoc": "^50.6.8",
"eslint-plugin-unicorn": "^56.0.1"
"@digitalbazaar/eslint-config": "^9.0.0",
"eslint": "^10.5.0"
},
"directories": {
"lib": "./lib"
},
"engines": {
"node": ">=18"
"node": ">=22"
}
}
9 changes: 0 additions & 9 deletions test/.eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion test/mocha/10-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Documents', function() {
header: {
kid: 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#' +
'z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc',
alg: 'ECDH-ES+A256KW',
alg: 'ECDH-ES+A256KW'
}
}];
const result = await documents.register({
Expand Down
Loading