@bitgo-beta/key-card 0.0.1-beta.49 → 0.0.1-beta.490
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/drawKeycard.d.ts +5 -0
- package/dist/src/drawKeycard.d.ts.map +1 -0
- package/dist/src/drawKeycard.js +215 -0
- package/dist/src/faq.d.ts +3 -0
- package/dist/src/faq.d.ts.map +1 -0
- package/dist/src/faq.js +76 -0
- package/dist/src/generateParamsForKeyCreation.d.ts +3 -0
- package/dist/src/generateParamsForKeyCreation.d.ts.map +1 -0
- package/dist/src/generateParamsForKeyCreation.js +40 -0
- package/dist/src/generateQrData.d.ts +3 -0
- package/dist/src/generateQrData.d.ts.map +1 -0
- package/dist/src/generateQrData.js +131 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +45 -0
- package/dist/src/types.d.ts +60 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +17 -0
- package/package.json +5 -5
- package/.mocharc.js +0 -9
- package/CHANGELOG.md +0 -32
- package/src/drawKeycard.ts +0 -240
- package/src/faq.ts +0 -82
- package/src/generateQrData.ts +0 -167
- package/src/index.ts +0 -22
- package/src/utils.ts +0 -15
- package/test/unit/faq.ts +0 -14
- package/test/unit/generateQrData.ts +0 -213
- package/test/unit/utils.ts +0 -30
- package/tsconfig.json +0 -20
package/src/generateQrData.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { BaseCoin } from '@bitgo-beta/statics';
|
|
2
|
-
import { Keychain } from '@bitgo-beta/sdk-core';
|
|
3
|
-
import { encrypt } from '@bitgo-beta/sdk-api';
|
|
4
|
-
import * as assert from 'assert';
|
|
5
|
-
|
|
6
|
-
export interface GenerateQrDataParams {
|
|
7
|
-
// The backup keychain as it is returned from the BitGo API upon creation
|
|
8
|
-
backupKeychain: Keychain,
|
|
9
|
-
// The name of the 3rd party provider of the backup key if neither the user nor BitGo stores it
|
|
10
|
-
backupKeyProvider?: string;
|
|
11
|
-
// The key id of the backup key, only used for cold keys
|
|
12
|
-
backupMasterKey?: string;
|
|
13
|
-
// The BitGo keychain as it is returned from the BitGo API upon creation
|
|
14
|
-
bitgoKeychain: Keychain,
|
|
15
|
-
// The coin of the wallet that was/ is about to be created
|
|
16
|
-
coin: Readonly<BaseCoin>;
|
|
17
|
-
// A code that can be used to encrypt the wallet password to.
|
|
18
|
-
// If both the passphrase and passcodeEncryptionCode are passed, then this code encrypts the passphrase with the
|
|
19
|
-
// passcodeEncryptionCode and puts the result into Box D. Allows recoveries of the wallet password.
|
|
20
|
-
passcodeEncryptionCode?: string;
|
|
21
|
-
// The wallet password
|
|
22
|
-
// If both the passphrase and passcodeEncryptionCode are passed, then this code encrypts the passphrase with the
|
|
23
|
-
// passcodeEncryptionCode and puts the result into Box D. Allows recoveries of the wallet password.
|
|
24
|
-
passphrase?: string;
|
|
25
|
-
// The user keychain as it is returned from the BitGo API upon creation
|
|
26
|
-
userKeychain: Keychain;
|
|
27
|
-
// The key id of the user key, only used for cold keys
|
|
28
|
-
userMasterKey?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface QrDataEntry {
|
|
32
|
-
data: string;
|
|
33
|
-
description: string;
|
|
34
|
-
title: string;
|
|
35
|
-
publicMasterKey?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface QrData {
|
|
39
|
-
backup?: QrDataEntry;
|
|
40
|
-
bitgo?: QrDataEntry;
|
|
41
|
-
passcode?: QrDataEntry;
|
|
42
|
-
user: QrDataEntry;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getPubFromKey(key: Keychain): string | undefined {
|
|
46
|
-
switch (key.type) {
|
|
47
|
-
case 'blsdkg':
|
|
48
|
-
return key.commonPub;
|
|
49
|
-
case 'tss':
|
|
50
|
-
return key.commonKeychain;
|
|
51
|
-
case 'independent':
|
|
52
|
-
return key.pub;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function generateUserQrData(userKeychain: Keychain, userMasterKey?: string): QrDataEntry {
|
|
57
|
-
if (userKeychain.encryptedPrv) {
|
|
58
|
-
return {
|
|
59
|
-
title: 'A: User Key',
|
|
60
|
-
description: 'This is your private key, encrypted with your wallet password.',
|
|
61
|
-
data: userKeychain.encryptedPrv,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const pub = getPubFromKey(userKeychain);
|
|
66
|
-
assert(pub);
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
title: 'A: Provided User Key',
|
|
70
|
-
description: 'This is the public key you provided for your wallet.',
|
|
71
|
-
data: pub,
|
|
72
|
-
publicMasterKey: userMasterKey,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function generateBackupQrData(coin: Readonly<BaseCoin>, backupKeychain: Keychain, {
|
|
77
|
-
backupKeyProvider,
|
|
78
|
-
backupMasterKey,
|
|
79
|
-
}: {
|
|
80
|
-
backupKeyProvider?: string;
|
|
81
|
-
backupMasterKey?: string;
|
|
82
|
-
} = {}): QrDataEntry {
|
|
83
|
-
const title = 'B: Backup Key';
|
|
84
|
-
if (backupKeychain.encryptedPrv) {
|
|
85
|
-
return {
|
|
86
|
-
title,
|
|
87
|
-
description: 'This is your backup private key, encrypted with your wallet password.',
|
|
88
|
-
data: backupKeychain.encryptedPrv,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (backupKeyProvider === 'BitGo Trust' && backupKeychain.type === 'tss') {
|
|
93
|
-
const keyShares = backupKeychain.keyShares?.filter((keyShare) => keyShare.to === 'backup');
|
|
94
|
-
assert(keyShares?.length === 2);
|
|
95
|
-
return {
|
|
96
|
-
title: 'B: Backup Key Shares',
|
|
97
|
-
description: `These are the key shares for ${backupKeyProvider}. If BitGo Inc. goes out of business,\r\n` +
|
|
98
|
-
`contact ${backupKeyProvider} and they will help you recover your funds.`,
|
|
99
|
-
data: JSON.stringify(keyShares),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const pub = getPubFromKey(backupKeychain);
|
|
104
|
-
assert(pub);
|
|
105
|
-
|
|
106
|
-
if (backupKeyProvider) {
|
|
107
|
-
return {
|
|
108
|
-
title: 'B: Backup Key',
|
|
109
|
-
description: `This is the public key held at ${backupKeyProvider}, an ${coin.name} recovery service. ` +
|
|
110
|
-
`If you lose\r\nyour key, ${backupKeyProvider} will be able to sign transactions to recover funds.`,
|
|
111
|
-
data: pub,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
title: 'B: Provided Backup Key',
|
|
117
|
-
description: 'This is the public key you provided for your wallet.',
|
|
118
|
-
data: pub,
|
|
119
|
-
publicMasterKey: backupMasterKey,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function generateBitGoQrData(bitgoKeychain: Keychain): QrDataEntry {
|
|
124
|
-
const bitgoData = getPubFromKey(bitgoKeychain);
|
|
125
|
-
assert(bitgoData);
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
title: 'C: BitGo Public Key',
|
|
129
|
-
description:
|
|
130
|
-
'This is the public part of the key that BitGo will use to ' +
|
|
131
|
-
'co-sign transactions\r\nwith you on your wallet.',
|
|
132
|
-
data: bitgoData,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function generateQrData({
|
|
137
|
-
backupKeychain,
|
|
138
|
-
backupKeyProvider,
|
|
139
|
-
backupMasterKey,
|
|
140
|
-
bitgoKeychain,
|
|
141
|
-
coin,
|
|
142
|
-
passcodeEncryptionCode,
|
|
143
|
-
passphrase,
|
|
144
|
-
userKeychain,
|
|
145
|
-
userMasterKey,
|
|
146
|
-
}: GenerateQrDataParams): QrData {
|
|
147
|
-
const qrData: QrData = {
|
|
148
|
-
user: generateUserQrData(userKeychain, userMasterKey),
|
|
149
|
-
backup: generateBackupQrData(coin, backupKeychain, {
|
|
150
|
-
backupKeyProvider,
|
|
151
|
-
backupMasterKey,
|
|
152
|
-
}),
|
|
153
|
-
bitgo: generateBitGoQrData(bitgoKeychain),
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
if (passphrase && passcodeEncryptionCode) {
|
|
157
|
-
const encryptedWalletPasscode = encrypt(passcodeEncryptionCode, passphrase);
|
|
158
|
-
|
|
159
|
-
qrData.passcode = {
|
|
160
|
-
title: 'D: Encrypted wallet Password',
|
|
161
|
-
description: 'This is the wallet password, encrypted client-side with a key held by BitGo.',
|
|
162
|
-
data: encryptedWalletPasscode,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return qrData;
|
|
167
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { generateQrData, GenerateQrDataParams } from './generateQrData';
|
|
2
|
-
import { generateFaq } from './faq';
|
|
3
|
-
import { drawKeycard } from './drawKeycard';
|
|
4
|
-
|
|
5
|
-
export * from './drawKeycard';
|
|
6
|
-
export * from './faq';
|
|
7
|
-
export * from './generateQrData';
|
|
8
|
-
export * from './utils';
|
|
9
|
-
|
|
10
|
-
export interface GenerateKeycardParams extends GenerateQrDataParams {
|
|
11
|
-
activationCode?: string;
|
|
12
|
-
keyCardImage?: HTMLImageElement;
|
|
13
|
-
walletLabel: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function generateKeycard(params: GenerateKeycardParams): Promise<void> {
|
|
17
|
-
const questions = generateFaq(params.coin.fullName);
|
|
18
|
-
const qrData = generateQrData(params);
|
|
19
|
-
const keycard = await drawKeycard({ ...params, questions, qrData });
|
|
20
|
-
// Save the PDF on the user's browser
|
|
21
|
-
keycard.save(`BitGo Keycard for ${params.walletLabel}.pdf`);
|
|
22
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function splitKeys(key: string, limit: number): string[] {
|
|
2
|
-
if (key.length <= limit) {
|
|
3
|
-
return [key];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const keys: string[] = [];
|
|
7
|
-
|
|
8
|
-
let rightIndex = limit;
|
|
9
|
-
for (let i = 0; i < key.length; i += limit) {
|
|
10
|
-
keys.push(key.substring(i, rightIndex));
|
|
11
|
-
rightIndex = Math.min(rightIndex + limit, key.length);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return keys;
|
|
15
|
-
}
|
package/test/unit/faq.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { generateFaq } from '../../src/faq';
|
|
2
|
-
|
|
3
|
-
describe('generateFaq', function () {
|
|
4
|
-
it('generates faq with filled in coin name', function () {
|
|
5
|
-
const coinName = 'fooCoin';
|
|
6
|
-
const questions = generateFaq(coinName);
|
|
7
|
-
|
|
8
|
-
questions.length.should.equal(7);
|
|
9
|
-
questions[0].answer[0].should.match(new RegExp(coinName));
|
|
10
|
-
questions[2].answer[0].should.match(new RegExp(coinName));
|
|
11
|
-
questions[5].answer[1].should.match(new RegExp(coinName));
|
|
12
|
-
questions[6].answer[2].should.match(new RegExp(coinName));
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import * as assert from 'assert';
|
|
2
|
-
import * as should from 'should';
|
|
3
|
-
import { generateQrData } from '../../src/generateQrData';
|
|
4
|
-
import { decrypt } from '@bitgo-beta/sdk-api';
|
|
5
|
-
import { ApiKeyShare, Keychain, KeyType } from '@bitgo-beta/sdk-core';
|
|
6
|
-
import { coins } from '@bitgo-beta/statics';
|
|
7
|
-
|
|
8
|
-
function createKeychain({
|
|
9
|
-
commonKeychain,
|
|
10
|
-
commonPub,
|
|
11
|
-
encryptedPrv,
|
|
12
|
-
keyShares,
|
|
13
|
-
provider,
|
|
14
|
-
pub,
|
|
15
|
-
type,
|
|
16
|
-
}: {
|
|
17
|
-
commonKeychain?: string;
|
|
18
|
-
commonPub?: string;
|
|
19
|
-
encryptedPrv?: string;
|
|
20
|
-
keyShares?: ApiKeyShare[];
|
|
21
|
-
provider?: string;
|
|
22
|
-
pub?: string;
|
|
23
|
-
type?: KeyType;
|
|
24
|
-
}): Keychain {
|
|
25
|
-
return {
|
|
26
|
-
commonKeychain,
|
|
27
|
-
commonPub,
|
|
28
|
-
encryptedPrv,
|
|
29
|
-
id: 'id',
|
|
30
|
-
keyShares,
|
|
31
|
-
provider,
|
|
32
|
-
pub: pub ?? 'pub',
|
|
33
|
-
type: type ?? 'independent',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe('generateQrData', function () {
|
|
38
|
-
it('hot wallet, backup key provided by user with encryptedPrv', function () {
|
|
39
|
-
const userEncryptedPrv = 'prv123encrypted';
|
|
40
|
-
const backupEncryptedPrv = 'prv456encrypted';
|
|
41
|
-
const bitgoPub = 'pub789bitgo';
|
|
42
|
-
const passphrase = 'testingIsFun';
|
|
43
|
-
const passcodeEncryptionCode = '123456';
|
|
44
|
-
const qrData = generateQrData({
|
|
45
|
-
backupKeychain: createKeychain({
|
|
46
|
-
encryptedPrv: backupEncryptedPrv,
|
|
47
|
-
}),
|
|
48
|
-
bitgoKeychain: createKeychain({
|
|
49
|
-
pub: bitgoPub,
|
|
50
|
-
}),
|
|
51
|
-
coin: coins.get('btc'),
|
|
52
|
-
passcodeEncryptionCode,
|
|
53
|
-
passphrase,
|
|
54
|
-
userKeychain: createKeychain({
|
|
55
|
-
encryptedPrv: userEncryptedPrv,
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
qrData.user.title.should.equal('A: User Key');
|
|
60
|
-
qrData.user.description.should.equal('This is your private key, encrypted with your wallet password.');
|
|
61
|
-
qrData.user.data.should.equal(userEncryptedPrv);
|
|
62
|
-
|
|
63
|
-
assert(qrData.backup);
|
|
64
|
-
qrData.backup.title.should.equal('B: Backup Key');
|
|
65
|
-
qrData.backup.description.should.equal('This is your backup private key, encrypted with your wallet password.');
|
|
66
|
-
qrData.backup.data.should.equal(backupEncryptedPrv);
|
|
67
|
-
|
|
68
|
-
assert(qrData.bitgo);
|
|
69
|
-
qrData.bitgo.title.should.equal('C: BitGo Public Key');
|
|
70
|
-
qrData.bitgo.description.should.equal('This is the public part of the key that BitGo will use to ' +
|
|
71
|
-
'co-sign transactions\r\nwith you on your wallet.');
|
|
72
|
-
qrData.bitgo.data.should.equal(bitgoPub);
|
|
73
|
-
|
|
74
|
-
assert(qrData.passcode);
|
|
75
|
-
qrData.passcode.title.should.equal('D: Encrypted wallet Password');
|
|
76
|
-
qrData.passcode.description.should.equal('This is the wallet password, encrypted client-side with a key held by BitGo.');
|
|
77
|
-
const decryptedData = decrypt(passcodeEncryptionCode, qrData.passcode.data);
|
|
78
|
-
decryptedData.should.equal(passphrase);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('cold wallet', function () {
|
|
82
|
-
const testSets: { coinName: string; keyType: KeyType }[] = [
|
|
83
|
-
{ coinName: 'btc', keyType: 'independent' },
|
|
84
|
-
{ coinName: 'sol', keyType: 'tss' },
|
|
85
|
-
{ coinName: 'eth', keyType: 'blsdkg' },
|
|
86
|
-
];
|
|
87
|
-
for (const testSet of testSets) {
|
|
88
|
-
it(`key type ${testSet.keyType}`, function () {
|
|
89
|
-
const userPub = 'pub012user';
|
|
90
|
-
const userMasterKey = 'userMasterKey';
|
|
91
|
-
const backupPub = 'pub345backup';
|
|
92
|
-
const backupMasterKey = 'backupMasterKey';
|
|
93
|
-
const bitgoPub = 'pub789bitgo';
|
|
94
|
-
const qrData = generateQrData({
|
|
95
|
-
backupKeychain: createKeychain({
|
|
96
|
-
commonKeychain: testSet.keyType === 'tss' ? backupPub : undefined,
|
|
97
|
-
commonPub: testSet.keyType === 'blsdkg' ? backupPub : undefined,
|
|
98
|
-
pub: testSet.keyType === 'independent' ? backupPub : undefined,
|
|
99
|
-
type: testSet.keyType,
|
|
100
|
-
}),
|
|
101
|
-
backupMasterKey,
|
|
102
|
-
bitgoKeychain: createKeychain({
|
|
103
|
-
commonKeychain: testSet.keyType === 'tss' ? bitgoPub : undefined,
|
|
104
|
-
commonPub: testSet.keyType === 'blsdkg' ? bitgoPub : undefined,
|
|
105
|
-
pub: testSet.keyType === 'independent' ? bitgoPub : undefined,
|
|
106
|
-
type: testSet.keyType,
|
|
107
|
-
}),
|
|
108
|
-
coin: coins.get('btc'),
|
|
109
|
-
userKeychain: createKeychain({
|
|
110
|
-
commonKeychain: testSet.keyType === 'tss' ? userPub : undefined,
|
|
111
|
-
commonPub: testSet.keyType === 'blsdkg' ? userPub : undefined,
|
|
112
|
-
pub: testSet.keyType === 'independent' ? userPub : undefined,
|
|
113
|
-
type: testSet.keyType,
|
|
114
|
-
}),
|
|
115
|
-
userMasterKey,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
qrData.user.title.should.equal('A: Provided User Key');
|
|
119
|
-
qrData.user.description.should.equal('This is the public key you provided for your wallet.');
|
|
120
|
-
qrData.user.data.should.equal(userPub);
|
|
121
|
-
should.equal(qrData.user.publicMasterKey, userMasterKey);
|
|
122
|
-
|
|
123
|
-
assert(qrData.backup);
|
|
124
|
-
qrData.backup.title.should.equal('B: Provided Backup Key');
|
|
125
|
-
qrData.backup.description.should.equal('This is the public key you provided for your wallet.');
|
|
126
|
-
qrData.backup.data.should.equal(backupPub);
|
|
127
|
-
should.equal(qrData.backup?.publicMasterKey, backupMasterKey);
|
|
128
|
-
|
|
129
|
-
assert(qrData.bitgo);
|
|
130
|
-
qrData.bitgo.data.should.equal(bitgoPub);
|
|
131
|
-
|
|
132
|
-
should.not.exist(qrData.passcode);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('backup key from provider', function () {
|
|
138
|
-
const coin = coins.get('btc');
|
|
139
|
-
const userEncryptedPrv = 'prv123encrypted';
|
|
140
|
-
const backupPub = 'pub673backup';
|
|
141
|
-
const provider = '3rd Party Provider';
|
|
142
|
-
const bitgoPub = 'pub789bitgo';
|
|
143
|
-
const qrData = generateQrData({
|
|
144
|
-
backupKeychain: createKeychain({
|
|
145
|
-
pub: backupPub,
|
|
146
|
-
provider,
|
|
147
|
-
}),
|
|
148
|
-
backupKeyProvider: provider,
|
|
149
|
-
bitgoKeychain: createKeychain({
|
|
150
|
-
pub: bitgoPub,
|
|
151
|
-
}),
|
|
152
|
-
coin,
|
|
153
|
-
userKeychain: createKeychain({
|
|
154
|
-
encryptedPrv: userEncryptedPrv,
|
|
155
|
-
}),
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
qrData.user.data.should.equal(userEncryptedPrv);
|
|
159
|
-
|
|
160
|
-
assert(qrData.backup);
|
|
161
|
-
qrData.backup.title.should.equal('B: Backup Key');
|
|
162
|
-
qrData.backup.description.should.equal('This is the public key held at ' +
|
|
163
|
-
provider +
|
|
164
|
-
', an ' +
|
|
165
|
-
coin.name +
|
|
166
|
-
' recovery service. If you lose\r\nyour key, ' +
|
|
167
|
-
provider +
|
|
168
|
-
' will be able to sign transactions to recover funds.');
|
|
169
|
-
qrData.backup.data.should.equal(backupPub);
|
|
170
|
-
|
|
171
|
-
assert(qrData.bitgo);
|
|
172
|
-
qrData.bitgo.data.should.equal(bitgoPub);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('tss backup key held at BitGo Trust', function () {
|
|
176
|
-
const coin = coins.get('btc');
|
|
177
|
-
const userEncryptedPrv = 'prv123encrypted';
|
|
178
|
-
const provider = 'BitGoTrustAsKRS';
|
|
179
|
-
const backupKeyProvider = 'BitGo Trust';
|
|
180
|
-
const userToBackupKeyShare: ApiKeyShare = { from: 'user', to: 'backup', publicShare: 'userToBackupPublic', privateShare: 'userToBackupPrivate' };
|
|
181
|
-
const bitgoToBackupKeyShare: ApiKeyShare = { from: 'bitgo', to: 'backup', publicShare: 'bitgoToBackupPublic', privateShare: 'bitgoToBackupPrivate' };
|
|
182
|
-
const bitgoCommonKeychain = 'commonCommonBitGo';
|
|
183
|
-
const qrData = generateQrData({
|
|
184
|
-
backupKeychain: createKeychain({
|
|
185
|
-
provider,
|
|
186
|
-
keyShares: [userToBackupKeyShare, bitgoToBackupKeyShare],
|
|
187
|
-
type: 'tss',
|
|
188
|
-
}),
|
|
189
|
-
backupKeyProvider,
|
|
190
|
-
bitgoKeychain: createKeychain({
|
|
191
|
-
type: 'tss',
|
|
192
|
-
commonKeychain: bitgoCommonKeychain,
|
|
193
|
-
}),
|
|
194
|
-
coin,
|
|
195
|
-
userKeychain: createKeychain({
|
|
196
|
-
encryptedPrv: userEncryptedPrv,
|
|
197
|
-
type: 'tss',
|
|
198
|
-
}),
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
qrData.user.data.should.equal(userEncryptedPrv);
|
|
202
|
-
|
|
203
|
-
assert(qrData.backup);
|
|
204
|
-
qrData.backup.title.should.equal('B: Backup Key Shares');
|
|
205
|
-
qrData.backup.description.should.equal(`These are the key shares for ${backupKeyProvider}. If BitGo Inc. goes out of business,\r\ncontact ${backupKeyProvider} and they will help you recover your funds.`);
|
|
206
|
-
qrData.backup.data.should.equal(JSON.stringify([userToBackupKeyShare, bitgoToBackupKeyShare]));
|
|
207
|
-
|
|
208
|
-
assert(qrData.bitgo);
|
|
209
|
-
qrData.bitgo.title.should.equal('C: BitGo Public Key');
|
|
210
|
-
qrData.bitgo.description.should.equal('This is the public part of the key that BitGo will use to co-sign transactions\r\nwith you on your wallet.');
|
|
211
|
-
qrData.bitgo.data.should.equal(bitgoCommonKeychain);
|
|
212
|
-
});
|
|
213
|
-
});
|
package/test/unit/utils.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import 'should';
|
|
2
|
-
import { splitKeys } from '../../src';
|
|
3
|
-
|
|
4
|
-
describe('getSplitKeys', function () {
|
|
5
|
-
it('only returns one item when input shorter than limit', function () {
|
|
6
|
-
const key = 'hello world';
|
|
7
|
-
const limit = 20;
|
|
8
|
-
const keys = splitKeys(key, limit);
|
|
9
|
-
keys.length.should.equal(1);
|
|
10
|
-
keys[0].should.equal(key);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('splits key up into multiple items when exceeding the limit', function () {
|
|
14
|
-
const key = 'hello world this is a short message';
|
|
15
|
-
const limit = 5;
|
|
16
|
-
const keys = splitKeys(key, limit);
|
|
17
|
-
keys.length.should.equal(7);
|
|
18
|
-
for (const splitKey of keys.slice(0, keys.length - 1)) {
|
|
19
|
-
splitKey.length.should.equal(limit);
|
|
20
|
-
}
|
|
21
|
-
keys[keys.length - 1].length.should.be.lessThanOrEqual(limit);
|
|
22
|
-
keys[0].should.equal('hello');
|
|
23
|
-
keys[1].should.equal(' worl');
|
|
24
|
-
keys[2].should.equal('d thi');
|
|
25
|
-
keys[3].should.equal('s is ');
|
|
26
|
-
keys[4].should.equal('a sho');
|
|
27
|
-
keys[5].should.equal('rt me');
|
|
28
|
-
keys[6].should.equal('ssage');
|
|
29
|
-
});
|
|
30
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src/**/*"],
|
|
8
|
-
"exclude": ["node_modules"],
|
|
9
|
-
"references": [
|
|
10
|
-
{
|
|
11
|
-
"path": "../statics"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"path": "../sdk-api"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "../sdk-core"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|