Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@canvas-js/signatures

Package Overview
Dependencies
Maintainers
0
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@canvas-js/signatures - npm Package Compare versions

Comparing version 0.10.0-beta.2 to 0.10.0-beta.4

13

lib/AbstractSessionSigner.d.ts
import { Logger } from "@libp2p/logger";
import type { Action, Session, Signer, Awaitable, SignatureScheme, AbstractSessionData, SessionSigner } from "@canvas-js/interfaces";
import type { Action, Session, Signer, Awaitable, SignatureScheme, AbstractSessionData, SessionSigner, DidIdentifier } from "@canvas-js/interfaces";
export interface AbstractSessionSignerOptions {
sessionDuration?: number | null;
}
export declare abstract class AbstractSessionSigner<AuthorizationData> implements SessionSigner<AuthorizationData> {
export declare abstract class AbstractSessionSigner<AuthorizationData, WalletAddress extends string = string> implements SessionSigner<AuthorizationData> {
#private;

@@ -21,3 +21,6 @@ readonly key: string;

abstract verifySession(topic: string, session: Session<AuthorizationData>): Awaitable<void>;
abstract getAddress(): Awaitable<string>;
abstract getDid(): Awaitable<DidIdentifier>;
abstract getDidParts(): number;
abstract getAddressFromDid(did: DidIdentifier): WalletAddress;
getWalletAddress(): Promise<WalletAddress>;
abstract authorize(data: AbstractSessionData): Awaitable<Session<AuthorizationData>>;

@@ -29,3 +32,3 @@ newSession(topic: string): Promise<{

getSession(topic: string, options?: {
address?: string;
did?: string;
}): Promise<{

@@ -35,4 +38,4 @@ payload: Session<AuthorizationData>;

} | null>;
hasSession(topic: string, address: string): boolean;
hasSession(topic: string, did: DidIdentifier): boolean;
clear(topic: string): Promise<void>;
}

@@ -19,2 +19,5 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {

}
async getWalletAddress() {
return this.getAddressFromDid(await this.getDid());
}
/*

@@ -25,11 +28,13 @@ * Create a new session and cache it for the given `topic`.

const signer = this.scheme.create();
const address = await this.getAddress();
const did = await this.getDid();
const session = await this.authorize({
topic,
address,
did,
publicKey: signer.publicKey,
timestamp: Date.now(),
duration: this.sessionDuration,
context: {
timestamp: Date.now(),
duration: this.sessionDuration,
},
});
const key = `canvas/${topic}/${address}`;
const key = `canvas/${topic}/${did}`;
__classPrivateFieldGet(this, _AbstractSessionSigner_cache, "f").set(key, { session, signer });

@@ -40,8 +45,8 @@ target.set(key, json.stringify({ session, ...signer.export() }));

/*
* Get an existing session for `topic`. You may also provide a specific CAIP-2 formatted
* address to check if a session exists for that specific address.
* Get an existing session for `topic`. You may also provide a specific DID to check
* if a session exists for that specific address.
*/
async getSession(topic, options = {}) {
const address = await Promise.resolve(options.address ?? this.getAddress());
const key = `canvas/${topic}/${address}`;
const did = await Promise.resolve(options.did ?? this.getDid());
const key = `canvas/${topic}/${did}`;
if (__classPrivateFieldGet(this, _AbstractSessionSigner_cache, "f").has(key)) {

@@ -60,4 +65,4 @@ const { session, signer } = __classPrivateFieldGet(this, _AbstractSessionSigner_cache, "f").get(key);

}
hasSession(topic, address) {
const key = `canvas/${topic}/${address}`;
hasSession(topic, did) {
const key = `canvas/${topic}/${did}`;
return __classPrivateFieldGet(this, _AbstractSessionSigner_cache, "f").has(key) || target.get(key) !== null;

@@ -64,0 +69,0 @@ }

{
"name": "@canvas-js/signatures",
"version": "0.10.0-beta.2",
"author": "Canvas Technologies, Inc. (https://canvas.xyz)",
"type": "module",
"engines": {
"node": ">=18.0.0"
},
"files": [
"lib"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"imports": {
"#target": {
"node": "./lib/targets/node/index.js",
"browser": "./lib/targets/browser/index.js",
"default": "./lib/targets/default/index.js"
}
},
"sideEffects": false,
"scripts": {
"test": "ava"
},
"dependencies": {
"@canvas-js/interfaces": "0.10.0-beta.2",
"@canvas-js/utils": "0.10.0-beta.2",
"@ipld/dag-cbor": "^9.2.0",
"@ipld/dag-json": "^10.2.0",
"@libp2p/logger": "^4.0.13",
"@noble/curves": "^1.4.0",
"@noble/hashes": "^1.3.1",
"ethers": "^6.9.1",
"multiformats": "^13.0.1"
},
"devDependencies": {
"@canvas-js/signatures": "0.10.0-beta.2"
}
"name": "@canvas-js/signatures",
"version": "0.10.0-beta.4",
"author": "Canvas Technologies, Inc. (https://canvas.xyz)",
"type": "module",
"engines": {
"node": ">=18.0.0"
},
"files": [
"lib"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"imports": {
"#target": {
"node": "./lib/targets/node/index.js",
"browser": "./lib/targets/browser/index.js",
"default": "./lib/targets/default/index.js"
}
},
"sideEffects": false,
"scripts": {
"test": "ava"
},
"dependencies": {
"@canvas-js/interfaces": "0.10.0-beta.4",
"@canvas-js/utils": "0.10.0-beta.4",
"@ipld/dag-cbor": "^9.2.0",
"@ipld/dag-json": "^10.2.1",
"@libp2p/logger": "^4.0.15",
"@noble/curves": "^1.4.0",
"@noble/hashes": "^1.3.1",
"ethers": "^6.13.1",
"multiformats": "^13.1.1"
},
"devDependencies": {
"@canvas-js/signatures": "0.10.0-beta.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc