azirid-react 0.10.3 → 0.10.5
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 +2 -2
- package/dist/index.cjs +14 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,7 +229,7 @@ const [view, setView] = useState<AuthView>('login')
|
|
|
229
229
|
| `onViewChange` | `(view: AuthView) => void` | — | Callback when navigation links are clicked (controlled mode) |
|
|
230
230
|
| `defaultView` | `AuthView` | `'login'` | Initial view for uncontrolled mode |
|
|
231
231
|
| `logo` | `ReactNode` | — | Logo passed to all child forms |
|
|
232
|
-
| `showSocialButtons` | `boolean` | `
|
|
232
|
+
| `showSocialButtons` | `boolean` | `false` | Show Apple/Google SSO buttons. Only enable when social login is configured in Azirid dashboard |
|
|
233
233
|
| `hideNavigation` | `boolean` | — | Hide navigation links between views |
|
|
234
234
|
| `resetToken` | `string` | — | Token for the reset-password view |
|
|
235
235
|
| `defaultValues` | `{ email?: string; password?: string }` | — | Default values passed to child forms |
|
|
@@ -376,7 +376,7 @@ import { useBootstrap } from 'azirid-react'
|
|
|
376
376
|
const { bootstrap, isBootstrapping } = useBootstrap()
|
|
377
377
|
```
|
|
378
378
|
|
|
379
|
-
> **Note:** The automatic bootstrap
|
|
379
|
+
> **Note:** The automatic bootstrap uses request deduplication — if React 18 Strict Mode (or any other scenario) triggers multiple bootstrap calls, only **one HTTP request** is made and all callers await the same promise. This prevents token rotation conflicts that would otherwise invalidate the session on page reload in development mode. Hooks like `usePayphoneCheckout` and `<PayphoneCallback>` wait for bootstrap to complete before making authenticated requests.
|
|
380
380
|
|
|
381
381
|
### `useRefresh`
|
|
382
382
|
|
package/dist/index.cjs
CHANGED
|
@@ -165,6 +165,7 @@ function createAccessClient(config, appContext) {
|
|
|
165
165
|
let refreshToken = ssGet(storageKeyRt);
|
|
166
166
|
let csrfToken = ssGet(storageKeyCsrf);
|
|
167
167
|
let refreshPromise = null;
|
|
168
|
+
let bootstrapPromise = null;
|
|
168
169
|
let channel = null;
|
|
169
170
|
try {
|
|
170
171
|
if (typeof BroadcastChannel !== "undefined") {
|
|
@@ -264,6 +265,13 @@ function createAccessClient(config, appContext) {
|
|
|
264
265
|
});
|
|
265
266
|
return refreshPromise;
|
|
266
267
|
}
|
|
268
|
+
function deduplicatedBootstrap() {
|
|
269
|
+
if (bootstrapPromise) return bootstrapPromise;
|
|
270
|
+
bootstrapPromise = request("POST", paths.bootstrap).finally(() => {
|
|
271
|
+
bootstrapPromise = null;
|
|
272
|
+
});
|
|
273
|
+
return bootstrapPromise;
|
|
274
|
+
}
|
|
267
275
|
async function request(method, path, body) {
|
|
268
276
|
const headers = {
|
|
269
277
|
"Content-Type": "application/json",
|
|
@@ -365,7 +373,8 @@ function createAccessClient(config, appContext) {
|
|
|
365
373
|
getRefreshToken,
|
|
366
374
|
setCsrfToken,
|
|
367
375
|
getCsrfToken,
|
|
368
|
-
refreshSession: (opts) => refreshTokens(opts)
|
|
376
|
+
refreshSession: (opts) => refreshTokens(opts),
|
|
377
|
+
bootstrapSession: () => deduplicatedBootstrap()
|
|
369
378
|
};
|
|
370
379
|
}
|
|
371
380
|
|
|
@@ -768,20 +777,14 @@ function AziridProviderInner({
|
|
|
768
777
|
},
|
|
769
778
|
[client]
|
|
770
779
|
);
|
|
771
|
-
const bootstrapCalled = react.useRef(false);
|
|
772
780
|
react.useEffect(() => {
|
|
773
781
|
const autoBootstrap = props.autoBootstrap ?? true;
|
|
774
782
|
if (!autoBootstrap) return;
|
|
775
|
-
if (bootstrapCalled.current) {
|
|
776
|
-
setIsBootstrapping(false);
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
bootstrapCalled.current = true;
|
|
780
783
|
let cancelled = false;
|
|
781
784
|
async function bootstrap() {
|
|
782
785
|
setIsBootstrapping(true);
|
|
783
786
|
try {
|
|
784
|
-
const response = await client.
|
|
787
|
+
const response = await client.bootstrapSession();
|
|
785
788
|
if (cancelled) return;
|
|
786
789
|
if (response.branding) {
|
|
787
790
|
setBranding(response.branding);
|
|
@@ -1161,7 +1164,7 @@ var LoginForm = react.forwardRef(
|
|
|
1161
1164
|
submitText: submitTextProp,
|
|
1162
1165
|
footer,
|
|
1163
1166
|
forgotPassword,
|
|
1164
|
-
showSocialButtons =
|
|
1167
|
+
showSocialButtons = false,
|
|
1165
1168
|
labels,
|
|
1166
1169
|
defaultValues
|
|
1167
1170
|
}, ref) => {
|
|
@@ -1347,7 +1350,7 @@ var SignupForm = react.forwardRef(
|
|
|
1347
1350
|
logo: logoProp,
|
|
1348
1351
|
submitText: submitTextProp,
|
|
1349
1352
|
footer,
|
|
1350
|
-
showSocialButtons =
|
|
1353
|
+
showSocialButtons = false,
|
|
1351
1354
|
labels
|
|
1352
1355
|
}, ref) => {
|
|
1353
1356
|
const msg = useMessages();
|
|
@@ -4355,7 +4358,7 @@ function usePasswordToggle() {
|
|
|
4355
4358
|
}
|
|
4356
4359
|
|
|
4357
4360
|
// src/index.ts
|
|
4358
|
-
var SDK_VERSION = "0.10.
|
|
4361
|
+
var SDK_VERSION = "0.10.5";
|
|
4359
4362
|
|
|
4360
4363
|
exports.AuthForm = AuthForm;
|
|
4361
4364
|
exports.AziridProvider = AziridProvider;
|