expo-ii-integration
Version:
Expo library to enable smartphone native applications to invoke Internet Identity through a web application
156 lines (144 loc) • 6.6 kB
TypeScript
import { default as default_2 } from 'react';
import { DelegationChain } from '@dfinity/identity';
import { DelegationIdentity } from '@dfinity/identity';
import { Ed25519KeyIdentity } from '@dfinity/identity';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { Storage as Storage_2 } from 'expo-storage-universal';
import { StorageWrapper } from 'expo-storage-universal';
/**
* A specialized storage wrapper for managing the application's Ed25519KeyIdentity.
* This class extends Ed25519KeyIdentityValueStorageWrapper to provide a dedicated
* storage location for the app's key identity using a predefined storage key.
*/
export declare class AppKeyStorage extends Ed25519KeyIdentityValueStorageWrapper {
/**
* Creates a new instance of AppKeyStorage.
* @param storage - The storage implementation to use for persistence
*/
constructor(storage: Storage_2);
}
/**
* A storage wrapper implementation for DelegationChain that handles serialization, deserialization, and validation.
* This wrapper provides a type-safe way to store and retrieve DelegationChain instances in a storage system,
* with automatic validation of delegation chains to ensure they are still valid.
*/
export declare class DelegationChainValueStorageWrapper implements StorageWrapper<DelegationChain> {
private storage;
private key;
/**
* Creates a new instance of DelegationChainValueStorageWrapper.
* @param storage - The storage implementation to use for persistence
* @param key - The key under which the DelegationChain will be stored
*/
constructor(storage: Storage_2, key: string);
/**
* Attempts to find and retrieve a DelegationChain from storage.
* If the stored delegation chain is invalid, it will be automatically removed from storage.
* @returns A Promise that resolves to the found DelegationChain or undefined if not found or invalid
*/
find(): Promise<DelegationChain | undefined>;
/**
* Retrieves a DelegationChain from storage, throwing an error if not found or invalid.
* @returns A Promise that resolves to the found and valid DelegationChain
* @throws {Error} If no valid DelegationChain is found for the configured key
*/
retrieve(): Promise<DelegationChain>;
/**
* Saves a DelegationChain to storage.
* @param value - The DelegationChain to save
* @returns A Promise that resolves when the save operation is complete
*/
save(value: DelegationChain): Promise<void>;
/**
* Removes the stored DelegationChain from storage.
* @returns A Promise that resolves when the removal operation is complete
*/
remove(): Promise<void>;
}
/**
* A specialized storage wrapper for managing the application's DelegationChain.
* This class extends DelegationChainValueStorageWrapper to provide a dedicated
* storage location for the delegation chain using a predefined storage key.
* It includes automatic validation of stored delegation chains and cleanup of invalid ones.
*/
export declare class DelegationStorage extends DelegationChainValueStorageWrapper {
/**
* Creates a new instance of DelegationStorage.
* @param storage - The storage implementation to use for persistence
*/
constructor(storage: Storage_2);
}
/**
* A storage wrapper implementation for Ed25519KeyIdentity that handles serialization and deserialization.
* This wrapper provides a type-safe way to store and retrieve Ed25519KeyIdentity instances in a storage system.
*/
export declare class Ed25519KeyIdentityValueStorageWrapper implements StorageWrapper<Ed25519KeyIdentity> {
private storage;
private key;
/**
* Creates a new instance of Ed25519KeyIdentityValueStorageWrapper.
* @param storage - The storage implementation to use for persistence
* @param key - The key under which the Ed25519KeyIdentity will be stored
*/
constructor(storage: Storage_2, key: string);
/**
* Attempts to find and retrieve an Ed25519KeyIdentity from storage.
* @returns A Promise that resolves to the found Ed25519KeyIdentity or undefined if not found
*/
find(): Promise<Ed25519KeyIdentity | undefined>;
/**
* Retrieves an Ed25519KeyIdentity from storage, throwing an error if not found.
* @returns A Promise that resolves to the found Ed25519KeyIdentity
* @throws {Error} If no Ed25519KeyIdentity is found for the configured key
*/
retrieve(): Promise<Ed25519KeyIdentity>;
/**
* Saves an Ed25519KeyIdentity to storage.
* @param value - The Ed25519KeyIdentity to save
* @returns A Promise that resolves when the save operation is complete
*/
save(value: Ed25519KeyIdentity): Promise<void>;
/**
* Removes the stored Ed25519KeyIdentity from storage.
* @returns A Promise that resolves when the removal operation is complete
*/
remove(): Promise<void>;
}
export declare interface IIIntegrationContextType {
identity: DelegationIdentity | undefined;
isReady: boolean;
isAuthenticated: boolean;
login: () => Promise<void>;
logout: () => Promise<void>;
pathWhenLogin: string | undefined;
clearPathWhenLogin: () => void;
authError: unknown | undefined;
}
export declare function IIIntegrationProvider({ children, value, }: IIIntegrationProviderProps): JSX_2.Element;
declare interface IIIntegrationProviderProps {
children: default_2.ReactNode;
value: IIIntegrationContextType;
}
export declare function useIIIntegration({ localIPAddress, dfxNetwork, easDeepLinkType, deepLink, frontendCanisterId, iiIntegrationCanisterId, appKeyStorage, delegationStorage, platform, }: UseIIIntegrationParams): {
identity: DelegationIdentity | undefined;
isReady: boolean;
isAuthenticated: boolean;
login: () => Promise<void>;
logout: () => Promise<void>;
pathWhenLogin: string | undefined;
clearPathWhenLogin: () => void;
authError: unknown;
};
export declare function useIIIntegrationContext(): IIIntegrationContextType;
declare type UseIIIntegrationParams = {
localIPAddress: string;
dfxNetwork: string;
easDeepLinkType: string | undefined;
deepLink: string;
frontendCanisterId: string;
iiIntegrationCanisterId: string;
appKeyStorage: Ed25519KeyIdentityValueStorageWrapper;
delegationStorage: DelegationChainValueStorageWrapper;
platform: string;
};
export { }