UNPKG

5.13 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as Bluebird from 'bluebird';
3import { BitGo } from '../bitgo';
4import { BaseCoin, KeyPair } from './baseCoin';
5import { NodeCallback } from './types';
6import { Wallet } from './wallet';
7import { RequestTracer } from './internal/util';
8export interface Keychain {
9 id: string;
10 pub: string;
11 prv?: string;
12 provider?: string;
13 encryptedPrv?: string;
14 derivationPath?: string;
15 derivedFromParentWithSeed?: string;
16}
17export interface ChangedKeychains {
18 [pubkey: string]: string;
19}
20export interface ListKeychainsResult {
21 keys: Keychain[];
22 nextBatchPrevId?: string;
23}
24export interface GetKeychainOptions {
25 id: string;
26 xpub?: string;
27 ethAddress?: string;
28 reqId?: RequestTracer;
29}
30export interface ListKeychainOptions {
31 limit?: number;
32 prevId?: string;
33}
34export interface UpdatePasswordOptions {
35 oldPassword: string;
36 newPassword: string;
37}
38interface UpdateSingleKeychainPasswordOptions {
39 keychain?: Keychain;
40 oldPassword?: string;
41 newPassword?: string;
42}
43interface AddKeychainOptions {
44 pub?: string;
45 encryptedPrv?: string;
46 type?: string;
47 source?: string;
48 originalPasscodeEncryptionCode?: string;
49 enterprise?: string;
50 derivedFromParentWithSeed?: any;
51 disableKRSEmail?: boolean;
52 provider?: string;
53 reqId?: RequestTracer;
54 krsSpecific?: any;
55}
56export interface CreateBackupOptions {
57 provider?: string;
58 source?: string;
59 disableKRSEmail?: boolean;
60 krsSpecific?: any;
61 type?: string;
62 reqId?: RequestTracer;
63}
64interface CreateBitGoOptions {
65 source?: 'bitgo';
66 enterprise?: string;
67 reqId?: RequestTracer;
68}
69interface GetKeysForSigningOptions {
70 reqId?: RequestTracer;
71 wallet?: Wallet;
72}
73export declare enum KeyIndices {
74 USER = 0,
75 BACKUP = 1,
76 BITGO = 2
77}
78export declare class Keychains {
79 private readonly bitgo;
80 private readonly baseCoin;
81 constructor(bitgo: BitGo, baseCoin: BaseCoin);
82 /**
83 * Get a keychain by ID
84 * @param params
85 * @param params.id
86 * @param params.xpub (optional)
87 * @param params.ethAddress (optional)
88 * @param params.reqId (optional)
89 * @param callback
90 */
91 get(params: GetKeychainOptions, callback?: NodeCallback<Keychain>): Bluebird<Keychain>;
92 /**
93 * list the users keychains
94 * @param params
95 * @param params.limit - Max number of results in a single call.
96 * @param params.prevId - Continue iterating (provided by nextBatchPrevId in the previous list)
97 * @param callback
98 * @returns {*}
99 */
100 list(params?: ListKeychainOptions, callback?: NodeCallback<ListKeychainsResult>): Bluebird<ListKeychainsResult>;
101 /**
102 * Change the decryption password for all possible keychains associated with a user.
103 *
104 * This function iterates through all keys associated with the user, decrypts
105 * them with the old password and re-encrypts them with the new password.
106 *
107 * This should be called when a user changes their login password, and are expecting
108 * that their wallet passwords are changed to match the new login password.
109 *
110 * @param params
111 * @param params.oldPassword - The old password used for encrypting the key
112 * @param params.newPassword - The new password to be used for encrypting the key
113 * @param callback
114 * @returns changedKeys Object - e.g.:
115 * {
116 * xpub1: encryptedPrv,
117 * ...
118 * }
119 */
120 updatePassword(params: UpdatePasswordOptions, callback?: NodeCallback<ChangedKeychains>): Bluebird<ChangedKeychains>;
121 /**
122 * Update the password used to decrypt a single keychain
123 * @param params
124 * @param params.keychain - The keychain whose password should be updated
125 * @param params.oldPassword - The old password used for encrypting the key
126 * @param params.newPassword - The new password to be used for encrypting the key
127 * @returns {object}
128 */
129 updateSingleKeychainPassword(params?: UpdateSingleKeychainPasswordOptions): Keychain;
130 /**
131 * Create a public/private key pair
132 * @param params.seed
133 */
134 create(params?: {
135 seed?: Buffer;
136 }): KeyPair;
137 /**
138 * Add a keychain to BitGo's records
139 * @param params
140 * @param callback
141 */
142 add(params?: AddKeychainOptions, callback?: NodeCallback<Keychain>): Bluebird<Keychain>;
143 /**
144 * Create a BitGo key
145 * @param params (empty)
146 * @param callback
147 */
148 createBitGo(params?: CreateBitGoOptions, callback?: NodeCallback<Keychain>): Bluebird<Keychain>;
149 /**
150 * Create a backup key
151 * @param params
152 * @param params.provider (optional)
153 * @param callback
154 */
155 createBackup(params?: CreateBackupOptions, callback?: NodeCallback<Keychain>): Bluebird<Keychain>;
156 /**
157 * Gets keys for signing from a wallet
158 * @param params
159 * @param callback
160 * @returns {Bluebird[]}
161 */
162 getKeysForSigning(params?: GetKeysForSigningOptions, callback?: NodeCallback<Keychain[]>): Bluebird<Keychain[]>;
163}
164export {};
165//# sourceMappingURL=keychains.d.ts.map
\No newline at end of file