From 078df15865fff172823da729f379c84620001853 Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Sat, 22 Feb 2025 12:54:45 -0500 Subject: [PATCH 01/11] switch to did-method-web --- package.json | 2 ++ src/declarations.d.ts | 2 ++ src/documentLoader.ts | 19 +++++++------------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index c68aedc..65dbd48 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ }, "dependencies": { "@digitalbazaar/data-integrity-context": "^2.0.0", + "@digitalbazaar/did-method-web": "file:../did-method-web", + "@digitalbazaar/ed25519-multikey": "^1.3.1", "@digitalbazaar/vc-bitstring-status-list-context": "^1.0.0", "@digitalbazaar/vc-status-list-context": "^3.0.1", "@digitalcredentials/credentials-v2-context": "~0.0.1-beta.0", diff --git a/src/declarations.d.ts b/src/declarations.d.ts index 66db07a..1567a6f 100644 --- a/src/declarations.d.ts +++ b/src/declarations.d.ts @@ -5,6 +5,8 @@ declare module '@digitalcredentials/vc'; declare module '@digitalbazaar/vc-bitstring-status-list-context'; declare module '@digitalcredentials/vc-status-list'; declare module '@digitalbazaar/vc-status-list-context'; +declare module '@digitalcredentials/did-method-web'; +declare module '@digitalbazaar/ed25519-multikey'; declare module '@digitalcredentials/vpqr'; declare module '@digitalbazaar/data-integrity-context'; declare module '@digitalcredentials/ed25519-verification-key-2020'; diff --git a/src/documentLoader.ts b/src/documentLoader.ts index f4ebde4..62ec20f 100644 --- a/src/documentLoader.ts +++ b/src/documentLoader.ts @@ -2,34 +2,29 @@ * Copyright (c) 2021 Interop Alliance and Dmitri Zagidulin. All rights reserved. */ import * as didKey from '@digitalcredentials/did-method-key'; -import * as didWeb from '@interop/did-web-resolver'; +import * as didWeb from '@digitalcredentials/did-method-web'; import * as vc2Context from '@digitalcredentials/credentials-v2-context'; import * as vcBitstringStatusListContext from '@digitalbazaar/vc-bitstring-status-list-context'; import vc1Context from 'credentials-context'; import vcStatusListContext from '@digitalbazaar/vc-status-list-context'; import dataIntegrityContext from '@digitalbazaar/data-integrity-context'; -import { Ed25519VerificationKey2020 } - from '@digitalcredentials/ed25519-verification-key-2020'; -import { X25519KeyAgreementKey2020 } - from '@digitalcredentials/x25519-key-agreement-key-2020'; +// import { Ed25519VerificationKey2020 } + // from '@digitalcredentials/ed25519-verification-key-2020'; +// import { X25519KeyAgreementKey2020 } + // from '@digitalcredentials/x25519-key-agreement-key-2020'; import { CachedResolver } from '@digitalcredentials/did-io'; import dccContext from '@digitalcredentials/dcc-context'; import didContext from 'did-context'; import ed25519Context from 'ed25519-signature-2020-context'; import x25519Context from 'x25519-key-agreement-2020-context'; import { JsonLdDocumentLoader } from 'jsonld-document-loader'; -import { CryptoLD } from '@digitalcredentials/crypto-ld'; import obContext from '@digitalcredentials/open-badges-context'; import { httpClient } from '@digitalcredentials/http-client'; import { parseResponseBody } from './parseResponse'; -const cryptoLd = new CryptoLD(); -cryptoLd.use(Ed25519VerificationKey2020); -cryptoLd.use(X25519KeyAgreementKey2020); -const didWebDriver = didWeb.driver({ cryptoLd }); - -const didKeyDriver = didKey.driver(); const resolver = new CachedResolver(); +const didKeyDriver = didKey.driver(); +const didWebDriver = didWeb.driver(); resolver.use(didKeyDriver); resolver.use(didWebDriver); From 7a44bd546c10c00f395d82a1684bf696922ed194 Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Thu, 6 Mar 2025 10:04:16 -0500 Subject: [PATCH 02/11] switch to dcc did-method-web --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 65dbd48..a902610 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ }, "dependencies": { "@digitalbazaar/data-integrity-context": "^2.0.0", - "@digitalbazaar/did-method-web": "file:../did-method-web", "@digitalbazaar/ed25519-multikey": "^1.3.1", "@digitalbazaar/vc-bitstring-status-list-context": "^1.0.0", "@digitalbazaar/vc-status-list-context": "^3.0.1", @@ -41,7 +40,8 @@ "@digitalcredentials/crypto-ld": "^7.0.2", "@digitalcredentials/dcc-context": "^1.0.0", "@digitalcredentials/did-io": "^1.0.2", - "@digitalcredentials/did-method-key": "^2.0.3", + "@digitalcredentials/did-method-key": "file:../did-method-key", + "@digitalcredentials/did-method-web": "file:../did-method-web", "@digitalcredentials/ed25519-verification-key-2020": "^3.2.2", "@digitalcredentials/http-client": "^5.0.1", "@digitalcredentials/open-badges-context": "^2.1.0", From b87fb96988903c4fa232f79a7cecfec66fc5a565 Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Thu, 6 Mar 2025 12:13:15 -0500 Subject: [PATCH 03/11] add multikey test --- test/documentLoader.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/documentLoader.spec.ts b/test/documentLoader.spec.ts index 2444ba3..32293e4 100644 --- a/test/documentLoader.spec.ts +++ b/test/documentLoader.spec.ts @@ -31,6 +31,23 @@ describe('documentLoader', () => { const result = await documentLoader(url); expect(result.document).to.exist; }); + + it('should load a did:web document from web', async () => { + const documentLoader = securityLoader({fetchRemoteContexts: true}).build(); + const url = 'https://digitalcredentials.github.io/dcc-did-web/did.json'; + const result = await documentLoader(url); + expect(result.document).to.exist; + expect(result.document.assertionMethod.type === 'Ed25519VerificationKey2020') + }); + + it('should load a multikey did:web document from web', async () => { + const documentLoader = securityLoader({fetchRemoteContexts: true}).build(); + const url = 'https://digitalcredentials.github.io/dcc-did-web/multikey/did.json'; + const result = await documentLoader(url); + expect(result.document).to.exist; + expect(result.document.verificationMethod.type === 'Multkey') + }); + it('supports beta OBv3 context', async () => { const load = securityLoader().build() From 89c47d1ba346b31fba306dc45d86d177ee499aef Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Sun, 9 Mar 2025 18:03:56 -0400 Subject: [PATCH 04/11] rework build process --- .eslintrc.js => .eslintrc.cjs | 2 +- package.json | 30 ++++++------ src/declarations.d.ts | 2 +- src/documentLoader.ts | 13 +++++- src/index.ts | 3 +- test/documentLoader.spec.ts | 2 +- tsconfig.cjs.json | 26 +++++++++++ tsconfig.esm.json | 26 +++++++++++ tsconfig.json | 86 ----------------------------------- tsconfig.test.json | 20 ++++++++ tsconfig.types.json | 22 +++++++++ 11 files changed, 126 insertions(+), 106 deletions(-) rename .eslintrc.js => .eslintrc.cjs (93%) create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json delete mode 100644 tsconfig.json create mode 100644 tsconfig.test.json create mode 100644 tsconfig.types.json diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 93% rename from .eslintrc.js rename to .eslintrc.cjs index fab9b28..d51d4d7 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -4,7 +4,7 @@ module.exports = { parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', 'prettier'], parserOptions: { - project: './tsconfig.json' + project: './tsconfig.esm.json' }, ignorePatterns: ['dist/', 'test'], rules: { diff --git a/package.json b/package.json index a902610..f89b9b0 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,20 @@ "description": "A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.", "version": "6.0.1", "scripts": { - "build": "npm run clear && tsc -p tsconfig.json && ./build-dist.sh", + "build-cjs": "tsc -p tsconfig.cjs.json", + "build-esm": "tsc -p tsconfig.esm.json", + "build-types": "tsc -p tsconfig.types.json", + "build-test": "tsc -p tsconfig.test.json", + "build": "npm run clear && npm run build-types && npm run build-cjs && npm run build-esm", "clear": "rimraf dist/*", "lint": "eslint .", "lint:fix": "eslint --fix .", "prepare": "npm run build", "rebuild": "npm run clear && npm run build", "test": "npm run lint && npm run test-node", + "test-node": "npm run build-test && mocha dist/esm/test/*.spec.js && rimraf dist/esm/test", "test-karma": "karma start karma.conf.js", - "test-node": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'test/*.ts'" + "test-node-old": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'test/*.ts'" }, "files": [ "dist", @@ -19,21 +24,21 @@ "README.md", "LICENSE.md" ], - "main": "dist/index.js", + "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "browser": "dist/index.js", - "types": "dist/index.d.ts", + "type": "module", + "browser": "dist/cjs/index.js", + "types": "dist/types/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/cjs/index.js", "import": "./dist/esm/index.js", - "types": "./dist/index.d.ts" + "types": "./dist/types/index.d.ts" }, "./package.json": "./package.json" }, "dependencies": { "@digitalbazaar/data-integrity-context": "^2.0.0", - "@digitalbazaar/ed25519-multikey": "^1.3.1", "@digitalbazaar/vc-bitstring-status-list-context": "^1.0.0", "@digitalbazaar/vc-status-list-context": "^3.0.1", "@digitalcredentials/credentials-v2-context": "~0.0.1-beta.0", @@ -42,6 +47,7 @@ "@digitalcredentials/did-io": "^1.0.2", "@digitalcredentials/did-method-key": "file:../did-method-key", "@digitalcredentials/did-method-web": "file:../did-method-web", + "@digitalcredentials/ed25519-multikey": "file:../ed25519-multikey", "@digitalcredentials/ed25519-verification-key-2020": "^3.2.2", "@digitalcredentials/http-client": "^5.0.1", "@digitalcredentials/open-badges-context": "^2.1.0", @@ -55,6 +61,7 @@ "x25519-key-agreement-2020-context": "^1.0.0" }, "devDependencies": { + "@npmcli/package-json": "^6.1.1", "@types/chai": "^4.3.3", "@types/mocha": "^10.0.0", "@types/node": "^18.11.0", @@ -86,13 +93,6 @@ "publishConfig": { "access": "public" }, - "mocha": { - "require": "ts-node/register", - "extension": [ - "ts" - ], - "spec": "test/**/*.ts" - }, "engines": { "node": ">=16.0" }, diff --git a/src/declarations.d.ts b/src/declarations.d.ts index 1567a6f..48ec2cc 100644 --- a/src/declarations.d.ts +++ b/src/declarations.d.ts @@ -6,7 +6,7 @@ declare module '@digitalbazaar/vc-bitstring-status-list-context'; declare module '@digitalcredentials/vc-status-list'; declare module '@digitalbazaar/vc-status-list-context'; declare module '@digitalcredentials/did-method-web'; -declare module '@digitalbazaar/ed25519-multikey'; +declare module '@digitalcredentials/ed25519-multikey'; declare module '@digitalcredentials/vpqr'; declare module '@digitalbazaar/data-integrity-context'; declare module '@digitalcredentials/ed25519-verification-key-2020'; diff --git a/src/documentLoader.ts b/src/documentLoader.ts index 62ec20f..93d7387 100644 --- a/src/documentLoader.ts +++ b/src/documentLoader.ts @@ -8,6 +8,7 @@ import * as vcBitstringStatusListContext from '@digitalbazaar/vc-bitstring-statu import vc1Context from 'credentials-context'; import vcStatusListContext from '@digitalbazaar/vc-status-list-context'; import dataIntegrityContext from '@digitalbazaar/data-integrity-context'; +import * as Ed25519Multikey from '@digitalcredentials/ed25519-multikey'; // import { Ed25519VerificationKey2020 } // from '@digitalcredentials/ed25519-verification-key-2020'; // import { X25519KeyAgreementKey2020 } @@ -20,7 +21,7 @@ import x25519Context from 'x25519-key-agreement-2020-context'; import { JsonLdDocumentLoader } from 'jsonld-document-loader'; import obContext from '@digitalcredentials/open-badges-context'; import { httpClient } from '@digitalcredentials/http-client'; -import { parseResponseBody } from './parseResponse'; +import { parseResponseBody } from './parseResponse.js'; const resolver = new CachedResolver(); const didKeyDriver = didKey.driver(); @@ -28,6 +29,16 @@ const didWebDriver = didWeb.driver(); resolver.use(didKeyDriver); resolver.use(didWebDriver); +didWebDriver.use({ + multibaseMultikeyHeader: 'z6Mk', + fromMultibase: Ed25519Multikey.from +}); + +didKeyDriver.use({ + multibaseMultikeyHeader: 'z6Mk', + fromMultibase: Ed25519Multikey.from +}); + export const httpClientHandler = { /** * @param {object} options - Options hashmap. diff --git a/src/index.ts b/src/index.ts index 381932e..eee940d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ /*! * Copyright (c) 2021 Interop Alliance and Dmitri Zagidulin. All rights reserved. */ -export { securityLoader, httpClientHandler } from './documentLoader' +export { httpClientHandler, securityLoader } from './documentLoader.js' + diff --git a/test/documentLoader.spec.ts b/test/documentLoader.spec.ts index 32293e4..b14ed11 100644 --- a/test/documentLoader.spec.ts +++ b/test/documentLoader.spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai' -import { httpClientHandler, securityLoader } from '../src'; +import { httpClientHandler, securityLoader } from '../src/index.js'; describe('documentLoader', () => { it('should load a document', async () => { diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..f47d541 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2022", + "lib": ["es2022", "dom"], + "module": "CommonJS", + "moduleResolution": "nodenext", + "outDir": "dist/cjs", + "noImplicitAny": true, + "removeComments": false, + "preserveConstEnums": true, + "baseUrl": ".", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true + }, + "ts-node": { + "files": true + }, + "include": [ + "src/**/*", + ".eslintrc.cjs", + "karma.conf.cjs" +, "src/test-fixtures/knownDidRegistries.ts" ], + "exclude": ["node_modules", "dist", "test"] +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..855bd32 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2022", + "lib": ["es2022", "dom"], + "module": "es6", + "moduleResolution": "nodenext", + "outDir": "dist/esm", + "noImplicitAny": true, + "removeComments": false, + "preserveConstEnums": true, + "baseUrl": ".", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true + }, + "ts-node": { + "files": true + }, + "include": [ + "src/**/*", + ".eslintrc.js", + "karma.conf.js" + ], + "exclude": ["node_modules", "dist"] +} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 5ccf6c9..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "include": [ - "src/**/*", - ".eslintrc.js", - "karma.conf.js" - ], - "exclude": [ - "./test/", - "./node_modules/", - "./dist/" - ], - "ts-node": { - "files": true - }, - "files": [ - "src/declarations.d.ts" - ], - "compileOnSave": true, - "compilerOptions": { - /* Basic Options */ - "target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - "lib": ["esnext", "dom"], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - "declarationDir": "./dist", - "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist", /* Redirect output structure to the directory. */ - "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - "resolveJsonModule": true, - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "skipDefaultLibCheck": true, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // https://github.com/microsoft/TypeScript/wiki/Performance#controlling-types-inclusion: - "types": ["mocha", "node"], /* Type declaration files to be included in compilation. */ - "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - // Prevent developers on different OSes from running into problems: - "forceConsistentCasingInFileNames": true, - - /* Advanced Options */ - "stripInternal": true, /* Do not emit declarations for code that has an @internal annotation in it’s JSDoc comment. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } -} diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..cfd01e9 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2022", + "lib": ["es2022", "dom"], + "module": "es2022", + "moduleResolution": "nodenext", + "outDir": "dist/esm", + "noImplicitAny": true, + "removeComments": false, + "preserveConstEnums": true, + "baseUrl": ".", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true + }, + "ts-node": {"files": true}, + "include": ["src/**/*", "test/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/tsconfig.types.json b/tsconfig.types.json new file mode 100644 index 0000000..a20ecf2 --- /dev/null +++ b/tsconfig.types.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2022", + "lib": ["es2022", "dom"], + "module": "es2022", + "moduleResolution": "nodenext", + "outDir": "dist/types", + "noImplicitAny": true, + "removeComments": false, + "preserveConstEnums": true, + "baseUrl": ".", + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "declaration": true, + "emitDeclarationOnly": true, + "declarationDir": "dist/types" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} From de86b8e16d071b95b611efd072988e9363e054e3 Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Sun, 9 Mar 2025 18:30:28 -0400 Subject: [PATCH 05/11] remove old build and test --- build-dist.sh | 12 ------------ package.json | 3 +-- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100755 build-dist.sh diff --git a/build-dist.sh b/build-dist.sh deleted file mode 100755 index 8501e09..0000000 --- a/build-dist.sh +++ /dev/null @@ -1,12 +0,0 @@ -mkdir ./dist/esm -cat >dist/esm/index.js <dist/esm/package.json < Date: Thu, 13 Mar 2025 06:58:45 -0400 Subject: [PATCH 06/11] remove cjs build --- package.json | 19 ++++--------------- tsconfig.cjs.json | 26 -------------------------- tsconfig.esm.json | 10 ++++------ tsconfig.test.json | 2 +- tsconfig.types.json | 6 +++--- 5 files changed, 12 insertions(+), 51 deletions(-) delete mode 100644 tsconfig.cjs.json diff --git a/package.json b/package.json index 2984c5c..d6a3563 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,17 @@ "description": "A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.", "version": "6.0.1", "scripts": { - "build-cjs": "tsc -p tsconfig.cjs.json", "build-esm": "tsc -p tsconfig.esm.json", "build-types": "tsc -p tsconfig.types.json", "build-test": "tsc -p tsconfig.test.json", - "build": "npm run clear && npm run build-types && npm run build-cjs && npm run build-esm", + "build": "npm run clear && npm run build-types && npm run build-esm", "clear": "rimraf dist/*", "lint": "eslint .", "lint:fix": "eslint --fix .", "prepare": "npm run build", "rebuild": "npm run clear && npm run build", "test": "npm run lint && npm run test-node", - "test-node": "npm run build-test && mocha dist/esm/test/*.spec.js && rimraf dist/esm/test", + "test-node": "npm run build-test && mocha dist/test/*.spec.js", "test-karma": "karma start karma.conf.js" }, "files": [ @@ -23,19 +22,9 @@ "README.md", "LICENSE.md" ], - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", "type": "module", - "browser": "dist/cjs/index.js", - "types": "dist/types/index.d.ts", - "exports": { - ".": { - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts" - }, - "./package.json": "./package.json" - }, + "exports": "./dist/index.js", + "types": "./dist/index.d.ts", "dependencies": { "@digitalbazaar/data-integrity-context": "^2.0.0", "@digitalbazaar/vc-bitstring-status-list-context": "^1.0.0", diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index f47d541..0000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "target": "es2022", - "lib": ["es2022", "dom"], - "module": "CommonJS", - "moduleResolution": "nodenext", - "outDir": "dist/cjs", - "noImplicitAny": true, - "removeComments": false, - "preserveConstEnums": true, - "baseUrl": ".", - "allowSyntheticDefaultImports": true, - "skipLibCheck": true, - "resolveJsonModule": true - }, - "ts-node": { - "files": true - }, - "include": [ - "src/**/*", - ".eslintrc.cjs", - "karma.conf.cjs" -, "src/test-fixtures/knownDidRegistries.ts" ], - "exclude": ["node_modules", "dist", "test"] -} diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 855bd32..f60d22e 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -3,9 +3,9 @@ "strict": true, "target": "es2022", "lib": ["es2022", "dom"], - "module": "es6", + "module": "es2022", "moduleResolution": "nodenext", - "outDir": "dist/esm", + "outDir": "dist", "noImplicitAny": true, "removeComments": false, "preserveConstEnums": true, @@ -14,13 +14,11 @@ "skipLibCheck": true, "resolveJsonModule": true }, - "ts-node": { - "files": true - }, + "ts-node": { "files": true }, "include": [ "src/**/*", ".eslintrc.js", "karma.conf.js" ], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "test"] } diff --git a/tsconfig.test.json b/tsconfig.test.json index cfd01e9..81578aa 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -5,7 +5,7 @@ "lib": ["es2022", "dom"], "module": "es2022", "moduleResolution": "nodenext", - "outDir": "dist/esm", + "outDir": "dist", "noImplicitAny": true, "removeComments": false, "preserveConstEnums": true, diff --git a/tsconfig.types.json b/tsconfig.types.json index a20ecf2..6ec87b1 100644 --- a/tsconfig.types.json +++ b/tsconfig.types.json @@ -5,7 +5,7 @@ "lib": ["es2022", "dom"], "module": "es2022", "moduleResolution": "nodenext", - "outDir": "dist/types", + "outDir": "dist", "noImplicitAny": true, "removeComments": false, "preserveConstEnums": true, @@ -15,8 +15,8 @@ "resolveJsonModule": true, "declaration": true, "emitDeclarationOnly": true, - "declarationDir": "dist/types" + "declarationDir": "dist" }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "test"] } From dd6dd13a889ff4ceed82f0fb3cb8ac6e8942fb6c Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Fri, 14 Mar 2025 13:46:22 -0400 Subject: [PATCH 07/11] update dependencies --- package.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d6a3563..2ed33de 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "rebuild": "npm run clear && npm run build", "test": "npm run lint && npm run test-node", "test-node": "npm run build-test && mocha dist/test/*.spec.js", - "test-karma": "karma start karma.conf.js" + "test-karma": "karma start karma.conf.js" }, "files": [ "dist", @@ -33,14 +33,13 @@ "@digitalcredentials/crypto-ld": "^7.0.2", "@digitalcredentials/dcc-context": "^1.0.0", "@digitalcredentials/did-io": "^1.0.2", - "@digitalcredentials/did-method-key": "file:../did-method-key", - "@digitalcredentials/did-method-web": "file:../did-method-web", - "@digitalcredentials/ed25519-multikey": "file:../ed25519-multikey", + "@digitalcredentials/did-method-key": "^3.0.0-beta.1", + "@digitalcredentials/did-method-web": "^1.1.0-beta.1", + "@digitalcredentials/ed25519-multikey": "^1.4.0-beta.1", "@digitalcredentials/ed25519-verification-key-2020": "^3.2.2", "@digitalcredentials/http-client": "^5.0.1", "@digitalcredentials/open-badges-context": "^2.1.0", "@digitalcredentials/x25519-key-agreement-key-2020": "^3.0.0", - "@interop/did-web-resolver": "^5.0.0", "credentials-context": "^2.0.0", "did-context": "^3.1.1", "ed25519-signature-2020-context": "^1.1.0", From a02c79b8e6a42b17fd719eb83f9e57eb6c20ef8d Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Fri, 14 Mar 2025 13:48:11 -0400 Subject: [PATCH 08/11] beta release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ed33de..3fd1099 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@digitalcredentials/security-document-loader", "description": "A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.", - "version": "6.0.1", + "version": "7.0.0-beta.1", "scripts": { "build-esm": "tsc -p tsconfig.esm.json", "build-types": "tsc -p tsconfig.types.json", From 18c889702329c2618b037ee6215c85d7ed65b6ee Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Mon, 17 Mar 2025 15:18:24 -0400 Subject: [PATCH 09/11] rename karma.conf.js --- karma.conf.js | 44 -------------------------------------------- package.json | 2 +- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 karma.conf.js diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 9939a80..0000000 --- a/karma.conf.js +++ /dev/null @@ -1,44 +0,0 @@ -module.exports = function (config) { - config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - frameworks: ['mocha', 'chai', 'karma-typescript'], - - files: [ - 'src/**/*.ts', - 'test/**/*.ts' // *.tsx for React Jsx - ], - - karmaTypescriptConfig: { - reports: {} // Disables the code coverage report - }, - - preprocessors: { - '**/*.ts': ['karma-typescript'] // *.tsx for React Jsx - }, - - reporters: ['mocha', 'karma-typescript'], - - browsers: ['ChromeHeadless'], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the test and exits - singleRun: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // Mocha - client: { - mocha: { - // increase from default 2s - timeout: 10000 - // reporter: 'html' - } - }, - - colors: true - }) -} diff --git a/package.json b/package.json index 3fd1099..9aa57c5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "rebuild": "npm run clear && npm run build", "test": "npm run lint && npm run test-node", "test-node": "npm run build-test && mocha dist/test/*.spec.js", - "test-karma": "karma start karma.conf.js" + "test-karma": "karma start karma.conf.cjs" }, "files": [ "dist", From 89d761d35be6636017f16b76fc3dabd30a2a62cf Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Mon, 17 Mar 2025 15:18:53 -0400 Subject: [PATCH 10/11] add karma conf --- karma.conf.cjs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 karma.conf.cjs diff --git a/karma.conf.cjs b/karma.conf.cjs new file mode 100644 index 0000000..9939a80 --- /dev/null +++ b/karma.conf.cjs @@ -0,0 +1,44 @@ +module.exports = function (config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + frameworks: ['mocha', 'chai', 'karma-typescript'], + + files: [ + 'src/**/*.ts', + 'test/**/*.ts' // *.tsx for React Jsx + ], + + karmaTypescriptConfig: { + reports: {} // Disables the code coverage report + }, + + preprocessors: { + '**/*.ts': ['karma-typescript'] // *.tsx for React Jsx + }, + + reporters: ['mocha', 'karma-typescript'], + + browsers: ['ChromeHeadless'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the test and exits + singleRun: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // Mocha + client: { + mocha: { + // increase from default 2s + timeout: 10000 + // reporter: 'html' + } + }, + + colors: true + }) +} From 53a7b5106b6f154bb3afb0c59c497a9ac0a630b3 Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Wed, 30 Apr 2025 17:04:44 -0400 Subject: [PATCH 11/11] prepare for npm publish --- CHANGELOG.md | 7 +++++++ package.json | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2771855..3e74e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # security-document-loader Changelog +## 7.0.0 - 2025-04-30 +### Changed +- switch to `@digitalcredentials/did-method-web` from `@interop/did-web-resolver` for did-web resolution +- rework build process +- update dependencies +- **BREAKING**: remove cjs build + ## 6.0.1 - 2024-11-12 ### Fixed - Fix Typescript types declaration ([PR #17](https://github.com/digitalcredentials/security-document-loader/pull/17/files)). diff --git a/package.json b/package.json index 9aa57c5..68ae807 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@digitalcredentials/security-document-loader", "description": "A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.", - "version": "7.0.0-beta.1", + "version": "7.0.0", "scripts": { "build-esm": "tsc -p tsconfig.esm.json", "build-types": "tsc -p tsconfig.types.json", @@ -33,9 +33,9 @@ "@digitalcredentials/crypto-ld": "^7.0.2", "@digitalcredentials/dcc-context": "^1.0.0", "@digitalcredentials/did-io": "^1.0.2", - "@digitalcredentials/did-method-key": "^3.0.0-beta.1", - "@digitalcredentials/did-method-web": "^1.1.0-beta.1", - "@digitalcredentials/ed25519-multikey": "^1.4.0-beta.1", + "@digitalcredentials/did-method-key": "^3.0.0", + "@digitalcredentials/did-method-web": "^1.1.0", + "@digitalcredentials/ed25519-multikey": "^1.4.0", "@digitalcredentials/ed25519-verification-key-2020": "^3.2.2", "@digitalcredentials/http-client": "^5.0.1", "@digitalcredentials/open-badges-context": "^2.1.0",