@instroc/auth 1.3.1 → 2.0.0-alpha.2
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/chunk-26ODM5TP.js +958 -0
- package/dist/forms.d.ts +1 -1
- package/dist/forms.js +1 -1
- package/dist/{index-iglVgSQI.d.ts → index-BsFMnPty.d.ts} +1 -1
- package/dist/index.d.ts +36 -11
- package/dist/index.js +36 -2
- package/package.json +11 -10
- package/dist/chunk-4FR5RRCB.js +0 -1036
package/dist/forms.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { M as MessageOverrides, O as OnErrorResult, m as UseForgotPasswordFormOptions, n as UseForgotPasswordFormReturn, U as UseLoginFormOptions, h as UseLoginFormReturn, k as UseOtpFormOptions, l as UseOtpFormReturn, o as UseResetPasswordFormOptions, p as UseResetPasswordFormReturn, i as UseSignupFormOptions, j as UseSignupFormReturn, f as useForgotPasswordForm, u as useLoginForm, e as useOtpForm, g as useResetPasswordForm, d as useSignupForm } from './index-
|
|
1
|
+
export { M as MessageOverrides, O as OnErrorResult, m as UseForgotPasswordFormOptions, n as UseForgotPasswordFormReturn, U as UseLoginFormOptions, h as UseLoginFormReturn, k as UseOtpFormOptions, l as UseOtpFormReturn, o as UseResetPasswordFormOptions, p as UseResetPasswordFormReturn, i as UseSignupFormOptions, j as UseSignupFormReturn, f as useForgotPasswordForm, u as useLoginForm, e as useOtpForm, g as useResetPasswordForm, d as useSignupForm } from './index-BsFMnPty.js';
|
package/dist/forms.js
CHANGED
|
@@ -369,4 +369,4 @@ interface UseResetPasswordFormReturn {
|
|
|
369
369
|
*/
|
|
370
370
|
declare function useResetPasswordForm(options: UseResetPasswordFormOptions): UseResetPasswordFormReturn;
|
|
371
371
|
|
|
372
|
-
export { type
|
|
372
|
+
export { type AuthContextValue as A, type LoginCredentials as L, type MessageOverrides as M, type OnErrorResult as O, type RefreshResponse as R, type SignupCredentials as S, type UseLoginFormOptions as U, type VisibilityConfig as V, type AuthUser as a, type AuthSession as b, type AuthProviderProps as c, useSignupForm as d, useOtpForm as e, useForgotPasswordForm as f, useResetPasswordForm as g, type UseLoginFormReturn as h, type UseSignupFormOptions as i, type UseSignupFormReturn as j, type UseOtpFormOptions as k, type UseOtpFormReturn as l, type UseForgotPasswordFormOptions as m, type UseForgotPasswordFormReturn as n, type UseResetPasswordFormOptions as o, type UseResetPasswordFormReturn as p, type AuthState as q, type AuthConfig as r, type OAuthProvider as s, type SignupResult as t, useLoginForm as u, type UpdateProfileData as v, type AuthResponse as w };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { r as AuthConfig, w as AuthResponse, q as AuthState, L as LoginCredentials, M as MessageOverrides, s as OAuthProvider, O as OnErrorResult, R as RefreshResponse, S as SignupCredentials, t as SignupResult, v as UpdateProfileData, m as UseForgotPasswordFormOptions, n as UseForgotPasswordFormReturn, U as UseLoginFormOptions, h as UseLoginFormReturn, k as UseOtpFormOptions, l as UseOtpFormReturn, o as UseResetPasswordFormOptions, p as UseResetPasswordFormReturn, i as UseSignupFormOptions, j as UseSignupFormReturn, V as VisibilityConfig, f as useForgotPasswordForm, u as useLoginForm, e as useOtpForm, g as useResetPasswordForm, d as useSignupForm } from './index-
|
|
3
|
-
|
|
4
|
-
declare function AuthProvider({ children, projectId: initialProjectId, baseUrl, persistSession, onAuthStateChange, }: AuthProviderProps): JSX.Element;
|
|
5
|
-
declare function useAuthContext(): AuthContextValue;
|
|
1
|
+
import { A as AuthContextValue, a as AuthUser, b as AuthSession, c as AuthProviderProps } from './index-BsFMnPty.js';
|
|
2
|
+
export { r as AuthConfig, w as AuthResponse, q as AuthState, L as LoginCredentials, M as MessageOverrides, s as OAuthProvider, O as OnErrorResult, R as RefreshResponse, S as SignupCredentials, t as SignupResult, v as UpdateProfileData, m as UseForgotPasswordFormOptions, n as UseForgotPasswordFormReturn, U as UseLoginFormOptions, h as UseLoginFormReturn, k as UseOtpFormOptions, l as UseOtpFormReturn, o as UseResetPasswordFormOptions, p as UseResetPasswordFormReturn, i as UseSignupFormOptions, j as UseSignupFormReturn, V as VisibilityConfig, f as useForgotPasswordForm, u as useLoginForm, e as useOtpForm, g as useResetPasswordForm, d as useSignupForm } from './index-BsFMnPty.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Primary auth hook. Reads state from the singleton auth store, returns
|
|
7
|
+
* imperative actions bound to the current config. Safe to call from any
|
|
8
|
+
* component depth — no provider tree required.
|
|
9
|
+
*
|
|
10
|
+
* `useAuthContext` is preserved as a legacy alias so existing generated
|
|
11
|
+
* code (`const { user } = useAuthContext()`) keeps working.
|
|
12
|
+
*/
|
|
7
13
|
declare function useAuth(): AuthContextValue;
|
|
14
|
+
/**
|
|
15
|
+
* Legacy alias — pre-v2 generated code uses `useAuthContext` and we keep
|
|
16
|
+
* it indefinitely so nothing breaks. New code should use `useAuth()`.
|
|
17
|
+
*/
|
|
18
|
+
declare const useAuthContext: typeof useAuth;
|
|
8
19
|
declare function useUser(): {
|
|
9
20
|
user: AuthUser | null;
|
|
10
21
|
loading: boolean;
|
|
@@ -34,12 +45,6 @@ declare function useAuthRequired(): {
|
|
|
34
45
|
* Returns `false` while loading or when unauthenticated.
|
|
35
46
|
*/
|
|
36
47
|
declare function useIsOwner(): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Minimal JWT payload decoder — no signature check (the server already
|
|
39
|
-
* verified it). Returns undefined if the token is malformed. We only read
|
|
40
|
-
* the `is_owner` boolean claim, which the BaaS auth signer sets from
|
|
41
|
-
* `_users.is_owner`.
|
|
42
|
-
*/
|
|
43
48
|
/**
|
|
44
49
|
* Returns true if the current visitor is a member of the Instroc workspace
|
|
45
50
|
* that owns this published app. Used by premium templates to gate owner-only
|
|
@@ -96,4 +101,24 @@ declare class AuthError extends Error {
|
|
|
96
101
|
constructor(message: string, status: number, code?: string);
|
|
97
102
|
}
|
|
98
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Legacy backward-compat shim for v1's `<AuthProvider>`.
|
|
106
|
+
*
|
|
107
|
+
* v2 of the SDK is store-based — auth state lives in a module-level
|
|
108
|
+
* singleton, hooks read from it directly, and there's no required
|
|
109
|
+
* provider in the tree. This component is kept so existing generated
|
|
110
|
+
* apps that mount `<AuthProvider projectId="...">` keep working
|
|
111
|
+
* unchanged. Internally it just calls `initInstroc` with the props and
|
|
112
|
+
* subscribes the `onAuthStateChange` listener.
|
|
113
|
+
*
|
|
114
|
+
* New code should call `initInstroc({ projectId })` once in main.tsx
|
|
115
|
+
* and skip the wrapper entirely.
|
|
116
|
+
*
|
|
117
|
+
* This shim is intentionally minimal — no React state, no useCallback
|
|
118
|
+
* gymnastics. The whole provider exists only so old generated main.tsx
|
|
119
|
+
* files don't crash with "AuthProvider is not a function" after the
|
|
120
|
+
* v2 upgrade.
|
|
121
|
+
*/
|
|
122
|
+
declare function AuthProvider({ children, projectId, baseUrl, persistSession, onAuthStateChange, }: AuthProviderProps): react_jsx_runtime.JSX.Element;
|
|
123
|
+
|
|
99
124
|
export { AuthContextValue, AuthError, AuthProvider, AuthProviderProps, AuthSession, AuthUser, useAuth, useAuthContext, useAuthRequired, useIsOwner, useIsWorkspaceMember, useSession, useUser };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthError,
|
|
3
|
-
|
|
3
|
+
ensureAuthBootstrap,
|
|
4
|
+
subscribeAuthStateChange,
|
|
4
5
|
useAuth,
|
|
5
6
|
useAuthContext,
|
|
6
7
|
useAuthRequired,
|
|
@@ -13,7 +14,40 @@ import {
|
|
|
13
14
|
useSession,
|
|
14
15
|
useSignupForm,
|
|
15
16
|
useUser
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-26ODM5TP.js";
|
|
18
|
+
|
|
19
|
+
// src/provider.tsx
|
|
20
|
+
import { useEffect } from "react";
|
|
21
|
+
import { initInstroc, setInstrocProjectId } from "@instroc/client";
|
|
22
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
23
|
+
function AuthProvider({
|
|
24
|
+
children,
|
|
25
|
+
projectId,
|
|
26
|
+
baseUrl,
|
|
27
|
+
persistSession,
|
|
28
|
+
onAuthStateChange
|
|
29
|
+
}) {
|
|
30
|
+
if (projectId) {
|
|
31
|
+
initInstroc({
|
|
32
|
+
projectId,
|
|
33
|
+
...baseUrl !== void 0 ? { baseUrl } : {},
|
|
34
|
+
...persistSession !== void 0 ? { persistSession } : {}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
ensureAuthBootstrap();
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (projectId) {
|
|
40
|
+
setInstrocProjectId(projectId);
|
|
41
|
+
}
|
|
42
|
+
}, [projectId]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!onAuthStateChange)
|
|
45
|
+
return;
|
|
46
|
+
const unsub = subscribeAuthStateChange(onAuthStateChange);
|
|
47
|
+
return unsub;
|
|
48
|
+
}, [onAuthStateChange]);
|
|
49
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
50
|
+
}
|
|
17
51
|
export {
|
|
18
52
|
AuthError,
|
|
19
53
|
AuthProvider,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instroc/auth",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Authentication hooks for Instroc Cloud — useAuth
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
|
+
"description": "Authentication hooks for Instroc Cloud — store-based useAuth/useUser with backward-compatible AuthProvider shim",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -18,16 +18,13 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsup",
|
|
23
|
-
"dev": "tsup --watch"
|
|
24
|
-
},
|
|
25
21
|
"peerDependencies": {
|
|
26
|
-
"react": "^18.0.0"
|
|
22
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@instroc/client": "1.0.0-alpha.1"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"react": "^18.2.0",
|
|
30
|
-
"@types/react": "^18.2.0",
|
|
31
28
|
"tsup": "^8.0.0",
|
|
32
29
|
"typescript": "^5.3.0"
|
|
33
30
|
},
|
|
@@ -39,5 +36,9 @@
|
|
|
39
36
|
},
|
|
40
37
|
"publishConfig": {
|
|
41
38
|
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"dev": "tsup --watch"
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|