@txnlab/use-wallet-ui-react 1.2.1 → 1.4.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 +121 -18
- package/dist/cjs/chunks/{floating-ui.react-O3sXJ80G.cjs → floating-ui.react-ChfuPAKc.cjs} +1 -1
- package/dist/cjs/chunks/{floating-ui.react-O3sXJ80G.cjs.map → floating-ui.react-ChfuPAKc.cjs.map} +1 -1
- package/dist/cjs/chunks/passkey-C8Dw6sNL.cjs +2 -0
- package/dist/cjs/chunks/passkey-C8Dw6sNL.cjs.map +1 -0
- package/dist/cjs/index.cjs +14 -14
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/plugins/export-key.cjs +2 -2
- package/dist/cjs/plugins/export-key.cjs.map +1 -1
- package/dist/cjs/plugins/passkey.cjs +2 -0
- package/dist/cjs/plugins/passkey.cjs.map +1 -0
- package/dist/esm/chunks/{floating-ui.react-Co7v2aHO.js → floating-ui.react-CxJSDrxv.js} +1 -1
- package/dist/esm/chunks/{floating-ui.react-Co7v2aHO.js.map → floating-ui.react-CxJSDrxv.js.map} +1 -1
- package/dist/esm/chunks/passkey-BbgvIGki.js +44 -0
- package/dist/esm/chunks/passkey-BbgvIGki.js.map +1 -0
- package/dist/esm/index.js +2888 -2601
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugins/export-key.js +13 -12
- package/dist/esm/plugins/export-key.js.map +1 -1
- package/dist/esm/plugins/passkey.js +578 -0
- package/dist/esm/plugins/passkey.js.map +1 -0
- package/dist/style.css +152 -0
- package/dist/types/components/ConnectWalletMenu.d.ts +7 -1
- package/dist/types/components/ConnectWalletMenu.d.ts.map +1 -1
- package/dist/types/components/ConnectedWalletMenu.d.ts.map +1 -1
- package/dist/types/components/PasskeyConnect.d.ts +29 -0
- package/dist/types/components/PasskeyConnect.d.ts.map +1 -0
- package/dist/types/components/WalletButton.d.ts +7 -1
- package/dist/types/components/WalletButton.d.ts.map +1 -1
- package/dist/types/components/WalletGroupLabel.d.ts +6 -0
- package/dist/types/components/WalletGroupLabel.d.ts.map +1 -0
- package/dist/types/components/WalletIcon.d.ts +6 -0
- package/dist/types/components/WalletIcon.d.ts.map +1 -0
- package/dist/types/components/WalletList.d.ts.map +1 -1
- package/dist/types/index.d.cts +5 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/plugins/passkey/PasskeyDisclosure.d.ts +11 -0
- package/dist/types/plugins/passkey/PasskeyDisclosure.d.ts.map +1 -0
- package/dist/types/plugins/passkey/PasskeyRecoveryDialog.d.ts +10 -0
- package/dist/types/plugins/passkey/PasskeyRecoveryDialog.d.ts.map +1 -0
- package/dist/types/plugins/passkey/PasskeyRecoveryMenuButton.d.ts +5 -0
- package/dist/types/plugins/passkey/PasskeyRecoveryMenuButton.d.ts.map +1 -0
- package/dist/types/plugins/passkey/PasskeySessionControl.d.ts +6 -0
- package/dist/types/plugins/passkey/PasskeySessionControl.d.ts.map +1 -0
- package/dist/types/plugins/passkey/constants.d.ts +3 -0
- package/dist/types/plugins/passkey/constants.d.ts.map +1 -0
- package/dist/types/plugins/passkey/index.d.cts +36 -0
- package/dist/types/plugins/passkey/index.d.ts +36 -0
- package/dist/types/plugins/passkey/index.d.ts.map +1 -0
- package/dist/types/plugins/passkey/index.test.d.ts +2 -0
- package/dist/types/plugins/passkey/index.test.d.ts.map +1 -0
- package/dist/types/plugins/passkey/storage.d.ts +5 -0
- package/dist/types/plugins/passkey/storage.d.ts.map +1 -0
- package/dist/types/plugins/passkey/storage.test.d.ts +2 -0
- package/dist/types/plugins/passkey/storage.test.d.ts.map +1 -0
- package/dist/types/plugins/passkey/usePasskeyAdapter.d.ts +10 -0
- package/dist/types/plugins/passkey/usePasskeyAdapter.d.ts.map +1 -0
- package/dist/types/providers/WalletUIProvider.d.ts +15 -1
- package/dist/types/providers/WalletUIProvider.d.ts.map +1 -1
- package/dist/types/utils/passkey.d.ts +59 -0
- package/dist/types/utils/passkey.d.ts.map +1 -0
- package/dist/types/utils/passkey.test.d.ts +2 -0
- package/dist/types/utils/passkey.test.d.ts.map +1 -0
- package/package.json +16 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const o = "passkey";
|
|
2
|
+
function a(e, s) {
|
|
3
|
+
return e ?? s ?? "list";
|
|
4
|
+
}
|
|
5
|
+
function i(e) {
|
|
6
|
+
return (e == null ? void 0 : e.id) === o;
|
|
7
|
+
}
|
|
8
|
+
function t(e) {
|
|
9
|
+
if (!(e instanceof Error) || e.name !== "PasskeyError") return null;
|
|
10
|
+
const { code: s } = e;
|
|
11
|
+
return typeof s == "string" ? s : null;
|
|
12
|
+
}
|
|
13
|
+
function u(e) {
|
|
14
|
+
const s = t(e);
|
|
15
|
+
if (!s) return null;
|
|
16
|
+
switch (s) {
|
|
17
|
+
case "cancelled":
|
|
18
|
+
return "The passkey request was cancelled or timed out, or no passkey was found.";
|
|
19
|
+
case "unsupported":
|
|
20
|
+
return "This browser can't use passkeys here. If you opened this page inside another app, open it in Safari or Chrome instead.";
|
|
21
|
+
case "prf-unsupported":
|
|
22
|
+
return "Your passkey provider doesn't support passkey accounts. Try a different provider, such as iCloud Keychain or Google Password Manager.";
|
|
23
|
+
case "key-mismatch":
|
|
24
|
+
return "This passkey belongs to a different account. Choose the passkey you used for this account.";
|
|
25
|
+
default:
|
|
26
|
+
return e.message || "The passkey request failed.";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function p(e) {
|
|
30
|
+
const r = (e == null ? void 0 : e.lastIndexOf(" · ")) ?? -1;
|
|
31
|
+
if (e && r !== -1) {
|
|
32
|
+
const n = e.slice(r + 3).trim();
|
|
33
|
+
if (n) return n;
|
|
34
|
+
}
|
|
35
|
+
return typeof location < "u" ? location.hostname : "";
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
t as a,
|
|
39
|
+
p as b,
|
|
40
|
+
u as g,
|
|
41
|
+
i,
|
|
42
|
+
a as r
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=passkey-BbgvIGki.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkey-BbgvIGki.js","sources":["../../../src/utils/passkey.ts"],"sourcesContent":["/** The wallet id registered by `passkey()` from `@txnlab/use-wallet-passkey` */\nexport const PASSKEY_WALLET_ID = 'passkey'\n\n/**\n * The `PasskeyAdapter` members this library uses. Typed structurally so the\n * library needs no dependency on `@txnlab/use-wallet-passkey`.\n */\nexport interface PasskeyWalletAdapter {\n /** True when the session key is unlocked */\n readonly isUnlocked: boolean\n /** Unlock the session with one passkey prompt */\n unlock: () => Promise<void>\n /** Drop the session key; the account stays connected */\n lock: () => void\n /** Return the account's recovery phrase after a fresh passkey prompt */\n exportRecoveryPhrase: () => Promise<{ scheme: 'falcon-1024'; phrase: string }>\n}\n\n/** The status of a passkey connect request, shown under the passkey section */\nexport interface PasskeyConnectStatus {\n walletId: string\n pending: boolean\n error: string | null\n /** Which control started the request, so it can show the pending state */\n action?: 'sign-in' | 'create'\n}\n\n/**\n * How the connect dialog presents a passkey wallet:\n * - `'list'` (default): \"Sign in with passkey\" and \"Create a passkey\" rows in\n * a Passkey group above a Wallets group. Suits apps where most users bring\n * a wallet.\n * - `'featured'`: a \"Continue with passkey\" button leads, with the other\n * wallets below. Suits apps where most users have no wallet.\n */\nexport type PasskeyConnectLayout = 'featured' | 'list'\n\n/** A menu's own layout wins over the provider's; the default is `'list'` */\nexport function resolvePasskeyLayout(\n menuLayout?: PasskeyConnectLayout,\n providerLayout?: PasskeyConnectLayout,\n): PasskeyConnectLayout {\n return menuLayout ?? providerLayout ?? 'list'\n}\n\n/** Arguments for connecting the passkey wallet */\nexport interface PasskeyConnectArgs {\n /** Create a new passkey (and account) instead of signing in */\n create?: boolean\n}\n\nexport function isPasskeyWallet(\n wallet: { id: string } | null | undefined,\n): boolean {\n return wallet?.id === PASSKEY_WALLET_ID\n}\n\n/** Returns a `PasskeyError`'s code, or null for any other error */\nexport function getPasskeyErrorCode(error: unknown): string | null {\n if (!(error instanceof Error) || error.name !== 'PasskeyError') return null\n const { code } = error as Error & { code?: unknown }\n return typeof code === 'string' ? code : null\n}\n\n/**\n * Returns a message to show users for a `PasskeyError`, or null for any other\n * error.\n */\nexport function getPasskeyErrorMessage(error: unknown): string | null {\n const code = getPasskeyErrorCode(error)\n if (!code) return null\n\n switch (code) {\n case 'cancelled':\n return 'The passkey request was cancelled or timed out, or no passkey was found.'\n case 'unsupported':\n return \"This browser can't use passkeys here. If you opened this page inside another app, open it in Safari or Chrome instead.\"\n case 'prf-unsupported':\n return \"Your passkey provider doesn't support passkey accounts. Try a different provider, such as iCloud Keychain or Google Password Manager.\"\n case 'key-mismatch':\n return 'This passkey belongs to a different account. Choose the passkey you used for this account.'\n default:\n return (error as Error).message || 'The passkey request failed.'\n }\n}\n\n/**\n * The domain a passkey account belongs to. The adapter names the account\n * `Passkey · <domain>`; fall back to the page's hostname.\n */\nexport function getPasskeyAccountDomain(accountName?: string | null): string {\n const separator = ' · '\n const index = accountName?.lastIndexOf(separator) ?? -1\n if (accountName && index !== -1) {\n const domain = accountName.slice(index + separator.length).trim()\n if (domain) return domain\n }\n return typeof location !== 'undefined' ? location.hostname : ''\n}\n"],"names":["PASSKEY_WALLET_ID","resolvePasskeyLayout","menuLayout","providerLayout","isPasskeyWallet","wallet","getPasskeyErrorCode","error","code","getPasskeyErrorMessage","getPasskeyAccountDomain","accountName","index","domain"],"mappings":"AACO,MAAMA,IAAoB;AAqC1B,SAASC,EACdC,GACAC,GACsB;AACtB,SAAOD,KAAcC,KAAkB;AACzC;AAQO,SAASC,EACdC,GACS;AACT,UAAOA,KAAA,gBAAAA,EAAQ,QAAOL;AACxB;AAGO,SAASM,EAAoBC,GAA+B;AACjE,MAAI,EAAEA,aAAiB,UAAUA,EAAM,SAAS,eAAgB,QAAO;AACvE,QAAM,EAAE,MAAAC,MAASD;AACjB,SAAO,OAAOC,KAAS,WAAWA,IAAO;AAC3C;AAMO,SAASC,EAAuBF,GAA+B;AACpE,QAAMC,IAAOF,EAAoBC,CAAK;AACtC,MAAI,CAACC,EAAM,QAAO;AAElB,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAQD,EAAgB,WAAW;AAAA,EAAA;AAEzC;AAMO,SAASG,EAAwBC,GAAqC;AAE3E,QAAMC,KAAQD,KAAA,gBAAAA,EAAa,YAAY,WAAc;AACrD,MAAIA,KAAeC,MAAU,IAAI;AAC/B,UAAMC,IAASF,EAAY,MAAMC,IAAQ,CAAgB,EAAE,KAAA;AAC3D,QAAIC,EAAQ,QAAOA;AAAA,EACrB;AACA,SAAO,OAAO,WAAa,MAAc,SAAS,WAAW;AAC/D;"}
|