UNPKG

@lit-protocol/auth-helpers

Version:

Advanced authentication utilities for managing blockchain resource permissions and capabilities within the Lit Protocol ecosystem. Built on top of SIWE (Sign-In with Ethereum) and SIWE-RECAP for robust authentication flows.

30 lines (29 loc) 1.53 kB
import { SiweMessage } from 'siwe'; import { CapacityDelegationFields, CapacityDelegationRequest, ILitNodeClient, LitResourceAbilityRequest } from '@lit-protocol/types'; /** * Sanitizes a SIWE message by unescaping double-escaped newlines and replacing escaped double quotes with single quotes. * * @param message - The SIWE message to sanitize. * @returns The sanitized SIWE message. */ export declare function sanitizeSiweMessage(message: string): string; /** * Creates the resource data for a capacity delegation request. * @param params - The capacity delegation fields. * @returns The capacity delegation request object. */ export declare const createCapacityCreditsResourceData: (params: CapacityDelegationFields) => CapacityDelegationRequest; /** * Adds recap capabilities to a SiweMessage. * @param siweMessage - The SiweMessage to add recap capabilities to. * @param resources - An array of LitResourceAbilityRequest objects representing the resources and abilities to add. * @param litNodeClient - The LitNodeClient interface * @returns The updated SiweMessage with recap capabilities added. * @throws An error if the resources array is empty or if litNodeClient is not provided. * @throws An error if the generated capabilities fail to verify for any resource and ability. */ export declare const addRecapToSiweMessage: ({ siweMessage, resources, litNodeClient, }: { siweMessage: SiweMessage; resources: LitResourceAbilityRequest[]; litNodeClient: ILitNodeClient; }) => Promise<SiweMessage>;