@make-software/csprclick-core-client
Advanced tools
Comparing version 1.3.0 to 1.4.5
import { SendResult } from "../types"; | ||
export default function sendSignedDeploy(rpcEndpoint: string, signingPublicKey: string, signatureHex: string, deployJson: any): Promise<SendResult>; | ||
export default function sendSignedDeploy(rpcEndpoint: string, digest: string, deployJson: object): Promise<SendResult>; |
@@ -1,2 +0,2 @@ | ||
import { SignResult, SendResult } from "../types"; | ||
import { SignResult, SendResult, CoreSdkSettings } from "../types"; | ||
import { Log4TS } from "../log-config"; | ||
@@ -6,3 +6,2 @@ import { AccountType } from "@make-software/csprclick-core-types"; | ||
export default class CasperSigner extends Provider { | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -14,4 +13,4 @@ private readonly provider; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
static getInstance(rpcEndpoint: string): CasperSigner; | ||
constructor(settings: CoreSdkSettings); | ||
static getInstance(settings: CoreSdkSettings): CasperSigner; | ||
static IsPresent(): boolean; | ||
@@ -27,3 +26,3 @@ static Name(): string; | ||
version(): Promise<string | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -34,6 +33,6 @@ disconnect(): Promise<boolean>; | ||
isUnlocked(): Promise<boolean | undefined>; | ||
sign(deploy: string, account: AccountType): Promise<SignResult | undefined>; | ||
sign(deploy: string | object, account: AccountType): Promise<SignResult | undefined>; | ||
signMessage(message: string, account: AccountType): Promise<SignResult | undefined>; | ||
send(deploy: string, account: AccountType): Promise<SendResult>; | ||
send(deploy: string | object, account: AccountType): Promise<SendResult>; | ||
triggerEvent(evtType: string, evtDetail: any): void; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { JsonTypes } from 'typedjson'; | ||
export type CasperSignerProvider = { | ||
@@ -28,5 +27,5 @@ /** | ||
sign: (deploy: { | ||
deploy: JsonTypes; | ||
deploy: any; | ||
}, signingPublicKeyHex: string, targetPublicKeyHex?: string) => Promise<{ | ||
deploy: JsonTypes; | ||
deploy: any; | ||
}>; | ||
@@ -33,0 +32,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { SignResult, SendResult } from "../types"; | ||
import { SignResult, SendResult, CoreSdkSettings } from "../types"; | ||
import { Log4TS } from "../log-config"; | ||
@@ -6,3 +6,2 @@ import { AccountType } from "@make-software/csprclick-core-types"; | ||
export default class CasperWallet extends Provider { | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -14,4 +13,4 @@ private readonly provider; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
static getInstance(rpcEndpoint: string): CasperWallet; | ||
constructor(settings: CoreSdkSettings); | ||
static getInstance(settings: CoreSdkSettings): CasperWallet; | ||
static IsPresent(): boolean; | ||
@@ -31,3 +30,3 @@ static Name(): string; | ||
version(): Promise<string | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -42,6 +41,6 @@ disconnect(): Promise<boolean>; | ||
isUnlocked(): Promise<boolean | undefined>; | ||
sign(deploy: string, account: AccountType): Promise<SignResult | undefined>; | ||
sign(deploy: string | object, account: AccountType): Promise<SignResult | undefined>; | ||
signMessage(message: string, account: AccountType): Promise<SignResult | undefined>; | ||
send(deploy: string, account: AccountType): Promise<SendResult>; | ||
send(deploy: string | object, account: AccountType): Promise<SendResult>; | ||
triggerEvent(evtType: string, evtDetail: any): void; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { SignResult, SendResult } from '../types'; | ||
import { SignResult, SendResult, CoreSdkSettings } from '../types'; | ||
import { Log4TS } from '../log-config'; | ||
@@ -6,3 +6,2 @@ import { AccountType } from '@make-software/csprclick-core-types'; | ||
export default class CasperDash extends Provider { | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -14,4 +13,4 @@ private readonly provider; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
static getInstance(rpcEndpoint: string): CasperDash; | ||
constructor(settings: CoreSdkSettings); | ||
static getInstance(settings: CoreSdkSettings): CasperDash; | ||
static IsPresent(): boolean; | ||
@@ -27,3 +26,3 @@ static Name(): string; | ||
version(): Promise<string | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -35,6 +34,6 @@ disconnect(): Promise<boolean>; | ||
forceConnect(): Promise<string | undefined>; | ||
sign(deploy: string, account: AccountType): Promise<SignResult | undefined>; | ||
sign(deploy: string | object, account: AccountType): Promise<SignResult | undefined>; | ||
signMessage(message: string, account: AccountType): Promise<SignResult | undefined>; | ||
send(deploy: string, account: AccountType): Promise<SendResult>; | ||
send(deploy: string | object, account: AccountType): Promise<SendResult>; | ||
triggerEvent(evtType: string, evtDetail: any): void; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { JsonTypes } from 'typedjson'; | ||
export type CasperDashProvider = { | ||
@@ -18,5 +17,5 @@ postMessage: (msg: any) => Promise<boolean>; | ||
sign: (deploy: { | ||
deploy: JsonTypes; | ||
deploy: any; | ||
}, signingPublicKeyHex: string, targetPublicKeyHex?: string) => Promise<{ | ||
deploy: JsonTypes; | ||
deploy: any; | ||
}>; | ||
@@ -23,0 +22,0 @@ /** * Send raw string message to Casper Dash for signing. * @param message string to be signed. * @param signingPublicKey public key in hex format, the corresponding secret key (from the vault) will be used to sign. * @returns `Base16` signature */ |
@@ -1,2 +0,2 @@ | ||
import { SendResult, SignResult } from "../types"; | ||
import { CoreSdkSettings, SendResult, SignResult } from "../types"; | ||
import { Log4TS } from "../log-config"; | ||
@@ -7,3 +7,2 @@ import { AccountType } from "@make-software/csprclick-core-types"; | ||
#private; | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -19,4 +18,4 @@ private _logger; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
static getInstance(rpcEndpoint: string): Ledger; | ||
constructor(settings: CoreSdkSettings); | ||
static getInstance(settings: CoreSdkSettings): Ledger; | ||
releaseListeners(): void; | ||
@@ -31,3 +30,3 @@ static IsPresent(): boolean; | ||
version(): Promise<string | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -38,4 +37,4 @@ disconnect(): Promise<boolean>; | ||
isUnlocked(): Promise<boolean>; | ||
sign(deploy: string, account: AccountType): Promise<SignResult | undefined>; | ||
send(deploy: string, account: AccountType): Promise<SendResult>; | ||
sign(deploy: string | object, account: AccountType): Promise<SignResult | undefined>; | ||
send(deploy: string | object, account: AccountType): Promise<SendResult>; | ||
signMessage(message: string, account: AccountType): Promise<SignResult>; | ||
@@ -42,0 +41,0 @@ } |
import { Logger } from "typescript-logging-log4ts-style"; | ||
export type Log4TS = Logger; | ||
export declare function setLogLevel(level: number): void; | ||
export declare function getLogger(name: string): Logger; |
@@ -1,2 +0,2 @@ | ||
import { SignResult, SendResult } from '../types'; | ||
import { SignResult, SendResult, CoreSdkSettings } from '../types'; | ||
import { Log4TS } from '../log-config'; | ||
@@ -7,3 +7,2 @@ import { AccountType } from '@make-software/csprclick-core-types'; | ||
#private; | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -15,4 +14,4 @@ private readonly provider; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
static getInstance(rpcEndpoint: string): MetamaskSnap; | ||
constructor(settings: CoreSdkSettings); | ||
static getInstance(settings: CoreSdkSettings): MetamaskSnap; | ||
static IsPresent(): boolean; | ||
@@ -28,3 +27,3 @@ static Name(): string; | ||
version(): Promise<string | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -35,6 +34,6 @@ disconnect(): Promise<boolean>; | ||
isUnlocked(): Promise<boolean | undefined>; | ||
sign(deploy: string, account: AccountType): Promise<SignResult>; | ||
sign(deploy: string | object, account: AccountType): Promise<SignResult>; | ||
signMessage(message: string, account: AccountType): Promise<SignResult>; | ||
send(deploy: string, account: AccountType): Promise<SendResult>; | ||
send(deploy: string | object, account: AccountType): Promise<SendResult>; | ||
triggerEvent(evtType: string, evtDetail: any): void; | ||
} |
{ | ||
"name": "@make-software/csprclick-core-client", | ||
"version": "1.3.0", | ||
"version": "1.4.5", | ||
"description": "CSPR.click core client package for web applications", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,5 +0,12 @@ | ||
import { AccountType } from "@make-software/csprclick-core-types"; | ||
import { SendResult, SignResult } from "./types"; | ||
import { AccountType, CoreRPCRequest, CoreRPCResponse } from "@make-software/csprclick-core-types"; | ||
import { AccountMetadata, CoreClientError, CoreSdkSettings, SendResult, SignResult } from "./types"; | ||
export type CoreServerMessageCallback<T1, T2> = (data: CoreRPCResponse<T1>, resolve: (o: T2) => void, reject: (e: string | CoreClientError) => void) => Promise<void>; | ||
export declare abstract class Provider { | ||
protected abstract rpcEndpoint: string; | ||
protected readonly rpcEndpoint: string; | ||
protected readonly emitter: Window; | ||
protected readonly csprclickHost: string; | ||
protected readonly origin: string; | ||
protected readonly digest: string; | ||
protected constructor(settings: CoreSdkSettings); | ||
protected get apiBaseUrl(): string; | ||
static IsConnected(): Promise<boolean | undefined>; | ||
@@ -13,17 +20,16 @@ static IsUnlocked(): Promise<boolean | undefined>; | ||
abstract version(): Promise<string | undefined>; | ||
abstract connect(options: any): Promise<void>; | ||
abstract connect(options: any): Promise<AccountType | undefined>; | ||
abstract switchAccount(options: any): Promise<void>; | ||
abstract disconnect(): Promise<boolean>; | ||
abstract disconnect(options?: any): Promise<boolean>; | ||
abstract getActivePublicKey(): Promise<string | undefined>; | ||
abstract isConnected(): Promise<boolean | undefined>; | ||
abstract isUnlocked(): Promise<boolean | undefined>; | ||
abstract sign(deploy: string, account: AccountType, options?: any): Promise<SignResult | undefined>; | ||
abstract sign(deploy: string | object, account: AccountType, options?: any): Promise<SignResult | undefined>; | ||
abstract signMessage(message: string, account: AccountType, options?: any): Promise<SignResult | undefined>; | ||
abstract send(deploy: string, account: AccountType, options?: any): Promise<SendResult | undefined>; | ||
sendSignedDeploy(signingPublicKey: string, signatureHex: string, deployJson: any): Promise<SendResult>; | ||
abstract send(deploy: string | object, account: AccountType, options?: any): Promise<SendResult | undefined>; | ||
protected sendCoreServerRequest<MsgType, ResponseType>(message: CoreRPCRequest<MsgType>, cb: CoreServerMessageCallback<MsgType, ResponseType>): Promise<ResponseType>; | ||
protected buildCoreServerRequestMessage<T>(method: string, params: T): CoreRPCRequest<T>; | ||
sendSignedDeploy(deployJson: object): Promise<SendResult>; | ||
abstract releaseListeners(): void; | ||
private getCsprCloudUrl; | ||
protected getTotalAccountBalance(public_key: string, chainName: string): Promise<any>; | ||
protected getAccountLogo(acc: AccountType, accountsInfo: Array<any>): string | undefined; | ||
protected getAccountInfoFromHashes(hashes: Array<string>, chainName: string): Promise<Array<any>>; | ||
protected getAccountMetadata(public_keys: string[], chainName: string): Promise<Array<AccountMetadata>>; | ||
} |
20
sdk.d.ts
import SafeEventEmitter from '@metamask/safe-event-emitter'; | ||
import { Log4TS } from "./log-config"; | ||
import { CsprClickInitOptions, SignResult, SendResult } from "./types"; | ||
import { CsprClickInitOptions, GetActiveAccountOptions, SendResult, SignResult } from "./types"; | ||
import { AccountType, ACTIONS, AppSettings, CONTENT_MODE } from "@make-software/csprclick-core-types"; | ||
import { Provider } from "./provider"; | ||
export declare class CSPRClickSDK extends SafeEventEmitter { | ||
#private; | ||
private _logger; | ||
@@ -15,2 +16,3 @@ get logger(): Log4TS; | ||
origin: string; | ||
digestAuth: string; | ||
signInPopup: Window | undefined; | ||
@@ -32,3 +34,3 @@ coreFrame: HTMLIFrameElement | null; | ||
isProviderPresent(providerName: string): boolean; | ||
getClickFrame(): void; | ||
getClickFrame(digestToken: string): void; | ||
getSignInOptions(refresh?: boolean): Promise<any>; | ||
@@ -40,5 +42,5 @@ signIn(): void; | ||
getProviderInstance(providerName: string): Promise<Provider | undefined>; | ||
connect(withProvider: string, options?: any): Promise<void>; | ||
connect(withProvider: string, options?: any): Promise<AccountType | undefined>; | ||
switchAccount(withProvider: string, options?: any): Promise<void>; | ||
disconnect(): void; | ||
disconnect(fromWallet: string, options?: any): Promise<void>; | ||
signOut(): void; | ||
@@ -49,2 +51,6 @@ getActivePublicKey(): Promise<string | undefined> | undefined; | ||
getActiveAccount(): AccountType | null; | ||
getActiveAccountAsync(options?: GetActiveAccountOptions): Promise<AccountType | null>; | ||
/** | ||
* @deprecated Use getActiveAccountAsync instead. | ||
*/ | ||
getActiveAccountWithBalance(): Promise<AccountType | null>; | ||
@@ -55,8 +61,10 @@ getProviderName(provider: string | undefined): Promise<string | undefined>; | ||
forgetAccount(account: AccountType): void; | ||
sign(deployJson: string, signingPublicKey: string): Promise<SignResult | undefined>; | ||
send(deployJson: string, signingPublicKey: string): Promise<SendResult | undefined>; | ||
sign(deployJson: string | object, signingPublicKey: string): Promise<SignResult | undefined>; | ||
send(deployJson: string | object, signingPublicKey: string): Promise<SendResult | undefined>; | ||
signMessage(message: string, signingPublicKey: string): Promise<SignResult | undefined>; | ||
getOrUseJWT(account: AccountType): Promise<boolean>; | ||
showByCsprUi: () => void; | ||
private shouldRedirectToInAppBrowser; | ||
getAccountIdenticon(hex: string, size?: number): HTMLCanvasElement; | ||
} | ||
export default CSPRClickSDK; |
@@ -1,2 +0,2 @@ | ||
import { SignResult, SendResult } from '../types'; | ||
import { SignResult, SendResult, CoreSdkSettings } from '../types'; | ||
import { Log4TS } from '../log-config'; | ||
@@ -6,3 +6,2 @@ import { AccountType, TorusConnectOptions } from '@make-software/csprclick-core-types'; | ||
export declare class TorusWallet extends Provider { | ||
protected readonly rpcEndpoint: string; | ||
private static instance; | ||
@@ -13,5 +12,5 @@ private provider; | ||
get logger(): Log4TS; | ||
constructor(rpcEndpoint: string); | ||
constructor(settings: CoreSdkSettings); | ||
private initializeTorus; | ||
static getInstance(rpcEndpoint: string): TorusWallet; | ||
static getInstance(settings: CoreSdkSettings): TorusWallet; | ||
releaseListeners(): void; | ||
@@ -27,3 +26,3 @@ static IsPresent(): boolean; | ||
isConnected(): Promise<boolean | undefined>; | ||
connect(options: any): Promise<void>; | ||
connect(options: any): Promise<AccountType | undefined>; | ||
switchAccount(options: any): Promise<void>; | ||
@@ -33,5 +32,5 @@ disconnect(): Promise<boolean>; | ||
isUnlocked(): Promise<boolean | undefined>; | ||
send(deploy: string, account: AccountType, options: TorusConnectOptions): Promise<SendResult>; | ||
send(deploy: string | object, account: AccountType, options: TorusConnectOptions): Promise<SendResult>; | ||
signMessage(message: any, account: AccountType, options: TorusConnectOptions): Promise<SignResult | undefined>; | ||
sign(deploy: string, account: AccountType, options: TorusConnectOptions): Promise<SignResult | undefined>; | ||
sign(deploy: string | object, account: AccountType, options: TorusConnectOptions): Promise<SignResult | undefined>; | ||
triggerEvent(evtType: string, evtDetail: any): void; | ||
@@ -38,0 +37,0 @@ } |
import { CONTENT_MODE } from '@make-software/csprclick-core-types'; | ||
export declare const CSPRCLICK_HOST: string; | ||
export type CoreSdkSettings = { | ||
options: CsprClickInitOptions; | ||
casperNode: string; | ||
chainName: string; | ||
origin: string; | ||
csprclickHost: string; | ||
coreServerEmitter: any; | ||
digest: string; | ||
}; | ||
export type WalletConnectSettings = { | ||
projectId: string; | ||
relayUrl?: string; | ||
logger?: string; | ||
}; | ||
export type CsprClickInitOptions = { | ||
@@ -12,2 +26,4 @@ csprclickHost?: string; | ||
chainName?: string; | ||
walletConnect?: WalletConnectSettings; | ||
logLevel?: number; | ||
}; | ||
@@ -26,2 +42,3 @@ export type WalletEventData = { | ||
signature: Uint8Array | null; | ||
deploy: object | null; | ||
error: string | null; | ||
@@ -35,1 +52,15 @@ }; | ||
}; | ||
export type GetActiveAccountOptions = { | ||
withBalance?: boolean; | ||
}; | ||
export type AccountMetadata = { | ||
public_key: string; | ||
liquid_balance: string; | ||
total_balance: string; | ||
account_logo: string | null; | ||
}; | ||
export type CoreClientError = { | ||
code: number; | ||
message: string; | ||
data?: any; | ||
}; |
@@ -10,1 +10,8 @@ export declare enum HashLength { | ||
export declare const formatHash: (hash: string, visibleHashLength?: HashLength) => string; | ||
export declare const _isRunningOnProviderInAppBrowser: () => string | undefined; | ||
export declare const _isRunningOnMobileDevice: () => { | ||
isIOS: boolean; | ||
isAndroid: boolean; | ||
androidVersion: string | undefined; | ||
iOSVersion: string | number; | ||
}; |
31245
33
698