import { createJsonRpcRequestPayload, standardizeJsonRpcRequestPayload } from '../core/json-rpc'; import { BaseModule } from './base-module'; import { SDKBase, MagicSDKAdditionalConfiguration, MagicSDKExtensionsOption } from '../core/sdk'; import { MagicExtensionError, MagicExtensionWarning } from '../core/sdk-exceptions'; import { createPromiEvent, encodeJSON, decodeJSON, storage, isPromiEvent } from '../util'; export declare abstract class BaseExtension extends BaseModule { /** * A structure describing the platform and version compatibility of this * extension. */ compat?: { 'magic-sdk': boolean | string; '@magic-sdk/react-native': boolean | string; '@magic-sdk/react-native-bare': boolean | string; '@magic-sdk/react-native-expo': boolean | string; }; abstract readonly name: TName; abstract readonly config: TConfig; private __sdk_access_field_descriptors__; private __is_initialized__; protected utils: { createPromiEvent: typeof createPromiEvent; isPromiEvent: typeof isPromiEvent; encodeJSON: typeof encodeJSON; decodeJSON: typeof decodeJSON; createJsonRpcRequestPayload: typeof createJsonRpcRequestPayload; standardizeJsonRpcRequestPayload: typeof standardizeJsonRpcRequestPayload; storage: typeof storage; }; constructor(); /** * Registers a Magic SDK instance with this Extension. * * @internal */ init(sdk: SDKBase): void; /** * Creates a deprecation warning wrapped with a native Magic SDK warning type. * Best practice is to warn users of upcoming deprecations at least one major * version before the change is implemented. You can use this method to * communicate deprecations in a manner consistent with Magic SDK core code. */ protected createDeprecationWarning(options: { method: string; removalVersion: string; useInstead?: string; }): MagicExtensionWarning; /** * Creates a warning wrapped with a native Magic SDK warning type. This * maintains consistency in warning messaging for consumers of Magic SDK and * this Extension. */ protected createWarning(code: string | number, message: string): MagicExtensionWarning; /** * Creates an error wrapped with a native Magic SDK error type. This maintains * consistency in error handling for consumers of Magic SDK and this * Extension. */ protected createError(code: string | number, message: string, data: TData): MagicExtensionError; } declare abstract class InternalExtension extends BaseExtension { abstract readonly config: TConfig; } /** * A base class representing "extensions" to the core Magic JS APIs. Extensions * enable new functionality by composing Magic endpoints methods together. */ export declare class Extension { /** * This is a special constructor used to mark "official" extensions. These * extensions are designed for special interaction with the Magic iframe using * custom JSON RPC methods, business logic, and global configurations. This is * intended for internal-use only (and provides no useful advantage to * open-source extension developers over the regular `Extension` class). * * @internal */ static Internal: typeof InternalExtension; } /** * Base class for multi-chain extensions, extracting getPublicAddress and revealPrivateKey logic. */ export declare abstract class MultichainExtension extends InternalExtension { readonly config: TConfig; readonly chain: string; constructor(config: TConfig); getPublicAddress(): import("../util").PromiEvent void; error: (reason: any) => void; settled: () => void; "closed-by-user": () => void; }>; revealPrivateKey(): import("../util").PromiEvent void; error: (reason: any) => void; settled: () => void; "closed-by-user": () => void; }>; } /** * These fields are exposed on the `Extension` type, * but should be hidden from the public interface. */ type HiddenExtensionFields = 'name' | 'init' | 'config' | 'compat'; /** * Gets the type contained in an array type. */ type UnwrapArray = T extends Array ? P : never; /** * Create a union type of Extension names from an * array of Extension types given by `TExt`. */ type ExtensionNames[]> = UnwrapArray extends BaseExtension ? R : never; /** * From the literal Extension name type given by `TExtName`, * extract a dictionary of Extension types. */ type GetExtensionFromName[], TExtName extends string> = { [P in TExtName]: Extract, BaseExtension>; }[TExtName]; /** * Wraps a Magic SDK constructor with the necessary type * information to support a strongly-typed `Extension` interface. */ export type WithExtensions = { new >(apiKey: string, options?: MagicSDKAdditionalConfiguration): InstanceWithExtensions; }; export type InstanceWithExtensions = SDK & { [P in Exclude[] ? ExtensionNames : keyof TExt, number>]: TExt extends BaseExtension[] ? Omit, HiddenExtensionFields> : TExt extends { [P in Exclude[] ? ExtensionNames : keyof TExt, number>]: BaseExtension; } ? Omit : never; }; export {};