@capgo/cli
Version:
A CLI to upload to capgo servers
52 lines (51 loc) • 2.76 kB
TypeScript
/**
* Bundle artifact preparation shared by `bundle upload` and the offline
* `bundle zip` packer. Everything here is local (no API key, no network): the
* online upload wires its analytics through the optional hooks, so both
* commands produce byte-for-byte the same zip, checksum, encryption metadata,
* native package list and delta encryption settings.
*/
import type { Buffer } from 'node:buffer';
import type { getLocalDependencies } from '../utils';
import type { OptionsUpload } from './upload_interface';
export type BundleArtifactOptions = Pick<OptionsUpload, 'mode' | 'keyV2' | 'keyDataV2' | 'key' | 'oldEncryption' | 'forceCrc32Checksum' | 'packageJson' | 'displayIvSession' | 'verbose'>;
export interface BundleArtifactHooks {
/** Called right before v2 encryption starts (the online upload sends its analytics event here). */
onEncryptV2?: () => Promise<void>;
}
interface ResolvedUpdaterForUpload {
packageName: string;
version: string;
}
export declare function resolveUpdaterForUpload(options: Pick<OptionsUpload, 'mode' | 'packageJson'>, root: string): Promise<ResolvedUpdaterForUpload | null>;
/**
* Zip the web assets, compute the checksum and apply v2 encryption exactly as
* `bundle upload` does (sha256/crc32 selection, .capgo_key_v2 default,
* --key-v2/--key-data-v2/--no-key, V3 hex vs V2 base64 checksum signature).
*/
export declare function prepareBundleArtifact(path: string, options: BundleArtifactOptions, publicKeyFromConfig?: string, hooks?: BundleArtifactHooks): Promise<{
zipped: Buffer<ArrayBufferLike>;
ivSessionKey: string | undefined;
sessionKey: Buffer<ArrayBufferLike> | undefined;
checksum: string;
checksumAlgorithm: "sha256" | "crc32";
checksumEncryption: "v2" | "v3" | undefined;
encryptionMethod: "none" | "v1" | "v2";
finalKeyData: string;
keyId: string;
updaterVersion: string | undefined;
updaterPackageName: string | undefined;
}>;
type LocalDependencies = Awaited<ReturnType<typeof getLocalDependencies>>;
/** native_packages payload stored on the bundle (same shape `bundle upload` sends). */
export declare function buildNativePackagesPayload(localDependencies: LocalDependencies | undefined, ignoreMetadataCheck?: boolean): any[] | undefined;
/**
* Resolve delta (manifest) encryption exactly like `bundle upload`: folds the
* deprecated --encrypt-partial alias into options.encryptDelta, refuses explicit
* delta encryption without v2, auto-enables it for updater >= 6.14.4 and picks
* the hex (V3) checksum format when the updater supports it.
*/
export declare function resolveDeltaEncryptionSettings(options: OptionsUpload, encryptionMethod: 'none' | 'v2' | 'v1'): Promise<{
supportsHexChecksum: boolean;
}>;
export {};