@tari-project/ootle-wallet-daemon-signer 0.11.1 → 0.12.0
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/README.md +8 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +53 -32
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -33,6 +33,14 @@ import { WalletDaemonSigner } from "@tari-project/ootle-wallet-daemon-signer";
|
|
|
33
33
|
const signer = await WalletDaemonSigner.connect({ url: "http://localhost:18103" });
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
Enrolling the wallet's first passkey needs the daemon's one-time setup token, which
|
|
37
|
+
`tari_ootle_walletd` prints at startup and writes to `<base_path>/setup_token`. Pass it
|
|
38
|
+
as `setupToken` until a passkey is enrolled:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const signer = await WalletDaemonSigner.connect({ url: "http://localhost:18103", setupToken });
|
|
42
|
+
```
|
|
43
|
+
|
|
36
44
|
### Node
|
|
37
45
|
|
|
38
46
|
WebAuthn is browser-only. If the daemon is configured for `method: "webauthn"`
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export declare interface AuthOptions {
|
|
|
29
29
|
permissions?: Permission[];
|
|
30
30
|
/** Application name used as the WebAuthn username/identifier. Defaults to `"tari-wallet-sdk"`. */
|
|
31
31
|
appName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* One-time setup token for enrolling the wallet's first passkey. `tari_ootle_walletd` prints it at
|
|
34
|
+
* startup and writes it to `<base_path>/setup_token`. Needed only while the wallet has no passkey.
|
|
35
|
+
*/
|
|
36
|
+
setupToken?: string;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export { WalletDaemonClient }
|
package/dist/index.js
CHANGED
|
@@ -148,6 +148,12 @@ var l = class e3 {
|
|
|
148
148
|
accountsCreate(e4) {
|
|
149
149
|
return this.sendRequest("accounts.create", e4);
|
|
150
150
|
}
|
|
151
|
+
accountsImportViewOnly(e4) {
|
|
152
|
+
return this.sendRequest("accounts.import_view_only", e4);
|
|
153
|
+
}
|
|
154
|
+
accountsExportViewKey(e4) {
|
|
155
|
+
return this.sendRequest("accounts.export_view_key", e4);
|
|
156
|
+
}
|
|
151
157
|
accountsRename(e4) {
|
|
152
158
|
return this.sendRequest("accounts.rename", e4);
|
|
153
159
|
}
|
|
@@ -322,6 +328,15 @@ var l = class e3 {
|
|
|
322
328
|
webauthnAuthStart(e4) {
|
|
323
329
|
return this.sendRequest("webauthn.auth_start", e4);
|
|
324
330
|
}
|
|
331
|
+
webauthnListPasskeys(e4 = {}) {
|
|
332
|
+
return this.sendRequest("webauthn.list_passkeys", e4);
|
|
333
|
+
}
|
|
334
|
+
webauthnRenamePasskey(e4) {
|
|
335
|
+
return this.sendRequest("webauthn.rename_passkey", e4);
|
|
336
|
+
}
|
|
337
|
+
webauthnRemovePasskey(e4) {
|
|
338
|
+
return this.sendRequest("webauthn.remove_passkey", e4);
|
|
339
|
+
}
|
|
325
340
|
stealthUtxosList(e4) {
|
|
326
341
|
return this.sendRequest("stealth_utxos.list", e4);
|
|
327
342
|
}
|
|
@@ -413,55 +428,59 @@ async function p(t2, n2) {
|
|
|
413
428
|
case "none":
|
|
414
429
|
return t2.authRequest(r2, "None");
|
|
415
430
|
case "webauthn":
|
|
416
|
-
return m(t2, i3, r2);
|
|
431
|
+
return m(t2, i3, r2, n2 == null ? void 0 : n2.setupToken);
|
|
417
432
|
default:
|
|
418
433
|
throw new e(`Unsupported wallet daemon auth method: ${a2}. Configure the daemon for one of: "none" or "webauthn", and pass that value to WalletDaemonSigner.connect.`);
|
|
419
434
|
}
|
|
420
435
|
}
|
|
421
|
-
async function m(t2, n2, r2) {
|
|
436
|
+
async function m(t2, n2, r2, i3) {
|
|
422
437
|
if (globalThis.navigator === void 0 || !globalThis.navigator.credentials) throw new e("WebAuthn is browser-only. Run in a browser, or pass `authToken` explicitly to `WalletDaemonSigner.connect({ url, authToken })` from Node.");
|
|
423
|
-
let { registered:
|
|
424
|
-
return
|
|
438
|
+
let { registered: a2 } = await t2.webauthnAlreadyRegistered({});
|
|
439
|
+
return a2 ? h(t2, r2) : g(t2, n2, i3);
|
|
425
440
|
}
|
|
426
|
-
async function h(t2, n2
|
|
441
|
+
async function h(t2, n2) {
|
|
427
442
|
var _a;
|
|
428
|
-
let
|
|
429
|
-
if (!
|
|
430
|
-
let
|
|
431
|
-
if (!((_a =
|
|
432
|
-
let { publicKey:
|
|
443
|
+
let r2 = await t2.webauthnAuthStart({});
|
|
444
|
+
if (!r2.challenge) throw new e("WebAuthn auth start: missing challenge");
|
|
445
|
+
let i3 = r2.challenge;
|
|
446
|
+
if (!((_a = i3.publicKey) == null ? void 0 : _a.challenge)) throw new e("WebAuthn auth start: malformed challenge response");
|
|
447
|
+
let { publicKey: a2 } = i3, o2 = f(a2.challenge), s2 = (a2.allowCredentials ?? []).map((e4) => ({
|
|
433
448
|
id: f(e4.id),
|
|
434
449
|
type: e4.type
|
|
435
|
-
})),
|
|
436
|
-
challenge:
|
|
437
|
-
allowCredentials:
|
|
450
|
+
})), c2 = await navigator.credentials.get({ publicKey: {
|
|
451
|
+
challenge: o2,
|
|
452
|
+
allowCredentials: s2,
|
|
438
453
|
timeout: 6e4,
|
|
439
454
|
userVerification: "required"
|
|
440
455
|
} });
|
|
441
|
-
if (!
|
|
442
|
-
return t2.authRequest(
|
|
443
|
-
session_id:
|
|
444
|
-
credential:
|
|
456
|
+
if (!c2) throw new e("WebAuthn authentication was cancelled");
|
|
457
|
+
return t2.authRequest(n2, { WebAuthN: {
|
|
458
|
+
session_id: r2.session_id,
|
|
459
|
+
credential: c2
|
|
445
460
|
} });
|
|
446
461
|
}
|
|
447
|
-
async function g(t2, n2) {
|
|
462
|
+
async function g(t2, n2, r2) {
|
|
448
463
|
var _a, _b, _c;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
464
|
+
if (r2 === void 0) throw new e("The wallet daemon has no passkey yet, and enrolling the first one needs its one-time setup token. Pass `setupToken` to `WalletDaemonSigner.connect` (tari_ootle_walletd prints it at startup and writes it to `<base_path>/setup_token`).");
|
|
465
|
+
let i3 = await t2.webauthnStartRegistration({
|
|
466
|
+
username: n2,
|
|
467
|
+
setup_token: r2
|
|
468
|
+
});
|
|
469
|
+
if (!i3.public_key) throw new e("WebAuthn registration start: missing public_key");
|
|
470
|
+
let a2 = i3.public_key;
|
|
471
|
+
if (!a2.challenge) throw new e("WebAuthn registration start: malformed public_key response");
|
|
472
|
+
let o2 = f(a2.challenge), s2 = await navigator.credentials.create({ publicKey: {
|
|
454
473
|
rp: {
|
|
455
|
-
name: ((_a =
|
|
456
|
-
id: ((_b =
|
|
474
|
+
name: ((_a = a2.rp) == null ? void 0 : _a.name) ?? "Tari Wallet",
|
|
475
|
+
id: ((_b = a2.rp) == null ? void 0 : _b.id) ?? ((_c = globalThis.location) == null ? void 0 : _c.hostname)
|
|
457
476
|
},
|
|
458
477
|
user: {
|
|
459
478
|
id: Uint8Array.from(n2, (e4) => e4.charCodeAt(0)),
|
|
460
479
|
name: n2,
|
|
461
480
|
displayName: n2
|
|
462
481
|
},
|
|
463
|
-
challenge:
|
|
464
|
-
pubKeyCredParams:
|
|
482
|
+
challenge: o2,
|
|
483
|
+
pubKeyCredParams: a2.pubKeyCredParams ?? [
|
|
465
484
|
{
|
|
466
485
|
type: "public-key",
|
|
467
486
|
alg: -8
|
|
@@ -480,12 +499,14 @@ async function g(t2, n2) {
|
|
|
480
499
|
attestation: "none",
|
|
481
500
|
authenticatorSelection: { userVerification: "required" }
|
|
482
501
|
} });
|
|
483
|
-
if (!
|
|
484
|
-
let { token:
|
|
485
|
-
session_id:
|
|
486
|
-
credential:
|
|
502
|
+
if (!s2) throw new e("WebAuthn registration was cancelled");
|
|
503
|
+
let { token: c2 } = await t2.webauthnFinishRegistration({
|
|
504
|
+
session_id: i3.session_id,
|
|
505
|
+
credential: s2,
|
|
506
|
+
setup_token: r2
|
|
487
507
|
});
|
|
488
|
-
|
|
508
|
+
if (!c2) throw new e("WebAuthn registration finish: the daemon returned no token");
|
|
509
|
+
return c2;
|
|
489
510
|
}
|
|
490
511
|
var _ = class i2 {
|
|
491
512
|
constructor(e4) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/ootle-wallet-daemon-signer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/tari-project/ootle.ts.git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tari-project/ootle-ts-bindings": "^1.
|
|
29
|
-
"@tari-project/wallet_jrpc_client": "^1.
|
|
30
|
-
"@tari-project/ootle": "0.
|
|
28
|
+
"@tari-project/ootle-ts-bindings": "^1.62.0",
|
|
29
|
+
"@tari-project/wallet_jrpc_client": "^1.28.0",
|
|
30
|
+
"@tari-project/ootle": "0.12.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@microsoft/api-extractor": "^7.57.7",
|