import type { DerivedIdentity, EncryptionKeyPair, KeyPair } from './crypto/types'; import { type NormalizedServerDescriptor, type ServerDescriptorInput, type ServerDescriptorResolver } from './server-descriptor'; export declare const MODULE_DELIVERY_PROTOCOL_ID = "/space-data-network/module-delivery/1.0.0"; export type ModuleDeliveryStage = 'provider-discovery' | 'challenge-sent' | 'challenge-received' | 'grant-received' | 'cid-fetch-start' | 'cid-fetch-complete' | 'cid-fetch-validated' | 'cid-fetch-error' | 'unwrap-start' | 'unwrap-complete' | 'decrypt-start' | 'decrypt-complete' | 'sdk-load-start' | 'sdk-load-complete' | 'invoke-start' | 'invoke-result' | 'invoke-error'; export interface ModuleDeliveryEvent { stage: ModuleDeliveryStage; timestamp: number; moduleId?: string; moduleVersion?: string; providerPeerId?: string; cid?: string; bytes?: number; detail?: string; error?: string; candidateAddrs?: string[]; discoveryCID?: string; } export interface ModuleDeliveryObserver { onEvent?: (event: ModuleDeliveryEvent) => void; } export interface ModuleDeliveryTransport { dialProtocol(targetPeerId: string, protocolId: string, payload: Uint8Array, candidateAddrs?: string[]): Promise; fetchCIDBytes(cid: string): Promise; discoverProviders?(discoveryCID: string): Promise; } export interface DiscoveredProvider { peerId: string; multiaddrs: string[]; } export interface RequesterIdentity { peerId: string; xpub?: string; signingKey: Pick; encryptionKey: Pick; } export interface ModuleGrantRequestOptions { serverDescriptor: ServerDescriptorInput; descriptorResolver?: ServerDescriptorResolver; requesterIdentity: Pick | RequesterIdentity; moduleId: string; moduleVersion?: string; moduleVariant?: string; requesterDomain: string; requestedTimeoutMs: number; reqId?: string; requestedAtMs?: number; observer?: ModuleDeliveryObserver; } export interface ModuleGrantResult { provider: NormalizedServerDescriptor; grant: GrantResponsePayload; grantResponseBytes: Uint8Array; } export interface EncryptedModuleBundleResult extends ModuleGrantResult { encryptedBundleBytes: Uint8Array; } interface BundleDescriptorPayload { cid: string; contentHash: Uint8Array; sizeBytes: number; moduleId: string; moduleVersion?: string; keyId?: string; requiredScope?: string; allowedDomains: string[]; maxGrantTimeoutMs: number; encrypted: boolean; } interface WrappedContentKeyPayload { wrappingAlgorithm: string; contentKeyId?: string; contentKeyRole?: string; contentKeyAlgorithm?: string; contentKeyEncoding?: string; keyBytes: Uint8Array; contentKeyVersion?: number; recipientKeyId?: string; requesterEphemeralPublicKey: Uint8Array; providerEphemeralPublicKey: Uint8Array; hkdfSalt: Uint8Array; iv: Uint8Array; ciphertext: Uint8Array; tag: Uint8Array; expiresAtMs: number; recipientPublicKey: Uint8Array; ephemeralPublicKey: Uint8Array; nonce: Uint8Array; header?: WrappedContentKeyHeaderPayload; encryptedPayload?: Uint8Array; recipientKeyIdBytes?: Uint8Array; schemaHash?: Uint8Array; keyMaterialRootType?: string; } interface WrappedContentKeyHeaderPayload { version: number; keyExchange: string; symmetric: string; keyDerivation: string; ephemeralPublicKey: Uint8Array; nonceStart: Uint8Array; recipientKeyId: Uint8Array; context?: string; schemaHash: Uint8Array; rootType?: string; timestamp?: number; } interface GrantResponsePayload { reqId: string; moduleId: string; moduleVersion?: string; requestedDomain?: string; requestedTimeoutMs: number; grantedDomain: string; grantedTimeoutMs: number; expiresAtMs: number; requiredScope?: string; grantStatus?: string; capabilityToken: Uint8Array; grantVerifierPublicKey: Uint8Array; providerSignature: Uint8Array; bundleDescriptor: BundleDescriptorPayload; wrappedContentKey: WrappedContentKeyPayload; } export declare function requestModuleGrant(transport: ModuleDeliveryTransport, options: ModuleGrantRequestOptions): Promise; export declare function fetchEncryptedModuleBundle(transport: Pick, result: ModuleGrantResult, observer?: ModuleDeliveryObserver): Promise; export declare function requestEncryptedModuleBundle(transport: ModuleDeliveryTransport, options: ModuleGrantRequestOptions): Promise; export declare class ModuleDeliveryProtocolError extends Error { readonly code: string; constructor(code: string, message: string); } export {}; //# sourceMappingURL=module-delivery.d.ts.map