UNPKG

@didtools/cacao

Version:
65 lines (64 loc) 2.84 kB
import type { Cacao } from '../cacao.js'; /** * Possible message error types. */ export declare enum ErrorTypes { /**Thrown when the `validate()` function can verify the message. */ INVALID_SIGNATURE = "Invalid signature.", /**Thrown when the `expirationTime` is present and in the past. */ EXPIRED_MESSAGE = "Expired message.", /**Thrown when some required field is missing. */ MALFORMED_SESSION = "Malformed session." } /** * Possible signature types that this library supports. */ export declare enum SignatureType { /**EIP-191 signature scheme */ PERSONAL_SIGNATURE = "Personal signature" } export declare class SiwxMessage { /**RFC 4501 dns authority that is requesting the signing. */ domain: string; /**Ethereum address performing the signing conformant to capitalization * encoded checksum specified in EIP-55 where applicable. */ address: string; /**Human-readable ASCII assertion that the user will sign, and it must not * contain `\n`. */ statement?: string; /**RFC 3986 URI referring to the resource that is the subject of the signing * (as in the __subject__ of a claim). */ uri: string; /**Current version of the message. */ version: string; /**Randomized token used to prevent replay attacks, at least 8 alphanumeric * characters. */ nonce?: string; /**ISO 8601 datetime string of the current time. */ issuedAt?: string; /**ISO 8601 datetime string that, if present, indicates when the signed * authentication message is no longer valid. */ expirationTime?: string; /**ISO 8601 datetime string that, if present, indicates when the signed * authentication message will become valid. */ notBefore?: string; /**System-specific identifier that may be used to uniquely refer to the * sign-in request. */ requestId?: string; /**EIP-155 Chain ID to which the session is bound, and the network where * Contract Accounts must be resolved. */ chainId: string; /**List of information or references to information the user wishes to have * resolved as part of authentication by the relying party. They are * expressed as RFC 3986 URIs separated by `\n- `. */ resources?: Array<string>; /**Signature of the message signed by the wallet. */ signature?: string; /**Type of sign message to be generated. */ type?: SignatureType; constructor(param: string | Partial<SiwxMessage>); static fromCacao<T extends SiwxMessage>(this: new (...args: Array<any>) => T, cacao: Cacao): T; toMessage(chain: string, address?: string): string; } export declare function asLegacyChainIdString(message: SiwxMessage, chainName: string): string; export declare function asString(message: SiwxMessage, chainName: string, address?: string): string;