@incorta/auth 1.0.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/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/chunk-LNPECE7W.js +62 -0
- package/dist/chunk-LNPECE7W.js.map +1 -0
- package/dist/cli.js +170 -0
- package/dist/config-B-2cbZDV.d.cts +116 -0
- package/dist/config-B-2cbZDV.d.ts +116 -0
- package/dist/express.cjs +134 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +42 -0
- package/dist/express.d.ts +42 -0
- package/dist/express.js +59 -0
- package/dist/express.js.map +1 -0
- package/dist/index.cjs +642 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +75 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +613 -0
- package/dist/index.js.map +1 -0
- package/dist/node.cjs +89 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +28 -0
- package/dist/node.d.ts +28 -0
- package/dist/node.js +13 -0
- package/dist/node.js.map +1 -0
- package/dist/react/index.cjs +179 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +81 -0
- package/dist/react/index.d.ts +81 -0
- package/dist/react/index.js +153 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { a as IncortaUser } from '../config-B-2cbZDV.js';
|
|
4
|
+
import 'jose';
|
|
5
|
+
|
|
6
|
+
interface SignInOptions {
|
|
7
|
+
/** Where to land after login. Defaults to the current URL. */
|
|
8
|
+
redirectTo?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SignOutOptions {
|
|
11
|
+
/** Navigate here after the session is cleared. Defaults to staying put. */
|
|
12
|
+
redirectTo?: string;
|
|
13
|
+
}
|
|
14
|
+
interface IncortaAuthContextValue {
|
|
15
|
+
/** False until the first session check completes. */
|
|
16
|
+
isLoaded: boolean;
|
|
17
|
+
isSignedIn: boolean;
|
|
18
|
+
user: IncortaUser | null;
|
|
19
|
+
/** Epoch millis when the session expires, when signed in. */
|
|
20
|
+
sessionExpiresAt: number | null;
|
|
21
|
+
/** Sends the browser through Incorta login and back. */
|
|
22
|
+
signIn: (options?: SignInOptions) => void;
|
|
23
|
+
signOut: (options?: SignOutOptions) => Promise<void>;
|
|
24
|
+
/** Re-checks the session against the backend. */
|
|
25
|
+
refresh: () => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the raw Incorta access token (requires `exposeAccessToken: true`
|
|
28
|
+
* on the server). Returns null when signed out or not exposed.
|
|
29
|
+
*/
|
|
30
|
+
getToken: () => Promise<string | null>;
|
|
31
|
+
}
|
|
32
|
+
interface IncortaAuthProviderProps {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
/** Must match the backend's basePath. @default "/auth" */
|
|
35
|
+
basePath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Re-check the session every N milliseconds so long-lived tabs keep their
|
|
38
|
+
* Incorta access token fresh (the backend refreshes it server-side).
|
|
39
|
+
* Set 0 to disable. @default 300000 (5 minutes)
|
|
40
|
+
*/
|
|
41
|
+
refetchInterval?: number;
|
|
42
|
+
}
|
|
43
|
+
declare function IncortaAuthProvider({ children, basePath, refetchInterval, }: IncortaAuthProviderProps): react.JSX.Element;
|
|
44
|
+
declare function useIncortaAuth(): IncortaAuthContextValue;
|
|
45
|
+
/** Clerk-style alias of {@link useIncortaAuth}. */
|
|
46
|
+
declare const useAuth: typeof useIncortaAuth;
|
|
47
|
+
/** The signed-in user, or null. */
|
|
48
|
+
declare function useUser(): IncortaUser | null;
|
|
49
|
+
|
|
50
|
+
/** Renders children only when the user is signed in (after the initial load). */
|
|
51
|
+
declare function SignedIn({ children }: {
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}): react.JSX.Element | null;
|
|
54
|
+
/** Renders children only when the user is signed out (after the initial load). */
|
|
55
|
+
declare function SignedOut({ children }: {
|
|
56
|
+
children: ReactNode;
|
|
57
|
+
}): react.JSX.Element | null;
|
|
58
|
+
/**
|
|
59
|
+
* Immediately sends the browser through Incorta login. Render it for signed-out
|
|
60
|
+
* users on protected pages:
|
|
61
|
+
*
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <SignedOut><RedirectToLogin /></SignedOut>
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function RedirectToLogin({ redirectTo }: {
|
|
67
|
+
redirectTo?: string;
|
|
68
|
+
}): null;
|
|
69
|
+
/**
|
|
70
|
+
* Gates children behind authentication: shows `loading` during the initial
|
|
71
|
+
* check, redirects signed-out users through Incorta login (or renders
|
|
72
|
+
* `fallback` when provided).
|
|
73
|
+
*/
|
|
74
|
+
declare function Protect({ children, fallback, loading, }: {
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
/** Rendered for signed-out users instead of redirecting. */
|
|
77
|
+
fallback?: ReactNode;
|
|
78
|
+
loading?: ReactNode;
|
|
79
|
+
}): react.JSX.Element;
|
|
80
|
+
|
|
81
|
+
export { type IncortaAuthContextValue, IncortaAuthProvider, type IncortaAuthProviderProps, IncortaUser, Protect, RedirectToLogin, type SignInOptions, type SignOutOptions, SignedIn, SignedOut, useAuth, useIncortaAuth, useUser };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// src/react/context.tsx
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var IncortaAuthContext = createContext(null);
|
|
13
|
+
function IncortaAuthProvider({
|
|
14
|
+
children,
|
|
15
|
+
basePath = "/auth",
|
|
16
|
+
refetchInterval = 5 * 60 * 1e3
|
|
17
|
+
}) {
|
|
18
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
19
|
+
const [user, setUser] = useState(null);
|
|
20
|
+
const [sessionExpiresAt, setSessionExpiresAt] = useState(null);
|
|
21
|
+
const mounted = useRef(true);
|
|
22
|
+
const refresh = useCallback(async () => {
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(`${basePath}/session`, {
|
|
25
|
+
headers: { accept: "application/json" }
|
|
26
|
+
});
|
|
27
|
+
const body = await response.json();
|
|
28
|
+
if (!mounted.current) return;
|
|
29
|
+
setUser(body.user ?? null);
|
|
30
|
+
setSessionExpiresAt(body.session?.expiresAt ?? null);
|
|
31
|
+
} catch {
|
|
32
|
+
if (!mounted.current) return;
|
|
33
|
+
setUser(null);
|
|
34
|
+
setSessionExpiresAt(null);
|
|
35
|
+
} finally {
|
|
36
|
+
if (mounted.current) setIsLoaded(true);
|
|
37
|
+
}
|
|
38
|
+
}, [basePath]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
mounted.current = true;
|
|
41
|
+
void refresh();
|
|
42
|
+
return () => {
|
|
43
|
+
mounted.current = false;
|
|
44
|
+
};
|
|
45
|
+
}, [refresh]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!refetchInterval) return;
|
|
48
|
+
const id = setInterval(() => void refresh(), refetchInterval);
|
|
49
|
+
return () => clearInterval(id);
|
|
50
|
+
}, [refetchInterval, refresh]);
|
|
51
|
+
const signIn = useCallback(
|
|
52
|
+
(options) => {
|
|
53
|
+
if (typeof window === "undefined") return;
|
|
54
|
+
const current = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
55
|
+
const redirectTo = options?.redirectTo ?? current;
|
|
56
|
+
window.location.assign(
|
|
57
|
+
`${basePath}/login?redirect_to=${encodeURIComponent(redirectTo)}`
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
[basePath]
|
|
61
|
+
);
|
|
62
|
+
const signOut = useCallback(
|
|
63
|
+
async (options) => {
|
|
64
|
+
try {
|
|
65
|
+
await fetch(`${basePath}/logout`, { method: "POST" });
|
|
66
|
+
} finally {
|
|
67
|
+
setUser(null);
|
|
68
|
+
setSessionExpiresAt(null);
|
|
69
|
+
if (options?.redirectTo && typeof window !== "undefined") {
|
|
70
|
+
window.location.assign(options.redirectTo);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[basePath]
|
|
75
|
+
);
|
|
76
|
+
const getToken = useCallback(async () => {
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetch(`${basePath}/token`, {
|
|
79
|
+
headers: { accept: "application/json" }
|
|
80
|
+
});
|
|
81
|
+
if (!response.ok) return null;
|
|
82
|
+
const body = await response.json();
|
|
83
|
+
return body.accessToken ?? null;
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}, [basePath]);
|
|
88
|
+
const value = useMemo(
|
|
89
|
+
() => ({
|
|
90
|
+
isLoaded,
|
|
91
|
+
isSignedIn: user !== null,
|
|
92
|
+
user,
|
|
93
|
+
sessionExpiresAt,
|
|
94
|
+
signIn,
|
|
95
|
+
signOut,
|
|
96
|
+
refresh,
|
|
97
|
+
getToken
|
|
98
|
+
}),
|
|
99
|
+
[isLoaded, user, sessionExpiresAt, signIn, signOut, refresh, getToken]
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ jsx(IncortaAuthContext.Provider, { value, children });
|
|
102
|
+
}
|
|
103
|
+
function useIncortaAuth() {
|
|
104
|
+
const context = useContext(IncortaAuthContext);
|
|
105
|
+
if (!context) {
|
|
106
|
+
throw new Error("[incorta-auth] useIncortaAuth must be used inside <IncortaAuthProvider>.");
|
|
107
|
+
}
|
|
108
|
+
return context;
|
|
109
|
+
}
|
|
110
|
+
var useAuth = useIncortaAuth;
|
|
111
|
+
function useUser() {
|
|
112
|
+
return useIncortaAuth().user;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/react/components.tsx
|
|
116
|
+
import { useEffect as useEffect2 } from "react";
|
|
117
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
118
|
+
function SignedIn({ children }) {
|
|
119
|
+
const { isLoaded, isSignedIn } = useIncortaAuth();
|
|
120
|
+
return isLoaded && isSignedIn ? /* @__PURE__ */ jsx2(Fragment, { children }) : null;
|
|
121
|
+
}
|
|
122
|
+
function SignedOut({ children }) {
|
|
123
|
+
const { isLoaded, isSignedIn } = useIncortaAuth();
|
|
124
|
+
return isLoaded && !isSignedIn ? /* @__PURE__ */ jsx2(Fragment, { children }) : null;
|
|
125
|
+
}
|
|
126
|
+
function RedirectToLogin({ redirectTo }) {
|
|
127
|
+
const { signIn } = useIncortaAuth();
|
|
128
|
+
useEffect2(() => {
|
|
129
|
+
signIn(redirectTo ? { redirectTo } : void 0);
|
|
130
|
+
}, [signIn, redirectTo]);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
function Protect({
|
|
134
|
+
children,
|
|
135
|
+
fallback,
|
|
136
|
+
loading = null
|
|
137
|
+
}) {
|
|
138
|
+
const { isLoaded, isSignedIn } = useIncortaAuth();
|
|
139
|
+
if (!isLoaded) return /* @__PURE__ */ jsx2(Fragment, { children: loading });
|
|
140
|
+
if (!isSignedIn) return fallback !== void 0 ? /* @__PURE__ */ jsx2(Fragment, { children: fallback }) : /* @__PURE__ */ jsx2(RedirectToLogin, {});
|
|
141
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
IncortaAuthProvider,
|
|
145
|
+
Protect,
|
|
146
|
+
RedirectToLogin,
|
|
147
|
+
SignedIn,
|
|
148
|
+
SignedOut,
|
|
149
|
+
useAuth,
|
|
150
|
+
useIncortaAuth,
|
|
151
|
+
useUser
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/context.tsx","../../src/react/components.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport type { IncortaUser } from \"../core/config.js\";\n\nexport interface SignInOptions {\n /** Where to land after login. Defaults to the current URL. */\n redirectTo?: string;\n}\n\nexport interface SignOutOptions {\n /** Navigate here after the session is cleared. Defaults to staying put. */\n redirectTo?: string;\n}\n\nexport interface IncortaAuthContextValue {\n /** False until the first session check completes. */\n isLoaded: boolean;\n isSignedIn: boolean;\n user: IncortaUser | null;\n /** Epoch millis when the session expires, when signed in. */\n sessionExpiresAt: number | null;\n /** Sends the browser through Incorta login and back. */\n signIn: (options?: SignInOptions) => void;\n signOut: (options?: SignOutOptions) => Promise<void>;\n /** Re-checks the session against the backend. */\n refresh: () => Promise<void>;\n /**\n * Fetches the raw Incorta access token (requires `exposeAccessToken: true`\n * on the server). Returns null when signed out or not exposed.\n */\n getToken: () => Promise<string | null>;\n}\n\nconst IncortaAuthContext = createContext<IncortaAuthContextValue | null>(null);\n\ninterface SessionResponse {\n user: IncortaUser | null;\n session?: { expiresAt: number; accessTokenExpiresAt: number };\n}\n\nexport interface IncortaAuthProviderProps {\n children: ReactNode;\n /** Must match the backend's basePath. @default \"/auth\" */\n basePath?: string;\n /**\n * Re-check the session every N milliseconds so long-lived tabs keep their\n * Incorta access token fresh (the backend refreshes it server-side).\n * Set 0 to disable. @default 300000 (5 minutes)\n */\n refetchInterval?: number;\n}\n\nexport function IncortaAuthProvider({\n children,\n basePath = \"/auth\",\n refetchInterval = 5 * 60 * 1000,\n}: IncortaAuthProviderProps) {\n const [isLoaded, setIsLoaded] = useState(false);\n const [user, setUser] = useState<IncortaUser | null>(null);\n const [sessionExpiresAt, setSessionExpiresAt] = useState<number | null>(null);\n const mounted = useRef(true);\n\n const refresh = useCallback(async () => {\n try {\n const response = await fetch(`${basePath}/session`, {\n headers: { accept: \"application/json\" },\n });\n const body = (await response.json()) as SessionResponse;\n if (!mounted.current) return;\n setUser(body.user ?? null);\n setSessionExpiresAt(body.session?.expiresAt ?? null);\n } catch {\n if (!mounted.current) return;\n setUser(null);\n setSessionExpiresAt(null);\n } finally {\n if (mounted.current) setIsLoaded(true);\n }\n }, [basePath]);\n\n useEffect(() => {\n mounted.current = true;\n void refresh();\n return () => {\n mounted.current = false;\n };\n }, [refresh]);\n\n useEffect(() => {\n if (!refetchInterval) return;\n const id = setInterval(() => void refresh(), refetchInterval);\n return () => clearInterval(id);\n }, [refetchInterval, refresh]);\n\n const signIn = useCallback(\n (options?: SignInOptions) => {\n if (typeof window === \"undefined\") return;\n const current = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n const redirectTo = options?.redirectTo ?? current;\n window.location.assign(\n `${basePath}/login?redirect_to=${encodeURIComponent(redirectTo)}`,\n );\n },\n [basePath],\n );\n\n const signOut = useCallback(\n async (options?: SignOutOptions) => {\n try {\n await fetch(`${basePath}/logout`, { method: \"POST\" });\n } finally {\n setUser(null);\n setSessionExpiresAt(null);\n if (options?.redirectTo && typeof window !== \"undefined\") {\n window.location.assign(options.redirectTo);\n }\n }\n },\n [basePath],\n );\n\n const getToken = useCallback(async () => {\n try {\n const response = await fetch(`${basePath}/token`, {\n headers: { accept: \"application/json\" },\n });\n if (!response.ok) return null;\n const body = (await response.json()) as { accessToken?: string };\n return body.accessToken ?? null;\n } catch {\n return null;\n }\n }, [basePath]);\n\n const value = useMemo<IncortaAuthContextValue>(\n () => ({\n isLoaded,\n isSignedIn: user !== null,\n user,\n sessionExpiresAt,\n signIn,\n signOut,\n refresh,\n getToken,\n }),\n [isLoaded, user, sessionExpiresAt, signIn, signOut, refresh, getToken],\n );\n\n return <IncortaAuthContext.Provider value={value}>{children}</IncortaAuthContext.Provider>;\n}\n\nexport function useIncortaAuth(): IncortaAuthContextValue {\n const context = useContext(IncortaAuthContext);\n if (!context) {\n throw new Error(\"[incorta-auth] useIncortaAuth must be used inside <IncortaAuthProvider>.\");\n }\n return context;\n}\n\n/** Clerk-style alias of {@link useIncortaAuth}. */\nexport const useAuth = useIncortaAuth;\n\n/** The signed-in user, or null. */\nexport function useUser(): IncortaUser | null {\n return useIncortaAuth().user;\n}\n","import { useEffect, type ReactNode } from \"react\";\nimport { useIncortaAuth } from \"./context.js\";\n\n/** Renders children only when the user is signed in (after the initial load). */\nexport function SignedIn({ children }: { children: ReactNode }) {\n const { isLoaded, isSignedIn } = useIncortaAuth();\n return isLoaded && isSignedIn ? <>{children}</> : null;\n}\n\n/** Renders children only when the user is signed out (after the initial load). */\nexport function SignedOut({ children }: { children: ReactNode }) {\n const { isLoaded, isSignedIn } = useIncortaAuth();\n return isLoaded && !isSignedIn ? <>{children}</> : null;\n}\n\n/**\n * Immediately sends the browser through Incorta login. Render it for signed-out\n * users on protected pages:\n *\n * ```tsx\n * <SignedOut><RedirectToLogin /></SignedOut>\n * ```\n */\nexport function RedirectToLogin({ redirectTo }: { redirectTo?: string }) {\n const { signIn } = useIncortaAuth();\n useEffect(() => {\n signIn(redirectTo ? { redirectTo } : undefined);\n }, [signIn, redirectTo]);\n return null;\n}\n\n/**\n * Gates children behind authentication: shows `loading` during the initial\n * check, redirects signed-out users through Incorta login (or renders\n * `fallback` when provided).\n */\nexport function Protect({\n children,\n fallback,\n loading = null,\n}: {\n children: ReactNode;\n /** Rendered for signed-out users instead of redirecting. */\n fallback?: ReactNode;\n loading?: ReactNode;\n}) {\n const { isLoaded, isSignedIn } = useIncortaAuth();\n if (!isLoaded) return <>{loading}</>;\n if (!isSignedIn) return fallback !== undefined ? <>{fallback}</> : <RedirectToLogin />;\n return <>{children}</>;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAmJE;AAnHT,IAAM,qBAAqB,cAA8C,IAAI;AAmBtE,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA,WAAW;AAAA,EACX,kBAAkB,IAAI,KAAK;AAC7B,GAA6B;AAC3B,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS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,SAAS,SAAS,EAAE,SAAS,GAA4B;AAC9D,QAAM,EAAE,UAAU,WAAW,IAAI,eAAe;AAChD,SAAO,YAAY,aAAa,gBAAAA,KAAA,YAAG,UAAS,IAAM;AACpD;AAGO,SAAS,UAAU,EAAE,SAAS,GAA4B;AAC/D,QAAM,EAAE,UAAU,WAAW,IAAI,eAAe;AAChD,SAAO,YAAY,CAAC,aAAa,gBAAAA,KAAA,YAAG,UAAS,IAAM;AACrD;AAUO,SAAS,gBAAgB,EAAE,WAAW,GAA4B;AACvE,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,EAAAC,WAAU,MAAM;AACd,WAAO,aAAa,EAAE,WAAW,IAAI,MAAS;AAAA,EAChD,GAAG,CAAC,QAAQ,UAAU,CAAC;AACvB,SAAO;AACT;AAOO,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAKG;AACD,QAAM,EAAE,UAAU,WAAW,IAAI,eAAe;AAChD,MAAI,CAAC,SAAU,QAAO,gBAAAD,KAAA,YAAG,mBAAQ;AACjC,MAAI,CAAC,WAAY,QAAO,aAAa,SAAY,gBAAAA,KAAA,YAAG,oBAAS,IAAM,gBAAAA,KAAC,mBAAgB;AACpF,SAAO,gBAAAA,KAAA,YAAG,UAAS;AACrB;","names":["useEffect","jsx","useEffect"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@incorta/auth",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Authenticate Incorta users in any Node.js app — OAuth 2.0/OIDC against Incorta's built-in authorization server, with a React provider and Express/TanStack Start integrations.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Incorta/IncortaAuthSDK.git",
|
|
9
|
+
"directory": "packages/auth"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./react": {
|
|
23
|
+
"types": "./dist/react/index.d.ts",
|
|
24
|
+
"import": "./dist/react/index.js",
|
|
25
|
+
"require": "./dist/react/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"./express": {
|
|
28
|
+
"types": "./dist/express.d.ts",
|
|
29
|
+
"import": "./dist/express.js",
|
|
30
|
+
"require": "./dist/express.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./node": {
|
|
33
|
+
"types": "./dist/node.d.ts",
|
|
34
|
+
"import": "./dist/node.js",
|
|
35
|
+
"require": "./dist/node.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"bin": {
|
|
39
|
+
"incorta-auth": "dist/cli.js"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"prepack": "pnpm build"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"jose": "^6.0.11"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"react": ">=18"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"react": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^22.16.5",
|
|
67
|
+
"@types/react": "^19.2.0",
|
|
68
|
+
"react": "^19.2.0",
|
|
69
|
+
"tsup": "^8.5.0",
|
|
70
|
+
"typescript": "^5.8.3",
|
|
71
|
+
"vitest": "^3.2.4"
|
|
72
|
+
}
|
|
73
|
+
}
|