@canvas-js/interfaces
Advanced tools
Comparing version 0.5.0 to 0.5.1
export type Action = { | ||
type: "action"; | ||
/** CAIP-2 prefix, e.g. "eip155:1" */ | ||
chain: string; | ||
/** CAIP-2 address (without the prefix, e.g. "0xb94d27...") */ | ||
address: string; | ||
@@ -5,0 +7,0 @@ name: string; |
import type { SignatureType } from "./Signature.js"; | ||
/** | ||
* Sessions consist of an ephemeral keypair and some chain-specific | ||
* data representing a user's (temporary) authorization of that | ||
* keypair to sign actions on their behalf. | ||
*/ | ||
export type Session<Data = any> = { | ||
type: "session"; | ||
/** CAIP-2 prefix, e.g. "eip155:1" for mainnet Ethereum */ | ||
chain: string; | ||
/** CAIP-2 address (without the prefix, e.g. "0xb94d27...") */ | ||
address: string; | ||
/** ephemeral session key used to sign subsequent actions */ | ||
publicKeyType: SignatureType; | ||
publicKey: Uint8Array; | ||
/** chain-specific session payload, e.g. a SIWE message & signature */ | ||
data: Data; | ||
@@ -9,0 +18,0 @@ timestamp: number; |
@@ -7,2 +7,16 @@ import type { MessageSigner } from "./MessageSigner.js"; | ||
match: (chain: 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 `chain?: string; timestamp?: number`, and `getSession` must return | ||
* a `Session` authorized for that topic, that specific chain (if provided), and that | ||
* is valid for the given timestamp (if provided). | ||
*/ | ||
getSession: (topic: string, options?: { | ||
@@ -12,3 +26,7 @@ chain?: string; | ||
}) => Awaitable<Session>; | ||
/** | ||
* Verify that `session.data` authorizes `session.publicKey` | ||
* to take actions on behalf of the user `${session.chain}:${session.address}` | ||
*/ | ||
verifySession: (session: Session) => Awaitable<void>; | ||
} |
{ | ||
"name": "@canvas-js/interfaces", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"type": "module", | ||
@@ -18,4 +18,4 @@ "author": "Canvas Technologies, Inc. (https://canvas.xyz)", | ||
"devDependencies": { | ||
"@canvas-js/chain-ethereum": "0.5.0" | ||
"@canvas-js/chain-ethereum": "0.5.1" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7227
112
0