|
| 1 | +/** |
| 2 | + * @prettier |
| 3 | + */ |
| 4 | +import type { FreezeOptions, Wallet, WalletShare } from '../wallet'; |
| 5 | + |
| 6 | +/** |
| 7 | + * The four static root-key slots of a vault, keyed by (curve, scheme): |
| 8 | + * - secp256k1Multisig ① — UTXO/XRP/XTZ/TRX/EOS |
| 9 | + * - ecdsaMpc ② — EVM/Cosmos (DKLS) |
| 10 | + * - eddsaMpc ③ — SOL/SUI/NEAR/TON/APT/DOT |
| 11 | + * - ed25519Multisig ④ — ALGO/XLM/HBAR |
| 12 | + */ |
| 13 | +export type RootKeyType = 'secp256k1Multisig' | 'ecdsaMpc' | 'eddsaMpc' | 'ed25519Multisig'; |
| 14 | + |
| 15 | +export type VaultPermission = 'view' | 'spend' | 'admin' | 'dapp'; |
| 16 | + |
| 17 | +/** |
| 18 | + * The 12 static root key ids, by (curve, scheme). Each entry is an ordered |
| 19 | + * [userKeyId, backupKeyId, bitgoKeyId] triplet — same shape and order as wallet.keys[]. |
| 20 | + */ |
| 21 | +export type VaultRootKeys = Record<RootKeyType, [userKeyId: string, backupKeyId: string, bitgoKeyId: string]>; |
| 22 | + |
| 23 | +export interface VaultMembershipData { |
| 24 | + userId: string; // new-model naming convention |
| 25 | + permissions: VaultPermission[]; |
| 26 | + needsRecovery?: boolean; |
| 27 | +} |
| 28 | + |
| 29 | +/** |
| 30 | + * A pending UMS spend grant awaiting a key share — mirror of the wallet's walletShareRequests[]. |
| 31 | + * Returned to spenders/admins and serviced via addMember. |
| 32 | + */ |
| 33 | +export interface VaultShareRequest { |
| 34 | + userId: string; |
| 35 | + permissions: VaultPermission[]; |
| 36 | + createdAt: string; |
| 37 | +} |
| 38 | + |
| 39 | +export interface VaultData { |
| 40 | + id: string; |
| 41 | + enterpriseId: string; |
| 42 | + label: string; |
| 43 | + // freeze is NOT a status — a frozen vault stays 'active' with the freeze field set (wallet precedent) |
| 44 | + status: 'initializing' | 'active' | 'archived'; |
| 45 | + creator: string; |
| 46 | + users: VaultMembershipData[]; |
| 47 | + vaultShareRequests?: VaultShareRequest[]; |
| 48 | + freeze?: { time?: string; expires?: string; reason?: string }; |
| 49 | + rootKeys?: VaultRootKeys; // ordered, like wallet.keys |
| 50 | + archivedAt?: string; |
| 51 | + createdAt: string; |
| 52 | +} |
| 53 | + |
| 54 | +export interface InitializeVaultOptions { |
| 55 | + label: string; // Phase 1 carries no key material — key generation happens in Phase 2 via the existing keychain APIs |
| 56 | +} |
| 57 | + |
| 58 | +// Phase 3 — the client hands back the 12 key ids it created in Phase 2: |
| 59 | +export interface FinalizeVaultOptions { |
| 60 | + rootKeys: VaultRootKeys; |
| 61 | +} |
| 62 | + |
| 63 | +/** Vault key-share states — identical to WalletShare states, no new states. */ |
| 64 | +export type VaultShareState = 'pendingapproval' | 'active' | 'accepted' | 'canceled' | 'rejected'; |
| 65 | + |
| 66 | +/** |
| 67 | + * One of the 4 root USER keyshares carried on a VaultShare, ECDH-re-encrypted to the recipient. |
| 68 | + * Body semantics land in the Part VI SDK ticket (WCN-1204). |
| 69 | + */ |
| 70 | +export interface VaultShareKeychain { |
| 71 | + rootKeyType: RootKeyType; |
| 72 | + rootKeyId: string; |
| 73 | + encryptedPrv: string; |
| 74 | + publicIdentifier: string; |
| 75 | + fromPubKey: string; |
| 76 | + toPubKey: string; |
| 77 | + path: string; |
| 78 | +} |
| 79 | + |
| 80 | +export interface VaultShareData { |
| 81 | + id: string; |
| 82 | + enterpriseId: string; |
| 83 | + vaultId: string; |
| 84 | + vaultLabel?: string; |
| 85 | + fromUser: string; |
| 86 | + toUser: string; |
| 87 | + permissions: VaultPermission[]; |
| 88 | + state: VaultShareState; |
| 89 | + message?: string; |
| 90 | + pendingApprovalId?: string; |
| 91 | + isUMSInitiated?: boolean; |
| 92 | + keychains?: VaultShareKeychain[]; |
| 93 | + createdAt: string; |
| 94 | + updatedAt?: string; |
| 95 | +} |
| 96 | + |
| 97 | +/** |
| 98 | + * Sharing ONE vault wallet with a non-member rides the existing wallet-share handshake (FR-13), |
| 99 | + * so the result is the existing WalletShare shape. |
| 100 | + */ |
| 101 | +export type WalletShareData = WalletShare; |
| 102 | + |
| 103 | +// ---- per-vault operation options (bodies land in WCN-1203 / WCN-1204) ---- |
| 104 | + |
| 105 | +export interface CreateVaultWalletOptions { |
| 106 | + coin: string; |
| 107 | + label: string; |
| 108 | + type?: string; |
| 109 | + multisigType?: string; |
| 110 | + multisigTypeVersion?: string; |
| 111 | +} |
| 112 | + |
| 113 | +export interface AddVaultMemberOptions { |
| 114 | + userId?: string; |
| 115 | + email?: string; |
| 116 | + permissions: VaultPermission[]; |
| 117 | + // required when 'spend' is included — the 4 root user keys ECDH-re-encrypted to the invitee |
| 118 | + keychains?: VaultShareKeychain[]; |
| 119 | + message?: string; |
| 120 | + disableEmail?: boolean; |
| 121 | +} |
| 122 | + |
| 123 | +export interface AddVaultWalletMemberOptions { |
| 124 | + walletId: string; |
| 125 | + email?: string; |
| 126 | + permissions?: string[]; |
| 127 | + message?: string; |
| 128 | +} |
| 129 | + |
| 130 | +export interface AcceptVaultShareOptions { |
| 131 | + vaultShareId: string; |
| 132 | + userPassword?: string; |
| 133 | + newWalletPassphrase?: string; |
| 134 | + overrideEncryptedPrv?: string; |
| 135 | +} |
| 136 | + |
| 137 | +export interface IVault { |
| 138 | + id(): string; |
| 139 | + enterpriseId(): string; |
| 140 | + label(): string; |
| 141 | + status(): VaultData['status']; |
| 142 | + url(extra?: string): string; |
| 143 | + createWallet(params: CreateVaultWalletOptions): Promise<Wallet>; |
| 144 | + // whole-vault: view/admin/spend; spend opens a key share (also how a spender services a |
| 145 | + // vaultShareRequests entry in UMS orgs) |
| 146 | + addMember(params: AddVaultMemberOptions): Promise<VaultData>; |
| 147 | + // share ONE vault wallet (FR-13), not the whole vault |
| 148 | + addMemberToWallet(params: AddVaultWalletMemberOptions): Promise<WalletShareData>; |
| 149 | + listShares(params?: { state?: VaultShareState }): Promise<VaultShareData[]>; |
| 150 | + acceptShare(params: AcceptVaultShareOptions): Promise<VaultShareData>; |
| 151 | + freeze(params?: FreezeOptions): Promise<VaultData>; |
| 152 | + archive(): Promise<VaultData>; |
| 153 | + toJSON(): VaultData; |
| 154 | +} |
0 commit comments