@canvas-js/interfaces
Advanced tools
Comparing version 0.9.1 to 0.10.0-alpha.1
@@ -1,35 +0,27 @@ | ||
import type { Signer } from "./Signer.js"; | ||
import type { SignatureScheme, Signer } from "./Signer.js"; | ||
import type { Session } from "./Session.js"; | ||
import type { Action } from "./Action.js"; | ||
import type { Awaitable } from "./Awaitable.js"; | ||
export interface SessionSigner<AuthorizationData = any> extends Pick<Signer<Action | Session<AuthorizationData>>, "codecs" | "sign" | "verify"> { | ||
export interface AbstractSessionData { | ||
topic: string; | ||
address: string; | ||
publicKey: string; | ||
timestamp: number; | ||
duration: number | null; | ||
} | ||
export interface SessionSigner<AuthorizationData = any> { | ||
scheme: SignatureScheme<Action | Session<AuthorizationData>>; | ||
match: (address: string) => boolean; | ||
/** | ||
* `getSession` is called by the Canvas runtime for every new action appended | ||
* to the log (ie for new actions taken by local users, not existing messages | ||
* received from other peers via merkle sync or GossipSub). | ||
* | ||
* It's responsible for returning a `Session` that matches the given parameters, | ||
* either by looking up a cached session, or by getting user authorization to create | ||
* a new one (and then caching it). | ||
* | ||
* "Matching the given parameters" means that the caller passes a `topic: string` | ||
* and an optional `timestamp?: number`, and `getSession` must return a `Session` | ||
* authorized for that topic, and that is valid for the given timestamp. | ||
*/ | ||
getAddress: () => Awaitable<string>; | ||
hasSession: (topic: string, address: string) => boolean; | ||
getSession: (topic: string, options?: { | ||
timestamp?: number; | ||
fromCache?: boolean; | ||
}) => Awaitable<Session<AuthorizationData>>; | ||
/** | ||
* `getCachedSession` returns the stored `Session` and `Signer` for a given topic and | ||
* address. This can be used by applications to check if a user has already authorised | ||
* Canvas to sign actions. | ||
* | ||
* Note that `getCachedSession` does not check if the `Session` has expired. | ||
*/ | ||
getCachedSession(topic: string, address: string): { | ||
session: Session; | ||
address?: string; | ||
}) => Awaitable<{ | ||
payload: Session<AuthorizationData>; | ||
signer: Signer<Action | Session<AuthorizationData>>; | ||
} | null; | ||
} | null>; | ||
newSession: (topic: string) => Awaitable<{ | ||
payload: Session<AuthorizationData>; | ||
signer: Signer<Action | Session<AuthorizationData>>; | ||
}>; | ||
/** | ||
@@ -36,0 +28,0 @@ * Verify that `session.data` authorizes `session.publicKey` |
@@ -1,11 +0,19 @@ | ||
import { Awaitable } from "./Awaitable.js"; | ||
import type { Awaitable } from "./Awaitable.js"; | ||
import type { Message } from "./Message.js"; | ||
import type { Signature } from "./Signature.js"; | ||
export interface SignatureScheme<Payload = unknown> { | ||
type: string; | ||
codecs: string[]; | ||
verify: (signature: Signature, message: Message<Payload>) => Awaitable<void>; | ||
create: (init?: { | ||
type: string; | ||
privateKey: Uint8Array; | ||
}) => Signer<Payload>; | ||
} | ||
export interface Signer<Payload = unknown> { | ||
uri: string; | ||
codecs: string[]; | ||
scheme: SignatureScheme<Payload>; | ||
publicKey: string; | ||
sign(message: Message<Payload>, options?: { | ||
codec?: string; | ||
}): Awaitable<Signature>; | ||
verify(signature: Signature, message: Message<Payload>): Awaitable<void>; | ||
export(): { | ||
@@ -12,0 +20,0 @@ type: string; |
{ | ||
"name": "@canvas-js/interfaces", | ||
"version": "0.9.1", | ||
"version": "0.10.0-alpha.1", | ||
"type": "module", | ||
@@ -18,9 +18,9 @@ "author": "Canvas Technologies, Inc. (https://canvas.xyz)", | ||
"devDependencies": { | ||
"@canvas-js/chain-cosmos": "0.9.1", | ||
"@canvas-js/chain-ethereum": "0.9.1", | ||
"@canvas-js/chain-ethereum-viem": "0.9.1", | ||
"@canvas-js/chain-solana": "0.9.1", | ||
"@canvas-js/chain-substrate": "0.9.1", | ||
"@canvas-js/interfaces": "0.9.1", | ||
"@canvas-js/signatures": "0.9.1", | ||
"@canvas-js/chain-cosmos": "0.10.0-alpha.1", | ||
"@canvas-js/chain-ethereum": "0.10.0-alpha.1", | ||
"@canvas-js/chain-ethereum-viem": "0.10.0-alpha.1", | ||
"@canvas-js/chain-solana": "0.10.0-alpha.1", | ||
"@canvas-js/chain-substrate": "0.10.0-alpha.1", | ||
"@canvas-js/interfaces": "0.10.0-alpha.1", | ||
"@canvas-js/signatures": "0.10.0-alpha.1", | ||
"@cosmjs/amino": "^0.32.3", | ||
@@ -27,0 +27,0 @@ "@noble/curves": "^1.4.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8279