@lightninglabs/wavelength-react 0.1.0 → 0.1.1-rc2
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 +2 -2
- package/package.json +2 -2
- package/dist/usePasskeyWallet.d.ts +0 -38
- package/dist/usePasskeyWallet.d.ts.map +0 -1
- package/dist/usePasskeyWallet.js +0 -65
package/README.md
CHANGED
|
@@ -64,5 +64,5 @@ verb-prefixed state, for example `useWalletSend()` returns
|
|
|
64
64
|
`{ send, sendPending, sendError, sendData, resetSend }`. `useWalletEngine()` is
|
|
65
65
|
the escape hatch for anything the hooks don't cover.
|
|
66
66
|
|
|
67
|
-
See the [
|
|
68
|
-
|
|
67
|
+
See the [hook reference](https://wavelength.lightning.engineering/reference/wavelength-react/)
|
|
68
|
+
in the documentation for the full surface.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightninglabs/wavelength-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-rc2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React provider and hooks for the Wavelength self-custodial Lightning wallet SDK.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lightninglabs/wavelength-core": "0.1.
|
|
37
|
+
"@lightninglabs/wavelength-core": "0.1.1-rc2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { OpenWalletFromPasskeyResult, PasskeyCeremony } from "@lightninglabs/walletdk-core";
|
|
2
|
-
/**
|
|
3
|
-
* Pairs the Go-side open result with the credential id that was used, so the app
|
|
4
|
-
* can persist it and scope future unlocks.
|
|
5
|
-
*/
|
|
6
|
-
export type PasskeyWalletOutcome = {
|
|
7
|
-
/** The result returned by opening the wallet from the passkey. */
|
|
8
|
-
result: OpenWalletFromPasskeyResult;
|
|
9
|
-
/** The credential id used in the ceremony, for persistence and scoping. */
|
|
10
|
-
credentialId: string;
|
|
11
|
-
};
|
|
12
|
-
/** The state and actions returned by {@link usePasskeyWallet}. */
|
|
13
|
-
export type UsePasskeyWallet = {
|
|
14
|
-
/** Whether the environment supports passkey PRF. */
|
|
15
|
-
supported: boolean;
|
|
16
|
-
/** True while a ceremony is in flight. */
|
|
17
|
-
busy: boolean;
|
|
18
|
-
/** The last error message, or "" when there is none. */
|
|
19
|
-
error: string;
|
|
20
|
-
/** Registers a passkey and creates the wallet from it. */
|
|
21
|
-
createPasskeyWallet: (appName: string) => Promise<PasskeyWalletOutcome | null>;
|
|
22
|
-
/**
|
|
23
|
-
* Asserts a passkey (scoped when allowCredentialId is set, discoverable
|
|
24
|
-
* otherwise) and imports/unlocks the wallet.
|
|
25
|
-
*/
|
|
26
|
-
openPasskeyWallet: (allowCredentialId?: string) => Promise<PasskeyWalletOutcome | null>;
|
|
27
|
-
/** Clears the current error message. */
|
|
28
|
-
clearError: () => void;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Drives a passkey ceremony and opens the wallet through the provider's client,
|
|
32
|
-
* refreshing provider state on success so the phase advances automatically. The
|
|
33
|
-
* ceremony is injected (browser: webPasskeyCeremony from walletdk-web; native
|
|
34
|
-
* transports supply their own), which keeps walletdk-react free of any transport
|
|
35
|
-
* dependency. Must be used inside a {@link WalletDKProvider}.
|
|
36
|
-
*/
|
|
37
|
-
export declare function usePasskeyWallet(ceremony: PasskeyCeremony): UsePasskeyWallet;
|
|
38
|
-
//# sourceMappingURL=usePasskeyWallet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePasskeyWallet.d.ts","sourceRoot":"","sources":["../src/usePasskeyWallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAGtC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,kEAAkE;IAClE,MAAM,EAAE,2BAA2B,CAAC;IACpC,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAC/E;;;OAGG;IACH,iBAAiB,EAAE,CACjB,iBAAiB,CAAC,EAAE,MAAM,KACvB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAC1C,wCAAwC;IACxC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,gBAAgB,CAyE5E"}
|
package/dist/usePasskeyWallet.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
import { useWalletDK } from "./provider";
|
|
3
|
-
/**
|
|
4
|
-
* Drives a passkey ceremony and opens the wallet through the provider's client,
|
|
5
|
-
* refreshing provider state on success so the phase advances automatically. The
|
|
6
|
-
* ceremony is injected (browser: webPasskeyCeremony from walletdk-web; native
|
|
7
|
-
* transports supply their own), which keeps walletdk-react free of any transport
|
|
8
|
-
* dependency. Must be used inside a {@link WalletDKProvider}.
|
|
9
|
-
*/
|
|
10
|
-
export function usePasskeyWallet(ceremony) {
|
|
11
|
-
const { client, refresh } = useWalletDK();
|
|
12
|
-
const [supported, setSupported] = useState(false);
|
|
13
|
-
const [busy, setBusy] = useState(false);
|
|
14
|
-
const [error, setError] = useState("");
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
let cancelled = false;
|
|
17
|
-
ceremony.supportsPasskeyPrf().then((v) => {
|
|
18
|
-
if (!cancelled)
|
|
19
|
-
setSupported(v);
|
|
20
|
-
}, () => {
|
|
21
|
-
// An injected ceremony whose probe rejects degrades to unsupported
|
|
22
|
-
// rather than leaving an unhandled rejection.
|
|
23
|
-
if (!cancelled)
|
|
24
|
-
setSupported(false);
|
|
25
|
-
});
|
|
26
|
-
return () => {
|
|
27
|
-
cancelled = true;
|
|
28
|
-
};
|
|
29
|
-
}, [ceremony]);
|
|
30
|
-
const run = useCallback(async (fn) => {
|
|
31
|
-
setError("");
|
|
32
|
-
setBusy(true);
|
|
33
|
-
try {
|
|
34
|
-
return await fn();
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
setBusy(false);
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
const createPasskeyWallet = useCallback((appName) => run(async () => {
|
|
45
|
-
const { prfOutput, credentialId } = await ceremony.registerPasskeyWallet(appName);
|
|
46
|
-
const result = await client.openWalletFromPasskey({ prfOutput });
|
|
47
|
-
await refresh().catch(() => undefined);
|
|
48
|
-
return { result, credentialId };
|
|
49
|
-
}), [run, client, refresh, ceremony]);
|
|
50
|
-
const openPasskeyWallet = useCallback((allowCredentialId) => run(async () => {
|
|
51
|
-
const { prfOutput, credentialId } = await ceremony.assertPasskeyPrf(allowCredentialId);
|
|
52
|
-
const result = await client.openWalletFromPasskey({ prfOutput });
|
|
53
|
-
await refresh().catch(() => undefined);
|
|
54
|
-
return { result, credentialId };
|
|
55
|
-
}), [run, client, refresh, ceremony]);
|
|
56
|
-
const clearError = useCallback(() => setError(""), []);
|
|
57
|
-
return {
|
|
58
|
-
supported,
|
|
59
|
-
busy,
|
|
60
|
-
error,
|
|
61
|
-
createPasskeyWallet,
|
|
62
|
-
openPasskeyWallet,
|
|
63
|
-
clearError,
|
|
64
|
-
};
|
|
65
|
-
}
|