delta-auth-next 0.1.49 → 0.1.50
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutButton.d.ts","sourceRoot":"","sources":["../src/LogoutButton.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"LogoutButton.d.ts","sourceRoot":"","sources":["../src/LogoutButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAIhD,UAAU,WAAY,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,GAAI,8DAM1B,WAAW,mDAyCb,CAAC"}
|
package/dist/LogoutButton.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
4
|
import { useLogout } from './UseLogout';
|
|
5
5
|
import { useDeltaAuth } from './hooks';
|
|
6
6
|
export const LogoutButton = ({ preferredText = 'Log Out', allSessions = false, className, onClick, ...props }) => {
|
|
7
7
|
const logout = useLogout();
|
|
8
8
|
const { deltaUser, loading, isAuthenticated } = useDeltaAuth(); // ✅ renamed user to deltaUser
|
|
9
|
+
const [displayText, setDisplayText] = useState(preferredText);
|
|
9
10
|
const hasCustomStyles = !!className;
|
|
10
11
|
// ✅ Default Tailwind styling
|
|
11
12
|
const defaultClasses = useMemo(() => 'px-6 py-2.5 rounded-xl font-semibold text-white transition-all duration-300 bg-red-600 hover:bg-red-700', []);
|
|
12
13
|
const handleClick = (e) => {
|
|
13
14
|
onClick?.(e);
|
|
14
15
|
if (!e.defaultPrevented) {
|
|
16
|
+
setDisplayText("Logging out");
|
|
15
17
|
logout({ allSessions });
|
|
16
18
|
}
|
|
17
19
|
};
|
|
@@ -24,6 +26,6 @@ export const LogoutButton = ({ preferredText = 'Log Out', allSessions = false, c
|
|
|
24
26
|
// ✅ updated to deltaUser
|
|
25
27
|
return null; // dev placeholder — nothing is rendered
|
|
26
28
|
}
|
|
27
|
-
return (_jsx("button", { ...props, onClick: handleClick, className: !hasCustomStyles ? defaultClasses : className, children:
|
|
29
|
+
return (_jsx("button", { ...props, onClick: handleClick, className: !hasCustomStyles ? defaultClasses : className, children: displayText }));
|
|
28
30
|
};
|
|
29
31
|
//# sourceMappingURL=LogoutButton.js.map
|
package/dist/LogoutButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutButton.js","sourceRoot":"","sources":["../src/LogoutButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LogoutButton.js","sourceRoot":"","sources":["../src/LogoutButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,aAAa,GAAG,SAAS,EACzB,WAAW,GAAG,KAAK,EACnB,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACI,EAAE,EAAE;IAChB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,8BAA8B;IAC9F,MAAM,CAAC,WAAW,EAAC,cAAc,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC5D,MAAM,eAAe,GAAG,CAAC,CAAC,SAAS,CAAC;IAEpC,6BAA6B;IAC7B,MAAM,cAAc,GAAG,OAAO,CAC5B,GAAG,EAAE,CACH,yGAAyG,EAC3G,EAAE,CACH,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC7D,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;YACxB,cAAc,CAAC,aAAa,CAAC,CAAA;YAC7B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC;IAEF,iCAAiC;IACjC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,cAAK,SAAS,EAAC,gDAAgD,GAAG,CAAC;IAC5E,CAAC;IAED,sDAAsD;IACtD,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,yBAAyB;QACzB,OAAO,IAAI,CAAC,CAAC,wCAAwC;IACvD,CAAC;IAED,OAAO,CACL,oBACM,KAAK,EACT,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,YAEvD,WAAW,GACL,CACV,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/UseLogout.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
interface UseLogoutOptions {
|
|
2
2
|
allSessions?: boolean;
|
|
3
|
-
redirectUrl?: string;
|
|
4
3
|
}
|
|
5
|
-
export declare function useLogout(): ({ allSessions
|
|
4
|
+
export declare function useLogout(): ({ allSessions }?: UseLogoutOptions) => Promise<void>;
|
|
6
5
|
export {};
|
|
7
6
|
//# sourceMappingURL=UseLogout.d.ts.map
|
package/dist/UseLogout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseLogout.d.ts","sourceRoot":"","sources":["../src/UseLogout.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UseLogout.d.ts","sourceRoot":"","sources":["../src/UseLogout.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,SAAS,uBAGwB,gBAAgB,mBA4BhE"}
|
package/dist/UseLogout.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { AuthContext } from './context';
|
|
3
3
|
export function useLogout() {
|
|
4
|
-
const { config } = useContext(AuthContext);
|
|
5
|
-
|
|
4
|
+
const { config, app, client } = useContext(AuthContext);
|
|
5
|
+
const logout = async ({ allSessions = false } = {}) => {
|
|
6
6
|
if (!config?.authDomain || !config?.publishableKey)
|
|
7
7
|
return;
|
|
8
8
|
const defaultRedirect = typeof window !== 'undefined'
|
|
9
9
|
? window.location.origin
|
|
10
10
|
: config?.frontendUrl || '/';
|
|
11
|
-
const finalRedirect =
|
|
12
|
-
const endpoint = allSessions ?
|
|
11
|
+
const finalRedirect = app?.redirect_url || defaultRedirect;
|
|
12
|
+
const endpoint = `/auth/logout?sessions=${allSessions ? `all` : `one`}`;
|
|
13
13
|
const url = `${config.authDomain}${endpoint}?client_id=${config.publishableKey}&redirect_uri=${encodeURIComponent(finalRedirect)}`;
|
|
14
14
|
if (typeof window !== 'undefined') {
|
|
15
15
|
window.location.href = url;
|
|
16
16
|
}
|
|
17
|
+
const res = await client.get(url, {
|
|
18
|
+
headers: { 'x-delta-publishable-key': config.publishableKey },
|
|
19
|
+
withCredentials: true,
|
|
20
|
+
});
|
|
21
|
+
if (res.data.success) {
|
|
22
|
+
window.location.href = finalRedirect;
|
|
23
|
+
}
|
|
17
24
|
};
|
|
25
|
+
return logout;
|
|
18
26
|
}
|
|
19
27
|
//# sourceMappingURL=UseLogout.js.map
|
package/dist/UseLogout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseLogout.js","sourceRoot":"","sources":["../src/UseLogout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"UseLogout.js","sourceRoot":"","sources":["../src/UseLogout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMxC,MAAM,UAAU,SAAS;IACvB,MAAM,EAAE,MAAM,EAAE,GAAG,EAAC,MAAM,EAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAEtD,MAAM,MAAM,GAAI,KAAK,EAAE,EAAE,WAAW,GAAG,KAAK,KAAsB,EAAE,EAAE,EAAE;QACtE,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE,cAAc;YAAE,OAAO;QAE3D,MAAM,eAAe,GACnB,OAAO,MAAM,KAAK,WAAW;YAC3B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;YACxB,CAAC,CAAC,MAAM,EAAE,WAAW,IAAI,GAAG,CAAC;QAEjC,MAAM,aAAa,GAAG,GAAG,EAAE,YAAY,IAAG,eAAe,CAAC;QAE1D,MAAM,QAAQ,GAAG,yBAAyB,WAAW,CAAA,CAAC,CAAA,KAAK,CAAA,CAAC,CAAA,KAAK,EAAE,CAAC;QAEpE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,GAAG,QAAQ,cACzC,MAAM,CAAC,cACT,iBAAiB,kBAAkB,CAAC,aAAa,CAAC,EAAE,CAAC;QAErD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;QAC7B,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;YAChC,OAAO,EAAE,EAAE,yBAAyB,EAAE,MAAM,CAAC,cAAc,EAAE;YAC7D,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;QACH,IAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAC,CAAC;YACnB,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,aAAa,CAAC;QACvC,CAAC;IACH,CAAC,CAAC;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "delta-auth-next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "A lightweight authentication system for Next.js that provides React context providers and Edge-safe middleware utilities for handling sign-in redirects and session management.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Samuel Onwodi",
|