@molecule/app-angular 3.3.1 → 3.5.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/README.md +3880 -1264
- package/dist/hooks/external-store.d.ts +32 -0
- package/dist/hooks/external-store.d.ts.map +1 -0
- package/dist/hooks/external-store.js +62 -0
- package/dist/hooks/external-store.js.map +1 -0
- package/dist/hooks/index.d.ts +24 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-ai-models.d.ts +46 -0
- package/dist/hooks/use-ai-models.d.ts.map +1 -0
- package/dist/hooks/use-ai-models.js +142 -0
- package/dist/hooks/use-ai-models.js.map +1 -0
- package/dist/hooks/use-async.d.ts +125 -0
- package/dist/hooks/use-async.d.ts.map +1 -0
- package/dist/hooks/use-async.js +189 -0
- package/dist/hooks/use-async.js.map +1 -0
- package/dist/hooks/use-auth-flows.d.ts +207 -0
- package/dist/hooks/use-auth-flows.d.ts.map +1 -0
- package/dist/hooks/use-auth-flows.js +460 -0
- package/dist/hooks/use-auth-flows.js.map +1 -0
- package/dist/hooks/use-auth.d.ts +80 -0
- package/dist/hooks/use-auth.d.ts.map +1 -0
- package/dist/hooks/use-auth.js +89 -0
- package/dist/hooks/use-auth.js.map +1 -0
- package/dist/hooks/use-forms.d.ts +177 -0
- package/dist/hooks/use-forms.d.ts.map +1 -0
- package/dist/hooks/use-forms.js +185 -0
- package/dist/hooks/use-forms.js.map +1 -0
- package/dist/hooks/use-http.d.ts +155 -0
- package/dist/hooks/use-http.d.ts.map +1 -0
- package/dist/hooks/use-http.js +212 -0
- package/dist/hooks/use-http.js.map +1 -0
- package/dist/hooks/use-ide.d.ts +208 -0
- package/dist/hooks/use-ide.d.ts.map +1 -0
- package/dist/hooks/use-ide.js +217 -0
- package/dist/hooks/use-ide.js.map +1 -0
- package/dist/hooks/use-logger.d.ts +40 -0
- package/dist/hooks/use-logger.d.ts.map +1 -0
- package/dist/hooks/use-logger.js +56 -0
- package/dist/hooks/use-logger.js.map +1 -0
- package/dist/hooks/use-native.d.ts +213 -0
- package/dist/hooks/use-native.d.ts.map +1 -0
- package/dist/hooks/use-native.js +158 -0
- package/dist/hooks/use-native.js.map +1 -0
- package/dist/hooks/use-profile-form.d.ts +113 -0
- package/dist/hooks/use-profile-form.d.ts.map +1 -0
- package/dist/hooks/use-profile-form.js +253 -0
- package/dist/hooks/use-profile-form.js.map +1 -0
- package/dist/hooks/use-router.d.ts +212 -0
- package/dist/hooks/use-router.d.ts.map +1 -0
- package/dist/hooks/use-router.js +251 -0
- package/dist/hooks/use-router.js.map +1 -0
- package/dist/hooks/use-storage.d.ts +128 -0
- package/dist/hooks/use-storage.d.ts.map +1 -0
- package/dist/hooks/use-storage.js +217 -0
- package/dist/hooks/use-storage.js.map +1 -0
- package/dist/hooks/use-store.d.ts +74 -0
- package/dist/hooks/use-store.d.ts.map +1 -0
- package/dist/hooks/use-store.js +103 -0
- package/dist/hooks/use-store.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +59 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +117 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/hooks/use-translation.d.ts +86 -0
- package/dist/hooks/use-translation.d.ts.map +1 -0
- package/dist/hooks/use-translation.js +146 -0
- package/dist/hooks/use-translation.js.map +1 -0
- package/dist/hooks/use-verify-payment-return.d.ts +86 -0
- package/dist/hooks/use-verify-payment-return.d.ts.map +1 -0
- package/dist/hooks/use-verify-payment-return.js +167 -0
- package/dist/hooks/use-verify-payment-return.js.map +1 -0
- package/dist/hooks/use-version.d.ts +49 -0
- package/dist/hooks/use-version.d.ts.map +1 -0
- package/dist/hooks/use-version.js +70 -0
- package/dist/hooks/use-version.js.map +1 -0
- package/dist/i18n-reactive.d.ts +2 -5
- package/dist/i18n-reactive.d.ts.map +1 -1
- package/dist/i18n-reactive.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/inject.d.ts +24 -0
- package/dist/inject.d.ts.map +1 -0
- package/dist/inject.js +33 -0
- package/dist/inject.js.map +1 -0
- package/dist/providers.d.ts +24 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +44 -3
- package/dist/providers.js.map +1 -1
- package/dist/session-ready.d.ts +41 -0
- package/dist/session-ready.d.ts.map +1 -0
- package/dist/session-ready.js +79 -0
- package/dist/session-ready.js.map +1 -0
- package/dist/site.d.ts +51 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +69 -0
- package/dist/site.js.map +1 -0
- package/dist/tokens.d.ts +15 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +12 -0
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular functions for the auth flows, mirroring `useLogin`, `useSignup`,
|
|
3
|
+
* `useChangePassword`, `usePasswordReset` and `useOAuth` from
|
|
4
|
+
* `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* The state fields of the tracked hooks are LIVE getters over the underlying
|
|
7
|
+
* `usePromise` state object: the result object is built once per instance (an
|
|
8
|
+
* Angular instantiation runs once), and every later read must show the
|
|
9
|
+
* current state, which React re-renders into a fresh result object.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { DestroyRef, inject } from '@angular/core';
|
|
14
|
+
import { t } from '@molecule/app-i18n';
|
|
15
|
+
import { usePromise } from './use-async.js';
|
|
16
|
+
import { useAuthClient } from './use-auth.js';
|
|
17
|
+
/**
|
|
18
|
+
* Login with async state tracking. Call it in an injection context.
|
|
19
|
+
*
|
|
20
|
+
* Registration is available through `const { register } = useAuth()`;
|
|
21
|
+
* call `register({ email, password, name })` to create an account. There is
|
|
22
|
+
* no separate `useRegister` hook. Use `usePromise(register)` when the form
|
|
23
|
+
* needs the same pending/error tracking as this login hook.
|
|
24
|
+
*
|
|
25
|
+
* @returns Login state and action.
|
|
26
|
+
*/
|
|
27
|
+
export function useLogin() {
|
|
28
|
+
const client = useAuthClient();
|
|
29
|
+
const loginFn = (credentials) => client.login(credentials);
|
|
30
|
+
const [state, call] = usePromise(loginFn);
|
|
31
|
+
return {
|
|
32
|
+
get status() {
|
|
33
|
+
return state.status;
|
|
34
|
+
},
|
|
35
|
+
get value() {
|
|
36
|
+
return state.value;
|
|
37
|
+
},
|
|
38
|
+
get error() {
|
|
39
|
+
return state.error;
|
|
40
|
+
},
|
|
41
|
+
login: call,
|
|
42
|
+
reset: state.reset,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Registration with async state tracking. Call it in an injection context.
|
|
47
|
+
*
|
|
48
|
+
* @returns Signup state and action.
|
|
49
|
+
*/
|
|
50
|
+
export function useSignup() {
|
|
51
|
+
const client = useAuthClient();
|
|
52
|
+
const registerFn = (data) => client.register(data);
|
|
53
|
+
const [state, call] = usePromise(registerFn);
|
|
54
|
+
return {
|
|
55
|
+
get status() {
|
|
56
|
+
return state.status;
|
|
57
|
+
},
|
|
58
|
+
get value() {
|
|
59
|
+
return state.value;
|
|
60
|
+
},
|
|
61
|
+
get error() {
|
|
62
|
+
return state.error;
|
|
63
|
+
},
|
|
64
|
+
signup: call,
|
|
65
|
+
reset: state.reset,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Changing a password with async state tracking. Call it in an injection
|
|
70
|
+
* context.
|
|
71
|
+
*
|
|
72
|
+
* @returns Change-password state and action.
|
|
73
|
+
*/
|
|
74
|
+
export function useChangePassword() {
|
|
75
|
+
const client = useAuthClient();
|
|
76
|
+
const changeFn = (oldPassword, newPassword) => client.changePassword(oldPassword, newPassword);
|
|
77
|
+
const [state, call] = usePromise(changeFn);
|
|
78
|
+
return {
|
|
79
|
+
get status() {
|
|
80
|
+
return state.status;
|
|
81
|
+
},
|
|
82
|
+
get error() {
|
|
83
|
+
return state.error;
|
|
84
|
+
},
|
|
85
|
+
changePassword: call,
|
|
86
|
+
reset: state.reset,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The password reset flow with async state tracking, one tracker per step.
|
|
91
|
+
* Call it in an injection context.
|
|
92
|
+
*
|
|
93
|
+
* @returns Password reset state and actions.
|
|
94
|
+
*/
|
|
95
|
+
export function usePasswordReset() {
|
|
96
|
+
const client = useAuthClient();
|
|
97
|
+
const requestFn = (data) => client.requestPasswordReset(data);
|
|
98
|
+
const confirmFn = (data) => client.confirmPasswordReset(data);
|
|
99
|
+
const [requestState, requestCall] = usePromise(requestFn);
|
|
100
|
+
const [confirmState, confirmCall] = usePromise(confirmFn);
|
|
101
|
+
return {
|
|
102
|
+
get requestStatus() {
|
|
103
|
+
return requestState.status;
|
|
104
|
+
},
|
|
105
|
+
get requestError() {
|
|
106
|
+
return requestState.error;
|
|
107
|
+
},
|
|
108
|
+
get confirmStatus() {
|
|
109
|
+
return confirmState.status;
|
|
110
|
+
},
|
|
111
|
+
get confirmError() {
|
|
112
|
+
return confirmState.error;
|
|
113
|
+
},
|
|
114
|
+
requestReset: requestCall,
|
|
115
|
+
confirmReset: confirmCall,
|
|
116
|
+
reset: () => {
|
|
117
|
+
requestState.reset();
|
|
118
|
+
confirmState.reset();
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** What `onError` gets when the server gives no reason of its own. */
|
|
123
|
+
const oauthFailed = () => t('angular.error.oauthFailed', undefined, { defaultValue: 'OAuth login failed' });
|
|
124
|
+
/**
|
|
125
|
+
* `window.open` name for the OAuth popup. The callback page relays its result
|
|
126
|
+
* to the opener ONLY when its own `window.name` equals this AND
|
|
127
|
+
* `window.opener` exists — so a normal (full-page) callback never takes the
|
|
128
|
+
* relay path.
|
|
129
|
+
*/
|
|
130
|
+
const OAUTH_POPUP_WINDOW_NAME = 'molecule-oauth-popup';
|
|
131
|
+
/** Private `postMessage` type for the popup→opener result relay. */
|
|
132
|
+
const OAUTH_RESULT_MESSAGE_TYPE = 'molecule:oauth-result';
|
|
133
|
+
/** Hard cap on how long the opener waits for the popup before giving up. */
|
|
134
|
+
const OAUTH_POPUP_TIMEOUT_MS = 5 * 60 * 1000;
|
|
135
|
+
/**
|
|
136
|
+
* OAuth authentication. Call it in an injection context.
|
|
137
|
+
*
|
|
138
|
+
* Reads OAuth configuration from the provided config and provides helpers to
|
|
139
|
+
* build OAuth URLs and start a login (full-page or popup). Automatically
|
|
140
|
+
* handles OAuth callbacks by detecting `code` and `state` URL parameters and
|
|
141
|
+
* exchanging them for a session — and, when the callback is running inside a
|
|
142
|
+
* popup we opened, relaying the result to the opener instead.
|
|
143
|
+
*
|
|
144
|
+
* Unmounting does not cancel a flow that has started. A popup result or a
|
|
145
|
+
* callback exchange that settles afterwards still establishes the session on
|
|
146
|
+
* the shared auth client, because the user did sign in. `onSuccess` and
|
|
147
|
+
* `onError` are not called after unmount: they belong to the unmounted view.
|
|
148
|
+
*
|
|
149
|
+
* @param config - Optional OAuth configuration override.
|
|
150
|
+
* @param config.baseURL - Base URL for the API server (e.g. "https://api.example.com").
|
|
151
|
+
* @param config.oauthProviders - List of supported OAuth provider names (e.g. ["google", "github"]).
|
|
152
|
+
* @param config.oauthEndpoint - Path prefix for OAuth routes (defaults to "/oauth").
|
|
153
|
+
* @param config.loginEndpoint - Path for the OAuth login POST endpoint (defaults to "/users/log-in/oauth").
|
|
154
|
+
* @param config.onSuccess - Callback after successful OAuth login.
|
|
155
|
+
* @param config.onError - Callback on OAuth login failure.
|
|
156
|
+
* @param config.navigate - How the page leaves for the provider: {@link UseOAuthReturn.redirect}
|
|
157
|
+
* and the blocked-popup fallback call it with the provider URL. Defaults to a
|
|
158
|
+
* full-page navigation (`window.location.href = url`); pass an in-app browser
|
|
159
|
+
* opener on native, or a router's external navigation.
|
|
160
|
+
* @returns OAuth helpers: providers, getOAuthUrl, redirect, and loginViaPopup.
|
|
161
|
+
*/
|
|
162
|
+
export function useOAuth(config) {
|
|
163
|
+
const authClient = useAuthClient();
|
|
164
|
+
// Whether the host is mounted, read when a flow settles (an Angular
|
|
165
|
+
// instantiation is never re-run, so one DestroyRef flag mirrors React's
|
|
166
|
+
// mounted ref).
|
|
167
|
+
const destroyRef = inject(DestroyRef);
|
|
168
|
+
let mounted = true;
|
|
169
|
+
destroyRef.onDestroy(() => {
|
|
170
|
+
mounted = false;
|
|
171
|
+
});
|
|
172
|
+
const providers = config?.oauthProviders ?? [];
|
|
173
|
+
const baseURL = config?.baseURL ?? '';
|
|
174
|
+
const oauthEndpoint = config?.oauthEndpoint ?? '/oauth';
|
|
175
|
+
const loginEndpoint = config?.loginEndpoint ?? '/users/log-in/oauth';
|
|
176
|
+
const getOAuthUrl = (provider) => {
|
|
177
|
+
// Encode the provider as a single path segment so a (future) caller passing an
|
|
178
|
+
// untrusted value can never inject a path/query/scheme into the opened URL —
|
|
179
|
+
// defense-in-depth on top of the upstream static provider allowlist. Plain
|
|
180
|
+
// provider names ('github', 'google') pass through unchanged.
|
|
181
|
+
return `${baseURL}${oauthEndpoint}/${encodeURIComponent(provider)}`;
|
|
182
|
+
};
|
|
183
|
+
/** Stash which provider initiated the flow so the callback knows it's ours. */
|
|
184
|
+
const stashProvider = (provider) => {
|
|
185
|
+
try {
|
|
186
|
+
sessionStorage.setItem('oauth_provider', provider);
|
|
187
|
+
}
|
|
188
|
+
catch (_error) {
|
|
189
|
+
/* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Append the current page's PATH as `redirect_to` so the api's initiation
|
|
194
|
+
* endpoint (`GET /users/oauth/:provider`) builds a provider `redirect_uri`
|
|
195
|
+
* that lands the callback back on THIS page — the one with `useOAuth`
|
|
196
|
+
* mounted (e.g. `/login`) — instead of the app root, where nothing may be
|
|
197
|
+
* listening for the `code` param. Path only (no origin/query): the server
|
|
198
|
+
* validates it as a same-origin absolute path, so it can never become an
|
|
199
|
+
* open redirect. Servers that predate the param simply ignore it.
|
|
200
|
+
*/
|
|
201
|
+
const withReturnPath = (url) => {
|
|
202
|
+
const path = typeof window !== 'undefined' ? window.location.pathname : '';
|
|
203
|
+
if (!path || path === '/')
|
|
204
|
+
return url;
|
|
205
|
+
return `${url}${url.includes('?') ? '&' : '?'}redirect_to=${encodeURIComponent(path)}`;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Establish the authenticated session from an exchange result: seed the
|
|
209
|
+
* access token + user and let `initialize()` flip `authenticated`. Mirrors
|
|
210
|
+
* what `authClient.login()` does for password login. Returns whether a user
|
|
211
|
+
* was set (a result with no user is not a real session).
|
|
212
|
+
*/
|
|
213
|
+
const establishSession = async (token, user) => {
|
|
214
|
+
// Seed the token via the auth client's configured token storage adapter
|
|
215
|
+
// (in-memory by default) — NOT localStorage directly. Writing the bearer
|
|
216
|
+
// token to localStorage violates the in-memory-default storage contract and
|
|
217
|
+
// makes it JS-readable (XSS-exfiltratable).
|
|
218
|
+
if (token)
|
|
219
|
+
authClient.setAccessToken(token);
|
|
220
|
+
if (user && typeof user === 'object') {
|
|
221
|
+
authClient.setUser(user);
|
|
222
|
+
await authClient.initialize();
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
};
|
|
227
|
+
const navigateOption = config?.navigate;
|
|
228
|
+
/** Leaves the page for the provider: the `navigate` option, else a full-page navigation. */
|
|
229
|
+
const leaveFor = (url) => {
|
|
230
|
+
if (navigateOption)
|
|
231
|
+
navigateOption(url);
|
|
232
|
+
else
|
|
233
|
+
window.location.href = url;
|
|
234
|
+
};
|
|
235
|
+
const redirect = (provider) => {
|
|
236
|
+
stashProvider(provider);
|
|
237
|
+
leaveFor(withReturnPath(getOAuthUrl(provider)));
|
|
238
|
+
};
|
|
239
|
+
// The currently-open OAuth popup, so a second click focuses it instead of
|
|
240
|
+
// stacking a second flow (the relay gates already fail safe, but one window is
|
|
241
|
+
// cleaner and avoids an orphaned listener until the timeout reaps it).
|
|
242
|
+
let activePopup = null;
|
|
243
|
+
const loginViaPopup = (provider) => {
|
|
244
|
+
// A flow is already open — focus it rather than starting another.
|
|
245
|
+
if (activePopup && !activePopup.closed) {
|
|
246
|
+
try {
|
|
247
|
+
activePopup.focus();
|
|
248
|
+
}
|
|
249
|
+
catch (_error) {
|
|
250
|
+
/* best-effort focus */
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
stashProvider(provider);
|
|
255
|
+
const url = withReturnPath(getOAuthUrl(provider));
|
|
256
|
+
// A named popup. We intentionally do NOT pass `noopener` — the popup needs
|
|
257
|
+
// `window.opener` to relay its result back. The window only ever navigates
|
|
258
|
+
// to OUR api → the trusted provider → OUR origin, so this is the standard
|
|
259
|
+
// OAuth-popup trade-off (a malicious *provider* could touch `window.opener`,
|
|
260
|
+
// which is out of scope; we don't open attacker-controlled URLs here).
|
|
261
|
+
const features = 'popup=yes,width=520,height=680,menubar=no,toolbar=no,location=yes';
|
|
262
|
+
const popup = window.open(url, OAUTH_POPUP_WINDOW_NAME, features);
|
|
263
|
+
// Popup blocked (or unavailable) → fall back to a full-page redirect so login
|
|
264
|
+
// still works. No listener is registered in this branch.
|
|
265
|
+
if (!popup) {
|
|
266
|
+
leaveFor(url);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
activePopup = popup;
|
|
270
|
+
let settled = false;
|
|
271
|
+
const timers = {};
|
|
272
|
+
const cleanup = () => {
|
|
273
|
+
window.removeEventListener('message', onMessage);
|
|
274
|
+
if (timers.closed)
|
|
275
|
+
clearInterval(timers.closed);
|
|
276
|
+
if (timers.timeout)
|
|
277
|
+
clearTimeout(timers.timeout);
|
|
278
|
+
if (activePopup === popup)
|
|
279
|
+
activePopup = null;
|
|
280
|
+
};
|
|
281
|
+
const onMessage = (event) => {
|
|
282
|
+
// SECURITY — accept the result ONLY from our own origin, ONLY from the exact
|
|
283
|
+
// popup window we opened, and ONLY when it carries our private type. Any one
|
|
284
|
+
// failing means a forged / unrelated message: ignore it silently. This is
|
|
285
|
+
// what prevents a malicious page from injecting a session.
|
|
286
|
+
if (event.origin !== window.location.origin)
|
|
287
|
+
return;
|
|
288
|
+
if (event.source !== popup)
|
|
289
|
+
return;
|
|
290
|
+
const data = event.data;
|
|
291
|
+
if (!data || typeof data !== 'object' || data.type !== OAUTH_RESULT_MESSAGE_TYPE)
|
|
292
|
+
return;
|
|
293
|
+
if (settled)
|
|
294
|
+
return;
|
|
295
|
+
settled = true;
|
|
296
|
+
cleanup();
|
|
297
|
+
try {
|
|
298
|
+
popup.close();
|
|
299
|
+
}
|
|
300
|
+
catch (_error) {
|
|
301
|
+
/* already closed — nothing to do */
|
|
302
|
+
}
|
|
303
|
+
if (data.ok) {
|
|
304
|
+
void establishSession(data.token, data.user).then((ok) => {
|
|
305
|
+
if (!mounted)
|
|
306
|
+
return;
|
|
307
|
+
if (ok)
|
|
308
|
+
config?.onSuccess?.();
|
|
309
|
+
else
|
|
310
|
+
config?.onError?.(oauthFailed());
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
else if (mounted) {
|
|
314
|
+
config?.onError?.(typeof data.error === 'string' ? data.error : oauthFailed());
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
window.addEventListener('message', onMessage);
|
|
318
|
+
// The user closed the popup without completing — silently stop waiting (no
|
|
319
|
+
// error toast for a deliberate cancel) and release the listener.
|
|
320
|
+
timers.closed = setInterval(() => {
|
|
321
|
+
if (popup.closed && !settled) {
|
|
322
|
+
settled = true;
|
|
323
|
+
cleanup();
|
|
324
|
+
}
|
|
325
|
+
}, 500);
|
|
326
|
+
// Hard safety timeout so a wedged popup never leaks a listener forever.
|
|
327
|
+
timers.timeout = setTimeout(() => {
|
|
328
|
+
if (!settled) {
|
|
329
|
+
settled = true;
|
|
330
|
+
cleanup();
|
|
331
|
+
try {
|
|
332
|
+
popup.close();
|
|
333
|
+
}
|
|
334
|
+
catch (_error) {
|
|
335
|
+
/* best-effort */
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, OAUTH_POPUP_TIMEOUT_MS);
|
|
339
|
+
};
|
|
340
|
+
// Handle OAuth callback — detect code + state in URL params.
|
|
341
|
+
{
|
|
342
|
+
const params = new URLSearchParams(window.location.search);
|
|
343
|
+
const code = params.get('code');
|
|
344
|
+
const state = params.get('state');
|
|
345
|
+
if (!code) {
|
|
346
|
+
return { providers, getOAuthUrl, redirect, loginViaPopup };
|
|
347
|
+
}
|
|
348
|
+
// Retrieve the provider that initiated the flow.
|
|
349
|
+
let provider = null;
|
|
350
|
+
try {
|
|
351
|
+
provider = sessionStorage.getItem('oauth_provider');
|
|
352
|
+
}
|
|
353
|
+
catch (_error) {
|
|
354
|
+
/* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
|
|
355
|
+
}
|
|
356
|
+
if (!provider) {
|
|
357
|
+
return { providers, getOAuthUrl, redirect, loginViaPopup };
|
|
358
|
+
}
|
|
359
|
+
// Are we the OAuth popup we opened? Relay the result to the opener instead of
|
|
360
|
+
// establishing the session in this (about-to-close) window. Gated on BOTH the
|
|
361
|
+
// window name AND window.opener so a normal full-page callback never relays.
|
|
362
|
+
const inPopup = typeof window !== 'undefined' && !!window.opener && window.name === OAUTH_POPUP_WINDOW_NAME;
|
|
363
|
+
// Clean up URL (remove code/state params) and sessionStorage.
|
|
364
|
+
const cleanUrl = new URL(window.location.href);
|
|
365
|
+
cleanUrl.searchParams.delete('code');
|
|
366
|
+
cleanUrl.searchParams.delete('state');
|
|
367
|
+
window.history.replaceState({}, '', cleanUrl.toString());
|
|
368
|
+
try {
|
|
369
|
+
sessionStorage.removeItem('oauth_provider');
|
|
370
|
+
}
|
|
371
|
+
catch (_error) {
|
|
372
|
+
/* SSR-safe — sessionStorage is unavailable in SSR/sandboxed environments */
|
|
373
|
+
}
|
|
374
|
+
/** Relay a result to the opener (popup path) — origin-pinned, never `'*'`. */
|
|
375
|
+
const relayToOpener = (message) => {
|
|
376
|
+
try {
|
|
377
|
+
// targetOrigin is our OWN origin: the browser delivers the message (and the
|
|
378
|
+
// token it carries) ONLY if the opener is still on this origin. Never '*'.
|
|
379
|
+
window.opener?.postMessage(message, window.location.origin);
|
|
380
|
+
}
|
|
381
|
+
catch (_error) {
|
|
382
|
+
/* opener gone / cross-origin — the opener's close-poll will recover */
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
window.close();
|
|
386
|
+
}
|
|
387
|
+
catch (_error) {
|
|
388
|
+
/* best-effort */
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
// Exchange code for session.
|
|
392
|
+
const exchangeCode = async () => {
|
|
393
|
+
try {
|
|
394
|
+
const response = await fetch(`${baseURL}${loginEndpoint}`, {
|
|
395
|
+
method: 'POST',
|
|
396
|
+
headers: { 'Content-Type': 'application/json' },
|
|
397
|
+
credentials: 'include', // Send cookies (oauth_state) for state validation
|
|
398
|
+
body: JSON.stringify({
|
|
399
|
+
server: provider,
|
|
400
|
+
code,
|
|
401
|
+
state: state || undefined,
|
|
402
|
+
redirect_uri: window.location.origin,
|
|
403
|
+
}),
|
|
404
|
+
});
|
|
405
|
+
if (!response.ok) {
|
|
406
|
+
// A body that is not JSON: report the generic failure.
|
|
407
|
+
const data = await response.json().catch((_error) => ({ error: oauthFailed() }));
|
|
408
|
+
const error = data.error || oauthFailed();
|
|
409
|
+
if (inPopup) {
|
|
410
|
+
relayToOpener({ type: OAUTH_RESULT_MESSAGE_TYPE, ok: false, error });
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (mounted)
|
|
414
|
+
config?.onError?.(error);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
// A body that is not JSON carries no user; the token comes from the header.
|
|
418
|
+
const data = await response.json().catch((_error) => null);
|
|
419
|
+
// Store the token from the response.
|
|
420
|
+
const authHeader = response.headers.get('authorization') || response.headers.get('set-authorization');
|
|
421
|
+
const token = authHeader ? authHeader.replace('Bearer ', '') : null;
|
|
422
|
+
// The authenticated user is `props` (molecule resource convention) or `user`
|
|
423
|
+
// (generic AuthResult). OAuth issues no refresh token, so we carry the token +
|
|
424
|
+
// user to whoever will own the session.
|
|
425
|
+
const user = data && typeof data === 'object'
|
|
426
|
+
? (data.props ??
|
|
427
|
+
data.user ??
|
|
428
|
+
null)
|
|
429
|
+
: null;
|
|
430
|
+
if (inPopup) {
|
|
431
|
+
// Relay to the opener — it (same origin) establishes the session in place.
|
|
432
|
+
// Do NOT establish it here; this window is about to close.
|
|
433
|
+
relayToOpener({ type: OAUTH_RESULT_MESSAGE_TYPE, ok: true, token, user });
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
// Full-page callback: establish the session here, then fire onSuccess —
|
|
437
|
+
// unchanged behavior.
|
|
438
|
+
const ok = await establishSession(token, user);
|
|
439
|
+
if (!mounted)
|
|
440
|
+
return;
|
|
441
|
+
if (ok)
|
|
442
|
+
config?.onSuccess?.();
|
|
443
|
+
else
|
|
444
|
+
config?.onError?.(oauthFailed());
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
const error = err instanceof Error ? err.message : oauthFailed();
|
|
448
|
+
if (inPopup) {
|
|
449
|
+
relayToOpener({ type: OAUTH_RESULT_MESSAGE_TYPE, ok: false, error });
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (mounted)
|
|
453
|
+
config?.onError?.(error);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
void exchangeCode();
|
|
457
|
+
}
|
|
458
|
+
return { providers, getOAuthUrl, redirect, loginViaPopup };
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=use-auth-flows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AM,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAC9C,IAAI,CAAC,OAAO;oBAAE,OAAM;gBACpB,IAAI,EAAE;oBAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAA;;oBACxB,MAAM,EAAE,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;YACvC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;gBAChE,IAAI,OAAO,EAAE,CAAC;oBACZ,aAAa,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;oBACpE,OAAM;gBACR,CAAC;gBACD,IAAI,OAAO;oBAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;YACvC,CAAC;QACH,CAAC,CAAA;QAED,KAAK,YAAY,EAAE,CAAA;IACrB,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular functions for authentication, mirroring `useAuth`,
|
|
3
|
+
* `useAuthClient`, `useUser` and `useIsAuthenticated` from
|
|
4
|
+
* `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type Signal } from '@angular/core';
|
|
9
|
+
import type { AuthClient, AuthResult, AuthSessionSeed, AuthState, LoginCredentials, RegisterData, RegisterExtraShape } from '@molecule/app-auth';
|
|
10
|
+
/**
|
|
11
|
+
* The auth client registered by `provideMolecule({ auth })` or `provideAuth`.
|
|
12
|
+
* Call it in an injection context.
|
|
13
|
+
*
|
|
14
|
+
* @returns The auth client.
|
|
15
|
+
* @throws {Error} When no auth client is registered.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useAuthClient<T = unknown, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(): AuthClient<T, TRegister>;
|
|
18
|
+
/** Options for {@link useAuth}. */
|
|
19
|
+
export interface UseAuthOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Refresh the session once on mount when the visitor is signed out and the
|
|
22
|
+
* state is decided (a silent probe for a token the storage may hold).
|
|
23
|
+
* Default `false`.
|
|
24
|
+
*/
|
|
25
|
+
autoRefresh?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What {@link useAuth} returns: every state field as a signal and every auth
|
|
29
|
+
* action as a plain function.
|
|
30
|
+
*/
|
|
31
|
+
export interface UseAuthResult<T = unknown, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>> {
|
|
32
|
+
/** `'loading'` until the client decides the session, then its status. */
|
|
33
|
+
readonly status: Signal<AuthState<T>['status']>;
|
|
34
|
+
/** The full auth state. */
|
|
35
|
+
readonly state: Signal<AuthState<T>>;
|
|
36
|
+
/** The signed-in user, or `null`. */
|
|
37
|
+
readonly user: Signal<T | null>;
|
|
38
|
+
/** Whether a session exists. */
|
|
39
|
+
readonly isAuthenticated: Signal<boolean>;
|
|
40
|
+
/** Whether the session is still being decided. */
|
|
41
|
+
readonly isLoading: Signal<boolean>;
|
|
42
|
+
/** Signs in with credentials. */
|
|
43
|
+
login: (credentials: LoginCredentials) => Promise<AuthResult<T>>;
|
|
44
|
+
/** Signs out. */
|
|
45
|
+
logout: () => Promise<void>;
|
|
46
|
+
/** Creates an account (also signs it in). */
|
|
47
|
+
register: (data: RegisterData<TRegister>) => Promise<AuthResult<T>>;
|
|
48
|
+
/** Refreshes the session from its token. */
|
|
49
|
+
refresh: () => Promise<AuthResult<T>>;
|
|
50
|
+
/** Saves profile edits through the client and publishes the saved user. */
|
|
51
|
+
updateProfile: (data: Partial<T>) => Promise<T>;
|
|
52
|
+
/** Caches a user without signing in. */
|
|
53
|
+
setUser: (user: T | null) => void;
|
|
54
|
+
/** Adopts a caller-issued session atomically. */
|
|
55
|
+
setSession: (session: AuthSessionSeed<T>) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Authentication state and actions. Call it in an injection context (a
|
|
59
|
+
* component field initializer or constructor).
|
|
60
|
+
*
|
|
61
|
+
* `status === 'loading'` is undecided; `'unavailable'` keeps the candidate
|
|
62
|
+
* session for retry; a restore failure never signs out.
|
|
63
|
+
*
|
|
64
|
+
* @param options - Hook options (`autoRefresh`).
|
|
65
|
+
* @returns Auth state as signals and the auth actions.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useAuth<T = unknown, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(options?: UseAuthOptions): UseAuthResult<T, TRegister>;
|
|
68
|
+
/**
|
|
69
|
+
* The signed-in user alone. Call it in an injection context.
|
|
70
|
+
*
|
|
71
|
+
* @returns A signal of the authenticated user or `null`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function useUser<T = unknown>(): Signal<T | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a session exists. Call it in an injection context.
|
|
76
|
+
*
|
|
77
|
+
* @returns A signal of the authentication flag.
|
|
78
|
+
*/
|
|
79
|
+
export declare function useIsAuthenticated(): Signal<boolean>;
|
|
80
|
+
//# sourceMappingURL=use-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../src/hooks/use-auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgC,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEjF,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAK3B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,CAAC,GAAG,OAAO,EAC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,2EAA2E;IAC3E,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IAC/C,wCAAwC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAA;IACjC,iDAAiD;IACjD,UAAU,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAClD;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACrB,CAAC,GAAG,OAAO,EACX,SAAS,SAAS,kBAAkB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACtE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,CAAC,EAAE,SAAS,CAAC,CA4CvD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,OAAO,CAAC,CAEpD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular functions for authentication, mirroring `useAuth`,
|
|
3
|
+
* `useAuthClient`, `useUser` and `useIsAuthenticated` from
|
|
4
|
+
* `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { computed, DestroyRef, inject, signal } from '@angular/core';
|
|
9
|
+
import { injectProvider } from '../inject.js';
|
|
10
|
+
import { AUTH_CLIENT } from '../tokens.js';
|
|
11
|
+
/**
|
|
12
|
+
* The auth client registered by `provideMolecule({ auth })` or `provideAuth`.
|
|
13
|
+
* Call it in an injection context.
|
|
14
|
+
*
|
|
15
|
+
* @returns The auth client.
|
|
16
|
+
* @throws {Error} When no auth client is registered.
|
|
17
|
+
*/
|
|
18
|
+
export function useAuthClient() {
|
|
19
|
+
return injectProvider(AUTH_CLIENT, 'useAuthOutsideProvider', 'useAuthClient must be used within an AuthProvider');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Authentication state and actions. Call it in an injection context (a
|
|
23
|
+
* component field initializer or constructor).
|
|
24
|
+
*
|
|
25
|
+
* `status === 'loading'` is undecided; `'unavailable'` keeps the candidate
|
|
26
|
+
* session for retry; a restore failure never signs out.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Hook options (`autoRefresh`).
|
|
29
|
+
* @returns Auth state as signals and the auth actions.
|
|
30
|
+
*/
|
|
31
|
+
export function useAuth(options) {
|
|
32
|
+
const client = useAuthClient();
|
|
33
|
+
const { autoRefresh = false } = options ?? {};
|
|
34
|
+
const state = signal(client.getState(), /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
36
|
+
const stop = client.onAuthChange(() => state.set(client.getState()));
|
|
37
|
+
inject(DestroyRef).onDestroy(stop);
|
|
38
|
+
// Refresh once on mount when asked and the visitor is signed out and decided.
|
|
39
|
+
if (autoRefresh) {
|
|
40
|
+
const current = client.getState();
|
|
41
|
+
if (!current.authenticated && !current.loading) {
|
|
42
|
+
client.refresh().catch((_error) => {
|
|
43
|
+
// No session to refresh: the state already says unauthenticated.
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const login = (credentials) => client.login(credentials);
|
|
48
|
+
const logout = () => client.logout();
|
|
49
|
+
const register = (data) => client.register(data);
|
|
50
|
+
const refresh = () => client.refresh();
|
|
51
|
+
const updateProfile = (data) => client.updateProfile(data);
|
|
52
|
+
const setUser = (user) => {
|
|
53
|
+
client.setUser(user);
|
|
54
|
+
};
|
|
55
|
+
const setSession = (session) => {
|
|
56
|
+
client.setSession(session);
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
status: computed(() => state().status),
|
|
60
|
+
state: state.asReadonly(),
|
|
61
|
+
user: computed(() => state().user),
|
|
62
|
+
isAuthenticated: computed(() => state().authenticated),
|
|
63
|
+
isLoading: computed(() => state().loading),
|
|
64
|
+
login,
|
|
65
|
+
logout,
|
|
66
|
+
register,
|
|
67
|
+
refresh,
|
|
68
|
+
updateProfile,
|
|
69
|
+
setUser,
|
|
70
|
+
setSession,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The signed-in user alone. Call it in an injection context.
|
|
75
|
+
*
|
|
76
|
+
* @returns A signal of the authenticated user or `null`.
|
|
77
|
+
*/
|
|
78
|
+
export function useUser() {
|
|
79
|
+
return useAuth().user;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether a session exists. Call it in an injection context.
|
|
83
|
+
*
|
|
84
|
+
* @returns A signal of the authentication flag.
|
|
85
|
+
*/
|
|
86
|
+
export function useIsAuthenticated() {
|
|
87
|
+
return useAuth().isAuthenticated;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=use-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-auth.js","sourceRoot":"","sources":["../../src/hooks/use-auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AAYjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAI3B,OAAO,cAAc,CACnB,WAAW,EACX,wBAAwB,EACxB,mDAAmD,CACxB,CAAA;AAC/B,CAAC;AA8CD;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAGrB,OAAwB;IACxB,MAAM,MAAM,GAAG,aAAa,EAAgB,CAAA;IAC5C,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA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