diff --git a/client/package.json b/client/package.json index c155af5cd..12f2ace05 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@nimiq/keyguard-client", - "version": "0.2.5-beta.3", + "version": "0.2.6-beta.3", "description": "Nimiq Keyguard client library", "main": "dist/KeyguardClient.common.js", "module": "dist/KeyguardClient.es.js", diff --git a/client/src/PublicRequest.ts b/client/src/PublicRequest.ts index a8c12073b..2bce91a45 100644 --- a/client/src/PublicRequest.ts +++ b/client/src/PublicRequest.ts @@ -12,6 +12,8 @@ export type SingleKeyResult = { keyPath: string, address: Uint8Array, }>; + fileExported: boolean; + wordsExported: boolean; }; export type TransactionInfo = { @@ -74,8 +76,8 @@ export type ExportRequest = SimpleRequest & { }; export type ExportResult = { - file: boolean, - words: boolean, + fileExported: boolean, + wordsExported: boolean, }; export type SignTransactionRequest = SimpleRequest & TransactionInfo & { diff --git a/src/request/create/Create.js b/src/request/create/Create.js index 53a2d4e23..d4e4fbdf8 100644 --- a/src/request/create/Create.js +++ b/src/request/create/Create.js @@ -114,6 +114,8 @@ class Create { address: key.deriveAddress(keyPath).serialize(), keyPath, }], + fileExported: false, + wordsExported: false, }]; this._resolve(result); diff --git a/src/request/export/Export.js b/src/request/export/Export.js index f9a9b71d6..c8a630247 100644 --- a/src/request/export/Export.js +++ b/src/request/export/Export.js @@ -23,8 +23,8 @@ class Export { // eslint-disable-line no-unused-vars this._reject = reject; this.exported = { - words: false, - file: false, + wordsExported: false, + fileExported: false, }; this._exportWordsHandler = new ExportWords(request, @@ -53,7 +53,7 @@ class Export { // eslint-disable-line no-unused-vars * @param {KeyguardRequest.SimpleResult} fileResult */ _fileExportSuccessful(fileResult) { - this.exported.file = fileResult.success; + this.exported.fileExported = fileResult.success; this._exportWordsHandler.run(); } @@ -62,7 +62,7 @@ class Export { // eslint-disable-line no-unused-vars * @param {KeyguardRequest.SimpleResult} wordsResult */ _wordsExportSuccessful(wordsResult) { - this.exported.words = wordsResult.success; + this.exported.wordsExported = wordsResult.success; this._resolve(this.exported); } } diff --git a/src/request/import/ImportFile.js b/src/request/import/ImportFile.js index 7bfb4fec8..a72392510 100644 --- a/src/request/import/ImportFile.js +++ b/src/request/import/ImportFile.js @@ -150,6 +150,8 @@ class ImportFile { keyId: /** @type {number} */ (key.id), keyType: key.type, addresses, + fileExported: true, + wordsExported: false, }]; this._resolve(result); diff --git a/src/request/import/ImportWords.js b/src/request/import/ImportWords.js index 76023a9c7..3233e2140 100644 --- a/src/request/import/ImportWords.js +++ b/src/request/import/ImportWords.js @@ -116,6 +116,9 @@ class ImportWords { ); downloadLoginFile.on(DownloadLoginFile.Events.DOWNLOADED, () => { + for (let i = 0; i < this._keyResults.length; i++) { + this._keyResults[i].fileExported = true; + } this._resolve(this._keyResults); }); window.location.hash = ImportWords.Pages.DOWNLOAD_LOGINFILE; @@ -180,18 +183,23 @@ class ImportWords { try { if (this._secrets.entropy) { const key = new Key(this._secrets.entropy, false); + /** @type {{keyPath: string, address: Uint8Array}[]} */ const addresses = this._request.requestedKeyPaths.map(keyPath => ({ keyPath, address: key.deriveAddress(keyPath).serialize(), })); + /** @type {KeyguardRequest.SingleKeyResult} */ const result = { keyId: await KeyStore.instance.put(key, encryptionKey || undefined), keyType: Nimiq.Secret.Type.ENTROPY, addresses, + fileExported: false, + wordsExported: true, }; this._keyResults.push(result); + const secretString = Nimiq.BufferUtils.toBase64(key.secret.serialize()); sessionStorage.setItem(ImportApi.SESSION_STORAGE_KEY_PREFIX + result.keyId, secretString); @@ -208,6 +216,8 @@ class ImportWords { } if (this._secrets.privateKey) { const key = new Key(this._secrets.privateKey, false); + + /** @type {KeyguardRequest.SingleKeyResult} */ const result = { keyId: await KeyStore.instance.put(key, encryptionKey || undefined), keyType: Nimiq.Secret.Type.PRIVATE_KEY, @@ -215,6 +225,8 @@ class ImportWords { keyPath: Constants.LEGACY_DERIVATION_PATH, address: key.deriveAddress(Constants.LEGACY_DERIVATION_PATH).serialize(), }], + fileExported: false, + wordsExported: true, }; this._keyResults.push(result); } else {