@medialane/ui 0.174.0 → 0.176.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/dist/components/account/account-section.cjs +50 -0
- package/dist/components/account/account-section.cjs.map +1 -0
- package/dist/components/account/account-section.d.cts +14 -0
- package/dist/components/account/account-section.d.ts +14 -0
- package/dist/components/account/account-section.js +26 -0
- package/dist/components/account/account-section.js.map +1 -0
- package/dist/components/account/account.test.cjs +86 -0
- package/dist/components/account/account.test.cjs.map +1 -0
- package/dist/components/account/account.test.d.cts +2 -0
- package/dist/components/account/account.test.d.ts +2 -0
- package/dist/components/account/account.test.js +85 -0
- package/dist/components/account/account.test.js.map +1 -0
- package/dist/components/account/add-guardian-dialog.cjs +90 -0
- package/dist/components/account/add-guardian-dialog.cjs.map +1 -0
- package/dist/components/account/add-guardian-dialog.d.cts +14 -0
- package/dist/components/account/add-guardian-dialog.d.ts +14 -0
- package/dist/components/account/add-guardian-dialog.js +66 -0
- package/dist/components/account/add-guardian-dialog.js.map +1 -0
- package/dist/components/account/device-approval-dialog.cjs +120 -0
- package/dist/components/account/device-approval-dialog.cjs.map +1 -0
- package/dist/components/account/device-approval-dialog.d.cts +14 -0
- package/dist/components/account/device-approval-dialog.d.ts +14 -0
- package/dist/components/account/device-approval-dialog.js +96 -0
- package/dist/components/account/device-approval-dialog.js.map +1 -0
- package/dist/components/account/devices-section.cjs +117 -0
- package/dist/components/account/devices-section.cjs.map +1 -0
- package/dist/components/account/devices-section.d.cts +12 -0
- package/dist/components/account/devices-section.d.ts +12 -0
- package/dist/components/account/devices-section.js +93 -0
- package/dist/components/account/devices-section.js.map +1 -0
- package/dist/components/account/email-code-entry.cjs +85 -0
- package/dist/components/account/email-code-entry.cjs.map +1 -0
- package/dist/components/account/email-code-entry.d.cts +11 -0
- package/dist/components/account/email-code-entry.d.ts +11 -0
- package/dist/components/account/email-code-entry.js +61 -0
- package/dist/components/account/email-code-entry.js.map +1 -0
- package/dist/components/account/guardian-recovery-section.cjs +161 -0
- package/dist/components/account/guardian-recovery-section.cjs.map +1 -0
- package/dist/components/account/guardian-recovery-section.d.cts +14 -0
- package/dist/components/account/guardian-recovery-section.d.ts +14 -0
- package/dist/components/account/guardian-recovery-section.js +130 -0
- package/dist/components/account/guardian-recovery-section.js.map +1 -0
- package/dist/components/account/input-otp.cjs +89 -0
- package/dist/components/account/input-otp.cjs.map +1 -0
- package/dist/components/account/input-otp.d.cts +37 -0
- package/dist/components/account/input-otp.d.ts +37 -0
- package/dist/components/account/input-otp.js +52 -0
- package/dist/components/account/input-otp.js.map +1 -0
- package/dist/components/account/wallet-types.cjs +17 -0
- package/dist/components/account/wallet-types.cjs.map +1 -0
- package/dist/components/account/wallet-types.d.cts +7 -0
- package/dist/components/account/wallet-types.d.ts +7 -0
- package/dist/components/account/wallet-types.js +1 -0
- package/dist/components/account/wallet-types.js.map +1 -0
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/index.cjs +56 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/app-wallet.cjs +84 -0
- package/dist/utils/app-wallet.cjs.map +1 -0
- package/dist/utils/app-wallet.d.cts +26 -0
- package/dist/utils/app-wallet.d.ts +26 -0
- package/dist/utils/app-wallet.js +65 -0
- package/dist/utils/app-wallet.js.map +1 -0
- package/dist/utils/email-code.cjs +58 -0
- package/dist/utils/email-code.cjs.map +1 -0
- package/dist/utils/email-code.d.cts +32 -0
- package/dist/utils/email-code.d.ts +32 -0
- package/dist/utils/email-code.js +30 -0
- package/dist/utils/email-code.js.map +1 -0
- package/dist/utils/passkey-support.cjs +37 -0
- package/dist/utils/passkey-support.cjs.map +1 -0
- package/dist/utils/passkey-support.d.cts +7 -0
- package/dist/utils/passkey-support.d.ts +7 -0
- package/dist/utils/passkey-support.js +13 -0
- package/dist/utils/passkey-support.js.map +1 -0
- package/dist/utils/use-email-code.cjs +75 -0
- package/dist/utils/use-email-code.cjs.map +1 -0
- package/dist/utils/use-email-code.d.cts +20 -0
- package/dist/utils/use-email-code.d.ts +20 -0
- package/dist/utils/use-email-code.js +51 -0
- package/dist/utils/use-email-code.js.map +1 -0
- package/dist/utils/wallet-failure.cjs +63 -0
- package/dist/utils/wallet-failure.cjs.map +1 -0
- package/dist/utils/wallet-failure.d.cts +12 -0
- package/dist/utils/wallet-failure.d.ts +12 -0
- package/dist/utils/wallet-failure.js +38 -0
- package/dist/utils/wallet-failure.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/email-code.ts"],"sourcesContent":["export const RESEND_COOLDOWN_SECONDS = 60;\n\nexport type EmailCodeStatus = \"idle\" | \"sending\" | \"ready\" | \"verifying\";\n\nexport interface EmailCodeState {\n status: EmailCodeStatus;\n code: string;\n error: string | null;\n cooldown: number;\n}\n\nexport type EmailCodeAction =\n | { type: \"code-changed\"; code: string }\n | { type: \"send-started\" }\n | { type: \"send-succeeded\" }\n | { type: \"send-failed\"; message: string }\n | { type: \"verify-started\" }\n | { type: \"verify-failed\"; message: string }\n | { type: \"tick\" };\n\nexport const initialEmailCodeState: EmailCodeState = { status: \"idle\", code: \"\", error: null, cooldown: 0 };\n\nexport function emailCodeReducer(state: EmailCodeState, action: EmailCodeAction): EmailCodeState {\n switch (action.type) {\n case \"code-changed\":\n return { ...state, code: action.code.replace(/\\D/g, \"\").slice(0, 6) };\n case \"send-started\":\n return { ...state, status: \"sending\", error: null };\n case \"send-succeeded\":\n return { ...state, status: \"ready\", error: null, cooldown: RESEND_COOLDOWN_SECONDS };\n case \"send-failed\":\n return { ...state, status: \"idle\", error: action.message };\n case \"verify-started\":\n return { ...state, status: \"verifying\", error: null };\n case \"verify-failed\":\n return { ...state, status: \"ready\", code: \"\", error: action.message };\n case \"tick\":\n return state.cooldown > 0 ? { ...state, cooldown: state.cooldown - 1 } : state;\n }\n}\n\nexport const canVerifyCode = (state: EmailCodeState): boolean =>\n state.status === \"ready\" && state.code.length === 6;\n\nexport const canResendCode = (state: EmailCodeState): boolean =>\n state.cooldown === 0 && state.status !== \"sending\" && state.status !== \"verifying\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,0BAA0B;AAoBhC,MAAM,wBAAwC,EAAE,QAAQ,QAAQ,MAAM,IAAI,OAAO,MAAM,UAAU,EAAE;AAEnG,SAAS,iBAAiB,OAAuB,QAAyC;AAC/F,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,MAAM,OAAO,KAAK,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE;AAAA,IACtE,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,IACpD,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,SAAS,OAAO,MAAM,UAAU,wBAAwB;AAAA,IACrF,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,QAAQ,OAAO,OAAO,QAAQ;AAAA,IAC3D,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,aAAa,OAAO,KAAK;AAAA,IACtD,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,SAAS,MAAM,IAAI,OAAO,OAAO,QAAQ;AAAA,IACtE,KAAK;AACH,aAAO,MAAM,WAAW,IAAI,EAAE,GAAG,OAAO,UAAU,MAAM,WAAW,EAAE,IAAI;AAAA,EAC7E;AACF;AAEO,MAAM,gBAAgB,CAAC,UAC5B,MAAM,WAAW,WAAW,MAAM,KAAK,WAAW;AAE7C,MAAM,gBAAgB,CAAC,UAC5B,MAAM,aAAa,KAAK,MAAM,WAAW,aAAa,MAAM,WAAW;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const RESEND_COOLDOWN_SECONDS = 60;
|
|
2
|
+
type EmailCodeStatus = "idle" | "sending" | "ready" | "verifying";
|
|
3
|
+
interface EmailCodeState {
|
|
4
|
+
status: EmailCodeStatus;
|
|
5
|
+
code: string;
|
|
6
|
+
error: string | null;
|
|
7
|
+
cooldown: number;
|
|
8
|
+
}
|
|
9
|
+
type EmailCodeAction = {
|
|
10
|
+
type: "code-changed";
|
|
11
|
+
code: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "send-started";
|
|
14
|
+
} | {
|
|
15
|
+
type: "send-succeeded";
|
|
16
|
+
} | {
|
|
17
|
+
type: "send-failed";
|
|
18
|
+
message: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "verify-started";
|
|
21
|
+
} | {
|
|
22
|
+
type: "verify-failed";
|
|
23
|
+
message: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "tick";
|
|
26
|
+
};
|
|
27
|
+
declare const initialEmailCodeState: EmailCodeState;
|
|
28
|
+
declare function emailCodeReducer(state: EmailCodeState, action: EmailCodeAction): EmailCodeState;
|
|
29
|
+
declare const canVerifyCode: (state: EmailCodeState) => boolean;
|
|
30
|
+
declare const canResendCode: (state: EmailCodeState) => boolean;
|
|
31
|
+
|
|
32
|
+
export { type EmailCodeAction, type EmailCodeState, type EmailCodeStatus, RESEND_COOLDOWN_SECONDS, canResendCode, canVerifyCode, emailCodeReducer, initialEmailCodeState };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const RESEND_COOLDOWN_SECONDS = 60;
|
|
2
|
+
type EmailCodeStatus = "idle" | "sending" | "ready" | "verifying";
|
|
3
|
+
interface EmailCodeState {
|
|
4
|
+
status: EmailCodeStatus;
|
|
5
|
+
code: string;
|
|
6
|
+
error: string | null;
|
|
7
|
+
cooldown: number;
|
|
8
|
+
}
|
|
9
|
+
type EmailCodeAction = {
|
|
10
|
+
type: "code-changed";
|
|
11
|
+
code: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "send-started";
|
|
14
|
+
} | {
|
|
15
|
+
type: "send-succeeded";
|
|
16
|
+
} | {
|
|
17
|
+
type: "send-failed";
|
|
18
|
+
message: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "verify-started";
|
|
21
|
+
} | {
|
|
22
|
+
type: "verify-failed";
|
|
23
|
+
message: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "tick";
|
|
26
|
+
};
|
|
27
|
+
declare const initialEmailCodeState: EmailCodeState;
|
|
28
|
+
declare function emailCodeReducer(state: EmailCodeState, action: EmailCodeAction): EmailCodeState;
|
|
29
|
+
declare const canVerifyCode: (state: EmailCodeState) => boolean;
|
|
30
|
+
declare const canResendCode: (state: EmailCodeState) => boolean;
|
|
31
|
+
|
|
32
|
+
export { type EmailCodeAction, type EmailCodeState, type EmailCodeStatus, RESEND_COOLDOWN_SECONDS, canResendCode, canVerifyCode, emailCodeReducer, initialEmailCodeState };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const RESEND_COOLDOWN_SECONDS = 60;
|
|
2
|
+
const initialEmailCodeState = { status: "idle", code: "", error: null, cooldown: 0 };
|
|
3
|
+
function emailCodeReducer(state, action) {
|
|
4
|
+
switch (action.type) {
|
|
5
|
+
case "code-changed":
|
|
6
|
+
return { ...state, code: action.code.replace(/\D/g, "").slice(0, 6) };
|
|
7
|
+
case "send-started":
|
|
8
|
+
return { ...state, status: "sending", error: null };
|
|
9
|
+
case "send-succeeded":
|
|
10
|
+
return { ...state, status: "ready", error: null, cooldown: RESEND_COOLDOWN_SECONDS };
|
|
11
|
+
case "send-failed":
|
|
12
|
+
return { ...state, status: "idle", error: action.message };
|
|
13
|
+
case "verify-started":
|
|
14
|
+
return { ...state, status: "verifying", error: null };
|
|
15
|
+
case "verify-failed":
|
|
16
|
+
return { ...state, status: "ready", code: "", error: action.message };
|
|
17
|
+
case "tick":
|
|
18
|
+
return state.cooldown > 0 ? { ...state, cooldown: state.cooldown - 1 } : state;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const canVerifyCode = (state) => state.status === "ready" && state.code.length === 6;
|
|
22
|
+
const canResendCode = (state) => state.cooldown === 0 && state.status !== "sending" && state.status !== "verifying";
|
|
23
|
+
export {
|
|
24
|
+
RESEND_COOLDOWN_SECONDS,
|
|
25
|
+
canResendCode,
|
|
26
|
+
canVerifyCode,
|
|
27
|
+
emailCodeReducer,
|
|
28
|
+
initialEmailCodeState
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=email-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/email-code.ts"],"sourcesContent":["export const RESEND_COOLDOWN_SECONDS = 60;\n\nexport type EmailCodeStatus = \"idle\" | \"sending\" | \"ready\" | \"verifying\";\n\nexport interface EmailCodeState {\n status: EmailCodeStatus;\n code: string;\n error: string | null;\n cooldown: number;\n}\n\nexport type EmailCodeAction =\n | { type: \"code-changed\"; code: string }\n | { type: \"send-started\" }\n | { type: \"send-succeeded\" }\n | { type: \"send-failed\"; message: string }\n | { type: \"verify-started\" }\n | { type: \"verify-failed\"; message: string }\n | { type: \"tick\" };\n\nexport const initialEmailCodeState: EmailCodeState = { status: \"idle\", code: \"\", error: null, cooldown: 0 };\n\nexport function emailCodeReducer(state: EmailCodeState, action: EmailCodeAction): EmailCodeState {\n switch (action.type) {\n case \"code-changed\":\n return { ...state, code: action.code.replace(/\\D/g, \"\").slice(0, 6) };\n case \"send-started\":\n return { ...state, status: \"sending\", error: null };\n case \"send-succeeded\":\n return { ...state, status: \"ready\", error: null, cooldown: RESEND_COOLDOWN_SECONDS };\n case \"send-failed\":\n return { ...state, status: \"idle\", error: action.message };\n case \"verify-started\":\n return { ...state, status: \"verifying\", error: null };\n case \"verify-failed\":\n return { ...state, status: \"ready\", code: \"\", error: action.message };\n case \"tick\":\n return state.cooldown > 0 ? { ...state, cooldown: state.cooldown - 1 } : state;\n }\n}\n\nexport const canVerifyCode = (state: EmailCodeState): boolean =>\n state.status === \"ready\" && state.code.length === 6;\n\nexport const canResendCode = (state: EmailCodeState): boolean =>\n state.cooldown === 0 && state.status !== \"sending\" && state.status !== \"verifying\";\n"],"mappings":"AAAO,MAAM,0BAA0B;AAoBhC,MAAM,wBAAwC,EAAE,QAAQ,QAAQ,MAAM,IAAI,OAAO,MAAM,UAAU,EAAE;AAEnG,SAAS,iBAAiB,OAAuB,QAAyC;AAC/F,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,MAAM,OAAO,KAAK,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE;AAAA,IACtE,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,IACpD,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,SAAS,OAAO,MAAM,UAAU,wBAAwB;AAAA,IACrF,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,QAAQ,OAAO,OAAO,QAAQ;AAAA,IAC3D,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,aAAa,OAAO,KAAK;AAAA,IACtD,KAAK;AACH,aAAO,EAAE,GAAG,OAAO,QAAQ,SAAS,MAAM,IAAI,OAAO,OAAO,QAAQ;AAAA,IACtE,KAAK;AACH,aAAO,MAAM,WAAW,IAAI,EAAE,GAAG,OAAO,UAAU,MAAM,WAAW,EAAE,IAAI;AAAA,EAC7E;AACF;AAEO,MAAM,gBAAgB,CAAC,UAC5B,MAAM,WAAW,WAAW,MAAM,KAAK,WAAW;AAE7C,MAAM,gBAAgB,CAAC,UAC5B,MAAM,aAAa,KAAK,MAAM,WAAW,aAAa,MAAM,WAAW;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var passkey_support_exports = {};
|
|
20
|
+
__export(passkey_support_exports, {
|
|
21
|
+
detectPasskeySupport: () => detectPasskeySupport
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(passkey_support_exports);
|
|
24
|
+
async function detectPasskeySupport(api = typeof PublicKeyCredential === "undefined" ? void 0 : PublicKeyCredential) {
|
|
25
|
+
if (!api) return "unavailable";
|
|
26
|
+
if (typeof api.isUserVerifyingPlatformAuthenticatorAvailable !== "function") return "unknown";
|
|
27
|
+
try {
|
|
28
|
+
return await api.isUserVerifyingPlatformAuthenticatorAvailable() ? "available" : "unavailable";
|
|
29
|
+
} catch {
|
|
30
|
+
return "unknown";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
detectPasskeySupport
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=passkey-support.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/passkey-support.ts"],"sourcesContent":["export type PasskeySupport = \"available\" | \"unavailable\" | \"unknown\";\n\ninterface PlatformPasskeyApi {\n isUserVerifyingPlatformAuthenticatorAvailable?: () => Promise<boolean>;\n}\n\nexport async function detectPasskeySupport(\n api: PlatformPasskeyApi | undefined = typeof PublicKeyCredential === \"undefined\" ? undefined : PublicKeyCredential,\n): Promise<PasskeySupport> {\n if (!api) return \"unavailable\";\n if (typeof api.isUserVerifyingPlatformAuthenticatorAvailable !== \"function\") return \"unknown\";\n try {\n return (await api.isUserVerifyingPlatformAuthenticatorAvailable()) ? \"available\" : \"unavailable\";\n } catch {\n return \"unknown\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,eAAsB,qBACpB,MAAsC,OAAO,wBAAwB,cAAc,SAAY,qBACtE;AACzB,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,OAAO,IAAI,kDAAkD,WAAY,QAAO;AACpF,MAAI;AACF,WAAQ,MAAM,IAAI,8CAA8C,IAAK,cAAc;AAAA,EACrF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type PasskeySupport = "available" | "unavailable" | "unknown";
|
|
2
|
+
interface PlatformPasskeyApi {
|
|
3
|
+
isUserVerifyingPlatformAuthenticatorAvailable?: () => Promise<boolean>;
|
|
4
|
+
}
|
|
5
|
+
declare function detectPasskeySupport(api?: PlatformPasskeyApi | undefined): Promise<PasskeySupport>;
|
|
6
|
+
|
|
7
|
+
export { type PasskeySupport, detectPasskeySupport };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type PasskeySupport = "available" | "unavailable" | "unknown";
|
|
2
|
+
interface PlatformPasskeyApi {
|
|
3
|
+
isUserVerifyingPlatformAuthenticatorAvailable?: () => Promise<boolean>;
|
|
4
|
+
}
|
|
5
|
+
declare function detectPasskeySupport(api?: PlatformPasskeyApi | undefined): Promise<PasskeySupport>;
|
|
6
|
+
|
|
7
|
+
export { type PasskeySupport, detectPasskeySupport };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
async function detectPasskeySupport(api = typeof PublicKeyCredential === "undefined" ? void 0 : PublicKeyCredential) {
|
|
2
|
+
if (!api) return "unavailable";
|
|
3
|
+
if (typeof api.isUserVerifyingPlatformAuthenticatorAvailable !== "function") return "unknown";
|
|
4
|
+
try {
|
|
5
|
+
return await api.isUserVerifyingPlatformAuthenticatorAvailable() ? "available" : "unavailable";
|
|
6
|
+
} catch {
|
|
7
|
+
return "unknown";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
detectPasskeySupport
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=passkey-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/passkey-support.ts"],"sourcesContent":["export type PasskeySupport = \"available\" | \"unavailable\" | \"unknown\";\n\ninterface PlatformPasskeyApi {\n isUserVerifyingPlatformAuthenticatorAvailable?: () => Promise<boolean>;\n}\n\nexport async function detectPasskeySupport(\n api: PlatformPasskeyApi | undefined = typeof PublicKeyCredential === \"undefined\" ? undefined : PublicKeyCredential,\n): Promise<PasskeySupport> {\n if (!api) return \"unavailable\";\n if (typeof api.isUserVerifyingPlatformAuthenticatorAvailable !== \"function\") return \"unknown\";\n try {\n return (await api.isUserVerifyingPlatformAuthenticatorAvailable()) ? \"available\" : \"unavailable\";\n } catch {\n return \"unknown\";\n }\n}\n"],"mappings":"AAMA,eAAsB,qBACpB,MAAsC,OAAO,wBAAwB,cAAc,SAAY,qBACtE;AACzB,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,OAAO,IAAI,kDAAkD,WAAY,QAAO;AACpF,MAAI;AACF,WAAQ,MAAM,IAAI,8CAA8C,IAAK,cAAc;AAAA,EACrF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var use_email_code_exports = {};
|
|
21
|
+
__export(use_email_code_exports, {
|
|
22
|
+
useEmailCode: () => useEmailCode
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(use_email_code_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_describe_error = require("./describe-error.js");
|
|
27
|
+
var import_email_code = require("./email-code.js");
|
|
28
|
+
function useEmailCode(email, api) {
|
|
29
|
+
const [state, dispatch] = (0, import_react.useReducer)(import_email_code.emailCodeReducer, import_email_code.initialEmailCodeState);
|
|
30
|
+
(0, import_react.useEffect)(() => {
|
|
31
|
+
if (state.cooldown === 0) return;
|
|
32
|
+
const id = setTimeout(() => dispatch({ type: "tick" }), 1e3);
|
|
33
|
+
return () => clearTimeout(id);
|
|
34
|
+
}, [state.cooldown]);
|
|
35
|
+
const send = (0, import_react.useCallback)(
|
|
36
|
+
async (to = email) => {
|
|
37
|
+
if (!to) return false;
|
|
38
|
+
dispatch({ type: "send-started" });
|
|
39
|
+
try {
|
|
40
|
+
await api().requestEmailCode(to);
|
|
41
|
+
dispatch({ type: "send-succeeded" });
|
|
42
|
+
return true;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
dispatch({ type: "send-failed", message: (0, import_describe_error.describeError)(err, "Couldn't send the code. Please try again.").message });
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
[email, api]
|
|
49
|
+
);
|
|
50
|
+
const verify = (0, import_react.useCallback)(
|
|
51
|
+
async ({ code, after } = {}) => {
|
|
52
|
+
const toVerify = code ?? state.code;
|
|
53
|
+
if (!email || toVerify.length !== 6) return false;
|
|
54
|
+
dispatch({ type: "verify-started" });
|
|
55
|
+
try {
|
|
56
|
+
await api().verifyEmailCode(email, toVerify);
|
|
57
|
+
await after?.();
|
|
58
|
+
return true;
|
|
59
|
+
} catch (err) {
|
|
60
|
+
dispatch({ type: "verify-failed", message: (0, import_describe_error.describeError)(err, "Incorrect code. Please try again.").message });
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[email, state.code, api]
|
|
65
|
+
);
|
|
66
|
+
const setCode = (0, import_react.useCallback)((code) => dispatch({ type: "code-changed", code }), []);
|
|
67
|
+
const markReady = (0, import_react.useCallback)(() => dispatch({ type: "send-succeeded" }), []);
|
|
68
|
+
const fail = (0, import_react.useCallback)((message) => dispatch({ type: "verify-failed", message }), []);
|
|
69
|
+
return { state, setCode, send, verify, markReady, fail };
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
useEmailCode
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=use-email-code.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-email-code.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useReducer } from \"react\";\nimport { describeError } from \"./describe-error.js\";\nimport { emailCodeReducer, initialEmailCodeState, type EmailCodeState } from \"./email-code.js\";\n\nexport interface EmailCodeApi {\n requestEmailCode(email: string): Promise<unknown>;\n verifyEmailCode(email: string, code: string): Promise<unknown>;\n}\n\nexport interface EmailCode {\n state: EmailCodeState;\n setCode(code: string): void;\n send(to?: string): Promise<boolean>;\n fail(message: string): void;\n verify(options?: { code?: string; after?: () => Promise<void> | void }): Promise<boolean>;\n markReady(): void;\n}\n\nexport function useEmailCode(email: string | null, api: () => EmailCodeApi): EmailCode {\n const [state, dispatch] = useReducer(emailCodeReducer, initialEmailCodeState);\n\n useEffect(() => {\n if (state.cooldown === 0) return;\n const id = setTimeout(() => dispatch({ type: \"tick\" }), 1000);\n return () => clearTimeout(id);\n }, [state.cooldown]);\n\n const send = useCallback(\n async (to = email) => {\n if (!to) return false;\n dispatch({ type: \"send-started\" });\n try {\n await api().requestEmailCode(to);\n dispatch({ type: \"send-succeeded\" });\n return true;\n } catch (err) {\n dispatch({ type: \"send-failed\", message: describeError(err, \"Couldn't send the code. Please try again.\").message });\n return false;\n }\n },\n [email, api],\n );\n\n const verify = useCallback<EmailCode[\"verify\"]>(\n async ({ code, after } = {}) => {\n const toVerify = code ?? state.code;\n if (!email || toVerify.length !== 6) return false;\n dispatch({ type: \"verify-started\" });\n try {\n await api().verifyEmailCode(email, toVerify);\n await after?.();\n return true;\n } catch (err) {\n dispatch({ type: \"verify-failed\", message: describeError(err, \"Incorrect code. Please try again.\").message });\n return false;\n }\n },\n [email, state.code, api],\n );\n\n const setCode = useCallback((code: string) => dispatch({ type: \"code-changed\", code }), []);\n const markReady = useCallback(() => dispatch({ type: \"send-succeeded\" }), []);\n const fail = useCallback((message: string) => dispatch({ type: \"verify-failed\", message }), []);\n\n return { state, setCode, send, verify, markReady, fail };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmD;AACnD,4BAA8B;AAC9B,wBAA6E;AAgBtE,SAAS,aAAa,OAAsB,KAAoC;AACrF,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAW,oCAAkB,uCAAqB;AAE5E,8BAAU,MAAM;AACd,QAAI,MAAM,aAAa,EAAG;AAC1B,UAAM,KAAK,WAAW,MAAM,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,GAAI;AAC5D,WAAO,MAAM,aAAa,EAAE;AAAA,EAC9B,GAAG,CAAC,MAAM,QAAQ,CAAC;AAEnB,QAAM,WAAO;AAAA,IACX,OAAO,KAAK,UAAU;AACpB,UAAI,CAAC,GAAI,QAAO;AAChB,eAAS,EAAE,MAAM,eAAe,CAAC;AACjC,UAAI;AACF,cAAM,IAAI,EAAE,iBAAiB,EAAE;AAC/B,iBAAS,EAAE,MAAM,iBAAiB,CAAC;AACnC,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,iBAAS,EAAE,MAAM,eAAe,aAAS,qCAAc,KAAK,2CAA2C,EAAE,QAAQ,CAAC;AAClH,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,OAAO,GAAG;AAAA,EACb;AAEA,QAAM,aAAS;AAAA,IACb,OAAO,EAAE,MAAM,MAAM,IAAI,CAAC,MAAM;AAC9B,YAAM,WAAW,QAAQ,MAAM;AAC/B,UAAI,CAAC,SAAS,SAAS,WAAW,EAAG,QAAO;AAC5C,eAAS,EAAE,MAAM,iBAAiB,CAAC;AACnC,UAAI;AACF,cAAM,IAAI,EAAE,gBAAgB,OAAO,QAAQ;AAC3C,cAAM,QAAQ;AACd,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,iBAAS,EAAE,MAAM,iBAAiB,aAAS,qCAAc,KAAK,mCAAmC,EAAE,QAAQ,CAAC;AAC5G,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM,MAAM,GAAG;AAAA,EACzB;AAEA,QAAM,cAAU,0BAAY,CAAC,SAAiB,SAAS,EAAE,MAAM,gBAAgB,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1F,QAAM,gBAAY,0BAAY,MAAM,SAAS,EAAE,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC5E,QAAM,WAAO,0BAAY,CAAC,YAAoB,SAAS,EAAE,MAAM,iBAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC;AAE9F,SAAO,EAAE,OAAO,SAAS,MAAM,QAAQ,WAAW,KAAK;AACzD;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EmailCodeState } from './email-code.cjs';
|
|
2
|
+
|
|
3
|
+
interface EmailCodeApi {
|
|
4
|
+
requestEmailCode(email: string): Promise<unknown>;
|
|
5
|
+
verifyEmailCode(email: string, code: string): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface EmailCode {
|
|
8
|
+
state: EmailCodeState;
|
|
9
|
+
setCode(code: string): void;
|
|
10
|
+
send(to?: string): Promise<boolean>;
|
|
11
|
+
fail(message: string): void;
|
|
12
|
+
verify(options?: {
|
|
13
|
+
code?: string;
|
|
14
|
+
after?: () => Promise<void> | void;
|
|
15
|
+
}): Promise<boolean>;
|
|
16
|
+
markReady(): void;
|
|
17
|
+
}
|
|
18
|
+
declare function useEmailCode(email: string | null, api: () => EmailCodeApi): EmailCode;
|
|
19
|
+
|
|
20
|
+
export { type EmailCode, type EmailCodeApi, useEmailCode };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EmailCodeState } from './email-code.js';
|
|
2
|
+
|
|
3
|
+
interface EmailCodeApi {
|
|
4
|
+
requestEmailCode(email: string): Promise<unknown>;
|
|
5
|
+
verifyEmailCode(email: string, code: string): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface EmailCode {
|
|
8
|
+
state: EmailCodeState;
|
|
9
|
+
setCode(code: string): void;
|
|
10
|
+
send(to?: string): Promise<boolean>;
|
|
11
|
+
fail(message: string): void;
|
|
12
|
+
verify(options?: {
|
|
13
|
+
code?: string;
|
|
14
|
+
after?: () => Promise<void> | void;
|
|
15
|
+
}): Promise<boolean>;
|
|
16
|
+
markReady(): void;
|
|
17
|
+
}
|
|
18
|
+
declare function useEmailCode(email: string | null, api: () => EmailCodeApi): EmailCode;
|
|
19
|
+
|
|
20
|
+
export { type EmailCode, type EmailCodeApi, useEmailCode };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useReducer } from "react";
|
|
3
|
+
import { describeError } from "./describe-error.js";
|
|
4
|
+
import { emailCodeReducer, initialEmailCodeState } from "./email-code.js";
|
|
5
|
+
function useEmailCode(email, api) {
|
|
6
|
+
const [state, dispatch] = useReducer(emailCodeReducer, initialEmailCodeState);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (state.cooldown === 0) return;
|
|
9
|
+
const id = setTimeout(() => dispatch({ type: "tick" }), 1e3);
|
|
10
|
+
return () => clearTimeout(id);
|
|
11
|
+
}, [state.cooldown]);
|
|
12
|
+
const send = useCallback(
|
|
13
|
+
async (to = email) => {
|
|
14
|
+
if (!to) return false;
|
|
15
|
+
dispatch({ type: "send-started" });
|
|
16
|
+
try {
|
|
17
|
+
await api().requestEmailCode(to);
|
|
18
|
+
dispatch({ type: "send-succeeded" });
|
|
19
|
+
return true;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
dispatch({ type: "send-failed", message: describeError(err, "Couldn't send the code. Please try again.").message });
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
[email, api]
|
|
26
|
+
);
|
|
27
|
+
const verify = useCallback(
|
|
28
|
+
async ({ code, after } = {}) => {
|
|
29
|
+
const toVerify = code ?? state.code;
|
|
30
|
+
if (!email || toVerify.length !== 6) return false;
|
|
31
|
+
dispatch({ type: "verify-started" });
|
|
32
|
+
try {
|
|
33
|
+
await api().verifyEmailCode(email, toVerify);
|
|
34
|
+
await after?.();
|
|
35
|
+
return true;
|
|
36
|
+
} catch (err) {
|
|
37
|
+
dispatch({ type: "verify-failed", message: describeError(err, "Incorrect code. Please try again.").message });
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[email, state.code, api]
|
|
42
|
+
);
|
|
43
|
+
const setCode = useCallback((code) => dispatch({ type: "code-changed", code }), []);
|
|
44
|
+
const markReady = useCallback(() => dispatch({ type: "send-succeeded" }), []);
|
|
45
|
+
const fail = useCallback((message) => dispatch({ type: "verify-failed", message }), []);
|
|
46
|
+
return { state, setCode, send, verify, markReady, fail };
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
useEmailCode
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=use-email-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-email-code.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useReducer } from \"react\";\nimport { describeError } from \"./describe-error.js\";\nimport { emailCodeReducer, initialEmailCodeState, type EmailCodeState } from \"./email-code.js\";\n\nexport interface EmailCodeApi {\n requestEmailCode(email: string): Promise<unknown>;\n verifyEmailCode(email: string, code: string): Promise<unknown>;\n}\n\nexport interface EmailCode {\n state: EmailCodeState;\n setCode(code: string): void;\n send(to?: string): Promise<boolean>;\n fail(message: string): void;\n verify(options?: { code?: string; after?: () => Promise<void> | void }): Promise<boolean>;\n markReady(): void;\n}\n\nexport function useEmailCode(email: string | null, api: () => EmailCodeApi): EmailCode {\n const [state, dispatch] = useReducer(emailCodeReducer, initialEmailCodeState);\n\n useEffect(() => {\n if (state.cooldown === 0) return;\n const id = setTimeout(() => dispatch({ type: \"tick\" }), 1000);\n return () => clearTimeout(id);\n }, [state.cooldown]);\n\n const send = useCallback(\n async (to = email) => {\n if (!to) return false;\n dispatch({ type: \"send-started\" });\n try {\n await api().requestEmailCode(to);\n dispatch({ type: \"send-succeeded\" });\n return true;\n } catch (err) {\n dispatch({ type: \"send-failed\", message: describeError(err, \"Couldn't send the code. Please try again.\").message });\n return false;\n }\n },\n [email, api],\n );\n\n const verify = useCallback<EmailCode[\"verify\"]>(\n async ({ code, after } = {}) => {\n const toVerify = code ?? state.code;\n if (!email || toVerify.length !== 6) return false;\n dispatch({ type: \"verify-started\" });\n try {\n await api().verifyEmailCode(email, toVerify);\n await after?.();\n return true;\n } catch (err) {\n dispatch({ type: \"verify-failed\", message: describeError(err, \"Incorrect code. Please try again.\").message });\n return false;\n }\n },\n [email, state.code, api],\n );\n\n const setCode = useCallback((code: string) => dispatch({ type: \"code-changed\", code }), []);\n const markReady = useCallback(() => dispatch({ type: \"send-succeeded\" }), []);\n const fail = useCallback((message: string) => dispatch({ type: \"verify-failed\", message }), []);\n\n return { state, setCode, send, verify, markReady, fail };\n}\n"],"mappings":";AAEA,SAAS,aAAa,WAAW,kBAAkB;AACnD,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB,6BAAkD;AAgBtE,SAAS,aAAa,OAAsB,KAAoC;AACrF,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,kBAAkB,qBAAqB;AAE5E,YAAU,MAAM;AACd,QAAI,MAAM,aAAa,EAAG;AAC1B,UAAM,KAAK,WAAW,MAAM,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,GAAI;AAC5D,WAAO,MAAM,aAAa,EAAE;AAAA,EAC9B,GAAG,CAAC,MAAM,QAAQ,CAAC;AAEnB,QAAM,OAAO;AAAA,IACX,OAAO,KAAK,UAAU;AACpB,UAAI,CAAC,GAAI,QAAO;AAChB,eAAS,EAAE,MAAM,eAAe,CAAC;AACjC,UAAI;AACF,cAAM,IAAI,EAAE,iBAAiB,EAAE;AAC/B,iBAAS,EAAE,MAAM,iBAAiB,CAAC;AACnC,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,iBAAS,EAAE,MAAM,eAAe,SAAS,cAAc,KAAK,2CAA2C,EAAE,QAAQ,CAAC;AAClH,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,OAAO,GAAG;AAAA,EACb;AAEA,QAAM,SAAS;AAAA,IACb,OAAO,EAAE,MAAM,MAAM,IAAI,CAAC,MAAM;AAC9B,YAAM,WAAW,QAAQ,MAAM;AAC/B,UAAI,CAAC,SAAS,SAAS,WAAW,EAAG,QAAO;AAC5C,eAAS,EAAE,MAAM,iBAAiB,CAAC;AACnC,UAAI;AACF,cAAM,IAAI,EAAE,gBAAgB,OAAO,QAAQ;AAC3C,cAAM,QAAQ;AACd,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,iBAAS,EAAE,MAAM,iBAAiB,SAAS,cAAc,KAAK,mCAAmC,EAAE,QAAQ,CAAC;AAC5G,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM,MAAM,GAAG;AAAA,EACzB;AAEA,QAAM,UAAU,YAAY,CAAC,SAAiB,SAAS,EAAE,MAAM,gBAAgB,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1F,QAAM,YAAY,YAAY,MAAM,SAAS,EAAE,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC5E,QAAM,OAAO,YAAY,CAAC,YAAoB,SAAS,EAAE,MAAM,iBAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC;AAE9F,SAAO,EAAE,OAAO,SAAS,MAAM,QAAQ,WAAW,KAAK;AACzD;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var wallet_failure_exports = {};
|
|
20
|
+
__export(wallet_failure_exports, {
|
|
21
|
+
describeWalletFailure: () => describeWalletFailure,
|
|
22
|
+
isPasskeyCancelled: () => isPasskeyCancelled
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(wallet_failure_exports);
|
|
25
|
+
const isPasskeyCancelled = (err) => typeof err === "object" && err !== null && err.name === "PasskeyCancelledError";
|
|
26
|
+
const message = (err) => err instanceof Error ? err.message : "";
|
|
27
|
+
function describeWalletFailure(err, support = "unknown") {
|
|
28
|
+
const raw = message(err);
|
|
29
|
+
if (isPasskeyCancelled(err)) {
|
|
30
|
+
return support === "unavailable" ? {
|
|
31
|
+
kind: "no-passkeys",
|
|
32
|
+
message: "Passkeys aren't available in this window. Open Medialane in a regular browser window (not Guest or Incognito) and try again.",
|
|
33
|
+
canRetry: true
|
|
34
|
+
} : {
|
|
35
|
+
kind: "cancelled",
|
|
36
|
+
message: "The passkey prompt was closed. Try again to finish setting up your account. If your browser says your device can't be used, open Medialane in a regular browser window (not Guest or Incognito).",
|
|
37
|
+
canRetry: true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (/PRF/.test(raw)) {
|
|
41
|
+
return { kind: "unsupported-browser", message: "Browser not supported. Please try another browser.", canRetry: false };
|
|
42
|
+
}
|
|
43
|
+
if (/has not appeared|submitted but/i.test(raw)) {
|
|
44
|
+
return {
|
|
45
|
+
kind: "still-deploying",
|
|
46
|
+
message: "Your wallet is still being set up. Give it a minute, then try again. Nothing is lost.",
|
|
47
|
+
canRetry: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (/deploy/i.test(raw)) {
|
|
51
|
+
return { kind: "deployment", message: "We couldn't finish setting up your wallet. Please try again in a moment.", canRetry: true };
|
|
52
|
+
}
|
|
53
|
+
if (/failed to fetch|networkerror|load failed|network request failed/i.test(raw)) {
|
|
54
|
+
return { kind: "network", message: "We couldn't reach Medialane. Check your connection and try again.", canRetry: true };
|
|
55
|
+
}
|
|
56
|
+
return { kind: "unknown", message: "We couldn't finish setting up your account. Please try again.", canRetry: true };
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
describeWalletFailure,
|
|
61
|
+
isPasskeyCancelled
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=wallet-failure.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/wallet-failure.ts"],"sourcesContent":["import type { PasskeySupport } from \"./passkey-support.js\";\n\nexport type WalletFailureKind =\n | \"cancelled\"\n | \"no-passkeys\"\n | \"unsupported-browser\"\n | \"network\"\n | \"still-deploying\"\n | \"deployment\"\n | \"unknown\";\n\nexport interface WalletFailureNotice {\n kind: WalletFailureKind;\n message: string;\n canRetry: boolean;\n}\n\nexport const isPasskeyCancelled = (err: unknown): boolean =>\n typeof err === \"object\" && err !== null && (err as { name?: unknown }).name === \"PasskeyCancelledError\";\n\nconst message = (err: unknown): string => (err instanceof Error ? err.message : \"\");\n\nexport function describeWalletFailure(err: unknown, support: PasskeySupport = \"unknown\"): WalletFailureNotice {\n const raw = message(err);\n\n if (isPasskeyCancelled(err)) {\n return support === \"unavailable\"\n ? {\n kind: \"no-passkeys\",\n message: \"Passkeys aren't available in this window. Open Medialane in a regular browser window (not Guest or Incognito) and try again.\",\n canRetry: true,\n }\n : {\n kind: \"cancelled\",\n message:\n \"The passkey prompt was closed. Try again to finish setting up your account. If your browser says your device can't be used, open Medialane in a regular browser window (not Guest or Incognito).\",\n canRetry: true,\n };\n }\n\n if (/PRF/.test(raw)) {\n return { kind: \"unsupported-browser\", message: \"Browser not supported. Please try another browser.\", canRetry: false };\n }\n\n if (/has not appeared|submitted but/i.test(raw)) {\n return {\n kind: \"still-deploying\",\n message: \"Your wallet is still being set up. Give it a minute, then try again. Nothing is lost.\",\n canRetry: true,\n };\n }\n\n if (/deploy/i.test(raw)) {\n return { kind: \"deployment\", message: \"We couldn't finish setting up your wallet. Please try again in a moment.\", canRetry: true };\n }\n\n if (/failed to fetch|networkerror|load failed|network request failed/i.test(raw)) {\n return { kind: \"network\", message: \"We couldn't reach Medialane. Check your connection and try again.\", canRetry: true };\n }\n\n return { kind: \"unknown\", message: \"We couldn't finish setting up your account. Please try again.\", canRetry: true };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,MAAM,qBAAqB,CAAC,QACjC,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAA2B,SAAS;AAElF,MAAM,UAAU,CAAC,QAA0B,eAAe,QAAQ,IAAI,UAAU;AAEzE,SAAS,sBAAsB,KAAc,UAA0B,WAAgC;AAC5G,QAAM,MAAM,QAAQ,GAAG;AAEvB,MAAI,mBAAmB,GAAG,GAAG;AAC3B,WAAO,YAAY,gBACf;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACZ,IACA;AAAA,MACE,MAAM;AAAA,MACN,SACE;AAAA,MACF,UAAU;AAAA,IACZ;AAAA,EACN;AAEA,MAAI,MAAM,KAAK,GAAG,GAAG;AACnB,WAAO,EAAE,MAAM,uBAAuB,SAAS,sDAAsD,UAAU,MAAM;AAAA,EACvH;AAEA,MAAI,kCAAkC,KAAK,GAAG,GAAG;AAC/C,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,MAAI,UAAU,KAAK,GAAG,GAAG;AACvB,WAAO,EAAE,MAAM,cAAc,SAAS,4EAA4E,UAAU,KAAK;AAAA,EACnI;AAEA,MAAI,mEAAmE,KAAK,GAAG,GAAG;AAChF,WAAO,EAAE,MAAM,WAAW,SAAS,qEAAqE,UAAU,KAAK;AAAA,EACzH;AAEA,SAAO,EAAE,MAAM,WAAW,SAAS,iEAAiE,UAAU,KAAK;AACrH;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PasskeySupport } from './passkey-support.cjs';
|
|
2
|
+
|
|
3
|
+
type WalletFailureKind = "cancelled" | "no-passkeys" | "unsupported-browser" | "network" | "still-deploying" | "deployment" | "unknown";
|
|
4
|
+
interface WalletFailureNotice {
|
|
5
|
+
kind: WalletFailureKind;
|
|
6
|
+
message: string;
|
|
7
|
+
canRetry: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const isPasskeyCancelled: (err: unknown) => boolean;
|
|
10
|
+
declare function describeWalletFailure(err: unknown, support?: PasskeySupport): WalletFailureNotice;
|
|
11
|
+
|
|
12
|
+
export { type WalletFailureKind, type WalletFailureNotice, describeWalletFailure, isPasskeyCancelled };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PasskeySupport } from './passkey-support.js';
|
|
2
|
+
|
|
3
|
+
type WalletFailureKind = "cancelled" | "no-passkeys" | "unsupported-browser" | "network" | "still-deploying" | "deployment" | "unknown";
|
|
4
|
+
interface WalletFailureNotice {
|
|
5
|
+
kind: WalletFailureKind;
|
|
6
|
+
message: string;
|
|
7
|
+
canRetry: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const isPasskeyCancelled: (err: unknown) => boolean;
|
|
10
|
+
declare function describeWalletFailure(err: unknown, support?: PasskeySupport): WalletFailureNotice;
|
|
11
|
+
|
|
12
|
+
export { type WalletFailureKind, type WalletFailureNotice, describeWalletFailure, isPasskeyCancelled };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const isPasskeyCancelled = (err) => typeof err === "object" && err !== null && err.name === "PasskeyCancelledError";
|
|
2
|
+
const message = (err) => err instanceof Error ? err.message : "";
|
|
3
|
+
function describeWalletFailure(err, support = "unknown") {
|
|
4
|
+
const raw = message(err);
|
|
5
|
+
if (isPasskeyCancelled(err)) {
|
|
6
|
+
return support === "unavailable" ? {
|
|
7
|
+
kind: "no-passkeys",
|
|
8
|
+
message: "Passkeys aren't available in this window. Open Medialane in a regular browser window (not Guest or Incognito) and try again.",
|
|
9
|
+
canRetry: true
|
|
10
|
+
} : {
|
|
11
|
+
kind: "cancelled",
|
|
12
|
+
message: "The passkey prompt was closed. Try again to finish setting up your account. If your browser says your device can't be used, open Medialane in a regular browser window (not Guest or Incognito).",
|
|
13
|
+
canRetry: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (/PRF/.test(raw)) {
|
|
17
|
+
return { kind: "unsupported-browser", message: "Browser not supported. Please try another browser.", canRetry: false };
|
|
18
|
+
}
|
|
19
|
+
if (/has not appeared|submitted but/i.test(raw)) {
|
|
20
|
+
return {
|
|
21
|
+
kind: "still-deploying",
|
|
22
|
+
message: "Your wallet is still being set up. Give it a minute, then try again. Nothing is lost.",
|
|
23
|
+
canRetry: true
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (/deploy/i.test(raw)) {
|
|
27
|
+
return { kind: "deployment", message: "We couldn't finish setting up your wallet. Please try again in a moment.", canRetry: true };
|
|
28
|
+
}
|
|
29
|
+
if (/failed to fetch|networkerror|load failed|network request failed/i.test(raw)) {
|
|
30
|
+
return { kind: "network", message: "We couldn't reach Medialane. Check your connection and try again.", canRetry: true };
|
|
31
|
+
}
|
|
32
|
+
return { kind: "unknown", message: "We couldn't finish setting up your account. Please try again.", canRetry: true };
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
describeWalletFailure,
|
|
36
|
+
isPasskeyCancelled
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=wallet-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/wallet-failure.ts"],"sourcesContent":["import type { PasskeySupport } from \"./passkey-support.js\";\n\nexport type WalletFailureKind =\n | \"cancelled\"\n | \"no-passkeys\"\n | \"unsupported-browser\"\n | \"network\"\n | \"still-deploying\"\n | \"deployment\"\n | \"unknown\";\n\nexport interface WalletFailureNotice {\n kind: WalletFailureKind;\n message: string;\n canRetry: boolean;\n}\n\nexport const isPasskeyCancelled = (err: unknown): boolean =>\n typeof err === \"object\" && err !== null && (err as { name?: unknown }).name === \"PasskeyCancelledError\";\n\nconst message = (err: unknown): string => (err instanceof Error ? err.message : \"\");\n\nexport function describeWalletFailure(err: unknown, support: PasskeySupport = \"unknown\"): WalletFailureNotice {\n const raw = message(err);\n\n if (isPasskeyCancelled(err)) {\n return support === \"unavailable\"\n ? {\n kind: \"no-passkeys\",\n message: \"Passkeys aren't available in this window. Open Medialane in a regular browser window (not Guest or Incognito) and try again.\",\n canRetry: true,\n }\n : {\n kind: \"cancelled\",\n message:\n \"The passkey prompt was closed. Try again to finish setting up your account. If your browser says your device can't be used, open Medialane in a regular browser window (not Guest or Incognito).\",\n canRetry: true,\n };\n }\n\n if (/PRF/.test(raw)) {\n return { kind: \"unsupported-browser\", message: \"Browser not supported. Please try another browser.\", canRetry: false };\n }\n\n if (/has not appeared|submitted but/i.test(raw)) {\n return {\n kind: \"still-deploying\",\n message: \"Your wallet is still being set up. Give it a minute, then try again. Nothing is lost.\",\n canRetry: true,\n };\n }\n\n if (/deploy/i.test(raw)) {\n return { kind: \"deployment\", message: \"We couldn't finish setting up your wallet. Please try again in a moment.\", canRetry: true };\n }\n\n if (/failed to fetch|networkerror|load failed|network request failed/i.test(raw)) {\n return { kind: \"network\", message: \"We couldn't reach Medialane. Check your connection and try again.\", canRetry: true };\n }\n\n return { kind: \"unknown\", message: \"We couldn't finish setting up your account. Please try again.\", canRetry: true };\n}\n"],"mappings":"AAiBO,MAAM,qBAAqB,CAAC,QACjC,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAA2B,SAAS;AAElF,MAAM,UAAU,CAAC,QAA0B,eAAe,QAAQ,IAAI,UAAU;AAEzE,SAAS,sBAAsB,KAAc,UAA0B,WAAgC;AAC5G,QAAM,MAAM,QAAQ,GAAG;AAEvB,MAAI,mBAAmB,GAAG,GAAG;AAC3B,WAAO,YAAY,gBACf;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACZ,IACA;AAAA,MACE,MAAM;AAAA,MACN,SACE;AAAA,MACF,UAAU;AAAA,IACZ;AAAA,EACN;AAEA,MAAI,MAAM,KAAK,GAAG,GAAG;AACnB,WAAO,EAAE,MAAM,uBAAuB,SAAS,sDAAsD,UAAU,MAAM;AAAA,EACvH;AAEA,MAAI,kCAAkC,KAAK,GAAG,GAAG;AAC/C,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,MAAI,UAAU,KAAK,GAAG,GAAG;AACvB,WAAO,EAAE,MAAM,cAAc,SAAS,4EAA4E,UAAU,KAAK;AAAA,EACnI;AAEA,MAAI,mEAAmE,KAAK,GAAG,GAAG;AAChF,WAAO,EAAE,MAAM,WAAW,SAAS,qEAAqE,UAAU,KAAK;AAAA,EACzH;AAEA,SAAO,EAAE,MAAM,WAAW,SAAS,iEAAiE,UAAU,KAAK;AACrH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.176.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"clsx": ">=2.0.0",
|
|
67
67
|
"cmdk": ">=1.0.0",
|
|
68
68
|
"framer-motion": ">=10.0.0",
|
|
69
|
+
"input-otp": ">=1.4.1",
|
|
69
70
|
"lucide-react": ">=0.400.0",
|
|
70
71
|
"next": ">=14.0.0",
|
|
71
72
|
"next-themes": ">=0.3.0",
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
"clsx": "^2.0.0",
|
|
99
100
|
"cmdk": "^1.1.1",
|
|
100
101
|
"framer-motion": "^11.0.0",
|
|
102
|
+
"input-otp": "1.4.1",
|
|
101
103
|
"lucide-react": "^0.400.0",
|
|
102
104
|
"next": "^15.5.23",
|
|
103
105
|
"next-themes": "^0.4.0",
|