UNPKG

@didtools/pkh-solana

Version:

Implements support to authenticate, authorize and verify with Solana accounts as a did:pkh with SIWS(X) and CACAO. Primarly used with `did-session` and `@didtools/cacao`.

46 lines (45 loc) 2.06 kB
import { AccountId } from 'caip'; import { AuthMethod } from '@didtools/cacao'; export declare const SOLANA_TESTNET_CHAIN_REF = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"; export declare const SOLANA_DEVNET_CHAIN_REF = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1"; export declare const SOLANA_MAINNET_CHAIN_REF = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"; export declare const VERSION = "1"; export declare const CHAIN_NAMESPACE = "solana"; export declare const chainIdMap: { mainnet: string; testnet: string; devnet: string; }; type SolanaNetwork = 'mainnet' | 'testnet' | 'devnet'; export declare namespace SolanaWebAuth { /** * Get a configured authMethod for a Solana account in a web based environment */ function getAuthMethod(solProvider: any, account: AccountId): Promise<AuthMethod>; } export declare namespace SolanaNodeAuth { /** * Get a configured authMethod for a Solana account in a node based environment */ function getAuthMethod(ethProvider: any, account: AccountId, appName: string): Promise<AuthMethod>; } export type SupportedProvider = { signMessage: (message: Uint8Array, type: string) => Promise<{ signature: Uint8Array; }>; }; export type SupportedConnection = { getGenesisHash: () => Promise<string>; }; export declare function assertSupportedProvider(solProvider: any): asserts solProvider is SupportedProvider; export declare function assertSupportedConnection(solConnection: any): asserts solConnection is SupportedConnection; export declare function requestChainId(solConnection: any): Promise<string>; /** * Helper function to get an accountId (CAIP10) for an Solana account by Solana Connection interface, Connection must implement 'getGenesisHash()' */ export declare function getAccountId(solConnection: any, address: string): Promise<AccountId>; /** * Helper function to get an accountId (CAIP10) for an Solana account by network string 'mainet' | 'testnet' | 'devenet' */ export declare function getAccountIdByNetwork(network: SolanaNetwork, address: string): AccountId; export {};