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.

41 lines (40 loc) 1.73 kB
import { SiweMessage } from 'siwe'; import { LIT_ABILITY_VALUES } from '@lit-protocol/constants'; import { ILitResource, ISessionCapabilityObject } from '@lit-protocol/types'; import { AttenuationsObject, CID as CIDString, PlainJSON } from '../models'; export declare class RecapSessionCapabilityObject implements ISessionCapabilityObject { private _inner; constructor(att?: AttenuationsObject, prf?: Array<CIDString> | Array<string>); static decode(encoded: string): RecapSessionCapabilityObject; static extract(siwe: SiweMessage): RecapSessionCapabilityObject; get attenuations(): AttenuationsObject; get proofs(): Array<CIDString>; get statement(): string; addProof(proof: string): void; addAttenuation(resource: string, namespace?: string, name?: string, restriction?: { [key: string]: PlainJSON; }): void; addToSiweMessage(siwe: SiweMessage): SiweMessage; encodeAsSiweResource(): string; /** LIT specific methods */ addCapabilityForResource(litResource: ILitResource, ability: LIT_ABILITY_VALUES, data?: any): void; verifyCapabilitiesForResource(litResource: ILitResource, ability: LIT_ABILITY_VALUES): boolean; /** * Returns the attenuated resource key to match against. This supports matching * against a wildcard resource key too. * * @example If the attenuations object contains the following: * * ``` * { * 'lit-acc://*': { * '*\/*': {} * } * } * ``` * * Then, if the provided litResource is 'lit-acc://123', the method will return 'lit-acc://*'. */ private _getResourceKeyToMatchAgainst; addAllCapabilitiesForResource(litResource: ILitResource): void; }