@adonis-agora/authkit-react 0.15.0 → 0.17.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/build/index.d.ts +92 -76
- package/build/index.js +48 -40
- package/build/src/authkit_provider.js +1 -1
- package/build/src/client/client.d.ts +1 -1
- package/build/src/client/client.js +4 -2
- package/build/src/client/context.d.ts +1 -1
- package/build/src/client/context.js +1 -1
- package/build/src/components/authenticated.js +1 -1
- package/build/src/components/can_permission.d.ts +1 -1
- package/build/src/components/can_permission.js +2 -2
- package/build/src/components/interaction_form.d.ts +298 -0
- package/build/src/components/interaction_form.js +6 -0
- package/build/src/components/key_rotation.js +1 -1
- package/build/src/components/magic_link_button.d.ts +8 -0
- package/build/src/components/magic_link_button.js +10 -0
- package/build/src/components/oauth_button.d.ts +296 -0
- package/build/src/components/oauth_button.js +13 -0
- package/build/src/components/organization_profile.js +3 -3
- package/build/src/components/passkey_button.d.ts +2 -2
- package/build/src/components/passkey_button.js +9 -10
- package/build/src/components/password_strength_meter.js +1 -4
- package/build/src/components/user_button.js +1 -1
- package/build/src/components/user_profile.js +1 -1
- package/build/src/config.d.ts +1 -1
- package/build/src/config.js +16 -19
- package/build/src/hooks/use_can.js +8 -8
- package/build/src/hooks/use_organization.js +3 -1
- package/build/src/hooks/use_passkey_assertion.d.ts +12 -0
- package/build/src/hooks/use_passkey_assertion.js +19 -0
- package/build/src/hooks/use_passkey_autofill.js +10 -11
- package/build/src/hooks/use_passkey_login.js +2 -2
- package/build/src/hooks/use_passkey_registration.d.ts +12 -0
- package/build/src/hooks/use_passkey_registration.js +19 -0
- package/build/src/hooks/use_profile.d.ts +1 -1
- package/build/src/hooks/use_profile.js +5 -1
- package/build/src/hooks/use_resource.js +1 -1
- package/build/src/hooks/use_sign_in.js +1 -1
- package/build/src/hooks/use_sign_out.js +1 -1
- package/build/src/interaction/urls.d.ts +12 -0
- package/build/src/interaction/urls.js +15 -0
- package/build/src/passkey/authenticate.d.ts +20 -1
- package/build/src/passkey/authenticate.js +51 -31
- package/build/src/passkey/classic_form.d.ts +9 -0
- package/build/src/passkey/classic_form.js +18 -0
- package/build/src/passkey/sudo.d.ts +12 -0
- package/build/src/passkey/sudo.js +20 -0
- package/build/src/queries/account/index.d.ts +1 -1
- package/build/src/queries/admin/index.d.ts +1 -1
- package/build/src/use_auth.js +1 -1
- package/build/src/utils.d.ts +1 -0
- package/build/src/utils.js +3 -0
- package/package.json +7 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface OAuthButtonProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
3
|
+
provider: string;
|
|
4
|
+
uid: string;
|
|
5
|
+
basePath?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function OAuthButton({ provider, uid, basePath, children, className, ...rest }: OAuthButtonProps): import("react").DetailedReactHTMLElement<{
|
|
9
|
+
id?: string | undefined | undefined;
|
|
10
|
+
slot?: string | undefined | undefined;
|
|
11
|
+
style?: import("react").CSSProperties | undefined;
|
|
12
|
+
title?: string | undefined | undefined;
|
|
13
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
|
14
|
+
role?: import("react").AriaRole | undefined;
|
|
15
|
+
hidden?: boolean | undefined | undefined;
|
|
16
|
+
resource?: string | undefined | undefined;
|
|
17
|
+
onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
18
|
+
type?: string | undefined | undefined;
|
|
19
|
+
defaultChecked?: boolean | undefined | undefined;
|
|
20
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
21
|
+
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
22
|
+
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
23
|
+
accessKey?: string | undefined | undefined;
|
|
24
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
25
|
+
autoFocus?: boolean | undefined | undefined;
|
|
26
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
27
|
+
contextMenu?: string | undefined | undefined;
|
|
28
|
+
dir?: string | undefined | undefined;
|
|
29
|
+
draggable?: (boolean | "true" | "false") | undefined;
|
|
30
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
31
|
+
lang?: string | undefined | undefined;
|
|
32
|
+
nonce?: string | undefined | undefined;
|
|
33
|
+
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
34
|
+
tabIndex?: number | undefined | undefined;
|
|
35
|
+
translate?: "yes" | "no" | undefined | undefined;
|
|
36
|
+
radioGroup?: string | undefined | undefined;
|
|
37
|
+
about?: string | undefined | undefined;
|
|
38
|
+
content?: string | undefined | undefined;
|
|
39
|
+
datatype?: string | undefined | undefined;
|
|
40
|
+
inlist?: any;
|
|
41
|
+
prefix?: string | undefined | undefined;
|
|
42
|
+
property?: string | undefined | undefined;
|
|
43
|
+
rel?: string | undefined | undefined;
|
|
44
|
+
rev?: string | undefined | undefined;
|
|
45
|
+
typeof?: string | undefined | undefined;
|
|
46
|
+
vocab?: string | undefined | undefined;
|
|
47
|
+
autoCorrect?: string | undefined | undefined;
|
|
48
|
+
autoSave?: string | undefined | undefined;
|
|
49
|
+
color?: string | undefined | undefined;
|
|
50
|
+
itemProp?: string | undefined | undefined;
|
|
51
|
+
itemScope?: boolean | undefined | undefined;
|
|
52
|
+
itemType?: string | undefined | undefined;
|
|
53
|
+
itemID?: string | undefined | undefined;
|
|
54
|
+
itemRef?: string | undefined | undefined;
|
|
55
|
+
results?: number | undefined | undefined;
|
|
56
|
+
security?: string | undefined | undefined;
|
|
57
|
+
unselectable?: "on" | "off" | undefined | undefined;
|
|
58
|
+
popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
|
|
59
|
+
popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
|
|
60
|
+
popoverTarget?: string | undefined | undefined;
|
|
61
|
+
inert?: boolean | undefined | undefined;
|
|
62
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
63
|
+
is?: string | undefined | undefined;
|
|
64
|
+
exportparts?: string | undefined | undefined;
|
|
65
|
+
part?: string | undefined | undefined;
|
|
66
|
+
"aria-activedescendant"?: string | undefined | undefined;
|
|
67
|
+
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
68
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
69
|
+
"aria-braillelabel"?: string | undefined | undefined;
|
|
70
|
+
"aria-brailleroledescription"?: string | undefined | undefined;
|
|
71
|
+
"aria-busy"?: (boolean | "true" | "false") | undefined;
|
|
72
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
|
|
73
|
+
"aria-colcount"?: number | undefined | undefined;
|
|
74
|
+
"aria-colindex"?: number | undefined | undefined;
|
|
75
|
+
"aria-colindextext"?: string | undefined | undefined;
|
|
76
|
+
"aria-colspan"?: number | undefined | undefined;
|
|
77
|
+
"aria-controls"?: string | undefined | undefined;
|
|
78
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
|
|
79
|
+
"aria-describedby"?: string | undefined | undefined;
|
|
80
|
+
"aria-description"?: string | undefined | undefined;
|
|
81
|
+
"aria-details"?: string | undefined | undefined;
|
|
82
|
+
"aria-disabled"?: (boolean | "true" | "false") | undefined;
|
|
83
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
|
|
84
|
+
"aria-errormessage"?: string | undefined | undefined;
|
|
85
|
+
"aria-expanded"?: (boolean | "true" | "false") | undefined;
|
|
86
|
+
"aria-flowto"?: string | undefined | undefined;
|
|
87
|
+
"aria-grabbed"?: (boolean | "true" | "false") | undefined;
|
|
88
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
|
|
89
|
+
"aria-hidden"?: (boolean | "true" | "false") | undefined;
|
|
90
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
|
|
91
|
+
"aria-keyshortcuts"?: string | undefined | undefined;
|
|
92
|
+
"aria-label"?: string | undefined | undefined;
|
|
93
|
+
"aria-labelledby"?: string | undefined | undefined;
|
|
94
|
+
"aria-level"?: number | undefined | undefined;
|
|
95
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
|
|
96
|
+
"aria-modal"?: (boolean | "true" | "false") | undefined;
|
|
97
|
+
"aria-multiline"?: (boolean | "true" | "false") | undefined;
|
|
98
|
+
"aria-multiselectable"?: (boolean | "true" | "false") | undefined;
|
|
99
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
|
|
100
|
+
"aria-owns"?: string | undefined | undefined;
|
|
101
|
+
"aria-placeholder"?: string | undefined | undefined;
|
|
102
|
+
"aria-posinset"?: number | undefined | undefined;
|
|
103
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
|
|
104
|
+
"aria-readonly"?: (boolean | "true" | "false") | undefined;
|
|
105
|
+
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
|
|
106
|
+
"aria-required"?: (boolean | "true" | "false") | undefined;
|
|
107
|
+
"aria-roledescription"?: string | undefined | undefined;
|
|
108
|
+
"aria-rowcount"?: number | undefined | undefined;
|
|
109
|
+
"aria-rowindex"?: number | undefined | undefined;
|
|
110
|
+
"aria-rowindextext"?: string | undefined | undefined;
|
|
111
|
+
"aria-rowspan"?: number | undefined | undefined;
|
|
112
|
+
"aria-selected"?: (boolean | "true" | "false") | undefined;
|
|
113
|
+
"aria-setsize"?: number | undefined | undefined;
|
|
114
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
|
|
115
|
+
"aria-valuemax"?: number | undefined | undefined;
|
|
116
|
+
"aria-valuemin"?: number | undefined | undefined;
|
|
117
|
+
"aria-valuenow"?: number | undefined | undefined;
|
|
118
|
+
"aria-valuetext"?: string | undefined | undefined;
|
|
119
|
+
dangerouslySetInnerHTML?: {
|
|
120
|
+
__html: string | TrustedHTML;
|
|
121
|
+
} | undefined | undefined;
|
|
122
|
+
onCopy?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
123
|
+
onCopyCapture?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
124
|
+
onCut?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
125
|
+
onCutCapture?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
126
|
+
onPaste?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
127
|
+
onPasteCapture?: import("react").ClipboardEventHandler<HTMLAnchorElement> | undefined;
|
|
128
|
+
onCompositionEnd?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
129
|
+
onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
130
|
+
onCompositionStart?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
131
|
+
onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
132
|
+
onCompositionUpdate?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
133
|
+
onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLAnchorElement> | undefined;
|
|
134
|
+
onFocus?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
|
|
135
|
+
onFocusCapture?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
|
|
136
|
+
onBlur?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
|
|
137
|
+
onBlurCapture?: import("react").FocusEventHandler<HTMLAnchorElement> | undefined;
|
|
138
|
+
onChange?: import("react").ChangeEventHandler<HTMLAnchorElement, Element> | undefined;
|
|
139
|
+
onChangeCapture?: import("react").ChangeEventHandler<HTMLAnchorElement, Element> | undefined;
|
|
140
|
+
onBeforeInput?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
|
|
141
|
+
onBeforeInputCapture?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
|
|
142
|
+
onInput?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
|
|
143
|
+
onInputCapture?: import("react").InputEventHandler<HTMLAnchorElement> | undefined;
|
|
144
|
+
onReset?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
145
|
+
onResetCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
146
|
+
onSubmit?: import("react").SubmitEventHandler<HTMLAnchorElement> | undefined;
|
|
147
|
+
onSubmitCapture?: import("react").SubmitEventHandler<HTMLAnchorElement> | undefined;
|
|
148
|
+
onInvalid?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
149
|
+
onInvalidCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
150
|
+
onLoad?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
151
|
+
onLoadCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
152
|
+
onError?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
153
|
+
onErrorCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
154
|
+
onKeyDown?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
155
|
+
onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
156
|
+
onKeyPress?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
157
|
+
onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
158
|
+
onKeyUp?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
159
|
+
onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLAnchorElement> | undefined;
|
|
160
|
+
onAbort?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
161
|
+
onAbortCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
162
|
+
onCanPlay?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
163
|
+
onCanPlayCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
164
|
+
onCanPlayThrough?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
165
|
+
onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
166
|
+
onDurationChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
167
|
+
onDurationChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
168
|
+
onEmptied?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
169
|
+
onEmptiedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
170
|
+
onEncrypted?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
171
|
+
onEncryptedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
172
|
+
onEnded?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
173
|
+
onEndedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
174
|
+
onLoadedData?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
175
|
+
onLoadedDataCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
176
|
+
onLoadedMetadata?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
177
|
+
onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
178
|
+
onLoadStart?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
179
|
+
onLoadStartCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
180
|
+
onPause?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
181
|
+
onPauseCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
182
|
+
onPlay?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
183
|
+
onPlayCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
184
|
+
onPlaying?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
185
|
+
onPlayingCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
186
|
+
onProgress?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
187
|
+
onProgressCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
188
|
+
onRateChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
189
|
+
onRateChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
190
|
+
onSeeked?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
191
|
+
onSeekedCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
192
|
+
onSeeking?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
193
|
+
onSeekingCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
194
|
+
onStalled?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
195
|
+
onStalledCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
196
|
+
onSuspend?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
197
|
+
onSuspendCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
198
|
+
onTimeUpdate?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
199
|
+
onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
200
|
+
onVolumeChange?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
201
|
+
onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
202
|
+
onWaiting?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
203
|
+
onWaitingCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
204
|
+
onAuxClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
205
|
+
onAuxClickCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
206
|
+
onClickCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
207
|
+
onContextMenu?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
208
|
+
onContextMenuCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
209
|
+
onDoubleClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
210
|
+
onDoubleClickCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
211
|
+
onDrag?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
212
|
+
onDragCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
213
|
+
onDragEnd?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
214
|
+
onDragEndCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
215
|
+
onDragEnter?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
216
|
+
onDragEnterCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
217
|
+
onDragExit?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
218
|
+
onDragExitCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
219
|
+
onDragLeave?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
220
|
+
onDragLeaveCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
221
|
+
onDragOver?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
222
|
+
onDragOverCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
223
|
+
onDragStart?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
224
|
+
onDragStartCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
225
|
+
onDrop?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
226
|
+
onDropCapture?: import("react").DragEventHandler<HTMLAnchorElement> | undefined;
|
|
227
|
+
onMouseDown?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
228
|
+
onMouseDownCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
229
|
+
onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
230
|
+
onMouseLeave?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
231
|
+
onMouseMove?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
232
|
+
onMouseMoveCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
233
|
+
onMouseOut?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
234
|
+
onMouseOutCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
235
|
+
onMouseOver?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
236
|
+
onMouseOverCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
237
|
+
onMouseUp?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
238
|
+
onMouseUpCapture?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
|
|
239
|
+
onSelect?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
240
|
+
onSelectCapture?: import("react").ReactEventHandler<HTMLAnchorElement> | undefined;
|
|
241
|
+
onTouchCancel?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
242
|
+
onTouchCancelCapture?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
243
|
+
onTouchEnd?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
244
|
+
onTouchEndCapture?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
245
|
+
onTouchMove?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
246
|
+
onTouchMoveCapture?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
247
|
+
onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
248
|
+
onTouchStartCapture?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
|
|
249
|
+
onPointerDown?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
250
|
+
onPointerDownCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
251
|
+
onPointerMove?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
252
|
+
onPointerMoveCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
253
|
+
onPointerUp?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
254
|
+
onPointerUpCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
255
|
+
onPointerCancel?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
256
|
+
onPointerCancelCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
257
|
+
onPointerEnter?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
258
|
+
onPointerLeave?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
259
|
+
onPointerOver?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
260
|
+
onPointerOverCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
261
|
+
onPointerOut?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
262
|
+
onPointerOutCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
263
|
+
onGotPointerCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
264
|
+
onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
265
|
+
onLostPointerCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
266
|
+
onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLAnchorElement> | undefined;
|
|
267
|
+
onScroll?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
|
|
268
|
+
onScrollCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
|
|
269
|
+
onScrollEnd?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
|
|
270
|
+
onScrollEndCapture?: import("react").UIEventHandler<HTMLAnchorElement> | undefined;
|
|
271
|
+
onWheel?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
|
|
272
|
+
onWheelCapture?: import("react").WheelEventHandler<HTMLAnchorElement> | undefined;
|
|
273
|
+
onAnimationStart?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
274
|
+
onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
275
|
+
onAnimationEnd?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
276
|
+
onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
277
|
+
onAnimationIteration?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
278
|
+
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLAnchorElement> | undefined;
|
|
279
|
+
onToggle?: import("react").ToggleEventHandler<HTMLAnchorElement> | undefined;
|
|
280
|
+
onBeforeToggle?: import("react").ToggleEventHandler<HTMLAnchorElement> | undefined;
|
|
281
|
+
onTransitionCancel?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
282
|
+
onTransitionCancelCapture?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
283
|
+
onTransitionEnd?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
284
|
+
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
285
|
+
onTransitionRun?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
286
|
+
onTransitionRunCapture?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
287
|
+
onTransitionStart?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
288
|
+
onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLAnchorElement> | undefined;
|
|
289
|
+
target?: import("react").HTMLAttributeAnchorTarget | undefined;
|
|
290
|
+
download?: any;
|
|
291
|
+
hrefLang?: string | undefined | undefined;
|
|
292
|
+
media?: string | undefined | undefined;
|
|
293
|
+
ping?: string | undefined | undefined;
|
|
294
|
+
href: string;
|
|
295
|
+
className: string;
|
|
296
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { oauthRedirectUrl } from '../interaction/urls.js';
|
|
3
|
+
import { buttonClass } from '../utils.js';
|
|
4
|
+
function capitalize(value) {
|
|
5
|
+
return value ? value[0].toUpperCase() + value.slice(1) : value;
|
|
6
|
+
}
|
|
7
|
+
export function OAuthButton({ provider, uid, basePath, children, className, ...rest }) {
|
|
8
|
+
return createElement('a', {
|
|
9
|
+
href: oauthRedirectUrl(provider, uid, basePath),
|
|
10
|
+
className: buttonClass('authkit-button--ghost', className),
|
|
11
|
+
...rest,
|
|
12
|
+
}, children ?? `Entrar com ${capitalize(provider)}`);
|
|
13
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createElement, useState } from 'react';
|
|
3
|
-
import { useOrganizations } from '../hooks/use_organizations.js';
|
|
4
|
-
import { useOrganization } from '../hooks/use_organization.js';
|
|
5
|
-
import { useAuth } from '../use_auth.js';
|
|
6
3
|
import { useAuthkitConfig } from '../config.js';
|
|
4
|
+
import { useOrganization } from '../hooks/use_organization.js';
|
|
5
|
+
import { useOrganizations } from '../hooks/use_organizations.js';
|
|
7
6
|
import { jsonRequest } from '../hooks/use_resource.js';
|
|
7
|
+
import { useAuth } from '../use_auth.js';
|
|
8
8
|
function OrganizationProfileInner({ inviteLabel = 'Convidar membro', leaveLabel = 'Sair da organização', className, }) {
|
|
9
9
|
const { isAuthenticated } = useAuth();
|
|
10
10
|
const config = useAuthkitConfig();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ButtonHTMLAttributes, type ReactNode } from
|
|
2
|
-
export interface PasskeyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>,
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface PasskeyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> {
|
|
3
3
|
optionsUrl: string;
|
|
4
4
|
verifyUrl: string;
|
|
5
5
|
csrfToken?: string;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { createElement
|
|
2
|
-
import { usePasskeyLogin } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { usePasskeyLogin } from '../hooks/use_passkey_login.js';
|
|
3
|
+
import { buttonClass } from '../utils.js';
|
|
4
|
+
const DEFAULT_ERROR = 'Não foi possível autenticar com a passkey. Tente novamente.';
|
|
5
|
+
export function PasskeyButton({ optionsUrl, verifyUrl, csrfToken, children = 'Entrar com passkey', errorContent, className, ...rest }) {
|
|
5
6
|
const { authenticate, busy, failed } = usePasskeyLogin({
|
|
6
7
|
optionsUrl,
|
|
7
8
|
verifyUrl,
|
|
8
9
|
csrfToken,
|
|
9
10
|
});
|
|
10
|
-
const button = createElement(
|
|
11
|
-
type:
|
|
12
|
-
className:
|
|
13
|
-
.filter(Boolean)
|
|
14
|
-
.join(" "),
|
|
11
|
+
const button = createElement('button', {
|
|
12
|
+
type: 'button',
|
|
13
|
+
className: buttonClass('authkit-button--ghost', className),
|
|
15
14
|
onClick: () => {
|
|
16
15
|
void authenticate();
|
|
17
16
|
},
|
|
@@ -20,5 +19,5 @@ export function PasskeyButton({ optionsUrl, verifyUrl, csrfToken, children = "En
|
|
|
20
19
|
}, children);
|
|
21
20
|
if (!failed || errorContent === null)
|
|
22
21
|
return button;
|
|
23
|
-
return createElement(
|
|
22
|
+
return createElement('div', { className: 'authkit-passkey' }, button, createElement('p', { className: 'authkit-passkey__error' }, errorContent ?? DEFAULT_ERROR));
|
|
24
23
|
}
|
|
@@ -12,10 +12,7 @@ export function PasswordStrengthMeter({ password, scorer, showFeedback = true, l
|
|
|
12
12
|
const cls = ['authkit-strength', className].filter(Boolean).join(' ');
|
|
13
13
|
const segments = [0, 1, 2, 3].map((i) => createElement('span', {
|
|
14
14
|
key: i,
|
|
15
|
-
className: [
|
|
16
|
-
'authkit-strength__segment',
|
|
17
|
-
i < score ? 'authkit-strength__segment--filled' : '',
|
|
18
|
-
]
|
|
15
|
+
className: ['authkit-strength__segment', i < score ? 'authkit-strength__segment--filled' : '']
|
|
19
16
|
.filter(Boolean)
|
|
20
17
|
.join(' '),
|
|
21
18
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElement, useState } from 'react';
|
|
2
|
-
import { useAuth } from '../use_auth.js';
|
|
3
2
|
import { useAuthkitConfig } from '../config.js';
|
|
4
3
|
import { useSignOut } from '../hooks/use_sign_out.js';
|
|
4
|
+
import { useAuth } from '../use_auth.js';
|
|
5
5
|
import { Avatar } from './avatar.js';
|
|
6
6
|
export function UserButton({ profileLabel = 'Perfil', signOutLabel = 'Sair', className, }) {
|
|
7
7
|
const { user, isAuthenticated } = useAuth();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createElement, useState } from 'react';
|
|
3
3
|
import { useAuthkitConfig } from '../config.js';
|
|
4
|
-
import { useAuth } from '../use_auth.js';
|
|
5
4
|
import { useProfile } from '../hooks/use_profile.js';
|
|
5
|
+
import { useAuth } from '../use_auth.js';
|
|
6
6
|
import { Avatar } from './avatar.js';
|
|
7
7
|
function UserProfileInner({ className }) {
|
|
8
8
|
const { user, isAuthenticated } = useAuth();
|
package/build/src/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface AuthkitEndpoints {
|
|
|
7
7
|
orgInvitations: string;
|
|
8
8
|
can: string;
|
|
9
9
|
}
|
|
10
|
-
export type AuthkitIdpMode =
|
|
10
|
+
export type AuthkitIdpMode = 'authkit' | 'external';
|
|
11
11
|
export interface AuthkitConfig {
|
|
12
12
|
loginUrl?: string;
|
|
13
13
|
logoutUrl?: string;
|
package/build/src/config.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createContext, useContext } from
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
2
|
export const DEFAULT_CONFIG = {
|
|
3
|
-
idp:
|
|
4
|
-
loginUrl:
|
|
5
|
-
logoutUrl:
|
|
6
|
-
profileUrl:
|
|
3
|
+
idp: 'authkit',
|
|
4
|
+
loginUrl: '/auth/login',
|
|
5
|
+
logoutUrl: '/account/logout',
|
|
6
|
+
profileUrl: '/account/security',
|
|
7
7
|
endpoints: {
|
|
8
|
-
profile:
|
|
9
|
-
sessions:
|
|
10
|
-
apps:
|
|
11
|
-
passkeys:
|
|
12
|
-
orgs:
|
|
13
|
-
orgInvitations:
|
|
14
|
-
can:
|
|
8
|
+
profile: '/account/security/profile',
|
|
9
|
+
sessions: '/account/security',
|
|
10
|
+
apps: '/account/apps',
|
|
11
|
+
passkeys: '/account/mfa/passkeys',
|
|
12
|
+
orgs: '/account/orgs/json',
|
|
13
|
+
orgInvitations: '/account/orgs/invitations/json',
|
|
14
|
+
can: '/authz/can',
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
export function resolveConfig(config) {
|
|
@@ -25,20 +25,17 @@ export function resolveConfig(config) {
|
|
|
25
25
|
apps: config?.endpoints?.apps ?? DEFAULT_CONFIG.endpoints.apps,
|
|
26
26
|
passkeys: config?.endpoints?.passkeys ?? DEFAULT_CONFIG.endpoints.passkeys,
|
|
27
27
|
orgs: config?.endpoints?.orgs ?? DEFAULT_CONFIG.endpoints.orgs,
|
|
28
|
-
orgInvitations: config?.endpoints?.orgInvitations ??
|
|
29
|
-
|
|
30
|
-
can: config?.endpoints?.can ??
|
|
31
|
-
config?.canPath ??
|
|
32
|
-
DEFAULT_CONFIG.endpoints.can,
|
|
28
|
+
orgInvitations: config?.endpoints?.orgInvitations ?? DEFAULT_CONFIG.endpoints.orgInvitations,
|
|
29
|
+
can: config?.endpoints?.can ?? config?.canPath ?? DEFAULT_CONFIG.endpoints.can,
|
|
33
30
|
},
|
|
34
31
|
csrfToken: config?.csrfToken,
|
|
35
|
-
idp: config?.idp ??
|
|
32
|
+
idp: config?.idp ?? 'authkit',
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
export function buildAuthUrl(base, returnTo) {
|
|
39
36
|
if (!returnTo)
|
|
40
37
|
return base;
|
|
41
|
-
const sep = base.includes(
|
|
38
|
+
const sep = base.includes('?') ? '&' : '?';
|
|
42
39
|
return `${base}${sep}returnTo=${encodeURIComponent(returnTo)}`;
|
|
43
40
|
}
|
|
44
41
|
export const AuthkitConfigContext = createContext(DEFAULT_CONFIG);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useAuthkitConfig } from
|
|
4
|
-
import { AuthContext } from
|
|
5
|
-
import { jsonRequest } from
|
|
6
|
-
const ANON_PRINCIPAL =
|
|
1
|
+
import { usePage } from '@inertiajs/react';
|
|
2
|
+
import { useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { useAuthkitConfig } from '../config.js';
|
|
4
|
+
import { AuthContext } from '../provider.js';
|
|
5
|
+
import { jsonRequest } from './use_resource.js';
|
|
6
|
+
const ANON_PRINCIPAL = 'anon';
|
|
7
7
|
function usePrincipalId() {
|
|
8
8
|
const fromContext = useContext(AuthContext);
|
|
9
9
|
let fromPage;
|
|
@@ -16,7 +16,7 @@ function usePrincipalId() {
|
|
|
16
16
|
return (fromContext ?? fromPage)?.user?.id ?? ANON_PRINCIPAL;
|
|
17
17
|
}
|
|
18
18
|
function cacheKey(path, principal, permission, resource) {
|
|
19
|
-
return [principal, path, permission, resource ??
|
|
19
|
+
return [principal, path, permission, resource ?? ''].join('|');
|
|
20
20
|
}
|
|
21
21
|
export const canCache = {
|
|
22
22
|
resolved: new Map(),
|
|
@@ -38,7 +38,7 @@ export async function checkCan(path, permission, resource, csrfToken, principal
|
|
|
38
38
|
if (pending)
|
|
39
39
|
return pending;
|
|
40
40
|
const promise = jsonRequest(path, {
|
|
41
|
-
method:
|
|
41
|
+
method: 'POST',
|
|
42
42
|
csrfToken,
|
|
43
43
|
body: JSON.stringify({ permission, ...(resource ? { resource } : {}) }),
|
|
44
44
|
})
|
|
@@ -2,7 +2,9 @@ import { useAuthkitConfig } from '../config.js';
|
|
|
2
2
|
import { useResource } from './use_resource.js';
|
|
3
3
|
export function useOrganization(orgId) {
|
|
4
4
|
const config = useAuthkitConfig();
|
|
5
|
-
const url = orgId
|
|
5
|
+
const url = orgId
|
|
6
|
+
? `${config.endpoints.orgs.replace('/json', '')}/${encodeURIComponent(orgId)}/json`
|
|
7
|
+
: '';
|
|
6
8
|
const { data, loading, error, refetch } = useResource(url, config.csrfToken);
|
|
7
9
|
return { data, loading: url ? loading : false, error, actions: { refetch } };
|
|
8
10
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UsePasskeyAssertionOptions {
|
|
2
|
+
optionsUrl: string;
|
|
3
|
+
actionUrl: string;
|
|
4
|
+
csrfToken?: string;
|
|
5
|
+
returnTo?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface UsePasskeyAssertionResult {
|
|
8
|
+
run: () => Promise<void>;
|
|
9
|
+
running: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function usePasskeyAssertion(options: UsePasskeyAssertionOptions): UsePasskeyAssertionResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { runPasskeyAssertion } from '../passkey/sudo.js';
|
|
3
|
+
export function usePasskeyAssertion(options) {
|
|
4
|
+
const { optionsUrl, actionUrl, csrfToken, returnTo } = options;
|
|
5
|
+
const [running, setRunning] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const run = useCallback(async () => {
|
|
8
|
+
setError(null);
|
|
9
|
+
setRunning(true);
|
|
10
|
+
try {
|
|
11
|
+
await runPasskeyAssertion({ optionsUrl, actionUrl, csrfToken, returnTo });
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
15
|
+
setRunning(false);
|
|
16
|
+
}
|
|
17
|
+
}, [optionsUrl, actionUrl, csrfToken, returnTo]);
|
|
18
|
+
return { run, running, error };
|
|
19
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useEffect, useRef } from
|
|
2
|
-
import { loadStartAuthentication
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { loadStartAuthentication } from '../passkey/authenticate.js';
|
|
3
3
|
export function usePasskeyAutofill(options) {
|
|
4
|
-
const { optionsUrl, verifyUrl, onSuccess, csrfToken, enabled = true
|
|
4
|
+
const { optionsUrl, verifyUrl, onSuccess, csrfToken, enabled = true } = options;
|
|
5
5
|
const abortRef = useRef(null);
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
if (!enabled)
|
|
8
8
|
return;
|
|
9
|
-
if (typeof window ===
|
|
9
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined')
|
|
10
10
|
return;
|
|
11
11
|
if (!window.PublicKeyCredential)
|
|
12
12
|
return;
|
|
@@ -15,8 +15,7 @@ export function usePasskeyAutofill(options) {
|
|
|
15
15
|
abortRef.current = ac;
|
|
16
16
|
const run = async () => {
|
|
17
17
|
try {
|
|
18
|
-
const supported = typeof PublicKeyCredential
|
|
19
|
-
.isConditionalMediationAvailable === "function"
|
|
18
|
+
const supported = typeof PublicKeyCredential.isConditionalMediationAvailable === 'function'
|
|
20
19
|
? await PublicKeyCredential.isConditionalMediationAvailable()
|
|
21
20
|
: false;
|
|
22
21
|
if (!supported || cancelled)
|
|
@@ -31,12 +30,12 @@ export function usePasskeyAutofill(options) {
|
|
|
31
30
|
if (cancelled)
|
|
32
31
|
return;
|
|
33
32
|
const headers = {
|
|
34
|
-
|
|
33
|
+
'content-type': 'application/json',
|
|
35
34
|
};
|
|
36
35
|
if (csrfToken)
|
|
37
|
-
headers[
|
|
36
|
+
headers['x-csrf-token'] = csrfToken;
|
|
38
37
|
const optRes = await fetch(optionsUrl, {
|
|
39
|
-
method:
|
|
38
|
+
method: 'POST',
|
|
40
39
|
headers,
|
|
41
40
|
body: JSON.stringify({}),
|
|
42
41
|
signal: ac.signal,
|
|
@@ -44,7 +43,7 @@ export function usePasskeyAutofill(options) {
|
|
|
44
43
|
if (!optRes.ok || cancelled)
|
|
45
44
|
return;
|
|
46
45
|
const optionsJSON = await optRes.json();
|
|
47
|
-
|
|
46
|
+
optionsJSON._discoverable = undefined;
|
|
48
47
|
if (cancelled)
|
|
49
48
|
return;
|
|
50
49
|
const assertion = await startAuthentication({
|
|
@@ -65,5 +64,5 @@ export function usePasskeyAutofill(options) {
|
|
|
65
64
|
ac.abort();
|
|
66
65
|
abortRef.current = null;
|
|
67
66
|
};
|
|
68
|
-
}, [enabled, optionsUrl, verifyUrl, csrfToken]);
|
|
67
|
+
}, [enabled, optionsUrl, verifyUrl, onSuccess, csrfToken]);
|
|
69
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCallback, useState } from
|
|
2
|
-
import { authenticatePasskey, submitPasskeyVerification
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { authenticatePasskey, submitPasskeyVerification } from '../passkey/authenticate.js';
|
|
3
3
|
export function usePasskeyLogin(options) {
|
|
4
4
|
const { optionsUrl, verifyUrl, csrfToken, onSuccess } = options;
|
|
5
5
|
const [busy, setBusy] = useState(false);
|