@adonis-agora/authkit-react 0.17.0 → 0.18.1
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/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/src/components/authorized_apps.d.ts +1 -1
- package/build/src/components/interaction_form.d.ts +3 -3
- package/build/src/components/interaction_form.js +15 -2
- package/build/src/components/magic_link_button.d.ts +3 -1
- package/build/src/components/magic_link_button.js +6 -4
- package/build/src/components/organization_profile.d.ts +1 -1
- package/build/src/components/organization_switcher.d.ts +1 -1
- package/build/src/components/user_profile.d.ts +1 -1
- package/build/src/interaction/urls.d.ts +3 -1
- package/build/src/interaction/urls.js +2 -0
- package/package.json +12 -12
package/build/index.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type { UsePasskeyRegistrationOptions, UsePasskeyRegistrationResult, } fro
|
|
|
44
44
|
export { usePasswordStrength, heuristicScorer, } from './src/hooks/use_password_strength.js';
|
|
45
45
|
export type { PasswordStrengthScore, PasswordStrengthResult, PasswordScorer, UsePasswordStrengthOptions, } from './src/hooks/use_password_strength.js';
|
|
46
46
|
export { deriveInitials, currentUrl, buttonClass } from './src/utils.js';
|
|
47
|
-
export { interactionUrls, oauthRedirectUrl } from './src/interaction/urls.js';
|
|
47
|
+
export { interactionUrls, oauthRedirectUrl, OTP_CODE_FIELD } from './src/interaction/urls.js';
|
|
48
48
|
export type { InteractionUrls, InteractionPostStep, } from './src/interaction/urls.js';
|
|
49
49
|
export { Authenticated, Guest } from './src/components/authenticated.js';
|
|
50
50
|
export type { AuthenticatedProps, GuestProps, } from './src/components/authenticated.js';
|
package/build/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { usePasskeyAssertion } from './src/hooks/use_passkey_assertion.js';
|
|
|
22
22
|
export { usePasskeyRegistration } from './src/hooks/use_passkey_registration.js';
|
|
23
23
|
export { usePasswordStrength, heuristicScorer, } from './src/hooks/use_password_strength.js';
|
|
24
24
|
export { deriveInitials, currentUrl, buttonClass } from './src/utils.js';
|
|
25
|
-
export { interactionUrls, oauthRedirectUrl } from './src/interaction/urls.js';
|
|
25
|
+
export { interactionUrls, oauthRedirectUrl, OTP_CODE_FIELD } from './src/interaction/urls.js';
|
|
26
26
|
export { Authenticated, Guest } from './src/components/authenticated.js';
|
|
27
27
|
export { CanPermission } from './src/components/can_permission.js';
|
|
28
28
|
export { useCan, checkCan, invalidateCanCache } from './src/hooks/use_can.js';
|
|
@@ -6,5 +6,5 @@ export interface AuthorizedAppsProps {
|
|
|
6
6
|
declare function AuthorizedAppsInner({ className, revokeLabel, emptyLabel, }: AuthorizedAppsProps): import("react").DetailedReactHTMLElement<{
|
|
7
7
|
className: string;
|
|
8
8
|
}, HTMLElement>;
|
|
9
|
-
export declare function AuthorizedApps(props: Parameters<typeof AuthorizedAppsInner>[0]): import("react
|
|
9
|
+
export declare function AuthorizedApps(props: Parameters<typeof AuthorizedAppsInner>[0]): import("react").JSX.Element | null;
|
|
10
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FormHTMLAttributes, type ReactNode } from 'react';
|
|
1
|
+
import { type FormHTMLAttributes, type ReactNode, type SubmitEvent } from 'react';
|
|
2
2
|
import { type InteractionPostStep } from '../interaction/urls.js';
|
|
3
3
|
export interface InteractionFormProps extends Omit<FormHTMLAttributes<HTMLFormElement>, 'method' | 'action'> {
|
|
4
4
|
uid: string;
|
|
@@ -7,7 +7,7 @@ export interface InteractionFormProps extends Omit<FormHTMLAttributes<HTMLFormEl
|
|
|
7
7
|
basePath?: string;
|
|
8
8
|
children?: ReactNode;
|
|
9
9
|
}
|
|
10
|
-
export declare function InteractionForm({ uid, step, csrfToken, basePath, children, ...rest }: InteractionFormProps): import("react").DetailedReactHTMLElement<{
|
|
10
|
+
export declare function InteractionForm({ uid, step, csrfToken, basePath, children, onSubmit, ...rest }: InteractionFormProps): import("react").DetailedReactHTMLElement<{
|
|
11
11
|
id?: string | undefined | undefined;
|
|
12
12
|
name?: string | undefined | undefined;
|
|
13
13
|
slot?: string | undefined | undefined;
|
|
@@ -145,7 +145,6 @@ export declare function InteractionForm({ uid, step, csrfToken, basePath, childr
|
|
|
145
145
|
onInputCapture?: import("react").InputEventHandler<HTMLFormElement> | undefined;
|
|
146
146
|
onReset?: import("react").ReactEventHandler<HTMLFormElement> | undefined;
|
|
147
147
|
onResetCapture?: import("react").ReactEventHandler<HTMLFormElement> | undefined;
|
|
148
|
-
onSubmit?: import("react").SubmitEventHandler<HTMLFormElement> | undefined;
|
|
149
148
|
onSubmitCapture?: import("react").SubmitEventHandler<HTMLFormElement> | undefined;
|
|
150
149
|
onInvalid?: import("react").ReactEventHandler<HTMLFormElement> | undefined;
|
|
151
150
|
onInvalidCapture?: import("react").ReactEventHandler<HTMLFormElement> | undefined;
|
|
@@ -295,4 +294,5 @@ export declare function InteractionForm({ uid, step, csrfToken, basePath, childr
|
|
|
295
294
|
target?: string | undefined | undefined;
|
|
296
295
|
method: string;
|
|
297
296
|
action: string;
|
|
297
|
+
onSubmit: (event: SubmitEvent<HTMLElement>) => void;
|
|
298
298
|
}, HTMLElement>;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { interactionUrls } from '../interaction/urls.js';
|
|
3
|
-
|
|
3
|
+
function lockOnSubmit(event, hostOnSubmit) {
|
|
4
|
+
const formEvent = event;
|
|
5
|
+
hostOnSubmit?.(formEvent);
|
|
6
|
+
const form = formEvent.currentTarget;
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
if (formEvent.defaultPrevented)
|
|
9
|
+
return;
|
|
10
|
+
for (const el of form.querySelectorAll('button[type="submit"], input[type="submit"]')) {
|
|
11
|
+
el.disabled = true;
|
|
12
|
+
}
|
|
13
|
+
form.setAttribute('aria-busy', 'true');
|
|
14
|
+
}, 0);
|
|
15
|
+
}
|
|
16
|
+
export function InteractionForm({ uid, step, csrfToken, basePath, children, onSubmit, ...rest }) {
|
|
4
17
|
const action = interactionUrls(uid, basePath)[step];
|
|
5
|
-
return createElement('form', { method: 'POST', action, ...rest }, createElement('input', { type: 'hidden', name: '_csrf', value: csrfToken }), children);
|
|
18
|
+
return createElement('form', { method: 'POST', action, onSubmit: (event) => lockOnSubmit(event, onSubmit), ...rest }, createElement('input', { type: 'hidden', name: '_csrf', value: csrfToken }), children);
|
|
6
19
|
}
|
|
@@ -3,6 +3,8 @@ export interface MagicLinkButtonProps extends Omit<ButtonHTMLAttributes<HTMLButt
|
|
|
3
3
|
uid: string;
|
|
4
4
|
csrfToken: string;
|
|
5
5
|
basePath?: string;
|
|
6
|
+
channel?: 'code' | 'link';
|
|
7
|
+
pendingChildren?: ReactNode;
|
|
6
8
|
children?: ReactNode;
|
|
7
9
|
}
|
|
8
|
-
export declare function MagicLinkButton({ uid, csrfToken, basePath, children, className, ...rest }: MagicLinkButtonProps): import("react").FunctionComponentElement<import("./interaction_form.js").InteractionFormProps>;
|
|
10
|
+
export declare function MagicLinkButton({ uid, csrfToken, basePath, channel, pendingChildren, children, className, disabled, ...rest }: MagicLinkButtonProps): import("react").FunctionComponentElement<import("./interaction_form.js").InteractionFormProps>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
1
|
+
import { createElement, useState } from 'react';
|
|
2
2
|
import { buttonClass } from '../utils.js';
|
|
3
3
|
import { InteractionForm } from './interaction_form.js';
|
|
4
|
-
export function MagicLinkButton({ uid, csrfToken, basePath, children = 'Enviar link de login', className, ...rest }) {
|
|
5
|
-
|
|
4
|
+
export function MagicLinkButton({ uid, csrfToken, basePath, channel, pendingChildren = 'Enviando…', children = 'Enviar link de login', className, disabled, ...rest }) {
|
|
5
|
+
const [pending, setPending] = useState(false);
|
|
6
|
+
return createElement(InteractionForm, { uid, step: 'magic', csrfToken, basePath, onSubmit: () => setPending(true) }, channel ? createElement('input', { type: 'hidden', name: 'channel', value: channel }) : null, createElement('button', {
|
|
6
7
|
type: 'submit',
|
|
8
|
+
disabled: disabled || pending,
|
|
7
9
|
className: buttonClass('authkit-button--ghost', className),
|
|
8
10
|
...rest,
|
|
9
|
-
}, children));
|
|
11
|
+
}, pending ? pendingChildren : children));
|
|
10
12
|
}
|
|
@@ -6,5 +6,5 @@ export interface OrganizationProfileProps {
|
|
|
6
6
|
declare function OrganizationProfileInner({ inviteLabel, leaveLabel, className, }: OrganizationProfileProps): import("react").DetailedReactHTMLElement<{
|
|
7
7
|
className: string;
|
|
8
8
|
}, HTMLElement> | null;
|
|
9
|
-
export declare function OrganizationProfile(props: Parameters<typeof OrganizationProfileInner>[0]): import("react
|
|
9
|
+
export declare function OrganizationProfile(props: Parameters<typeof OrganizationProfileInner>[0]): import("react").JSX.Element | null;
|
|
10
10
|
export {};
|
|
@@ -5,5 +5,5 @@ export interface OrganizationSwitcherProps {
|
|
|
5
5
|
declare function OrganizationSwitcherInner({ personalAccountLabel, className, }: OrganizationSwitcherProps): import("react").DetailedReactHTMLElement<{
|
|
6
6
|
className: string;
|
|
7
7
|
}, HTMLElement> | null;
|
|
8
|
-
export declare function OrganizationSwitcher(props: Parameters<typeof OrganizationSwitcherInner>[0]): import("react
|
|
8
|
+
export declare function OrganizationSwitcher(props: Parameters<typeof OrganizationSwitcherInner>[0]): import("react").JSX.Element | null;
|
|
9
9
|
export {};
|
|
@@ -4,5 +4,5 @@ export interface UserProfileProps {
|
|
|
4
4
|
declare function UserProfileInner({ className }: UserProfileProps): import("react").DetailedReactHTMLElement<{
|
|
5
5
|
className: string;
|
|
6
6
|
}, HTMLElement> | null;
|
|
7
|
-
export declare function UserProfile(props: Parameters<typeof UserProfileInner>[0]): import("react
|
|
7
|
+
export declare function UserProfile(props: Parameters<typeof UserProfileInner>[0]): import("react").JSX.Element | null;
|
|
8
8
|
export {};
|
|
@@ -6,7 +6,9 @@ export interface InteractionUrls {
|
|
|
6
6
|
switch: string;
|
|
7
7
|
passkeyOptions: string;
|
|
8
8
|
passkeyVerify: string;
|
|
9
|
+
otpVerify: string;
|
|
9
10
|
}
|
|
10
11
|
export declare function interactionUrls(uid: string, basePath?: string): InteractionUrls;
|
|
11
|
-
export type InteractionPostStep = 'identifier' | 'login' | 'magic';
|
|
12
|
+
export type InteractionPostStep = 'identifier' | 'login' | 'magic' | 'otpVerify';
|
|
13
|
+
export declare const OTP_CODE_FIELD = "code";
|
|
12
14
|
export declare function oauthRedirectUrl(provider: string, uid: string, basePath?: string): string;
|
|
@@ -8,8 +8,10 @@ export function interactionUrls(uid, basePath = '/auth/interaction') {
|
|
|
8
8
|
switch: `${base}/switch`,
|
|
9
9
|
passkeyOptions: `${base}/passkey/options`,
|
|
10
10
|
passkeyVerify: `${base}/passkey/verify`,
|
|
11
|
+
otpVerify: `${base}/otp-verify`,
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
export const OTP_CODE_FIELD = 'code';
|
|
13
15
|
export function oauthRedirectUrl(provider, uid, basePath = '/auth') {
|
|
14
16
|
return `${basePath}/${provider}/redirect/${uid}`;
|
|
15
17
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|
|
7
|
-
"homepage": "https://github.com/DavideCarvalho/adonis-authkit/tree/main/packages/authkit-react#readme",
|
|
7
|
+
"homepage": "https://github.com/DavideCarvalho/adonis-agora-authkit/tree/main/packages/authkit-react#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/DavideCarvalho/adonis-authkit.git",
|
|
10
|
+
"url": "https://github.com/DavideCarvalho/adonis-agora-authkit.git",
|
|
11
11
|
"directory": "packages/authkit-react"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/DavideCarvalho/adonis-authkit/issues"
|
|
14
|
+
"url": "https://github.com/DavideCarvalho/adonis-agora-authkit/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"adonisjs",
|
|
@@ -50,25 +50,25 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@adonis-agora/authkit-core": "0.7.
|
|
53
|
+
"@adonis-agora/authkit-core": "0.7.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@adonisjs/tsconfig": "2.0.0",
|
|
57
|
-
"@inertiajs/react": "3.
|
|
57
|
+
"@inertiajs/react": "3.6.1",
|
|
58
58
|
"@japa/assert": "4.2.0",
|
|
59
59
|
"@japa/runner": "5.3.0",
|
|
60
60
|
"@poppinss/ts-exec": "1.4.4",
|
|
61
|
-
"@tanstack/react-query": "5.
|
|
61
|
+
"@tanstack/react-query": "5.101.4",
|
|
62
62
|
"@types/node": "25.9.1",
|
|
63
|
-
"@types/react": "19.2.
|
|
64
|
-
"@types/react-dom": "19.2.
|
|
65
|
-
"react": "19.2.
|
|
66
|
-
"react-dom": "19.2.
|
|
63
|
+
"@types/react": "19.2.18",
|
|
64
|
+
"@types/react-dom": "19.2.4",
|
|
65
|
+
"react": "19.2.8",
|
|
66
|
+
"react-dom": "19.2.8",
|
|
67
67
|
"typescript": "6.0.3"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsc",
|
|
71
|
-
"typecheck": "tsc --noEmit",
|
|
71
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json",
|
|
72
72
|
"test": "node --import=@poppinss/ts-exec bin/test.ts"
|
|
73
73
|
}
|
|
74
74
|
}
|