@adonis-agora/authkit-react 0.14.0 → 0.16.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 +15 -1
- package/build/index.js +8 -1
- package/build/src/components/interaction_form.d.ts +298 -0
- package/build/src/components/interaction_form.js +6 -0
- 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/passkey_button.d.ts +11 -0
- package/build/src/components/passkey_button.js +23 -0
- package/build/src/components/sign_in_button.d.ts +1 -1
- package/build/src/components/sign_out_button.d.ts +1 -1
- package/build/src/hooks/use_passkey_autofill.js +19 -26
- package/build/src/hooks/use_passkey_login.d.ts +12 -0
- package/build/src/hooks/use_passkey_login.js +25 -0
- package/build/src/interaction/urls.d.ts +12 -0
- package/build/src/interaction/urls.js +15 -0
- package/build/src/passkey/authenticate.d.ts +22 -0
- package/build/src/passkey/authenticate.js +63 -0
- package/build/src/utils.d.ts +1 -0
- package/build/src/utils.js +8 -5
- package/package.json +1 -1
- package/styles.css +135 -31
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface PasskeyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
3
|
+
optionsUrl: string;
|
|
4
|
+
verifyUrl: string;
|
|
5
|
+
csrfToken?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
errorContent?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function PasskeyButton({ optionsUrl, verifyUrl, csrfToken, children, errorContent, className, ...rest }: PasskeyButtonProps): import("react").DetailedReactHTMLElement<{
|
|
10
|
+
className: string;
|
|
11
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 }) {
|
|
6
|
+
const { authenticate, busy, failed } = usePasskeyLogin({
|
|
7
|
+
optionsUrl,
|
|
8
|
+
verifyUrl,
|
|
9
|
+
csrfToken,
|
|
10
|
+
});
|
|
11
|
+
const button = createElement("button", {
|
|
12
|
+
type: "button",
|
|
13
|
+
className: buttonClass("authkit-button--ghost", className),
|
|
14
|
+
onClick: () => {
|
|
15
|
+
void authenticate();
|
|
16
|
+
},
|
|
17
|
+
disabled: busy,
|
|
18
|
+
...rest,
|
|
19
|
+
}, children);
|
|
20
|
+
if (!failed || errorContent === null)
|
|
21
|
+
return button;
|
|
22
|
+
return createElement("div", { className: "authkit-passkey" }, button, createElement("p", { className: "authkit-passkey__error" }, errorContent ?? DEFAULT_ERROR));
|
|
23
|
+
}
|
|
@@ -13,6 +13,7 @@ export declare function SignInButton({ children, returnTo, showWhenAuthenticated
|
|
|
13
13
|
style?: import("react").CSSProperties | undefined;
|
|
14
14
|
title?: string | undefined | undefined;
|
|
15
15
|
role?: import("react").AriaRole | undefined;
|
|
16
|
+
hidden?: boolean | undefined | undefined;
|
|
16
17
|
resource?: string | undefined | undefined;
|
|
17
18
|
disabled?: boolean | undefined | undefined;
|
|
18
19
|
formAction?: string | ((formData: FormData) => void | Promise<void>) | undefined;
|
|
@@ -33,7 +34,6 @@ export declare function SignInButton({ children, returnTo, showWhenAuthenticated
|
|
|
33
34
|
dir?: string | undefined | undefined;
|
|
34
35
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
35
36
|
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
36
|
-
hidden?: boolean | undefined | undefined;
|
|
37
37
|
lang?: string | undefined | undefined;
|
|
38
38
|
nonce?: string | undefined | undefined;
|
|
39
39
|
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
@@ -12,6 +12,7 @@ export declare function SignOutButton({ children, returnTo, className, ...rest }
|
|
|
12
12
|
style?: import("react").CSSProperties | undefined;
|
|
13
13
|
title?: string | undefined | undefined;
|
|
14
14
|
role?: import("react").AriaRole | undefined;
|
|
15
|
+
hidden?: boolean | undefined | undefined;
|
|
15
16
|
resource?: string | undefined | undefined;
|
|
16
17
|
disabled?: boolean | undefined | undefined;
|
|
17
18
|
formAction?: string | ((formData: FormData) => void | Promise<void>) | undefined;
|
|
@@ -32,7 +33,6 @@ export declare function SignOutButton({ children, returnTo, className, ...rest }
|
|
|
32
33
|
dir?: string | undefined | undefined;
|
|
33
34
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
34
35
|
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
35
|
-
hidden?: boolean | undefined | undefined;
|
|
36
36
|
lang?: string | undefined | undefined;
|
|
37
37
|
nonce?: string | undefined | undefined;
|
|
38
38
|
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { loadStartAuthentication, } from "../passkey/authenticate.js";
|
|
10
3
|
export function usePasskeyAutofill(options) {
|
|
11
|
-
const { optionsUrl, verifyUrl, onSuccess, csrfToken, enabled = true } = options;
|
|
4
|
+
const { optionsUrl, verifyUrl, onSuccess, csrfToken, enabled = true, } = options;
|
|
12
5
|
const abortRef = useRef(null);
|
|
13
6
|
useEffect(() => {
|
|
14
7
|
if (!enabled)
|
|
15
8
|
return;
|
|
16
|
-
if (typeof window ===
|
|
9
|
+
if (typeof window === "undefined" || typeof navigator === "undefined")
|
|
17
10
|
return;
|
|
18
11
|
if (!window.PublicKeyCredential)
|
|
19
12
|
return;
|
|
@@ -22,32 +15,28 @@ export function usePasskeyAutofill(options) {
|
|
|
22
15
|
abortRef.current = ac;
|
|
23
16
|
const run = async () => {
|
|
24
17
|
try {
|
|
25
|
-
const supported = typeof PublicKeyCredential
|
|
18
|
+
const supported = typeof PublicKeyCredential
|
|
19
|
+
.isConditionalMediationAvailable === "function"
|
|
26
20
|
? await PublicKeyCredential.isConditionalMediationAvailable()
|
|
27
21
|
: false;
|
|
28
22
|
if (!supported || cancelled)
|
|
29
23
|
return;
|
|
30
24
|
let startAuthentication;
|
|
31
25
|
try {
|
|
32
|
-
|
|
33
|
-
startAuthentication = mod.startAuthentication;
|
|
26
|
+
startAuthentication = await loadStartAuthentication();
|
|
34
27
|
}
|
|
35
28
|
catch {
|
|
36
|
-
|
|
37
|
-
const mod = await import(__rewriteRelativeImportExtension('https://cdn.jsdelivr.net/npm/@simplewebauthn/browser@13/dist/bundle/index.js'));
|
|
38
|
-
startAuthentication = mod.startAuthentication;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
29
|
+
return;
|
|
43
30
|
}
|
|
44
|
-
if (
|
|
31
|
+
if (cancelled)
|
|
45
32
|
return;
|
|
46
|
-
const headers = {
|
|
33
|
+
const headers = {
|
|
34
|
+
"content-type": "application/json",
|
|
35
|
+
};
|
|
47
36
|
if (csrfToken)
|
|
48
|
-
headers[
|
|
37
|
+
headers["x-csrf-token"] = csrfToken;
|
|
49
38
|
const optRes = await fetch(optionsUrl, {
|
|
50
|
-
method:
|
|
39
|
+
method: "POST",
|
|
51
40
|
headers,
|
|
52
41
|
body: JSON.stringify({}),
|
|
53
42
|
signal: ac.signal,
|
|
@@ -58,7 +47,11 @@ export function usePasskeyAutofill(options) {
|
|
|
58
47
|
delete optionsJSON._discoverable;
|
|
59
48
|
if (cancelled)
|
|
60
49
|
return;
|
|
61
|
-
const assertion = await startAuthentication({
|
|
50
|
+
const assertion = await startAuthentication({
|
|
51
|
+
optionsJSON,
|
|
52
|
+
useBrowserAutofill: true,
|
|
53
|
+
verifyBrowserAutofillInput: true,
|
|
54
|
+
}, ac.signal);
|
|
62
55
|
if (cancelled)
|
|
63
56
|
return;
|
|
64
57
|
onSuccess(JSON.stringify(assertion));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UsePasskeyLoginOptions {
|
|
2
|
+
optionsUrl: string;
|
|
3
|
+
verifyUrl: string;
|
|
4
|
+
csrfToken?: string;
|
|
5
|
+
onSuccess?: (assertion: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface UsePasskeyLoginResult {
|
|
8
|
+
authenticate: () => Promise<void>;
|
|
9
|
+
busy: boolean;
|
|
10
|
+
failed: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function usePasskeyLogin(options: UsePasskeyLoginOptions): UsePasskeyLoginResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { authenticatePasskey, submitPasskeyVerification, } from "../passkey/authenticate.js";
|
|
3
|
+
export function usePasskeyLogin(options) {
|
|
4
|
+
const { optionsUrl, verifyUrl, csrfToken, onSuccess } = options;
|
|
5
|
+
const [busy, setBusy] = useState(false);
|
|
6
|
+
const [failed, setFailed] = useState(false);
|
|
7
|
+
const authenticate = useCallback(async () => {
|
|
8
|
+
setFailed(false);
|
|
9
|
+
setBusy(true);
|
|
10
|
+
try {
|
|
11
|
+
const assertion = await authenticatePasskey({ optionsUrl, csrfToken });
|
|
12
|
+
if (onSuccess) {
|
|
13
|
+
onSuccess(assertion);
|
|
14
|
+
setBusy(false);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
submitPasskeyVerification({ verifyUrl, assertion, csrfToken });
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
setFailed(true);
|
|
21
|
+
setBusy(false);
|
|
22
|
+
}
|
|
23
|
+
}, [optionsUrl, verifyUrl, csrfToken, onSuccess]);
|
|
24
|
+
return { authenticate, busy, failed };
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface InteractionUrls {
|
|
2
|
+
identifier: string;
|
|
3
|
+
login: string;
|
|
4
|
+
magic: string;
|
|
5
|
+
signup: string;
|
|
6
|
+
switch: string;
|
|
7
|
+
passkeyOptions: string;
|
|
8
|
+
passkeyVerify: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function interactionUrls(uid: string, basePath?: string): InteractionUrls;
|
|
11
|
+
export type InteractionPostStep = "identifier" | "login" | "magic";
|
|
12
|
+
export declare function oauthRedirectUrl(provider: string, uid: string, basePath?: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function interactionUrls(uid, basePath = "/auth/interaction") {
|
|
2
|
+
const base = `${basePath}/${uid}`;
|
|
3
|
+
return {
|
|
4
|
+
identifier: `${base}/identifier`,
|
|
5
|
+
login: `${base}/login`,
|
|
6
|
+
magic: `${base}/magic`,
|
|
7
|
+
signup: `${base}/signup`,
|
|
8
|
+
switch: `${base}/switch`,
|
|
9
|
+
passkeyOptions: `${base}/passkey/options`,
|
|
10
|
+
passkeyVerify: `${base}/passkey/verify`,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function oauthRedirectUrl(provider, uid, basePath = "/auth") {
|
|
14
|
+
return `${basePath}/${provider}/redirect/${uid}`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type StartAuthenticationFn = (opts: {
|
|
2
|
+
optionsJSON: unknown;
|
|
3
|
+
useBrowserAutofill?: boolean;
|
|
4
|
+
verifyBrowserAutofillInput?: boolean;
|
|
5
|
+
}, signal?: AbortSignal) => Promise<unknown>;
|
|
6
|
+
export declare function loadStartAuthentication(): Promise<StartAuthenticationFn>;
|
|
7
|
+
export interface AuthenticatePasskeyOptions {
|
|
8
|
+
optionsUrl: string;
|
|
9
|
+
csrfToken?: string;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface PasskeyCeremonyDeps {
|
|
13
|
+
fetch?: typeof globalThis.fetch;
|
|
14
|
+
loadStartAuthentication?: () => Promise<StartAuthenticationFn>;
|
|
15
|
+
}
|
|
16
|
+
export declare function authenticatePasskey(options: AuthenticatePasskeyOptions, deps?: PasskeyCeremonyDeps): Promise<string>;
|
|
17
|
+
export interface SubmitPasskeyVerificationOptions {
|
|
18
|
+
verifyUrl: string;
|
|
19
|
+
assertion: string;
|
|
20
|
+
csrfToken?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function submitPasskeyVerification(options: SubmitPasskeyVerificationOptions): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
const CDN_URL = "https://cdn.jsdelivr.net/npm/@simplewebauthn/browser@13/dist/bundle/index.js";
|
|
10
|
+
export async function loadStartAuthentication() {
|
|
11
|
+
try {
|
|
12
|
+
const mod = await import(__rewriteRelativeImportExtension("@simplewebauthn/browser"));
|
|
13
|
+
return mod.startAuthentication;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
const mod = await import(__rewriteRelativeImportExtension(CDN_URL));
|
|
17
|
+
return mod.startAuthentication;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function authenticatePasskey(options, deps = {}) {
|
|
21
|
+
const { optionsUrl, csrfToken, signal } = options;
|
|
22
|
+
const doFetch = deps.fetch ?? globalThis.fetch;
|
|
23
|
+
const loadFn = deps.loadStartAuthentication ?? loadStartAuthentication;
|
|
24
|
+
const headers = {
|
|
25
|
+
"content-type": "application/json",
|
|
26
|
+
};
|
|
27
|
+
if (csrfToken)
|
|
28
|
+
headers["x-csrf-token"] = csrfToken;
|
|
29
|
+
const res = await doFetch(optionsUrl, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers,
|
|
32
|
+
body: JSON.stringify({}),
|
|
33
|
+
signal,
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
throw new Error(`passkey options request failed: ${res.status}`);
|
|
37
|
+
}
|
|
38
|
+
const optionsJSON = await res.json();
|
|
39
|
+
const startAuthentication = await loadFn();
|
|
40
|
+
const assertion = await startAuthentication({ optionsJSON }, signal);
|
|
41
|
+
return JSON.stringify(assertion);
|
|
42
|
+
}
|
|
43
|
+
export function submitPasskeyVerification(options) {
|
|
44
|
+
const { verifyUrl, assertion, csrfToken } = options;
|
|
45
|
+
if (typeof document === "undefined")
|
|
46
|
+
return;
|
|
47
|
+
const form = document.createElement("form");
|
|
48
|
+
form.method = "POST";
|
|
49
|
+
form.action = verifyUrl;
|
|
50
|
+
form.hidden = true;
|
|
51
|
+
if (csrfToken)
|
|
52
|
+
form.appendChild(hiddenInput("_csrf", csrfToken));
|
|
53
|
+
form.appendChild(hiddenInput("response", assertion));
|
|
54
|
+
document.body.appendChild(form);
|
|
55
|
+
form.submit();
|
|
56
|
+
}
|
|
57
|
+
function hiddenInput(name, value) {
|
|
58
|
+
const input = document.createElement("input");
|
|
59
|
+
input.type = "hidden";
|
|
60
|
+
input.name = name;
|
|
61
|
+
input.value = value;
|
|
62
|
+
return input;
|
|
63
|
+
}
|
package/build/src/utils.d.ts
CHANGED