@adonis-agora/authkit-react 0.12.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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +146 -0
  3. package/build/index.d.ts +68 -0
  4. package/build/index.js +36 -0
  5. package/build/src/authkit_provider.d.ts +13 -0
  6. package/build/src/authkit_provider.js +11 -0
  7. package/build/src/client/client.d.ts +172 -0
  8. package/build/src/client/client.js +218 -0
  9. package/build/src/client/context.d.ts +11 -0
  10. package/build/src/client/context.js +28 -0
  11. package/build/src/client/types.d.ts +425 -0
  12. package/build/src/client/types.js +1 -0
  13. package/build/src/components/authenticated.d.ts +11 -0
  14. package/build/src/components/authenticated.js +10 -0
  15. package/build/src/components/authorized_apps.d.ts +10 -0
  16. package/build/src/components/authorized_apps.js +34 -0
  17. package/build/src/components/avatar.d.ts +22 -0
  18. package/build/src/components/avatar.js +15 -0
  19. package/build/src/components/can.d.ts +10 -0
  20. package/build/src/components/can.js +19 -0
  21. package/build/src/components/key_rotation.d.ts +8 -0
  22. package/build/src/components/key_rotation.js +36 -0
  23. package/build/src/components/organization_profile.d.ts +10 -0
  24. package/build/src/components/organization_profile.js +94 -0
  25. package/build/src/components/organization_switcher.d.ts +9 -0
  26. package/build/src/components/organization_switcher.js +65 -0
  27. package/build/src/components/password_strength_meter.d.ts +11 -0
  28. package/build/src/components/password_strength_meter.js +39 -0
  29. package/build/src/components/sign_in_button.d.ts +297 -0
  30. package/build/src/components/sign_in_button.js +16 -0
  31. package/build/src/components/sign_out_button.d.ts +296 -0
  32. package/build/src/components/sign_out_button.js +16 -0
  33. package/build/src/components/user_button.d.ts +8 -0
  34. package/build/src/components/user_button.js +31 -0
  35. package/build/src/components/user_profile.d.ts +8 -0
  36. package/build/src/components/user_profile.js +35 -0
  37. package/build/src/config.d.ts +30 -0
  38. package/build/src/config.js +42 -0
  39. package/build/src/hooks/use_authorized_apps.d.ts +16 -0
  40. package/build/src/hooks/use_authorized_apps.js +15 -0
  41. package/build/src/hooks/use_org_invitations.d.ts +19 -0
  42. package/build/src/hooks/use_org_invitations.js +20 -0
  43. package/build/src/hooks/use_organization.d.ts +23 -0
  44. package/build/src/hooks/use_organization.js +8 -0
  45. package/build/src/hooks/use_organizations.d.ts +18 -0
  46. package/build/src/hooks/use_organizations.js +14 -0
  47. package/build/src/hooks/use_passkey_autofill.d.ts +8 -0
  48. package/build/src/hooks/use_passkey_autofill.js +76 -0
  49. package/build/src/hooks/use_password_strength.d.ts +11 -0
  50. package/build/src/hooks/use_password_strength.js +34 -0
  51. package/build/src/hooks/use_profile.d.ts +13 -0
  52. package/build/src/hooks/use_profile.js +28 -0
  53. package/build/src/hooks/use_resource.d.ts +11 -0
  54. package/build/src/hooks/use_resource.js +48 -0
  55. package/build/src/hooks/use_sessions.d.ts +16 -0
  56. package/build/src/hooks/use_sessions.js +15 -0
  57. package/build/src/hooks/use_sign_in.d.ts +6 -0
  58. package/build/src/hooks/use_sign_in.js +13 -0
  59. package/build/src/hooks/use_sign_out.d.ts +6 -0
  60. package/build/src/hooks/use_sign_out.js +11 -0
  61. package/build/src/hooks/use_switch_organization.d.ts +7 -0
  62. package/build/src/hooks/use_switch_organization.js +42 -0
  63. package/build/src/hooks/use_user.d.ts +6 -0
  64. package/build/src/hooks/use_user.js +5 -0
  65. package/build/src/provider.d.ts +16 -0
  66. package/build/src/provider.js +5 -0
  67. package/build/src/queries/account/index.d.ts +86 -0
  68. package/build/src/queries/account/index.js +150 -0
  69. package/build/src/queries/admin/index.d.ts +226 -0
  70. package/build/src/queries/admin/index.js +287 -0
  71. package/build/src/queries/keys.d.ts +50 -0
  72. package/build/src/queries/keys.js +34 -0
  73. package/build/src/roles.d.ts +7 -0
  74. package/build/src/roles.js +39 -0
  75. package/build/src/types.d.ts +27 -0
  76. package/build/src/types.js +1 -0
  77. package/build/src/use_auth.d.ts +2 -0
  78. package/build/src/use_auth.js +33 -0
  79. package/build/src/utils.d.ts +2 -0
  80. package/build/src/utils.js +18 -0
  81. package/package.json +68 -0
  82. package/styles.css +303 -0
package/styles.css ADDED
@@ -0,0 +1,303 @@
1
+ /**
2
+ * Estilos prontos dos componentes do @adonis-agora/authkit-react.
3
+ * Temáveis via CSS vars `--authkit-*` (defaults Adonis-violet).
4
+ * Importe em algum ponto da app: `import '@adonis-agora/authkit-react/styles.css'`
5
+ */
6
+ :root {
7
+ --authkit-primary: #5a45ff;
8
+ --authkit-primary-contrast: #ffffff;
9
+ --authkit-danger: #e5484d;
10
+ --authkit-fg: #1a1523;
11
+ --authkit-muted: #6f6e77;
12
+ --authkit-bg: #ffffff;
13
+ --authkit-border: #e4e2e8;
14
+ --authkit-radius: 8px;
15
+ --authkit-gap: 0.5rem;
16
+ }
17
+
18
+ .authkit-button {
19
+ display: inline-flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ gap: 0.4rem;
23
+ padding: 0.5rem 0.9rem;
24
+ font: inherit;
25
+ font-weight: 500;
26
+ border-radius: var(--authkit-radius);
27
+ border: 1px solid transparent;
28
+ cursor: pointer;
29
+ line-height: 1.2;
30
+ }
31
+ .authkit-button:disabled {
32
+ opacity: 0.6;
33
+ cursor: not-allowed;
34
+ }
35
+ .authkit-button--primary {
36
+ background: var(--authkit-primary);
37
+ color: var(--authkit-primary-contrast);
38
+ }
39
+ .authkit-button--ghost {
40
+ background: transparent;
41
+ color: var(--authkit-fg);
42
+ border-color: var(--authkit-border);
43
+ }
44
+ .authkit-button--danger {
45
+ background: transparent;
46
+ color: var(--authkit-danger);
47
+ border-color: var(--authkit-border);
48
+ }
49
+
50
+ .authkit-avatar {
51
+ display: inline-flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+ border-radius: 50%;
55
+ background: var(--authkit-primary);
56
+ color: var(--authkit-primary-contrast);
57
+ font-weight: 600;
58
+ font-size: 0.85rem;
59
+ object-fit: cover;
60
+ overflow: hidden;
61
+ }
62
+
63
+ .authkit-userbutton {
64
+ position: relative;
65
+ display: inline-block;
66
+ }
67
+ .authkit-userbutton__trigger {
68
+ background: none;
69
+ border: none;
70
+ padding: 0;
71
+ cursor: pointer;
72
+ }
73
+ .authkit-userbutton__menu {
74
+ position: absolute;
75
+ right: 0;
76
+ margin-top: 0.4rem;
77
+ min-width: 12rem;
78
+ background: var(--authkit-bg);
79
+ border: 1px solid var(--authkit-border);
80
+ border-radius: var(--authkit-radius);
81
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
82
+ padding: 0.3rem;
83
+ z-index: 50;
84
+ }
85
+ .authkit-userbutton__header {
86
+ padding: 0.5rem 0.6rem;
87
+ border-bottom: 1px solid var(--authkit-border);
88
+ margin-bottom: 0.3rem;
89
+ }
90
+ .authkit-userbutton__name {
91
+ font-weight: 600;
92
+ color: var(--authkit-fg);
93
+ }
94
+ .authkit-userbutton__email {
95
+ font-size: 0.8rem;
96
+ color: var(--authkit-muted);
97
+ }
98
+ .authkit-userbutton__item {
99
+ display: block;
100
+ width: 100%;
101
+ text-align: left;
102
+ padding: 0.5rem 0.6rem;
103
+ background: none;
104
+ border: none;
105
+ border-radius: 6px;
106
+ color: var(--authkit-fg);
107
+ text-decoration: none;
108
+ font: inherit;
109
+ cursor: pointer;
110
+ }
111
+ .authkit-userbutton__item:hover {
112
+ background: rgba(90, 69, 255, 0.08);
113
+ }
114
+
115
+ .authkit-card {
116
+ background: var(--authkit-bg);
117
+ border: 1px solid var(--authkit-border);
118
+ border-radius: var(--authkit-radius);
119
+ padding: 1rem;
120
+ }
121
+ .authkit-profile__header {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 0.75rem;
125
+ margin-bottom: 1rem;
126
+ }
127
+ .authkit-profile__name {
128
+ font-weight: 600;
129
+ color: var(--authkit-fg);
130
+ }
131
+ .authkit-profile__email {
132
+ font-size: 0.85rem;
133
+ color: var(--authkit-muted);
134
+ }
135
+ .authkit-profile__form {
136
+ display: flex;
137
+ flex-direction: column;
138
+ gap: var(--authkit-gap);
139
+ }
140
+ .authkit-label {
141
+ font-size: 0.85rem;
142
+ color: var(--authkit-muted);
143
+ }
144
+ .authkit-input {
145
+ padding: 0.5rem 0.6rem;
146
+ border: 1px solid var(--authkit-border);
147
+ border-radius: var(--authkit-radius);
148
+ font: inherit;
149
+ }
150
+ .authkit-error {
151
+ color: var(--authkit-danger);
152
+ font-size: 0.85rem;
153
+ }
154
+
155
+ .authkit-apps {
156
+ list-style: none;
157
+ margin: 0;
158
+ padding: 0;
159
+ display: flex;
160
+ flex-direction: column;
161
+ gap: var(--authkit-gap);
162
+ }
163
+ .authkit-apps__item {
164
+ display: flex;
165
+ align-items: center;
166
+ justify-content: space-between;
167
+ padding: 0.6rem 0.75rem;
168
+ border: 1px solid var(--authkit-border);
169
+ border-radius: var(--authkit-radius);
170
+ }
171
+ .authkit-apps__info {
172
+ display: flex;
173
+ align-items: center;
174
+ gap: 0.5rem;
175
+ }
176
+ .authkit-apps__logo {
177
+ width: 24px;
178
+ height: 24px;
179
+ border-radius: 4px;
180
+ }
181
+ .authkit-apps__name {
182
+ font-weight: 500;
183
+ color: var(--authkit-fg);
184
+ }
185
+ .authkit-apps__empty,
186
+ .authkit-apps__loading {
187
+ color: var(--authkit-muted);
188
+ font-size: 0.9rem;
189
+ }
190
+
191
+ /* Medidor de força de senha (PasswordStrengthMeter). */
192
+ .authkit-strength {
193
+ display: flex;
194
+ flex-direction: column;
195
+ gap: 0.35rem;
196
+ }
197
+ .authkit-strength__bar {
198
+ display: flex;
199
+ gap: 0.25rem;
200
+ }
201
+ .authkit-strength__segment {
202
+ flex: 1 1 0;
203
+ height: 5px;
204
+ border-radius: 999px;
205
+ background: var(--authkit-border);
206
+ transition: background-color 0.15s ease;
207
+ }
208
+ /* Cor por score, do mais fraco ao mais forte (via data-score no bar). */
209
+ .authkit-strength__bar[data-score='1'] .authkit-strength__segment--filled {
210
+ background: var(--authkit-danger);
211
+ }
212
+ .authkit-strength__bar[data-score='2'] .authkit-strength__segment--filled {
213
+ background: #f5a524;
214
+ }
215
+ .authkit-strength__bar[data-score='3'] .authkit-strength__segment--filled {
216
+ background: #d6c20a;
217
+ }
218
+ .authkit-strength__bar[data-score='4'] .authkit-strength__segment--filled {
219
+ background: #2fb344;
220
+ }
221
+ .authkit-strength__label {
222
+ font-size: 0.8rem;
223
+ color: var(--authkit-muted);
224
+ }
225
+ .authkit-strength__feedback {
226
+ margin: 0;
227
+ padding-left: 1.1rem;
228
+ font-size: 0.8rem;
229
+ color: var(--authkit-muted);
230
+ }
231
+
232
+ /* ─── OrganizationSwitcher ─────────────────────────────────────────────── */
233
+ .authkit-orgswitcher {
234
+ position: relative;
235
+ display: inline-block;
236
+ }
237
+ .authkit-orgswitcher__trigger {
238
+ display: inline-flex;
239
+ align-items: center;
240
+ gap: 0.4rem;
241
+ padding: 0.4rem 0.75rem;
242
+ background: var(--authkit-bg);
243
+ border: 1px solid var(--authkit-border);
244
+ border-radius: var(--authkit-radius);
245
+ cursor: pointer;
246
+ font-size: 0.875rem;
247
+ color: var(--authkit-fg);
248
+ }
249
+ .authkit-orgswitcher__trigger:disabled { opacity: 0.6; cursor: default; }
250
+ .authkit-orgswitcher__chevron { font-size: 0.65rem; color: var(--authkit-muted); }
251
+ .authkit-orgswitcher__menu {
252
+ position: absolute;
253
+ top: calc(100% + 4px);
254
+ left: 0;
255
+ min-width: 180px;
256
+ background: var(--authkit-bg);
257
+ border: 1px solid var(--authkit-border);
258
+ border-radius: var(--authkit-radius);
259
+ box-shadow: 0 4px 16px rgba(0,0,0,.1);
260
+ z-index: 50;
261
+ overflow: hidden;
262
+ }
263
+ .authkit-orgswitcher__item {
264
+ display: flex;
265
+ align-items: center;
266
+ justify-content: space-between;
267
+ width: 100%;
268
+ padding: 0.5rem 1rem;
269
+ background: transparent;
270
+ border: none;
271
+ cursor: pointer;
272
+ font-size: 0.875rem;
273
+ color: var(--authkit-fg);
274
+ text-align: left;
275
+ }
276
+ .authkit-orgswitcher__item:hover { background: color-mix(in srgb, var(--authkit-primary) 8%, transparent); }
277
+ .authkit-orgswitcher__item--active { font-weight: 600; }
278
+ .authkit-orgswitcher__item-name { flex: 1; }
279
+ .authkit-orgswitcher__item-role { font-size: 0.75rem; color: var(--authkit-muted); margin-left: 0.5rem; }
280
+
281
+ /* ─── OrganizationProfile ──────────────────────────────────────────────── */
282
+ .authkit-org-profile { display: flex; flex-direction: column; gap: var(--authkit-gap); }
283
+ .authkit-org-profile__header { margin-bottom: 0.5rem; }
284
+ .authkit-org-profile__name { font-weight: 600; font-size: 1rem; color: var(--authkit-fg); }
285
+ .authkit-org-profile__slug { font-size: 0.8rem; color: var(--authkit-muted); }
286
+ .authkit-org-profile__section-title { font-size: 0.85rem; font-weight: 600; color: var(--authkit-fg); margin-bottom: 0.4rem; }
287
+ .authkit-org-profile__members { display: flex; flex-direction: column; gap: 0.25rem; }
288
+ .authkit-org-profile__member { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--authkit-border); }
289
+ .authkit-org-profile__member:last-child { border-bottom: none; }
290
+ .authkit-org-profile__member-info { display: flex; flex-direction: column; }
291
+ .authkit-org-profile__member-email { font-size: 0.875rem; color: var(--authkit-fg); }
292
+ .authkit-org-profile__member-role { font-size: 0.75rem; color: var(--authkit-muted); }
293
+ .authkit-org-profile__invite-form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
294
+ .authkit-org-profile__empty { font-size: 0.875rem; color: var(--authkit-muted); }
295
+
296
+ /* ─── KeyRotation ──────────────────────────────────────────────────────────── */
297
+ .authkit-keys { display: flex; flex-direction: column; gap: var(--authkit-gap); }
298
+ .authkit-keys__title { font-size: 1rem; font-weight: 600; color: var(--authkit-fg); margin: 0 0 0.5rem; }
299
+ .authkit-keys__stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.75rem; margin: 0 0 0.5rem; font-size: 0.875rem; }
300
+ .authkit-keys__stats dt { color: var(--authkit-muted); }
301
+ .authkit-keys__stats dd { margin: 0; color: var(--authkit-fg); }
302
+ .authkit-keys__retire { display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--authkit-fg); cursor: pointer; }
303
+ .authkit-keys__loading { color: var(--authkit-muted); font-size: 0.9rem; }