@wallet-standard/base
Advanced tools
Comparing version 1.0.0-rc.0 to 1.0.0-rc.1
@@ -17,6 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./account.js"), exports); | ||
__exportStar(require("./types.js"), exports); | ||
__exportStar(require("./wallet.js"), exports); | ||
__exportStar(require("./window.js"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,3 @@ | ||
export * from './account.js'; | ||
export * from './types.js'; | ||
export * from './wallet.js'; | ||
export * from './window.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,3 @@ | ||
export * from './account.js'; | ||
export * from './types.js'; | ||
export * from './wallet.js'; | ||
export * from './window.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,10 +0,14 @@ | ||
import type { WalletAccount } from './account.js'; | ||
import type { IconString, IdentifierArray, IdentifierRecord } from './types.js'; | ||
/** A namespaced identifier in the format `${namespace}:${string}`. */ | ||
export declare type IdentifierString = `${string}:${string}`; | ||
/** An array of namespaced identifiers in the format `${namespace}:${string}`. */ | ||
export declare type IdentifierArray = ReadonlyArray<IdentifierString>; | ||
/** An object where the keys are namespaced identifiers in the format `${namespace}:${string}`. */ | ||
export declare type IdentifierRecord<T> = Record<IdentifierString, T>; | ||
/** TODO: docs */ | ||
export declare type WalletVersion = '1.0.0'; | ||
/** A data URI containing a base64-encoded SVG, WebP, PNG, or GIF image. */ | ||
export declare type WalletIcon = `data:image/${'svg+xml' | 'webp' | 'png' | 'gif'};base64,${string}`; | ||
/** TODO: docs */ | ||
export interface Wallet { | ||
/** | ||
* Version of the Wallet Standard. | ||
*/ | ||
/** Version of the Wallet Standard implemented by the wallet. */ | ||
readonly version: WalletVersion; | ||
@@ -17,3 +21,3 @@ /** | ||
/** Icon of the wallet, to be displayed by apps. */ | ||
readonly icon: IconString; | ||
readonly icon: WalletIcon; | ||
/** Chains supported by the wallet. */ | ||
@@ -29,9 +33,18 @@ readonly chains: IdentifierArray; | ||
} | ||
/** An account in the wallet that the app has been authorized to use. */ | ||
export interface WalletAccount { | ||
/** Address of the account, corresponding with the public key. */ | ||
readonly address: string; | ||
/** Public key of the account, corresponding with the secret key to sign, encrypt, or decrypt using. */ | ||
readonly publicKey: Uint8Array; | ||
/** Chains supported by the account. */ | ||
readonly chains: IdentifierArray; | ||
/** Features supported by the account. */ | ||
readonly features: IdentifierArray; | ||
/** Optional user-friendly descriptive label or name for the account, to be displayed by apps. */ | ||
readonly label?: string; | ||
/** Optional user-friendly icon for the account, to be displayed by apps. */ | ||
readonly icon?: WalletIcon; | ||
} | ||
/** TODO: docs */ | ||
export declare type WalletPropertyName = NonNullable<{ | ||
[K in keyof Wallet]: Wallet[K] extends (...args: any) => any ? never : K; | ||
}[keyof Wallet]>; | ||
/** TODO: docs */ | ||
export declare type WalletProperties = Pick<Wallet, WalletPropertyName>; | ||
/** TODO: docs */ | ||
export declare type WalletWithFeatures<Features extends Wallet['features']> = Omit<Wallet, 'features'> & { | ||
@@ -38,0 +51,0 @@ features: Features; |
import type { Wallet } from './wallet.js'; | ||
/** Global `window` containing a `navigator.wallets` interface. */ | ||
export interface WalletsWindow extends Window { | ||
navigator: WalletsNavigator; | ||
} | ||
/** Global `window.navigator` containing a `wallets` interface. */ | ||
export interface WalletsNavigator extends Navigator { | ||
wallets?: Wallets; | ||
} | ||
/** Global `window.navigator.wallets` interface. */ | ||
export interface Wallets { | ||
export interface WindowNavigatorWallets { | ||
/** | ||
* TODO: docs | ||
*/ | ||
push(...callbacks: ReadonlyArray<WalletsCallback>): void; | ||
push(...callbacks: WindowNavigatorWalletsPushCallback[]): void; | ||
} | ||
@@ -20,5 +12,15 @@ /** | ||
*/ | ||
export declare type WalletsCallback = (wallets: { | ||
register(...wallets: ReadonlyArray<Wallet>): () => void; | ||
export declare type WindowNavigatorWalletsPushCallback = ({ register }: { | ||
register(...wallets: Wallet[]): () => void; | ||
}) => void; | ||
/** Global `navigator` containing a `wallets` interface. */ | ||
export interface WalletsNavigator extends Navigator { | ||
/** TODO: docs */ | ||
wallets?: WindowNavigatorWallets; | ||
} | ||
/** Global `window` containing a `navigator.wallets` interface. */ | ||
export interface NavigatorWalletsWindow extends Window { | ||
/** TODO: docs */ | ||
navigator: WalletsNavigator; | ||
} | ||
//# sourceMappingURL=window.d.ts.map |
{ | ||
"name": "@wallet-standard/base", | ||
"version": "1.0.0-rc.0", | ||
"version": "1.0.0-rc.1", | ||
"author": "Solana Maintainers <maintainers@solana.foundation>", | ||
"repository": "https://github.com/wallet-standard/wallet-standard", | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"type": "module", | ||
@@ -8,0 +11,0 @@ "sideEffects": false, |
@@ -1,3 +0,5 @@ | ||
# [WIP] Wallet Standard | ||
# Wallet Standard | ||
**NOTE: This document is no longer up to date with respect to the code. It will be updated soon!** | ||
This package outlines the Wallet Standard. | ||
@@ -15,5 +17,7 @@ | ||
- [Global `window.navigator.wallets` interface](src/window.ts) | ||
- [Wallet interface](src/wallet.ts) | ||
- [Example of how Standard Wallets attach to the window](../../example/wallets/src/window.ts) | ||
- Global [`window.navigator.wallets`](src/window.ts) interface | ||
- [`Wallet`](src/wallet.ts) and [`WalletAccount`](src/account.ts) interfaces | ||
- Wallet [`setupWindowNavigatorWallets`](../wallet/src/setup.ts) function | ||
- App [`initializeWindowNavigatorWallets`](../app/src/initialize.ts) function | ||
- [Example](../../example/wallets/src/window.ts) of how wallets attach to the window | ||
@@ -20,0 +24,0 @@ ## Design Principles and Goals |
@@ -1,4 +0,2 @@ | ||
export * from './account.js'; | ||
export * from './types.js'; | ||
export * from './wallet.js'; | ||
export * from './window.js'; |
@@ -1,12 +0,19 @@ | ||
import type { WalletAccount } from './account.js'; | ||
import type { IconString, IdentifierArray, IdentifierRecord } from './types.js'; | ||
/** A namespaced identifier in the format `${namespace}:${string}`. */ | ||
export type IdentifierString = `${string}:${string}`; | ||
/** An array of namespaced identifiers in the format `${namespace}:${string}`. */ | ||
export type IdentifierArray = ReadonlyArray<IdentifierString>; | ||
/** An object where the keys are namespaced identifiers in the format `${namespace}:${string}`. */ | ||
export type IdentifierRecord<T> = Record<IdentifierString, T>; | ||
/** TODO: docs */ | ||
export type WalletVersion = '1.0.0'; | ||
/** A data URI containing a base64-encoded SVG, WebP, PNG, or GIF image. */ | ||
export type WalletIcon = `data:image/${'svg+xml' | 'webp' | 'png' | 'gif'};base64,${string}`; | ||
/** TODO: docs */ | ||
export interface Wallet { | ||
/** | ||
* Version of the Wallet Standard. | ||
*/ | ||
/** Version of the Wallet Standard implemented by the wallet. */ | ||
readonly version: WalletVersion; | ||
@@ -21,3 +28,3 @@ | ||
/** Icon of the wallet, to be displayed by apps. */ | ||
readonly icon: IconString; | ||
readonly icon: WalletIcon; | ||
@@ -37,12 +44,23 @@ /** Chains supported by the wallet. */ | ||
/** TODO: docs */ | ||
export type WalletPropertyName = NonNullable< | ||
{ | ||
[K in keyof Wallet]: Wallet[K] extends (...args: any) => any ? never : K; | ||
}[keyof Wallet] | ||
>; | ||
/** An account in the wallet that the app has been authorized to use. */ | ||
export interface WalletAccount { | ||
/** Address of the account, corresponding with the public key. */ | ||
readonly address: string; | ||
/** TODO: docs */ | ||
export type WalletProperties = Pick<Wallet, WalletPropertyName>; | ||
/** Public key of the account, corresponding with the secret key to sign, encrypt, or decrypt using. */ | ||
readonly publicKey: Uint8Array; | ||
/** Chains supported by the account. */ | ||
readonly chains: IdentifierArray; | ||
/** Features supported by the account. */ | ||
readonly features: IdentifierArray; | ||
/** Optional user-friendly descriptive label or name for the account, to be displayed by apps. */ | ||
readonly label?: string; | ||
/** Optional user-friendly icon for the account, to be displayed by apps. */ | ||
readonly icon?: WalletIcon; | ||
} | ||
/** TODO: docs */ | ||
@@ -49,0 +67,0 @@ export type WalletWithFeatures<Features extends Wallet['features']> = Omit<Wallet, 'features'> & { |
import type { Wallet } from './wallet.js'; | ||
/** Global `window` containing a `navigator.wallets` interface. */ | ||
export interface WalletsWindow extends Window { | ||
navigator: WalletsNavigator; | ||
} | ||
/** Global `window.navigator` containing a `wallets` interface. */ | ||
export interface WalletsNavigator extends Navigator { | ||
wallets?: Wallets; | ||
} | ||
/** Global `window.navigator.wallets` interface. */ | ||
export interface Wallets { | ||
export interface WindowNavigatorWallets { | ||
/** | ||
* TODO: docs | ||
*/ | ||
push(...callbacks: ReadonlyArray<WalletsCallback>): void; | ||
push(...callbacks: WindowNavigatorWalletsPushCallback[]): void; | ||
} | ||
@@ -24,2 +14,14 @@ | ||
*/ | ||
export type WalletsCallback = (wallets: { register(...wallets: ReadonlyArray<Wallet>): () => void }) => void; | ||
export type WindowNavigatorWalletsPushCallback = ({ register }: { register(...wallets: Wallet[]): () => void }) => void; | ||
/** Global `navigator` containing a `wallets` interface. */ | ||
export interface WalletsNavigator extends Navigator { | ||
/** TODO: docs */ | ||
wallets?: WindowNavigatorWallets; | ||
} | ||
/** Global `window` containing a `navigator.wallets` interface. */ | ||
export interface NavigatorWalletsWindow extends Window { | ||
/** TODO: docs */ | ||
navigator: WalletsNavigator; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
185
31124
25
176
1