Skip to content
Open
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
13 changes: 0 additions & 13 deletions babel.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"plugins": ["@babel/plugin-transform-modules-commonjs"],
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
bail: true,
clearMocks: true,
testTimeout: 30000,
Expand Down
67 changes: 47 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
{
"name": "@docknetwork/universal-wallet",
"version": "2.1.1",
"main": "index.js",
"version": "3.3.4",
"license": "MIT",
"type": "module",
"main": "./dist/esm/index.js",
"repository": {
"type": "git",
"url": "https://github.com/docknetwork/wallet"
},
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"default": "./dist/esm/index.js"
},
"./*": {
"import": "./dist/esm/*/index.js",
"require": "./dist/cjs/*/index.cjs",
"default": "./dist/esm/*/index.js"
},
"./src/*": {
"import": "./dist/esm/*",
"require": "./dist/cjs/*",
"default": "./dist/esm/*"
}
},
"engines": {
"node": ">=16.0.0"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.4",
"@babel/node": "^7.15.4",
"@babel/preset-env": "^7.15.6",
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.3",
"@babel/node": "^7.23.9",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.3",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-wasm": "^5.1.0",
"rollup-plugin-multi-input": "^1.3.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup": "2.79.2",
"@types/jest": "^26.0.24",
"@types/node": "^14.14.35",
"babel-jest": "24.5.0",
"concurrently": "^4.1.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-sonarjs": "0.5.0",
"glob": "^7.1.6",
"jest": "24.5.0",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"jsdoc": "^3.6.3",
"rollup": "2.28.1",
"typescript": "^4.2.3",
"@docknetwork/sdk": "2.5.1"
"typescript": "^4.2.3"
},
"scripts": {
"lint": "eslint \"src/**/*.js\"",
Expand All @@ -47,19 +74,19 @@
"test-keys": "jest --verbose ./tests/keys",
"test-creds": "jest --verbose ./tests/credentials",
"docs": "mkdir out && touch out/.nojekyll && jsdoc src -r -c .jsdoc -d out/reference",
"type-check": "tsc --allowJs --checkJs --noEmit --moduleResolution node --resolveJsonModule --target ES6 --skipLibCheck true --allowSyntheticDefaultImports true"
"type-check": "tsc --allowJs --checkJs --noEmit --moduleResolution node --resolveJsonModule --target ES6 --skipLibCheck true --allowSyntheticDefaultImports true",
"prepublishOnly": "yarn build"
},
"dependencies": {
"@digitalbazaar/ed25519-verification-key-2018": "3.1.1",
"@digitalbazaar/ed25519-verification-key-2020": "3.3.0",
"@digitalbazaar/x25519-key-agreement-key-2019": "5.0.1",
"@digitalbazaar/x25519-key-agreement-key-2020": "2.1.0",
"@digitalbazaar/minimal-cipher": "4.0.2",
"@peculiar/webcrypto": "^1.1.6",
"@digitalbazaar/ed25519-verification-key-2018": "4.0.0",
"@digitalbazaar/ed25519-verification-key-2020": "4.2.0",
"@digitalbazaar/x25519-key-agreement-key-2019": "6.0.0",
"@digitalbazaar/x25519-key-agreement-key-2020": "3.0.1",
"@digitalbazaar/minimal-cipher": "6.0.0",
"babel-polyfill": "^6.26.0",
"base58-universal": "1.0.0"
"base58-universal": "2.0.0"
},
"optionalDependencies": {
"@digitalbazaar/edv-client": "^11.3.2"
"@digitalbazaar/edv-client": "15.0.2"
}
}
36 changes: 0 additions & 36 deletions rollup.config.js

This file was deleted.

37 changes: 37 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import json from "@rollup/plugin-json";
import multiInput from "rollup-plugin-multi-input";
import commonjs from "@rollup/plugin-commonjs";

export default async function () {
return [
{
plugins: [
multiInput(),
json(),
// terser(),
commonjs(),
// Temporarily disabled, not sure if required
// since rify is a node module doesnt seem to work
// but would be nice to try embed it
// wasm({
// sync: ['*.wasm'],
// }),
],
input: ["src/**/*.js"],
output: [
{
sourcemap: true,
dir: "dist/esm",
format: "esm",
entryFileNames: "[name].js",
},
{
sourcemap: true,
dir: "dist/cjs",
format: "cjs",
entryFileNames: "[name].cjs",
},
],
},
];
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import DockWallet from './dock-wallet';
import EDVWallet from './edv-wallet';

export * from './methods/index';
export * from './constants';
export * from './storage';

export { EDVWallet };

export default DockWallet;
20 changes: 19 additions & 1 deletion src/storage/edv-http-storage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { EdvClient, EdvDocument } from '@digitalbazaar/edv-client';
import * as base64url from 'base64url-universal';

import StorageInterface from './storage-interface';

async function blindString(hmac, value) {
// convert value to Uint8Array
const data = new TextEncoder().encode(value);
const signature = await hmac.sign({data});
if (typeof signature === 'string') {
// presume base64url-encoded
return signature;
}
// base64url-encode Uint8Array signature
return base64url.encode(signature);
}

/** EDV HTTP client storage implementation */
class EDVHTTPStorageInterface extends StorageInterface {
constructor({
Expand Down Expand Up @@ -143,7 +157,7 @@ class EDVHTTPStorageInterface extends StorageInterface {
}
}

connectTo(id) {
connectTo(id, attributeVersion = 1) {
if (this.client) {
throw new Error('Already connected');
}
Expand All @@ -154,13 +168,17 @@ class EDVHTTPStorageInterface extends StorageInterface {

const { keyAgreementKey, hmac } = this.keys;
this.client = new EdvClient({
_attributeVersion: attributeVersion,
defaultHeaders: this.defaultHeaders,
keyResolver: this.keyResolver,
httpsAgent: this.httpsAgent,
keyAgreementKey,
hmac,
id,
});

this.client.indexHelper._blindString = blindString.bind(this.client.indexHelper);

this.documents = new Map();
}

Expand Down
4 changes: 4 additions & 0 deletions src/storage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import EDVHTTPStorageInterface from './edv-http-storage';
import FSStorageInterface from './fs-storage-interface';

export { EDVHTTPStorageInterface, FSStorageInterface };
6 changes: 0 additions & 6 deletions tests/keys.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import DockWallet from '../src/index';
import dock from '@docknetwork/sdk';

import {
getKeypairFromDerivedKey,
Expand All @@ -19,10 +18,6 @@ import {
describe('Wallet - Key storage and usage', () => {
const wallet = new DockWallet();

beforeAll(async () => {
await dock.initKeyring();
});

test('Can add a local base58 key', () => {
wallet.add(KEY_LOCAL);
expect(wallet.has(KEY_LOCAL.id)).toBe(true);
Expand All @@ -47,7 +42,6 @@ describe('Wallet - Key generation', () => {
let derivedKey;
beforeAll(async () => {
derivedKey = await passwordToKey('testpass');
await dock.initKeyring();
});

test('Can generate X25519KeyAgreementKey2019', async () => {
Expand Down
7 changes: 4 additions & 3 deletions tests/test-environment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NodeEnvironment = require('jest-environment-node');
import { TestEnvironment as NodeEnvironment } from "jest-environment-node";

class MyEnvironment extends NodeEnvironment {
constructor(config, context) {
Expand All @@ -12,9 +12,10 @@ class MyEnvironment extends NodeEnvironment {
ArrayBuffer,
TextDecoder,
TextEncoder,
Buffer,
},
},
context,
context
);
}

Expand All @@ -23,4 +24,4 @@ class MyEnvironment extends NodeEnvironment {
async teardown() {}
}

module.exports = MyEnvironment;
export default MyEnvironment;
Loading
Loading