@authsome/ui-core 0.1.2 → 0.1.4
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 +39 -3
- package/dist/index.d.ts +39 -3
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -1
- 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 +1 -1
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() {
|
|
@@ -1080,6 +1180,7 @@ var AuthClient = class {
|
|
|
1080
1180
|
error: authError,
|
|
1081
1181
|
isLoading: false
|
|
1082
1182
|
});
|
|
1183
|
+
throw authError;
|
|
1083
1184
|
}
|
|
1084
1185
|
startAutoRefresh() {
|
|
1085
1186
|
this.stopAutoRefresh();
|
|
@@ -1583,6 +1684,6 @@ var predefinedFlows = {
|
|
|
1583
1684
|
["password_reset_flow" /* PASSWORD_RESET_FLOW */]: passwordResetFlow
|
|
1584
1685
|
};
|
|
1585
1686
|
|
|
1586
|
-
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 };
|
|
1687
|
+
export { AuthClient, AuthError, AuthErrorType, AuthState, BaseAuthProvider, FlowAction, FlowConfigType, FlowEngine, FlowStep, LocalStorageAdapter, MemoryStorageAdapter, OAuthProvider, Observable, SessionStorageAdapter, TokenManager, TwoFactorMethod, completeSignUpFlow, createAuthError, createLocale, defaultLocale, 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 };
|
|
1587
1688
|
//# sourceMappingURL=index.mjs.map
|
|
1588
1689
|
//# sourceMappingURL=index.mjs.map
|