@bitgo-beta/key-card 0.1.2-alpha.9 → 0.1.2-alpha.91

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.
@@ -0,0 +1,60 @@
1
+ import { Keychain } from '@bitgo-beta/sdk-core';
2
+ import { BaseCoin, KeyCurve } from '@bitgo-beta/statics';
3
+ export interface GenerateQrDataBaseParams {
4
+ activationCode?: string;
5
+ keyCardImage?: HTMLImageElement;
6
+ walletLabel: string;
7
+ }
8
+ export interface GenerateQrDataForKeychainParams {
9
+ bitgoKeychain: Keychain;
10
+ curve: KeyCurve;
11
+ }
12
+ export interface GenerateQrDataParams {
13
+ backupKeychain: Keychain;
14
+ backupKeyProvider?: string;
15
+ backupMasterKey?: string;
16
+ /**
17
+ * @description The key used to derive the backup key using {@link backupMasterKey} as the seed.
18
+ */
19
+ backupMasterPublicKey?: string;
20
+ bitgoKeychain: Keychain;
21
+ coin: Readonly<BaseCoin>;
22
+ passcodeEncryptionCode?: string;
23
+ passphrase?: string;
24
+ userKeychain: Keychain;
25
+ userMasterKey?: string;
26
+ /**
27
+ * @description The key used to derive the user key using {@link userMasterKey} as the seed.
28
+ */
29
+ userMasterPublicKey?: string;
30
+ }
31
+ export declare type GenerateKeycardParams = GenerateQrDataBaseParams & (GenerateQrDataForKeychainParams | GenerateQrDataParams);
32
+ export interface IDrawKeyCard {
33
+ activationCode?: string;
34
+ keyCardImage?: HTMLImageElement;
35
+ qrData: QrData;
36
+ questions: FAQ[];
37
+ walletLabel: string;
38
+ curve?: KeyCurve;
39
+ }
40
+ export interface FAQ {
41
+ question: string;
42
+ answer: string[];
43
+ }
44
+ export interface QrDataEntry {
45
+ data: string;
46
+ description: string;
47
+ title: string;
48
+ publicMasterKey?: string;
49
+ }
50
+ export declare type MasterPublicKeyQrDataEntry = Omit<QrDataEntry, 'publicMasterKey'>;
51
+ export interface QrData {
52
+ backup?: QrDataEntry;
53
+ backupMasterPublicKey?: MasterPublicKeyQrDataEntry;
54
+ bitgo?: QrDataEntry;
55
+ passcode?: QrDataEntry;
56
+ curve?: KeyCurve;
57
+ user: QrDataEntry;
58
+ userMasterPublicKey?: MasterPublicKeyQrDataEntry;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,+BAA+B;IAE9C,aAAa,EAAE,QAAQ,CAAC;IAExB,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IAEnC,cAAc,EAAE,QAAQ,CAAC;IAEzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,aAAa,EAAE,QAAQ,CAAC;IAExB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAIzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAIhC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,EAAE,QAAQ,CAAC;IAEvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,oBAAY,qBAAqB,GAAG,wBAAwB,GAAG,CAAC,+BAA+B,GAAG,oBAAoB,CAAC,CAAC;AAExH,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,GAAG,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,oBAAY,0BAA0B,GAAG,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAE9E,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;IACnD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,0BAA0B,CAAC;CAClD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEtleWNoYWluIH0gZnJvbSAnQGJpdGdvLWJldGEvc2RrLWNvcmUnO1xuaW1wb3J0IHsgQmFzZUNvaW4sIEtleUN1cnZlIH0gZnJvbSAnQGJpdGdvLWJldGEvc3RhdGljcyc7XG5cbmV4cG9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2aWR1YWwgbGluZXMgb2YgdGV4dFxuICBhbnN3ZXI6IHN0cmluZ1tdO1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIFFyRGF0YUVudHJ5IHtcbiAgZGF0YTogc3RyaW5nO1xuICBkZXNjcmlwdGlvbjogc3RyaW5nO1xuICB0aXRsZTogc3RyaW5nO1xuICBwdWJsaWNNYXN0ZXJLZXk/OiBzdHJpbmc7XG59XG5cbmV4cG9ydCB0eXBlIE1hc3RlclB1YmxpY0tleVFyRGF0YUVudHJ5ID0gT21pdDxRckRhdGFFbnRyeSwgJ3B1YmxpY01hc3RlcktleSc+O1xuXG5leHBvcnQgaW50ZXJmYWNlIFFyRGF0YSB7XG4gIGJhY2t1cD86IFFyRGF0YUVudHJ5O1xuICBiYWNrdXBNYXN0ZXJQdWJsaWNLZXk/OiBNYXN0ZXJQdWJsaWNLZXlRckRhdGFFbnRyeTtcbiAgYml0Z28/OiBRckRhdGFFbnRyeTtcbiAgcGFzc2NvZGU/OiBRckRhdGFFbnRyeTtcbiAgY3VydmU/OiBLZXlDdXJ2ZTtcbiAgdXNlcjogUXJEYXRhRW50cnk7XG4gIHVzZXJNYXN0ZXJQdWJsaWNLZXk/OiBNYXN0ZXJQdWJsaWNLZXlRckRhdGFFbnRyeTtcbn1cbiJdfQ==
@@ -0,0 +1,2 @@
1
+ export declare function splitKeys(key: string, limit: number): string[];
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAc9D"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitKeys = void 0;
4
+ function splitKeys(key, limit) {
5
+ if (key.length <= limit) {
6
+ return [key];
7
+ }
8
+ const keys = [];
9
+ let rightIndex = limit;
10
+ for (let i = 0; i < key.length; i += limit) {
11
+ keys.push(key.substring(i, rightIndex));
12
+ rightIndex = Math.min(rightIndex + limit, key.length);
13
+ }
14
+ return keys;
15
+ }
16
+ exports.splitKeys = splitKeys;
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsU0FBZ0IsU0FBUyxDQUFDLEdBQVcsRUFBRSxLQUFhO0lBQ2xELElBQUksR0FBRyxDQUFDLE1BQU0sSUFBSSxLQUFLLEVBQUU7UUFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0tBQ2Q7SUFFRCxNQUFNLElBQUksR0FBYSxFQUFFLENBQUM7SUFFMUIsSUFBSSxVQUFVLEdBQUcsS0FBSyxDQUFDO0lBQ3ZCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxHQUFHLENBQUMsTUFBTSxFQUFFLENBQUMsSUFBSSxLQUFLLEVBQUU7UUFDMUMsSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxVQUFVLENBQUMsQ0FBQyxDQUFDO1FBQ3hDLFVBQVUsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLFVBQVUsR0FBRyxLQUFLLEVBQUUsR0FBRyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0tBQ3ZEO0lBRUQsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDO0FBZEQsOEJBY0MiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gc3BsaXRLZXlzKGtleTogc3RyaW5nLCBsaW1pdDogbnVtYmVyKTogc3RyaW5nW10ge1xuICBpZiAoa2V5Lmxlbmd0aCA8PSBsaW1pdCkge1xuICAgIHJldHVybiBba2V5XTtcbiAgfVxuXG4gIGNvbnN0IGtleXM6IHN0cmluZ1tdID0gW107XG5cbiAgbGV0IHJpZ2h0SW5kZXggPSBsaW1pdDtcbiAgZm9yIChsZXQgaSA9IDA7IGkgPCBrZXkubGVuZ3RoOyBpICs9IGxpbWl0KSB7XG4gICAga2V5cy5wdXNoKGtleS5zdWJzdHJpbmcoaSwgcmlnaHRJbmRleCkpO1xuICAgIHJpZ2h0SW5kZXggPSBNYXRoLm1pbihyaWdodEluZGV4ICsgbGltaXQsIGtleS5sZW5ndGgpO1xuICB9XG5cbiAgcmV0dXJuIGtleXM7XG59XG4iXX0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo-beta/key-card",
3
- "version": "0.1.2-alpha.9",
3
+ "version": "0.1.2-alpha.91",
4
4
  "description": "key card generator for BitGo wallets",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -33,14 +33,14 @@
33
33
  ]
34
34
  },
35
35
  "dependencies": {
36
- "@bitgo-beta/sdk-api": "1.6.1-alpha.30",
37
- "@bitgo-beta/sdk-core": "2.4.1-alpha.30",
38
- "@bitgo-beta/statics": "10.0.1-alpha.30",
36
+ "@bitgo-beta/sdk-api": "1.6.1-alpha.112",
37
+ "@bitgo-beta/sdk-core": "2.4.1-alpha.112",
38
+ "@bitgo-beta/statics": "10.0.1-alpha.112",
39
39
  "jspdf": "^2.5.1",
40
40
  "qrcode": "^1.5.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/qrcode": "1.5.0"
44
44
  },
45
- "gitHead": "864c3f83d02299f9a68da6cc94aee428280bd958"
45
+ "gitHead": "3d8245ab9153b14cc556ea72c9be91b3d1a8546c"
46
46
  }
package/.mocharc.js DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- require: 'ts-node/register',
5
- reporter: 'min',
6
- 'reporter-option': ['cdn=true', 'json=false'],
7
- exit: true,
8
- spec: ['test/unit/*.ts'],
9
- };
package/CHANGELOG.md DELETED
@@ -1,32 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.1.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/key-card@0.1.0...@bitgo/key-card@0.1.1) (2023-02-17)
7
-
8
- **Note:** Version bump only for package @bitgo/key-card
9
-
10
-
11
-
12
-
13
-
14
- # 0.1.0 (2023-02-16)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * **key-card:** fix errors in key-card drawing code ([092bc0a](https://github.com/BitGo/BitGoJS/commit/092bc0a4b851d6cf9d396e8eb5af476b4c52954d))
20
- * **key-card:** reduce size of QR codes ([c8e08b8](https://github.com/BitGo/BitGoJS/commit/c8e08b8ca007bd45cb0628c5a06a80b81f5a308e))
21
- * **root:** manually fix up incorrect versions ([3b1d28a](https://github.com/BitGo/BitGoJS/commit/3b1d28a8a4925e6dc1d89bb7482ea3b2f52b7b95))
22
-
23
-
24
- ### Features
25
-
26
- * **key-card:** add basic code to generate key cards ([83b01fc](https://github.com/BitGo/BitGoJS/commit/83b01fc5c31801e4f8db1166b06f2b8e7de3183f))
27
- * **key-card:** add code to select qrData ([8b0e814](https://github.com/BitGo/BitGoJS/commit/8b0e814e54d9e33c41e5459d4fc69dac7b7d7737))
28
- * **key-card:** add function to generate key card faqs ([749798d](https://github.com/BitGo/BitGoJS/commit/749798d184153e8257a7926f62e6c72420c31bc8))
29
- * **key-card:** add support for qrcodes ([d79b9f7](https://github.com/BitGo/BitGoJS/commit/d79b9f7192dcabe9a7a1d5c261b799b5cbedb6f7))
30
- * **key-card:** add utils function to split keys ([3547b19](https://github.com/BitGo/BitGoJS/commit/3547b194b49a50da8901b8d76c5f9a96c2f9c994))
31
- * **key-card:** change contents of Boxes B & C for SMHA wallets ([2c27cd0](https://github.com/BitGo/BitGoJS/commit/2c27cd055bcdeb1a1a444d204298a8adb1d7a1c8))
32
- * **key-card:** support BitGo Trust holding TSS backup key ([6cb8f94](https://github.com/BitGo/BitGoJS/commit/6cb8f94a4916a211f73c774ee9d94f6fdf6e6650))
@@ -1,240 +0,0 @@
1
- import { jsPDF } from 'jspdf';
2
- import * as QRCode from 'qrcode';
3
- import { FAQ } from './faq';
4
- import { QrData } from './generateQrData';
5
- import { splitKeys } from './utils';
6
-
7
- // Max for Binary/Byte Data https://github.com/soldair/node-qrcode#qr-code-capacity
8
- // the largest theoretically possible value is actually 2953 but the QR codes get so dense that scanning them with a
9
- // phone (off of a printed page) doesn't work anymore
10
- // this limitation was chosen by trial and error
11
- export const QRBinaryMaxLength = 1500;
12
-
13
- const font = {
14
- header: 24,
15
- subheader: 15,
16
- body: 12,
17
- };
18
-
19
- const color = {
20
- black: '#000000',
21
- darkgray: '#4c4c4c',
22
- gray: '#9b9b9b',
23
- red: '#e21e1e',
24
- };
25
-
26
- const margin = 30;
27
-
28
- // Helpers for data formatting / positioning on the paper
29
- function left(x: number): number {
30
- return margin + x;
31
- }
32
- function moveDown(y: number, ydelta: number): number {
33
- return y + ydelta;
34
- }
35
-
36
- function drawOnePageOfQrCodes(qrImages: HTMLCanvasElement[], doc: jsPDF, y: number, qrSize: number, startIndex): number {
37
- doc.setFont('helvetica');
38
- let qrIndex: number = startIndex;
39
- for (; qrIndex < qrImages.length; qrIndex++) {
40
- const image = qrImages[qrIndex];
41
- const textBuffer = 15;
42
- if (y + qrSize + textBuffer >= doc.internal.pageSize.getHeight()) {
43
- return qrIndex;
44
- }
45
-
46
- doc.addImage(image, left(0), y, qrSize, qrSize);
47
-
48
- if (qrImages.length === 1) {
49
- return qrIndex + 1;
50
- }
51
-
52
- y = moveDown(y, qrSize + textBuffer);
53
- doc.setFontSize(font.body).setTextColor(color.black);
54
- doc.text('Part ' + (qrIndex + 1).toString(), left(0), y);
55
- y = moveDown(y, 20);
56
- }
57
- return qrIndex + 1;
58
- }
59
-
60
- export async function drawKeycard({ activationCode, questions, keyCardImage, qrData, walletLabel }: {
61
- activationCode?: string;
62
- keyCardImage?: HTMLImageElement;
63
- qrData: QrData;
64
- questions: FAQ[];
65
- walletLabel: string;
66
- }): Promise<jsPDF> {
67
- // document details
68
- const width = 8.5 * 72;
69
- let y = 0;
70
-
71
- // Create the PDF instance
72
- const doc = new jsPDF('portrait', 'pt', 'letter'); // jshint ignore:line
73
- doc.setFont('helvetica');
74
-
75
- // PDF Header Area - includes the logo and company name
76
- // This is data for the BitGo logo in the top left of the PDF
77
- y = moveDown(y, 30);
78
-
79
- if (keyCardImage) {
80
- doc.addImage(keyCardImage, left(0), y, 303, 40);
81
- }
82
-
83
- // Activation Code
84
- if (activationCode) {
85
- y = moveDown(y, 8);
86
- doc.setFontSize(font.body).setTextColor(color.gray);
87
- doc.text('Activation Code', left(460), y);
88
- }
89
- doc.setFontSize(font.header).setTextColor(color.black);
90
- y = moveDown(y, 25);
91
- doc.text('KeyCard', left(325), y - 1);
92
- if (activationCode) {
93
- doc.setFontSize(font.header).setTextColor(color.gray);
94
- doc.text(activationCode, left(460), y);
95
- }
96
-
97
- // Subheader
98
- // titles
99
- const date = new Date().toDateString();
100
- y = moveDown(y, margin);
101
- doc.setFontSize(font.body).setTextColor(color.gray);
102
- doc.text('Created on ' + date + ' for wallet named:', left(0), y);
103
- // copy
104
- y = moveDown(y, 25);
105
- doc.setFontSize(font.subheader).setTextColor(color.black);
106
- doc.text(walletLabel, left(0), y);
107
- // Red Bar
108
- y = moveDown(y, 20);
109
- doc.setFillColor(255, 230, 230);
110
- doc.rect(left(0), y, width - 2 * margin, 32, 'F');
111
-
112
- // warning message
113
- y = moveDown(y, 20);
114
- doc.setFontSize(font.body).setTextColor(color.red);
115
- doc.text('Print this document, or keep it securely offline. See below for FAQ.', left(75), y);
116
-
117
- // Generate the first page's data for the backup PDF
118
- y = moveDown(y, 35);
119
- const qrSize = 130;
120
-
121
- const qrKeys = ['user', 'passcode', 'backup', 'bitgo'];
122
- for (let index = 0; index < qrKeys.length; index++) {
123
- const name = qrKeys[index];
124
- if (index === 2) {
125
- // Add 2nd Page
126
- doc.addPage();
127
-
128
- // 2nd page title
129
- y = 30;
130
- }
131
-
132
- const qr = qrData[name];
133
- let topY = y;
134
- const textLeft = left(qrSize + 15);
135
- let textHeight = 0;
136
-
137
- const qrImages: HTMLCanvasElement[] = [];
138
- const keys = splitKeys(qr.data, QRBinaryMaxLength);
139
- for (const key of keys) {
140
- qrImages.push(await QRCode.toCanvas(key, { errorCorrectionLevel: 'L' }));
141
- }
142
-
143
- let nextQrIndex = drawOnePageOfQrCodes(qrImages, doc, y, qrSize, 0);
144
-
145
- doc.setFontSize(font.subheader).setTextColor(color.black);
146
- y = moveDown(y, 10);
147
- textHeight += 10;
148
- doc.text(qr.title, textLeft, y);
149
- textHeight += doc.getLineHeight();
150
- y = moveDown(y, 15);
151
- textHeight += 15;
152
- doc.setFontSize(font.body).setTextColor(color.darkgray);
153
- doc.text(qr.description, textLeft, y);
154
- textHeight += doc.getLineHeight();
155
- doc.setFontSize(font.body - 2);
156
- if (qr?.data?.length > QRBinaryMaxLength) {
157
- y = moveDown(y, 30);
158
- textHeight += 30;
159
- doc.text('Note: you will need to put all Parts together for the full key', textLeft, y);
160
- }
161
- y = moveDown(y, 30);
162
- textHeight += 30;
163
- doc.text('Data:', textLeft, y);
164
- textHeight += doc.getLineHeight();
165
- y = moveDown(y, 15);
166
- textHeight += 15;
167
- const width = 72 * 8.5 - textLeft - 30;
168
- doc.setFont('courier').setFontSize(9).setTextColor(color.black);
169
- const lines = doc.splitTextToSize(qr.data, width);
170
- const buffer = 10;
171
- for (let line = 0; line < lines.length; line++) {
172
- // add new page if data does not fit on one page
173
- if (y + buffer >= doc.internal.pageSize.getHeight()) {
174
- doc.addPage();
175
- textHeight = 0;
176
- y = 30;
177
- topY = y;
178
- nextQrIndex = drawOnePageOfQrCodes(qrImages, doc, y, qrSize, nextQrIndex);
179
- doc.setFont('courier').setFontSize(9).setTextColor(color.black);
180
- }
181
- doc.text(lines[line], textLeft, y);
182
- if (line !== lines.length - 1) {
183
- y = moveDown(y, buffer);
184
- textHeight += buffer;
185
- }
186
- }
187
-
188
- // Add public key if exists
189
- if (qr.publicMasterKey) {
190
- const text = 'Key Id: ' + qr.publicMasterKey;
191
-
192
- // Gray bar
193
- y = moveDown(y, 20);
194
- textHeight += 20;
195
- doc.setFillColor(247, 249, 249); // Gray background
196
- doc.setDrawColor(0, 0, 0); // Border
197
-
198
- // Leave a bit of space for the side of the rectangle.
199
- const splitKeyId = doc.splitTextToSize(text, width - 10);
200
-
201
- // The height of the box must be at least 15 px (for single line case), or
202
- // a multiple of 13 for each line. This allows for proper padding.
203
- doc.rect(textLeft, y, width, Math.max(12 * splitKeyId.length, 15), 'FD');
204
- textHeight += splitKeyId.length * doc.getLineHeight();
205
- doc.text(splitKeyId, textLeft + 5, y + 10);
206
- }
207
-
208
- doc.setFont('helvetica');
209
- // Move down the size of the QR code minus accumulated height on the right side, plus margin
210
- // if we have a key that spans multiple pages, then exclude QR code size
211
- const rowHeight = Math.max(qr.data.length > QRBinaryMaxLength ? qrSize + 20 : qrSize, textHeight);
212
- const marginBottom = 15;
213
- y = moveDown(y, rowHeight - (y - topY) + marginBottom);
214
- }
215
-
216
- // Add next Page
217
- doc.addPage();
218
-
219
- // next pages title
220
- y = 0;
221
- y = moveDown(y, 55);
222
- doc.setFontSize(font.header).setTextColor(color.black);
223
- doc.text('BitGo KeyCard FAQ', left(0), y);
224
-
225
- // Generate the second page's data for the backup PDF
226
- y = moveDown(y, 30);
227
- questions.forEach(function (q) {
228
- doc.setFontSize(font.subheader).setTextColor(color.black);
229
- doc.text(q.question, left(0), y);
230
- y = moveDown(y, 20);
231
- doc.setFontSize(font.body).setTextColor(color.darkgray);
232
- q.answer.forEach(function (line) {
233
- doc.text(line, left(0), y);
234
- y = moveDown(y, font.body + 3);
235
- });
236
- y = moveDown(y, 22);
237
- });
238
-
239
- return doc;
240
- }
package/src/faq.ts DELETED
@@ -1,82 +0,0 @@
1
- export interface FAQ {
2
- question: string;
3
- // the answer to the question, already split into individual lines of text
4
- answer: string[];
5
- }
6
-
7
- export function generateFaq(coinName: string): FAQ[] {
8
- const sectionACoinSpecific =
9
- `The KeyCard contains important information which can be used to recover the ${coinName} `;
10
- const sectionBCoinSpecific =
11
- `If you have lost or damaged all copies of your KeyCard, your ${coinName} is still safe, but this `;
12
- const sectionCCoinSpecific =
13
- `source tools at https://github.com/bitgo to recover your ${coinName}. Note: You should never enter `;
14
- const sectionDCoinSpecific =
15
- `your KeyCard will be able to steal your ${coinName}. We recommend keeping your wallet password `;
16
-
17
- return [
18
- {
19
- question: 'What is the KeyCard?',
20
- answer: [
21
- sectionACoinSpecific,
22
- 'from your wallet in several situations. Each BitGo wallet has its own, unique KeyCard. ',
23
- 'If you have created multiple wallets, you should retain the KeyCard for each of them.',
24
- ],
25
- },
26
- {
27
- question: 'What should I do with it?',
28
- answer: [
29
- 'You should print the KeyCard and/or save the PDF to an offline storage device. The print-out ',
30
- "or USB stick should be kept in a safe place, such as a bank vault or home safe. It's a good idea ",
31
- 'to keep a second copy in a different location.',
32
- '',
33
- "Important: If you haven't provided an external backup key, then the original PDF should be ",
34
- 'deleted from any machine where the wallet will be regularly accessed to prevent malware from ',
35
- 'capturing both the KeyCard and your wallet passcode.',
36
- ],
37
- },
38
- {
39
- question: 'What should I do if I lose it?',
40
- answer: [
41
- sectionBCoinSpecific,
42
- 'Wallet should be considered at risk for loss. As soon as is convenient, you should use BitGo ',
43
- 'to empty the wallet into a new wallet and discontinue use of the old wallet.',
44
- ],
45
- },
46
- {
47
- question: 'What if someone sees my KeyCard?',
48
- answer: [
49
- "Don't panic! All sensitive information on the KeyCard is encrypted with your passcode, or with a",
50
- 'key which only BitGo has. But, in general, you should make best efforts to keep your ',
51
- 'KeyCard private. If your KeyCard does get exposed or copied in a way that makes you ',
52
- 'uncomfortable, the best course of action is to empty the corresponding wallet into another ',
53
- 'wallet and discontinue use of the old wallet.',
54
- ],
55
- },
56
- {
57
- question: 'What if I forget or lose my wallet password?',
58
- answer: [
59
- 'BitGo can use the information in QR Code D to help you recover access to your wallet. ',
60
- 'Without the KeyCard, BitGo is not able to recover funds from a wallet with a lost password.',
61
- ],
62
- },
63
- {
64
- question: 'What if BitGo becomes inaccessible for an extended period?',
65
- answer: [
66
- "Your KeyCard and wallet passcode can be used together with BitGo's published open ",
67
- sectionCCoinSpecific,
68
- 'information from your KeyCard into tools other than the tools BitGo has published, or your ',
69
- 'funds may be at risk for theft.',
70
- ],
71
- },
72
- {
73
- question: 'Should I write my wallet password on my KeyCard?',
74
- answer: [
75
- "No! BitGo's signature scheme approach to security depends on there not being a single point ",
76
- 'of attack. But if your wallet password is on your KeyCard, then anyone who gains access to ',
77
- sectionDCoinSpecific,
78
- 'safe in a secure password manager such as LastPass, 1Password or KeePass.',
79
- ],
80
- },
81
- ];
82
- }
@@ -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
- }