@krak-stack/auth 0.2.32 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +101 -5
- package/dist/access.d.ts +3 -1
- package/dist/admin/api.group.d.ts +41 -41
- package/dist/admin/schema.d.ts +23 -23
- package/dist/admin/schema.js +21 -19
- package/dist/api.d.ts +126 -77
- package/dist/auth/api.group.d.ts +18 -18
- package/dist/auth/schema.d.ts +49 -33
- package/dist/auth/schema.js +18 -18
- package/dist/components/admin-organization-form.js +2 -2
- package/dist/components/admin-organizations.js +6 -5
- package/dist/components/admin-users.js +6 -6
- package/dist/components/api-key-edit-form.js +19 -11
- package/dist/components/associated-projects-notice.d.ts +2 -1
- package/dist/components/associated-projects-notice.js +6 -2
- package/dist/components/auth-atoms.js +1 -2
- package/dist/components/auth-client-api.d.ts +61 -61
- package/dist/components/auth-forms.d.ts +1 -0
- package/dist/components/auth-forms.js +41 -56
- package/dist/components/auth-provider.d.ts +3 -1
- package/dist/components/hooks.d.ts +2 -0
- package/dist/components/hooks.js +13 -6
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +2 -0
- package/dist/components/member-required.js +3 -5
- package/dist/components/oauth-consent.d.ts +22 -0
- package/dist/components/oauth-consent.js +79 -0
- package/dist/components/organization-switcher.d.ts +1 -1
- package/dist/components/organization-switcher.js +83 -54
- package/dist/components/project-card-list.d.ts +6 -0
- package/dist/components/project-card-list.js +4 -0
- package/dist/components/user-button.js +115 -54
- package/dist/extra/schema.d.ts +3 -1
- package/dist/oauth/authorization.d.ts +3 -0
- package/dist/oauth/authorization.js +39 -0
- package/dist/oauth/schema.d.ts +24 -0
- package/dist/oauth/schema.js +12 -0
- package/dist/oauth/verify.d.ts +13 -0
- package/dist/oauth/verify.js +67 -0
- package/dist/schema.js +1 -1
- package/dist/server/actor.js +2 -4
- package/dist/server/api.group.d.ts +49 -0
- package/dist/server/api.group.js +10 -1
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.js +2 -1
- package/dist/server/mcp.d.ts +20 -0
- package/dist/server/mcp.js +66 -0
- package/dist/server/middleware.d.ts +5 -5
- package/dist/server/middleware.js +15 -5
- package/dist/server/schema.d.ts +51 -0
- package/dist/server/schema.js +7 -0
- package/dist/server/webhook-layer.js +8 -4
- package/dist/server/webhooks.d.ts +9 -3
- package/dist/service.d.ts +152 -46
- package/dist/service.js +56 -9
- package/package.json +2 -1
|
@@ -2,7 +2,7 @@ import { Effect } from "effect";
|
|
|
2
2
|
import { AtomHttpApi } from "effect/reactivity";
|
|
3
3
|
import { HttpApi, HttpApiClient } from "effect/http-api";
|
|
4
4
|
import { AuthClientApi } from "../api.js";
|
|
5
|
-
export declare const authHttpClient: (baseUrl?: string
|
|
5
|
+
export declare const authHttpClient: (baseUrl?: string, getLocale?: () => "en" | "fr") => Effect.Effect<{
|
|
6
6
|
readonly admin: {
|
|
7
7
|
readonly createDomain: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"createDomain", "POST", "/api/auth/admin/domains", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
8
8
|
readonly hostname: import("effect/Schema").NonEmptyString;
|
|
@@ -39,7 +39,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
39
39
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
40
40
|
readonly userId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
41
41
|
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
42
|
-
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").
|
|
42
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
43
43
|
readonly memberPreviews: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
44
44
|
readonly id: import("effect/Schema").String;
|
|
45
45
|
readonly name: import("effect/Schema").String;
|
|
@@ -56,26 +56,26 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
56
56
|
readonly dashboardStats: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"dashboardStats", "GET", "/api/auth/admin/dashboard-stats", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
57
57
|
readonly days: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"7">, import("effect/Schema").Literal<"14">, import("effect/Schema").Literal<"30">, import("effect/Schema").Literal<"90">]>>;
|
|
58
58
|
}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
59
|
-
readonly totalUsers: import("effect/Schema").
|
|
60
|
-
readonly totalOrganizations: import("effect/Schema").
|
|
61
|
-
readonly totalProjects: import("effect/Schema").
|
|
62
|
-
readonly totalDomains: import("effect/Schema").
|
|
63
|
-
readonly totalApiKeys: import("effect/Schema").
|
|
64
|
-
readonly totalOauthClients: import("effect/Schema").
|
|
65
|
-
readonly dailyActiveUsers: import("effect/Schema").
|
|
59
|
+
readonly totalUsers: import("effect/Schema").Finite;
|
|
60
|
+
readonly totalOrganizations: import("effect/Schema").Finite;
|
|
61
|
+
readonly totalProjects: import("effect/Schema").Finite;
|
|
62
|
+
readonly totalDomains: import("effect/Schema").Finite;
|
|
63
|
+
readonly totalApiKeys: import("effect/Schema").Finite;
|
|
64
|
+
readonly totalOauthClients: import("effect/Schema").Finite;
|
|
65
|
+
readonly dailyActiveUsers: import("effect/Schema").Finite;
|
|
66
66
|
readonly dailyActiveUsersByDay: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
67
67
|
readonly date: import("effect/Schema").String;
|
|
68
|
-
readonly count: import("effect/Schema").
|
|
68
|
+
readonly count: import("effect/Schema").Finite;
|
|
69
69
|
}>>;
|
|
70
70
|
readonly signupsByDay: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
71
71
|
readonly date: import("effect/Schema").String;
|
|
72
|
-
readonly count: import("effect/Schema").
|
|
72
|
+
readonly count: import("effect/Schema").Finite;
|
|
73
73
|
}>>;
|
|
74
74
|
readonly projectConnections: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
75
75
|
readonly projectId: import("effect/Schema").String;
|
|
76
76
|
readonly projectName: import("effect/Schema").String;
|
|
77
|
-
readonly users: import("effect/Schema").
|
|
78
|
-
readonly organizations: import("effect/Schema").
|
|
77
|
+
readonly users: import("effect/Schema").Finite;
|
|
78
|
+
readonly organizations: import("effect/Schema").Finite;
|
|
79
79
|
}>>;
|
|
80
80
|
}>>, import("effect/Schema").toCodecJson<typeof import("effect/http-api/HttpApiError").Unauthorized | typeof import("effect/http-api/HttpApiError").Forbidden | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>, never, never>;
|
|
81
81
|
readonly deleteApiKey: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"deleteApiKey", "DELETE", "/api/auth/admin/api-keys/:id", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
@@ -89,10 +89,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
89
89
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
90
90
|
readonly enabled: import("effect/Schema").Boolean;
|
|
91
91
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
92
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
93
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
94
|
-
readonly requestCount: import("effect/Schema").
|
|
95
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
92
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
93
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
94
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
95
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
96
96
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
97
97
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
98
98
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -128,7 +128,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
128
128
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
129
129
|
readonly userId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
130
130
|
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
131
|
-
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").
|
|
131
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
132
132
|
readonly memberPreviews: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
133
133
|
readonly id: import("effect/Schema").String;
|
|
134
134
|
readonly name: import("effect/Schema").String;
|
|
@@ -153,10 +153,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
153
153
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
154
154
|
readonly enabled: import("effect/Schema").Boolean;
|
|
155
155
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
156
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
157
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
158
|
-
readonly requestCount: import("effect/Schema").
|
|
159
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
156
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
157
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
158
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
159
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
160
160
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
161
161
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
162
162
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -175,10 +175,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
175
175
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
176
176
|
readonly enabled: import("effect/Schema").Boolean;
|
|
177
177
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
178
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
179
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
180
|
-
readonly requestCount: import("effect/Schema").
|
|
181
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
178
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
179
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
180
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
181
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
182
182
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
183
183
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
184
184
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -204,10 +204,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
204
204
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
205
205
|
readonly enabled: import("effect/Schema").Boolean;
|
|
206
206
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
207
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
208
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
209
|
-
readonly requestCount: import("effect/Schema").
|
|
210
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
207
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
208
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
209
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
210
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
211
211
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
212
212
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
213
213
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -299,7 +299,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
299
299
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
300
300
|
readonly userId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
301
301
|
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
302
|
-
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").
|
|
302
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
303
303
|
readonly memberPreviews: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
304
304
|
readonly id: import("effect/Schema").String;
|
|
305
305
|
readonly name: import("effect/Schema").String;
|
|
@@ -421,10 +421,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
421
421
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
422
422
|
readonly enabled: import("effect/Schema").Boolean;
|
|
423
423
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
424
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
425
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
426
|
-
readonly requestCount: import("effect/Schema").
|
|
427
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
424
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
425
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
426
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
427
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
428
428
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
429
429
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
430
430
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -438,8 +438,8 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
438
438
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
439
439
|
readonly enabled: import("effect/Schema").optional<import("effect/Schema").Boolean>;
|
|
440
440
|
readonly rateLimitEnabled: import("effect/Schema").optional<import("effect/Schema").Boolean>;
|
|
441
|
-
readonly rateLimitMax: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").
|
|
442
|
-
readonly rateLimitTimeWindow: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").
|
|
441
|
+
readonly rateLimitMax: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Finite>>;
|
|
442
|
+
readonly rateLimitTimeWindow: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Finite>>;
|
|
443
443
|
readonly referrers: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").String>>;
|
|
444
444
|
}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
445
445
|
readonly id: import("effect/Schema").String;
|
|
@@ -450,10 +450,10 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
450
450
|
readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
451
451
|
readonly enabled: import("effect/Schema").Boolean;
|
|
452
452
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
453
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
454
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
455
|
-
readonly requestCount: import("effect/Schema").
|
|
456
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
453
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
454
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
455
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
456
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
457
457
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
458
458
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
459
459
|
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
@@ -500,7 +500,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
500
500
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
501
501
|
readonly userId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
502
502
|
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
503
|
-
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").
|
|
503
|
+
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
504
504
|
readonly memberPreviews: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
505
505
|
readonly id: import("effect/Schema").String;
|
|
506
506
|
readonly name: import("effect/Schema").String;
|
|
@@ -519,7 +519,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
519
519
|
readonly adminBanUser: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"adminBanUser", "POST", "/api/auth/admin/ban-user", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
520
520
|
readonly userId: import("effect/Schema").String;
|
|
521
521
|
readonly banReason: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
522
|
-
readonly banExpiresIn: import("effect/Schema").optional<import("effect/Schema").
|
|
522
|
+
readonly banExpiresIn: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
523
523
|
}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
524
524
|
readonly user: import("effect/Schema").Struct<{
|
|
525
525
|
readonly id: import("effect/Schema").String;
|
|
@@ -759,8 +759,8 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
759
759
|
readonly apiKeyList: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"apiKeyList", "GET", "/api/auth/api-key/list", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
760
760
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
761
761
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
762
|
-
readonly limit: import("effect/Schema").optional<import("effect/Schema").
|
|
763
|
-
readonly offset: import("effect/Schema").optional<import("effect/Schema").
|
|
762
|
+
readonly limit: import("effect/Schema").optional<import("effect/Schema").FiniteFromString>;
|
|
763
|
+
readonly offset: import("effect/Schema").optional<import("effect/Schema").FiniteFromString>;
|
|
764
764
|
readonly sortBy: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
765
765
|
readonly sortDirection: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["asc", "desc"]>>;
|
|
766
766
|
}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
@@ -772,15 +772,15 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
772
772
|
readonly userId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
773
773
|
readonly referenceId: import("effect/Schema").String;
|
|
774
774
|
readonly configId: import("effect/Schema").String;
|
|
775
|
-
readonly refillInterval: import("effect/Schema").NullOr<import("effect/Schema").
|
|
776
|
-
readonly refillAmount: import("effect/Schema").NullOr<import("effect/Schema").
|
|
775
|
+
readonly refillInterval: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
776
|
+
readonly refillAmount: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
777
777
|
readonly lastRefillAt: import("effect/Schema").NullOr<import("effect/Schema").DateFromString>;
|
|
778
778
|
readonly enabled: import("effect/Schema").Boolean;
|
|
779
779
|
readonly rateLimitEnabled: import("effect/Schema").Boolean;
|
|
780
|
-
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").
|
|
781
|
-
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").
|
|
782
|
-
readonly requestCount: import("effect/Schema").
|
|
783
|
-
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").
|
|
780
|
+
readonly rateLimitTimeWindow: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
781
|
+
readonly rateLimitMax: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
782
|
+
readonly requestCount: import("effect/Schema").Finite;
|
|
783
|
+
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Finite>;
|
|
784
784
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").DateFromString>;
|
|
785
785
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").DateFromString>;
|
|
786
786
|
readonly createdAt: import("effect/Schema").DateFromString;
|
|
@@ -789,9 +789,9 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
789
789
|
readonly permissions: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>>;
|
|
790
790
|
readonly referrers: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
791
791
|
}>>;
|
|
792
|
-
readonly total: import("effect/Schema").
|
|
793
|
-
readonly limit: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").
|
|
794
|
-
readonly offset: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").
|
|
792
|
+
readonly total: import("effect/Schema").Finite;
|
|
793
|
+
readonly limit: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Finite>>;
|
|
794
|
+
readonly offset: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Finite>>;
|
|
795
795
|
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
796
796
|
readonly changePassword: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"changePassword", "POST", "/api/auth/change-password", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
797
797
|
readonly newPassword: import("effect/Schema").String;
|
|
@@ -1089,7 +1089,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1089
1089
|
readonly organizationGetFull: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"organizationGetFull", "GET", "/api/auth/organization/get-full-organization", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
1090
1090
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1091
1091
|
readonly organizationSlug: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1092
|
-
readonly membersLimit: import("effect/Schema").optional<import("effect/Schema").
|
|
1092
|
+
readonly membersLimit: import("effect/Schema").optional<import("effect/Schema").FiniteFromString>;
|
|
1093
1093
|
}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
1094
1094
|
readonly id: import("effect/Schema").String;
|
|
1095
1095
|
readonly name: import("effect/Schema").String;
|
|
@@ -1177,7 +1177,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1177
1177
|
readonly organizationId: import("effect/Schema").NonEmptyString;
|
|
1178
1178
|
readonly actorUserId: import("effect/Schema").NonEmptyString;
|
|
1179
1179
|
readonly targetUserId: import("effect/Schema").NonEmptyString;
|
|
1180
|
-
readonly expiresInSeconds: import("effect/Schema").optional<import("effect/Schema").
|
|
1180
|
+
readonly expiresInSeconds: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
1181
1181
|
}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
1182
1182
|
readonly session: import("effect/Schema").Struct<{
|
|
1183
1183
|
readonly id: import("effect/Schema").String;
|
|
@@ -1293,8 +1293,8 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1293
1293
|
readonly createdAt: import("effect/Schema").optional<import("effect/Schema").DateFromString>;
|
|
1294
1294
|
}>>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
1295
1295
|
readonly organizationListMembers: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"organizationListMembers", "GET", "/api/auth/organization/list-members", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
1296
|
-
readonly limit: import("effect/Schema").optional<import("effect/Schema").
|
|
1297
|
-
readonly offset: import("effect/Schema").optional<import("effect/Schema").
|
|
1296
|
+
readonly limit: import("effect/Schema").optional<import("effect/Schema").FiniteFromString>;
|
|
1297
|
+
readonly offset: import("effect/Schema").optional<import("effect/Schema").FiniteFromString>;
|
|
1298
1298
|
readonly sortBy: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1299
1299
|
readonly sortDirection: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["asc", "desc"]>>;
|
|
1300
1300
|
readonly filterField: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -1348,7 +1348,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1348
1348
|
}>, import("effect/Schema").Unknown, never, never>>>;
|
|
1349
1349
|
}>;
|
|
1350
1350
|
}>>;
|
|
1351
|
-
readonly total: import("effect/Schema").
|
|
1351
|
+
readonly total: import("effect/Schema").Finite;
|
|
1352
1352
|
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
1353
1353
|
readonly organizationListUserInvitations: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"organizationListUserInvitations", "GET", "/api/auth/organization/list-user-invitations", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
1354
1354
|
readonly id: import("effect/Schema").String;
|
|
@@ -1589,7 +1589,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1589
1589
|
readonly nonce: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1590
1590
|
readonly accessToken: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1591
1591
|
readonly refreshToken: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1592
|
-
readonly expiresAt: import("effect/Schema").optional<import("effect/Schema").
|
|
1592
|
+
readonly expiresAt: import("effect/Schema").optional<import("effect/Schema").Finite>;
|
|
1593
1593
|
readonly user: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
1594
1594
|
readonly name: import("effect/Schema").optional<import("effect/Schema").Struct<{
|
|
1595
1595
|
readonly firstName: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -2100,5 +2100,5 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
2100
2100
|
}, never, never>;
|
|
2101
2101
|
type AuthClientApiGroups = typeof AuthClientApi extends HttpApi.HttpApi<string, infer Groups> ? Groups : never;
|
|
2102
2102
|
type AuthClientApiClient = Pick<AtomHttpApi.AtomHttpApiClient<never, string, AuthClientApiGroups>, "mutation" | "query" | "runtime">;
|
|
2103
|
-
export declare const authClientApi: (baseUrl?: string
|
|
2103
|
+
export declare const authClientApi: (baseUrl?: string) => AuthClientApiClient;
|
|
2104
2104
|
export {};
|
|
@@ -5,6 +5,7 @@ type AuthFormProps = {
|
|
|
5
5
|
locale?: KrakstackAuthLocale | undefined;
|
|
6
6
|
defaultRedirectTo?: string | undefined;
|
|
7
7
|
};
|
|
8
|
+
export declare const authMethodSearch: (searchString: string, method: "password" | "emailOtp", email?: string) => import("@tanstack/router-core").AnySchema;
|
|
8
9
|
type AuthMethod = "password" | "emailOtp";
|
|
9
10
|
export declare const resolveInitialAuthMethod: ({ requestedMethod, lastLoginMethod, emailPassword, emailOtp, }: {
|
|
10
11
|
requestedMethod: string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { RegistryContext, useAtomSet, useAtomSuspense, useAtomValue, } from "@effect/atom-react";
|
|
3
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
|
-
import { Link, useNavigate, useRouter, useRouterState, } from "@tanstack/react-router";
|
|
4
|
+
import { defaultParseSearch, Link, useNavigate, useRouter, useRouterState, } from "@tanstack/react-router";
|
|
5
5
|
import { Effect, Option, Schema } from "effect";
|
|
6
6
|
import { Atom, AsyncResult } from "effect/reactivity";
|
|
7
7
|
import { HttpClientError } from "effect/http";
|
|
@@ -21,6 +21,7 @@ import { passwordResetSearch, passwordResetConfirmation, passwordResetConfirmati
|
|
|
21
21
|
import { PasswordResetActions, PasswordResetFeedback, usePasswordResetRequest, } from "./password-reset-flow.js";
|
|
22
22
|
import { useKrakstackAuth } from "./auth-provider.js";
|
|
23
23
|
import { cn } from "./utils.js";
|
|
24
|
+
import { getOAuthAuthorizationQuery } from "../oauth/authorization.js";
|
|
24
25
|
import { ExtraProjectPublicConfig as ExtraProjectPublicConfigSchema, } from "../extra/schema.js";
|
|
25
26
|
import { AuthBadRequest, AuthInternalServerError, AuthTooManyRequests, AuthUnauthorized, AuthRedirectURLFromString, } from "../auth/schema.js";
|
|
26
27
|
const signinFormBuilder = FormBuilder.empty
|
|
@@ -245,18 +246,18 @@ const useAuthProjectConfig = (baseUrl, searchString, projectConfig) => {
|
|
|
245
246
|
const result = useAtomSuspense(atom, { suspendOnWaiting: true });
|
|
246
247
|
return result.value === null
|
|
247
248
|
? null
|
|
248
|
-
: Schema.
|
|
249
|
+
: Schema.decodeSync(ExtraProjectPublicConfigSchema)(result.value);
|
|
249
250
|
};
|
|
250
251
|
const text = (value, params) => Object.entries(params ?? {}).reduce((current, [key, replacement]) => current.replace(`{${key}}`, replacement), value);
|
|
251
252
|
const authLinkClassName = cn(buttonVariants({ variant: "link", size: null }), "h-auto align-baseline");
|
|
252
|
-
const authMethodSearch = (searchString, method, email) => {
|
|
253
|
+
export const authMethodSearch = (searchString, method, email) => {
|
|
253
254
|
const search = new URLSearchParams(searchString);
|
|
254
255
|
search.set("method", method);
|
|
255
256
|
if (email?.trim())
|
|
256
257
|
search.set("email", email.trim());
|
|
257
258
|
else if (email !== undefined)
|
|
258
259
|
search.delete("email");
|
|
259
|
-
return
|
|
260
|
+
return defaultParseSearch(search.toString());
|
|
260
261
|
};
|
|
261
262
|
export const resolveInitialAuthMethod = ({ requestedMethod, lastLoginMethod, emailPassword, emailOtp, }) => {
|
|
262
263
|
if (requestedMethod === "password" && emailPassword)
|
|
@@ -303,8 +304,10 @@ export function Signin(props) {
|
|
|
303
304
|
const [emailOtpResendAvailableAt, setEmailOtpResendAvailableAt] = useState(() => initialMethodStep && initialAuthMethod === "emailOtp"
|
|
304
305
|
? Date.now() + EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000
|
|
305
306
|
: 0);
|
|
306
|
-
const [emailOtpResendSeconds, setEmailOtpResendSeconds] = useState(
|
|
307
|
-
|
|
307
|
+
const [emailOtpResendSeconds, setEmailOtpResendSeconds] = useState(initialMethodStep && initialAuthMethod === "emailOtp"
|
|
308
|
+
? EMAIL_OTP_RESEND_COOLDOWN_SECONDS
|
|
309
|
+
: 0);
|
|
310
|
+
const [otpSendsAtom] = useState(() => Atom.make(new Map(initialMethodStep && initialAuthMethod === "emailOtp"
|
|
308
311
|
? [
|
|
309
312
|
[
|
|
310
313
|
initialEmail,
|
|
@@ -312,7 +315,7 @@ export function Signin(props) {
|
|
|
312
315
|
EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000,
|
|
313
316
|
],
|
|
314
317
|
]
|
|
315
|
-
: []));
|
|
318
|
+
: [])));
|
|
316
319
|
const [errorContext, setErrorContext] = useState("signIn");
|
|
317
320
|
const selectedAuthMethod = authMethod === "password" && options.emailPassword
|
|
318
321
|
? "password"
|
|
@@ -322,17 +325,14 @@ export function Signin(props) {
|
|
|
322
325
|
const hasPrimaryAuth = options.emailPassword || options.emailOtp;
|
|
323
326
|
const canChangeAuthMethod = options.emailPassword && options.emailOtp;
|
|
324
327
|
useEffect(() => {
|
|
325
|
-
if (!emailOtpResendAvailableAt)
|
|
326
|
-
setEmailOtpResendSeconds(0);
|
|
328
|
+
if (!emailOtpResendAvailableAt)
|
|
327
329
|
return;
|
|
328
|
-
}
|
|
329
330
|
const updateResendSeconds = () => {
|
|
330
331
|
const seconds = getEmailOtpResendSeconds(emailOtpResendAvailableAt, Date.now());
|
|
331
332
|
setEmailOtpResendSeconds(seconds);
|
|
332
333
|
if (seconds === 0)
|
|
333
334
|
setEmailOtpResendAvailableAt(0);
|
|
334
335
|
};
|
|
335
|
-
updateResendSeconds();
|
|
336
336
|
const interval = window.setInterval(updateResendSeconds, 1000);
|
|
337
337
|
return () => window.clearInterval(interval);
|
|
338
338
|
}, [emailOtpResendAvailableAt]);
|
|
@@ -340,7 +340,7 @@ export function Signin(props) {
|
|
|
340
340
|
runtime: authClientApi(baseUrl).runtime,
|
|
341
341
|
fields: { email: TextField, password: PasswordField, otp: OtpField },
|
|
342
342
|
mode: { validation: "onSubmit" },
|
|
343
|
-
onSubmit: (action, { decoded: value }) => Effect.gen(function* () {
|
|
343
|
+
onSubmit: (action, { decoded: value, get }) => Effect.gen(function* () {
|
|
344
344
|
const email = value.email.trim();
|
|
345
345
|
if (action.type === "resetPassword") {
|
|
346
346
|
yield* requestPasswordResetEmail({
|
|
@@ -358,10 +358,10 @@ export function Signin(props) {
|
|
|
358
358
|
const sendEmailOtpRequest = authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.sendVerificationOtp({
|
|
359
359
|
payload: { email, type: "sign-in" },
|
|
360
360
|
})), Effect.asVoid, Effect.tap(() => Effect.sync(() => {
|
|
361
|
-
|
|
361
|
+
get.set(otpSendsAtom, new Map(get(otpSendsAtom)).set(email, Date.now()));
|
|
362
362
|
})));
|
|
363
363
|
const sendEmailOtp = (shouldSendEmailOtp({
|
|
364
|
-
sentAt:
|
|
364
|
+
sentAt: get(otpSendsAtom).get(email),
|
|
365
365
|
now: Date.now(),
|
|
366
366
|
resend: action.type === "resendEmailOtp",
|
|
367
367
|
})
|
|
@@ -370,13 +370,15 @@ export function Signin(props) {
|
|
|
370
370
|
setAuthMethod("emailOtp");
|
|
371
371
|
setEmailSubmitted(true);
|
|
372
372
|
setOtpSentTo(email);
|
|
373
|
-
navigate({
|
|
373
|
+
void navigate({
|
|
374
374
|
to: "/sign-in",
|
|
375
375
|
search: authMethodSearch(searchString, "emailOtp", email),
|
|
376
376
|
replace: true,
|
|
377
377
|
});
|
|
378
|
-
|
|
379
|
-
EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000
|
|
378
|
+
const availableAt = (get(otpSendsAtom).get(email) ?? 0) +
|
|
379
|
+
EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000;
|
|
380
|
+
setEmailOtpResendAvailableAt(availableAt);
|
|
381
|
+
setEmailOtpResendSeconds(getEmailOtpResendSeconds(availableAt, Date.now()));
|
|
380
382
|
})));
|
|
381
383
|
if (action.type === "sendEmailOtp" ||
|
|
382
384
|
action.type === "resendEmailOtp") {
|
|
@@ -388,7 +390,7 @@ export function Signin(props) {
|
|
|
388
390
|
yield* sendEmailOtp;
|
|
389
391
|
else {
|
|
390
392
|
setEmailSubmitted(true);
|
|
391
|
-
navigate({
|
|
393
|
+
void navigate({
|
|
392
394
|
to: "/sign-in",
|
|
393
395
|
search: authMethodSearch(searchString, "password", email),
|
|
394
396
|
replace: true,
|
|
@@ -409,7 +411,7 @@ export function Signin(props) {
|
|
|
409
411
|
},
|
|
410
412
|
})));
|
|
411
413
|
yield* refreshAuthSession(registry, baseUrl);
|
|
412
|
-
onNavigate(redirectTarget);
|
|
414
|
+
yield* Effect.promise(() => Promise.resolve(onNavigate(redirectTarget)));
|
|
413
415
|
return;
|
|
414
416
|
}
|
|
415
417
|
const payload = oauthQuery
|
|
@@ -426,11 +428,11 @@ export function Signin(props) {
|
|
|
426
428
|
};
|
|
427
429
|
const result = yield* authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.signInEmail({ payload })));
|
|
428
430
|
if (hasTwoFactorRedirect(result)) {
|
|
429
|
-
onTwoFactorRedirect(`/2fa${oauthQuery ? `?${oauthQuery}` : `?callbackURL=${encodeURIComponent(redirectTarget)}`}`);
|
|
431
|
+
yield* Effect.promise(() => Promise.resolve(onTwoFactorRedirect(`/2fa${oauthQuery ? `?${oauthQuery}` : `?callbackURL=${encodeURIComponent(redirectTarget)}`}`)));
|
|
430
432
|
return;
|
|
431
433
|
}
|
|
432
434
|
yield* refreshAuthSession(registry, baseUrl);
|
|
433
|
-
onNavigate(result.url ?? redirectTarget);
|
|
435
|
+
yield* Effect.promise(() => Promise.resolve(onNavigate(result.url ?? redirectTarget)));
|
|
434
436
|
}),
|
|
435
437
|
}));
|
|
436
438
|
const submit = useAtomSet(form.submit);
|
|
@@ -451,8 +453,9 @@ export function Signin(props) {
|
|
|
451
453
|
};
|
|
452
454
|
const result = yield* authHttpClient(baseUrl, locale).pipe(Effect.flatMap((client) => client.auth.signInSocial({ payload })));
|
|
453
455
|
notifyAuthChange();
|
|
454
|
-
|
|
455
|
-
|
|
456
|
+
const redirectUrl = result.url;
|
|
457
|
+
if (redirectUrl)
|
|
458
|
+
yield* Effect.promise(() => Promise.resolve(onNavigate(redirectUrl)));
|
|
456
459
|
})));
|
|
457
460
|
const startSocialSignIn = useAtomSet(socialSignIn);
|
|
458
461
|
const socialSignInResult = useAtomValue(socialSignIn);
|
|
@@ -472,7 +475,7 @@ export function Signin(props) {
|
|
|
472
475
|
setEmailSubmitted(false);
|
|
473
476
|
setOtpSentTo("");
|
|
474
477
|
setEmailOtpResendAvailableAt(0);
|
|
475
|
-
navigate({
|
|
478
|
+
void navigate({
|
|
476
479
|
to: "/sign-in",
|
|
477
480
|
search: authMethodSearch(searchString, selectedAuthMethod, ""),
|
|
478
481
|
replace: true,
|
|
@@ -485,7 +488,7 @@ export function Signin(props) {
|
|
|
485
488
|
resetForm();
|
|
486
489
|
setEmail(formValues.email);
|
|
487
490
|
setAuthMethod("password");
|
|
488
|
-
navigate({
|
|
491
|
+
void navigate({
|
|
489
492
|
to: "/sign-in",
|
|
490
493
|
search: authMethodSearch(searchString, "password", formValues.email),
|
|
491
494
|
replace: true,
|
|
@@ -596,7 +599,7 @@ export function VerifyEmail(props) {
|
|
|
596
599
|
},
|
|
597
600
|
})));
|
|
598
601
|
yield* refreshAuthSession(registry, baseUrl);
|
|
599
|
-
onNavigate(redirectTarget);
|
|
602
|
+
yield* Effect.promise(() => Promise.resolve(onNavigate(redirectTarget)));
|
|
600
603
|
}),
|
|
601
604
|
}));
|
|
602
605
|
const submit = useAtomSet(form.submit);
|
|
@@ -690,7 +693,7 @@ function ResetPasswordForm({ token, ...props }) {
|
|
|
690
693
|
token,
|
|
691
694
|
});
|
|
692
695
|
notifyAuthChange();
|
|
693
|
-
onSuccess();
|
|
696
|
+
yield* Effect.promise(() => Promise.resolve(onSuccess()));
|
|
694
697
|
}),
|
|
695
698
|
}));
|
|
696
699
|
const submit = useAtomSet(form.submit);
|
|
@@ -745,7 +748,7 @@ export function TwoFactor(props) {
|
|
|
745
748
|
payload: verification,
|
|
746
749
|
})));
|
|
747
750
|
yield* refreshAuthSession(registry, baseUrl);
|
|
748
|
-
onNavigate(getResultRedirectUrl(result) ?? redirectTarget);
|
|
751
|
+
yield* Effect.promise(() => Promise.resolve(onNavigate(getResultRedirectUrl(result) ?? redirectTarget)));
|
|
749
752
|
}),
|
|
750
753
|
}));
|
|
751
754
|
const submit = useAtomSet(form.submit);
|
|
@@ -812,14 +815,14 @@ export const getSocialRedirectTarget = (searchString, defaultRedirectTo = "/", o
|
|
|
812
815
|
// may be a different origin from the site displaying the sign-in form.
|
|
813
816
|
if (!origin)
|
|
814
817
|
return target;
|
|
815
|
-
return Schema.
|
|
818
|
+
return Schema.decodeOption(AuthRedirectURLFromString(origin))(target).pipe(Option.map((url) => url.href), Option.getOrElse(() => origin));
|
|
816
819
|
};
|
|
817
820
|
export const getSocialSignInDestinations = (router, defaultRedirectTo = "/", browserHref) => {
|
|
818
|
-
const browserURL = Schema.
|
|
821
|
+
const browserURL = Schema.decodeSync(AuthRedirectURLFromString())(browserHref);
|
|
819
822
|
const searchString = router.state.location.searchStr;
|
|
820
823
|
const defaultTarget = getRedirectTarget("", defaultRedirectTo);
|
|
821
|
-
const defaultURL = Schema.
|
|
822
|
-
const defaultHref = Option.isSome(Schema.
|
|
824
|
+
const defaultURL = Schema.decodeSync(AuthRedirectURLFromString(browserURL.origin))(defaultTarget);
|
|
825
|
+
const defaultHref = Option.isSome(Schema.decodeOption(Schema.URLFromString)(defaultTarget))
|
|
823
826
|
? defaultTarget
|
|
824
827
|
: router.buildLocation({
|
|
825
828
|
to: defaultURL.pathname,
|
|
@@ -837,19 +840,14 @@ export const getSocialSignInDestinations = (router, defaultRedirectTo = "/", bro
|
|
|
837
840
|
};
|
|
838
841
|
};
|
|
839
842
|
const getOAuthAuthorizeTarget = (searchString) => {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
const search = new URLSearchParams(searchString);
|
|
843
|
-
if (!search.has("sig"))
|
|
844
|
-
return null;
|
|
845
|
-
return `/api/auth/oauth2/authorize${searchString}`;
|
|
843
|
+
const query = getOAuthAuthorizationQuery(searchString);
|
|
844
|
+
return query ? `/api/auth/oauth2/authorize?${query}` : null;
|
|
846
845
|
};
|
|
847
846
|
const getOAuthAuthorizeTargetWithoutPromptLogin = (searchString) => {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
const search = new URLSearchParams(searchString);
|
|
851
|
-
if (!search.has("sig"))
|
|
847
|
+
const query = getOAuthAuthorizationQuery(searchString);
|
|
848
|
+
if (!query)
|
|
852
849
|
return null;
|
|
850
|
+
const search = new URLSearchParams(query);
|
|
853
851
|
const prompts = search
|
|
854
852
|
.get("prompt")
|
|
855
853
|
?.split(" ")
|
|
@@ -863,20 +861,7 @@ const getOAuthAuthorizeTargetWithoutPromptLogin = (searchString) => {
|
|
|
863
861
|
const nextSearchString = search.toString();
|
|
864
862
|
return `/api/auth/oauth2/authorize${nextSearchString ? `?${nextSearchString}` : ""}`;
|
|
865
863
|
};
|
|
866
|
-
const getOAuthQuery =
|
|
867
|
-
if (!searchString)
|
|
868
|
-
return null;
|
|
869
|
-
const search = new URLSearchParams(searchString);
|
|
870
|
-
if (!search.has("sig"))
|
|
871
|
-
return null;
|
|
872
|
-
const signedSearch = new URLSearchParams();
|
|
873
|
-
for (const [key, value] of search.entries()) {
|
|
874
|
-
signedSearch.append(key, value);
|
|
875
|
-
if (key === "sig")
|
|
876
|
-
break;
|
|
877
|
-
}
|
|
878
|
-
return signedSearch.toString();
|
|
879
|
-
};
|
|
864
|
+
const getOAuthQuery = getOAuthAuthorizationQuery;
|
|
880
865
|
const getAuthRedirectParam = (searchString) => {
|
|
881
866
|
const search = new URLSearchParams(searchString);
|
|
882
867
|
return (search.get("callbackURL") ??
|
|
@@ -7,7 +7,9 @@ export type KrakstackAuthLocale = "en" | "fr";
|
|
|
7
7
|
export type KrakstackAuthStatus = "loading" | "ready" | "degraded" | "error";
|
|
8
8
|
declare const KrakstackAuthUnavailableError_base: Schema.Class<KrakstackAuthUnavailableError, Schema.TaggedStruct<"KrakstackAuthUnavailableError", {
|
|
9
9
|
readonly cause: Schema.Defect;
|
|
10
|
-
}>, Cause.YieldableError
|
|
10
|
+
}>, Cause.YieldableError & {
|
|
11
|
+
readonly brand: unique symbol;
|
|
12
|
+
}>;
|
|
11
13
|
export declare class KrakstackAuthUnavailableError extends KrakstackAuthUnavailableError_base {
|
|
12
14
|
readonly status = 503;
|
|
13
15
|
}
|