@towns-protocol/sdk
Version:
For more details, visit the following resources:
51 lines • 4.18 kB
TypeScript
import { Envelope, EventRef, StreamEvent, Miniblock, StreamAndCookie, Tags, PlainMessage, Snapshot } from '@towns-protocol/proto';
import { ParsedEvent, ParsedMiniblock, ParsedSnapshot, ParsedStreamAndCookie, ParsedStreamResponse } from './types';
import { SignerContext } from './signerContext';
export interface UnpackEnvelopeOpts {
disableHashValidation?: boolean;
disableSignatureValidation?: boolean;
}
export declare const _impl_makeEvent_impl_: (context: SignerContext, payload: PlainMessage<StreamEvent>["payload"], prevMiniblockHash?: Uint8Array, prevMiniblockNum?: bigint, tags?: PlainMessage<Tags>) => Promise<Envelope>;
export declare const makeEvent: (context: SignerContext, payload: PlainMessage<StreamEvent>["payload"], prevMiniblockHash?: Uint8Array, prevMiniblockNum?: bigint, tags?: PlainMessage<Tags>) => Promise<Envelope>;
export declare const makeEvents: (context: SignerContext, payloads: PlainMessage<StreamEvent>["payload"][], prevMiniblockHash?: Uint8Array) => Promise<Envelope[]>;
export declare const unpackStream: (stream: StreamAndCookie | undefined, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedStreamResponse>;
export declare const unpackStreamEx: (miniblocks: Miniblock[], opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedStreamResponse>;
export declare const unpackStreamAndCookie: (streamAndCookie: StreamAndCookie, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedStreamAndCookie>;
export declare const unpackMiniblock: (miniblock: Miniblock, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedMiniblock>;
export declare const unpackEnvelope: (envelope: Envelope, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedEvent>;
export declare const unpackSnapshot: (miniblockHeader: StreamEvent | undefined, miniblockHeaderSnapshotHash: Uint8Array | undefined, snapshot: Envelope, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedSnapshot>;
export declare function checkEventSignature(event: {
creatorAddress: Uint8Array;
delegateSig: Uint8Array;
delegateExpiryEpochMs: bigint;
}, hash: Uint8Array, signature: Uint8Array): void;
export declare function makeParsedEvent(event: StreamEvent, hash: Uint8Array | undefined, signature: Uint8Array | undefined): {
event: StreamEvent;
hash: Uint8Array<ArrayBufferLike>;
hashStr: string;
signature: Uint8Array<ArrayBufferLike> | undefined;
creatorUserId: string;
};
export declare function makeParsedSnapshot(snapshot: Snapshot, hash: Uint8Array | undefined, signature: Uint8Array | undefined): {
snapshot: Snapshot;
hash: Uint8Array<ArrayBufferLike>;
hashStr: string;
signature: Uint8Array<ArrayBufferLike> | undefined;
};
export declare const unpackEnvelopes: (event: Envelope[], opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedEvent[]>;
export declare const unpackStreamEnvelopes: (stream: StreamAndCookie, opts: UnpackEnvelopeOpts | undefined) => Promise<ParsedEvent[]>;
export declare const makeEventRef: (streamId: string | Uint8Array, event: Envelope) => EventRef;
export declare function riverHash(data: Uint8Array): Uint8Array;
export declare function riverSnapshotHash(data: Uint8Array): Uint8Array;
export declare function riverDelegateHashSrc(devicePublicKey: Uint8Array, expiryEpochMs: bigint): Uint8Array;
export declare function notificationServiceHash(userId: Uint8Array, expiration: bigint, // unix seconds
challenge: Uint8Array): Uint8Array<ArrayBufferLike>;
export declare function appRegistryHash(userId: Uint8Array, expiration: bigint, // unix seconds
challenge: Uint8Array): Uint8Array<ArrayBufferLike>;
export declare function riverSign(hash: Uint8Array, privateKey: Uint8Array | string): Promise<Uint8Array>;
export declare function riverVerifySignature(hash: Uint8Array, signature: Uint8Array, publicKey: Uint8Array | string): boolean;
export declare function riverRecoverPubKey(hash: Uint8Array, signature: Uint8Array): Uint8Array;
export declare function publicKeyToAddress(publicKey: Uint8Array): Uint8Array;
export declare function publicKeyToUint8Array(publicKey: string): Uint8Array;
export declare function hexToNumber(hex: string): bigint;
//# sourceMappingURL=sign.d.ts.map