Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade deps #25

Merged
merged 2 commits into from
Jun 13, 2024
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
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
}
3,196 changes: 1,455 additions & 1,741 deletions package-lock.json

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "@toruslabs/metadata-helpers",
"version": "5.1.0",
"description": "Helper methods for metadata",
"main": "dist/metadataHelpers.cjs.js",
"module": "dist/metadataHelpers.esm.js",
"main": "dist/lib.cjs/index.js",
"module": "dist/lib.esm/index.js",
"unpkg": "dist/metadataHelpers.umd.min.js",
"jsdelivr": "dist/metadataHelpers.umd.min.js",
"types": "dist/types/index.d.ts",
"sideEffects": false,
"scripts": {
"start": "torus-scripts start",
"build": "torus-scripts build",
Expand All @@ -23,29 +24,29 @@
"@babel/runtime": "7.x"
},
"dependencies": {
"@toruslabs/eccrypto": "^4.0.0",
"@toruslabs/http-helpers": "^6.1.0",
"@toruslabs/eccrypto": "^5.0.0",
"@toruslabs/http-helpers": "^7.0.0",
"elliptic": "^6.5.5",
"ethereum-cryptography": "^2.1.3",
"ethereum-cryptography": "^2.2.0",
"json-stable-stringify": "^1.1.1"
},
"devDependencies": {
"@babel/register": "^7.23.7",
"@toruslabs/config": "^2.0.2",
"@toruslabs/eslint-config-node": "^3.2.0",
"@toruslabs/torus-scripts": "^5.3.0",
"@babel/register": "^7.24.6",
"@toruslabs/config": "^2.1.0",
"@toruslabs/eslint-config-node": "^3.3.1",
"@toruslabs/torus-scripts": "^6.0.1",
"@types/elliptic": "^6.4.18",
"@types/json-stable-stringify": "^1.0.36",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.25",
"@types/node": "^20.14.2",
"eslint": "^8.57.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"mocha": "^10.3.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"lint-staged": "^15.2.7",
"mocha": "^10.4.0",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
"typescript": "^5.4.5"
},
"author": "Torus Labs",
"license": "MIT",
Expand Down
4 changes: 1 addition & 3 deletions src/MetadataStorageLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type MetadataParams = PubKeyParams & {
signature: string;
};

class MetadataStorageLayer {
export class MetadataStorageLayer {
public metadataHost: string;

public serverTimeOffset: number; // ms
Expand Down Expand Up @@ -72,5 +72,3 @@ class MetadataStorageLayer {
return metadataResponse.message;
}
}

export default MetadataStorageLayer;
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./MetadataStorageLayer";
export { default } from "./MetadataStorageLayer";
export * from "./utils";
export * from "./webAuthnShareResolver";
2 changes: 1 addition & 1 deletion src/webAuthnShareResolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { decrypt, Ecies, encrypt, getPublic } from "@toruslabs/eccrypto";

import MetadataStorageLayer, { PubKeyParams } from "./MetadataStorageLayer";
import { MetadataStorageLayer, PubKeyParams } from "./MetadataStorageLayer";
import { ec } from "./utils";

const WEBAUTHN_TORUS_SHARE = "webauthn_torus_share";
Expand Down
13 changes: 13 additions & 0 deletions test/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ import register from "@babel/register";
import path from "path";
import { register as tsRegister } from "ts-node";

import currentPkg from "../package.json" assert { type: "json" };

const runtimeVersion = currentPkg.peerDependencies["@babel/runtime"];

tsRegister({ project: path.resolve("tsconfig.json") });

register({
presets: [["@babel/env", { bugfixes: true }], "@babel/typescript"],
plugins: [
"@babel/plugin-syntax-bigint",
"@babel/plugin-transform-object-rest-spread",
"@babel/plugin-transform-class-properties",
["@babel/transform-runtime", { version: runtimeVersion }],
"@babel/plugin-transform-numeric-separator",
],
sourceType: "unambiguous",
extensions: [".ts", ".js"],
});
6 changes: 5 additions & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generatePrivate } from "@toruslabs/eccrypto";
import assert from "assert";
import elliptic from "elliptic";

import MetadataStorageLayer from "../src/MetadataStorageLayer";
import { MetadataStorageLayer } from "../src/MetadataStorageLayer";
import { keccak256 } from "../src/utils";
// import { getDeviceShare, setDeviceShare } from "../src/webAuthnShareResolver";
import { getDeviceShare, getTorusShare, setDeviceShare, setTorusShare } from "../src/webAuthnShareResolver";
Expand All @@ -20,19 +20,23 @@ const pubKey2 = keyPair2.getPublic();

describe("Metadata", function () {
let randomMessage: string;

it("should get nothing by default", async function () {
const res = await storage.getMetadata({ pub_key_X: pubKey.getX().toString(16), pub_key_Y: pubKey.getY().toString(16) }, null);
assert.strictEqual(res, "");
});

it("should set", async function () {
randomMessage = JSON.stringify({ message: keccak256(Buffer.from(Date.now().toString(), "utf-8")).toString("hex") });
const params = storage.generateMetadataParams(randomMessage, privKey.toString("hex"));
await storage.setMetadata(params, "metadata-test");
});

it("should get", async function () {
const message = await storage.getMetadata(storage.generatePubKeyParams(privKey.toString("hex")), "metadata-test");
assert.strictEqual(message, randomMessage);
});

it("should set and get WebAuthn Torus Share", async function () {
await setTorusShare(
storage,
Expand Down
Loading