@authsome/ui-core 0.1.3 → 0.1.5
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/adapters/index.d.mts +9 -1
- package/dist/adapters/index.d.ts +9 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/index.d.mts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +132 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-C8km9A8U.d.mts → provider-KGfwPsXv.d.mts} +58 -1
- package/dist/{provider-C8km9A8U.d.ts → provider-KGfwPsXv.d.ts} +58 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/package.json +11 -12
package/dist/index.mjs
CHANGED
|
@@ -552,6 +552,106 @@ var TokenManager = class {
|
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
554
|
|
|
555
|
+
// src/utils/cookies.ts
|
|
556
|
+
function parseCookie(setCookieHeader) {
|
|
557
|
+
if (!setCookieHeader) return null;
|
|
558
|
+
const parts = setCookieHeader.split(";").map((p) => p.trim());
|
|
559
|
+
if (parts.length === 0) return null;
|
|
560
|
+
const [nameValue] = parts;
|
|
561
|
+
const [name, value] = nameValue.split("=");
|
|
562
|
+
if (!name || value === void 0) return null;
|
|
563
|
+
const cookieData = { name, value };
|
|
564
|
+
const options = {};
|
|
565
|
+
for (let i = 1; i < parts.length; i++) {
|
|
566
|
+
const part = parts[i];
|
|
567
|
+
const lowerPart = part.toLowerCase();
|
|
568
|
+
if (lowerPart === "httponly") {
|
|
569
|
+
options.httpOnly = true;
|
|
570
|
+
} else if (lowerPart === "secure") {
|
|
571
|
+
options.secure = true;
|
|
572
|
+
} else if (lowerPart.startsWith("path=")) {
|
|
573
|
+
options.path = part.substring(5);
|
|
574
|
+
} else if (lowerPart.startsWith("domain=")) {
|
|
575
|
+
options.domain = part.substring(7);
|
|
576
|
+
} else if (lowerPart.startsWith("max-age=")) {
|
|
577
|
+
const maxAge = parseInt(part.substring(8), 10);
|
|
578
|
+
if (!isNaN(maxAge)) {
|
|
579
|
+
options.maxAge = maxAge;
|
|
580
|
+
}
|
|
581
|
+
} else if (lowerPart.startsWith("expires=")) {
|
|
582
|
+
const expiresStr = part.substring(8);
|
|
583
|
+
const expiresDate = new Date(expiresStr);
|
|
584
|
+
if (!isNaN(expiresDate.getTime())) {
|
|
585
|
+
options.expires = expiresDate;
|
|
586
|
+
}
|
|
587
|
+
} else if (lowerPart.startsWith("samesite=")) {
|
|
588
|
+
const sameSiteValue = lowerPart.substring(9);
|
|
589
|
+
if (sameSiteValue === "strict" || sameSiteValue === "lax" || sameSiteValue === "none") {
|
|
590
|
+
options.sameSite = sameSiteValue;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (Object.keys(options).length > 0) {
|
|
595
|
+
cookieData.options = options;
|
|
596
|
+
}
|
|
597
|
+
return cookieData;
|
|
598
|
+
}
|
|
599
|
+
function extractCookiesFromHeaders(setCookieHeaders) {
|
|
600
|
+
const headers = Array.isArray(setCookieHeaders) ? setCookieHeaders : [setCookieHeaders];
|
|
601
|
+
const cookies = [];
|
|
602
|
+
for (const header of headers) {
|
|
603
|
+
const cookie = parseCookie(header);
|
|
604
|
+
if (cookie) {
|
|
605
|
+
cookies.push(cookie);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return cookies;
|
|
609
|
+
}
|
|
610
|
+
function serializeCookie(cookie) {
|
|
611
|
+
const parts = [`${cookie.name}=${cookie.value}`];
|
|
612
|
+
if (cookie.options) {
|
|
613
|
+
const opts = cookie.options;
|
|
614
|
+
if (opts.path) {
|
|
615
|
+
parts.push(`Path=${opts.path}`);
|
|
616
|
+
}
|
|
617
|
+
if (opts.domain) {
|
|
618
|
+
parts.push(`Domain=${opts.domain}`);
|
|
619
|
+
}
|
|
620
|
+
if (opts.expires) {
|
|
621
|
+
parts.push(`Expires=${opts.expires.toUTCString()}`);
|
|
622
|
+
}
|
|
623
|
+
if (opts.maxAge !== void 0) {
|
|
624
|
+
parts.push(`Max-Age=${opts.maxAge}`);
|
|
625
|
+
}
|
|
626
|
+
if (opts.httpOnly) {
|
|
627
|
+
parts.push("HttpOnly");
|
|
628
|
+
}
|
|
629
|
+
if (opts.secure) {
|
|
630
|
+
parts.push("Secure");
|
|
631
|
+
}
|
|
632
|
+
if (opts.sameSite) {
|
|
633
|
+
const sameSite = opts.sameSite.charAt(0).toUpperCase() + opts.sameSite.slice(1);
|
|
634
|
+
parts.push(`SameSite=${sameSite}`);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return parts.join("; ");
|
|
638
|
+
}
|
|
639
|
+
function parseCookieOptions(cookieHeader) {
|
|
640
|
+
const cookies = {};
|
|
641
|
+
if (!cookieHeader) return cookies;
|
|
642
|
+
const pairs = cookieHeader.split(";").map((p) => p.trim());
|
|
643
|
+
for (const pair of pairs) {
|
|
644
|
+
const [name, value] = pair.split("=");
|
|
645
|
+
if (name && value !== void 0) {
|
|
646
|
+
cookies[name.trim()] = value.trim();
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return cookies;
|
|
650
|
+
}
|
|
651
|
+
function serializeCookies(cookies) {
|
|
652
|
+
return Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
653
|
+
}
|
|
654
|
+
|
|
555
655
|
// src/adapters/base-provider.ts
|
|
556
656
|
var BaseAuthProvider = class {
|
|
557
657
|
constructor() {
|
|
@@ -1149,6 +1249,7 @@ var FlowConfigType = /* @__PURE__ */ ((FlowConfigType2) => {
|
|
|
1149
1249
|
FlowConfigType2["COMPLETE_SIGN_UP_FLOW"] = "complete_sign_up_flow";
|
|
1150
1250
|
FlowConfigType2["SECURE_SIGN_IN_FLOW"] = "secure_sign_in_flow";
|
|
1151
1251
|
FlowConfigType2["PASSWORD_RESET_FLOW"] = "password_reset_flow";
|
|
1252
|
+
FlowConfigType2["EMAIL_VERIFICATION_FLOW"] = "email_verification_flow";
|
|
1152
1253
|
FlowConfigType2["CUSTOM"] = "custom";
|
|
1153
1254
|
return FlowConfigType2;
|
|
1154
1255
|
})(FlowConfigType || {});
|
|
@@ -1554,6 +1655,27 @@ var passwordResetFlow = {
|
|
|
1554
1655
|
}
|
|
1555
1656
|
}
|
|
1556
1657
|
};
|
|
1658
|
+
var emailVerificationFlow = {
|
|
1659
|
+
name: "Email Verification",
|
|
1660
|
+
description: "Verify email address with code or link",
|
|
1661
|
+
initialStep: "email_verification_required" /* EMAIL_VERIFICATION_REQUIRED */,
|
|
1662
|
+
allowedSteps: [
|
|
1663
|
+
"email_verification_required" /* EMAIL_VERIFICATION_REQUIRED */,
|
|
1664
|
+
"email_verification_sent" /* EMAIL_VERIFICATION_SENT */,
|
|
1665
|
+
"success" /* SUCCESS */,
|
|
1666
|
+
"error" /* ERROR */
|
|
1667
|
+
],
|
|
1668
|
+
transitions: {
|
|
1669
|
+
["email_verification_required" /* EMAIL_VERIFICATION_REQUIRED */]: {
|
|
1670
|
+
onSuccess: "email_verification_sent" /* EMAIL_VERIFICATION_SENT */,
|
|
1671
|
+
onError: "email_verification_required" /* EMAIL_VERIFICATION_REQUIRED */
|
|
1672
|
+
},
|
|
1673
|
+
["email_verification_sent" /* EMAIL_VERIFICATION_SENT */]: {
|
|
1674
|
+
onSuccess: "success" /* SUCCESS */,
|
|
1675
|
+
onError: "email_verification_required" /* EMAIL_VERIFICATION_REQUIRED */
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1557
1679
|
function getFlowConfig(type) {
|
|
1558
1680
|
switch (type) {
|
|
1559
1681
|
case "simple_sign_in" /* SIMPLE_SIGN_IN */:
|
|
@@ -1570,6 +1692,8 @@ function getFlowConfig(type) {
|
|
|
1570
1692
|
return oauthSignInFlow;
|
|
1571
1693
|
case "password_reset_flow" /* PASSWORD_RESET_FLOW */:
|
|
1572
1694
|
return passwordResetFlow;
|
|
1695
|
+
case "email_verification_flow" /* EMAIL_VERIFICATION_FLOW */:
|
|
1696
|
+
return emailVerificationFlow;
|
|
1573
1697
|
default:
|
|
1574
1698
|
throw new Error(`Unknown flow type: ${type}`);
|
|
1575
1699
|
}
|
|
@@ -1581,9 +1705,10 @@ var predefinedFlows = {
|
|
|
1581
1705
|
["magic_link_flow" /* MAGIC_LINK_FLOW */]: magicLinkFlow,
|
|
1582
1706
|
["phone_auth_flow" /* PHONE_AUTH_FLOW */]: phoneAuthFlow,
|
|
1583
1707
|
["oauth_sign_in" /* OAUTH_SIGN_IN */]: oauthSignInFlow,
|
|
1584
|
-
["password_reset_flow" /* PASSWORD_RESET_FLOW */]: passwordResetFlow
|
|
1708
|
+
["password_reset_flow" /* PASSWORD_RESET_FLOW */]: passwordResetFlow,
|
|
1709
|
+
["email_verification_flow" /* EMAIL_VERIFICATION_FLOW */]: emailVerificationFlow
|
|
1585
1710
|
};
|
|
1586
1711
|
|
|
1587
|
-
export { AuthClient, AuthError, AuthErrorType, AuthState, BaseAuthProvider, FlowAction, FlowConfigType, FlowEngine, FlowStep, LocalStorageAdapter, MemoryStorageAdapter, OAuthProvider, Observable, SessionStorageAdapter, TokenManager, TwoFactorMethod, completeSignUpFlow, createAuthError, createLocale, defaultLocale, getFlowConfig, interpolate, isAuthError, isMFARequiredError, isNetworkError, isUnauthenticatedError, magicLinkFlow, oauthSignInFlow, passwordResetFlow, phoneAuthFlow, predefinedFlows, signInWithMFAFlow, simpleSignInFlow, toAuthError, validate2FACode, validateEmail, validatePassword, validatePhone, validateRequired, validateUsername };
|
|
1712
|
+
export { AuthClient, AuthError, AuthErrorType, AuthState, BaseAuthProvider, FlowAction, FlowConfigType, FlowEngine, FlowStep, LocalStorageAdapter, MemoryStorageAdapter, OAuthProvider, Observable, SessionStorageAdapter, TokenManager, TwoFactorMethod, completeSignUpFlow, createAuthError, createLocale, defaultLocale, emailVerificationFlow, extractCookiesFromHeaders, getFlowConfig, interpolate, isAuthError, isMFARequiredError, isNetworkError, isUnauthenticatedError, magicLinkFlow, oauthSignInFlow, parseCookie, parseCookieOptions, passwordResetFlow, phoneAuthFlow, predefinedFlows, serializeCookie, serializeCookies, signInWithMFAFlow, simpleSignInFlow, toAuthError, validate2FACode, validateEmail, validatePassword, validatePhone, validateRequired, validateUsername };
|
|
1588
1713
|
//# sourceMappingURL=index.mjs.map
|
|
1589
1714
|
//# sourceMappingURL=index.mjs.map
|