@streambird/streambird-js
Version:
152 lines (150 loc) • 6.3 kB
TypeScript
import { StreambirdWalletType } from '@streambird/web3-core';
import { Session } from '../models';
import { AbstractService } from './abstract-service';
declare type BeginRegistrationRequest = {
/**
* Public wallet address of the wallet.
*/
publicAddress: string;
/**
* Determines the type of wallet to register. Possible values: ETH, SOL (more coming soon!).
*/
walletType?: StreambirdWalletType;
};
declare type BeginRegistrationResponse = {
id: string;
appId: string;
userId: string;
publicAddress: string;
walletType: StreambirdWalletType;
challenge: string;
expiresAt: number;
updatedAt: number;
createdt: number;
};
declare type VerifyRegistrationRequest = {
/**
* Public wallet address of the wallet.
*/
publicAddress: string;
/**
* Determines the type of wallet to register. Possible values: ETH, SOL (more coming soon!).
*/
walletType?: StreambirdWalletType;
/**
* Signed message using the associated private key of the wallet address. We ETH signed
* message to be base64 encoded (e.g. 0x...) and SOL signed message will be bs58 encoded.
*/
signature: string;
/**
* Time in minutes. Extend the session expiration time to N minutes from now, must be between 5 to 525600 minutes (365 days).
*/
sessionExpiresIn?: number;
};
declare type VerifyRegistrationResponse = {
id: string;
appId: string;
userId: string;
publicAddress: string;
walletType: StreambirdWalletType;
verified: boolean;
isDefault: boolean;
isReadOnly: boolean;
isImported: boolean;
updatedAt: number;
createdAt: number;
sessionToken: string;
sessionJwt: string;
};
declare type NonceRegistrationResponse = {
id: string;
userId: string;
nonce: string;
userCreated: boolean;
};
declare type SiweVerifyRequest = {
walletType: StreambirdWalletType;
publicAddress: string;
siweChallenge: string;
signature: string;
sessionExpiresIn: number;
sessionJwt: string;
};
declare type SiweVerifyResponse = {
id: string;
appId: string;
userId: string;
publicAddress: string;
walletType: StreambirdWalletType;
verified: boolean;
isDefault: boolean;
isReadOnly: boolean;
isImported: boolean;
updatedAt: number;
createdAt: number;
sessionToken: string;
sessionJwt: string;
session: Session;
};
declare type MessageToSignRequest = {
publicWalletAddress: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
walletConnector: any;
nonce: string;
projectEnvironmentId: string;
};
declare type MessageToSignResponse = {
messageToSign: string;
signedMessage: string;
};
export declare class WalletService extends AbstractService {
url: string;
/**
* Initiates a wallet registration request for the specified user. This endpoint will return
* a challenge that must be signed by the private key of the wallet address you are registering
* against the user. Once verified, we will attach the wallet to the user specified.
* If session token is sent in, the user from the session token will be used as the user to
* attach the wallet to. However, if the no session token is sent it, a new user will be created
* if there is no existing verified user attached to the same address and if it is an existing
* verified wallet,it will be treated as a login.
* @returns sessions data
*/
beginRegistration(body: BeginRegistrationRequest): Promise<BeginRegistrationResponse>;
/**
* Verifies the signature created by the wallet's private key of the challenge returned by
* "beginRegistration". If successful, a wallet will be created and associated with the user.
* Wallet imported will be marked as isImported and isReadOnly true. If it is an existing
* associated wallet for the specified user, we allow you to create a Streambird managed session.
* @returns sessions data
*/
verifyRegistration(body: VerifyRegistrationRequest): Promise<VerifyRegistrationResponse>;
/**
* Initiates a wallet registration request for the specified user. This endpoint will return a nonce
* that must be signed by the private key of the wallet address you are registering against the user
* using the SIWE EIP-4361 (Sign in with Ethereum) spec. We will apply this to both Ethereum and Solana.
* In the case of Solana, instead of ${domain} wants you to sign in with your Ethereum account:,
* we will expect ${domain} wants you to sign in with your Solana account: and also Chain ID will not
* be expected either for Solana. Once verified, we will attach the wallet to the user specified.
*/
nonceRegistration(body: BeginRegistrationRequest): Promise<NonceRegistrationResponse>;
/**
* Verifies the signature created by the wallet's private key signing a SIWE challenge using the
* SIWE EIP-4361 (Sign in with Ethereum) spec using the nonce returned by GetWalletRegistrationNonce
* and the wallet address used during registration. If successful, a wallet will be created and
* associated with the user. Wallet imported will be marked as is_imported and is_read_only true.
* If it is an existing associated wallet for the specified user, we allow you to create a
* Streambird managed session.
* This public endpoint can be called directly from the browser using the PublicToken or our Auth SDK.
*/
siweVerify(body: SiweVerifyRequest): Promise<SiweVerifyResponse>;
/**
* Describes how wallet accounts authenticate with off-chain services by signing a standard message
* format parameterized by scope, session details, and security mechanisms (e.g., a nonce). The goals
* of this specification are to provide a self-custodied alternative to centralized identity providers,
* improve interoperability across off-chain services for Ethereum-based authentication, and provide
* wallet vendors a consistent machine-readable message format to achieve improved user experiences and
* consent management.
*/
generateMessages(message: MessageToSignRequest): Promise<MessageToSignResponse>;
}
export {};