@krak-stack/auth 0.2.24 → 0.2.26
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 +24 -0
- package/README.md +44 -15
- package/dist/api.d.ts +731 -695
- package/dist/auth/api.group.d.ts +16 -0
- package/dist/auth/schema.d.ts +11 -0
- package/dist/auth/schema.js +3 -1
- package/dist/components/auth-atoms.d.ts +66 -2
- package/dist/components/auth-atoms.js +12 -3
- package/dist/components/auth-client-api.d.ts +16 -0
- package/dist/components/auth-provider.d.ts +2 -1
- package/dist/components/auth-provider.js +29 -3
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +5 -0
- package/dist/server/actor.js +12 -1
- package/dist/server/api.group.d.ts +4 -0
- package/dist/server/attribution.d.ts +1 -1
- package/dist/server/attribution.js +4 -2
- package/dist/server/middleware.js +12 -5
- package/dist/server/schema.d.ts +2 -0
- package/dist/service.d.ts +40 -0
- package/package.json +3 -3
package/dist/auth/api.group.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
12
12
|
readonly name: Schema.String;
|
|
13
13
|
readonly email: Schema.String;
|
|
14
14
|
readonly emailVerified: Schema.Boolean;
|
|
15
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
15
16
|
readonly image: Schema.NullOr<Schema.String>;
|
|
16
17
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
17
18
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -75,6 +76,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
75
76
|
readonly name: Schema.String;
|
|
76
77
|
readonly email: Schema.String;
|
|
77
78
|
readonly emailVerified: Schema.Boolean;
|
|
79
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
78
80
|
readonly image: Schema.NullOr<Schema.String>;
|
|
79
81
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
80
82
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -136,6 +138,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
136
138
|
readonly name: Schema.String;
|
|
137
139
|
readonly email: Schema.String;
|
|
138
140
|
readonly emailVerified: Schema.Boolean;
|
|
141
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
139
142
|
readonly image: Schema.NullOr<Schema.String>;
|
|
140
143
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
141
144
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -186,6 +189,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
186
189
|
readonly name: Schema.String;
|
|
187
190
|
readonly email: Schema.String;
|
|
188
191
|
readonly emailVerified: Schema.Boolean;
|
|
192
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
189
193
|
readonly image: Schema.NullOr<Schema.String>;
|
|
190
194
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
191
195
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -280,6 +284,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
280
284
|
readonly name: Schema.String;
|
|
281
285
|
readonly email: Schema.String;
|
|
282
286
|
readonly emailVerified: Schema.Boolean;
|
|
287
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
283
288
|
readonly image: Schema.NullOr<Schema.String>;
|
|
284
289
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
285
290
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -344,6 +349,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
344
349
|
readonly name: Schema.String;
|
|
345
350
|
readonly email: Schema.String;
|
|
346
351
|
readonly emailVerified: Schema.Boolean;
|
|
352
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
347
353
|
readonly image: Schema.NullOr<Schema.String>;
|
|
348
354
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
349
355
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -410,6 +416,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
410
416
|
readonly name: Schema.String;
|
|
411
417
|
readonly email: Schema.String;
|
|
412
418
|
readonly emailVerified: Schema.Boolean;
|
|
419
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
413
420
|
readonly image: Schema.NullOr<Schema.String>;
|
|
414
421
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
415
422
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -639,6 +646,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
639
646
|
readonly name: Schema.String;
|
|
640
647
|
readonly email: Schema.String;
|
|
641
648
|
readonly emailVerified: Schema.Boolean;
|
|
649
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
642
650
|
readonly image: Schema.NullOr<Schema.String>;
|
|
643
651
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
644
652
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -900,6 +908,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
900
908
|
readonly name: Schema.String;
|
|
901
909
|
readonly email: Schema.String;
|
|
902
910
|
readonly emailVerified: Schema.Boolean;
|
|
911
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
903
912
|
readonly image: Schema.NullOr<Schema.String>;
|
|
904
913
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
905
914
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -958,6 +967,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
958
967
|
readonly name: Schema.String;
|
|
959
968
|
readonly email: Schema.String;
|
|
960
969
|
readonly emailVerified: Schema.Boolean;
|
|
970
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
961
971
|
readonly image: Schema.NullOr<Schema.String>;
|
|
962
972
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
963
973
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1034,6 +1044,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1034
1044
|
readonly name: Schema.String;
|
|
1035
1045
|
readonly email: Schema.String;
|
|
1036
1046
|
readonly emailVerified: Schema.Boolean;
|
|
1047
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1037
1048
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1038
1049
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1039
1050
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1105,6 +1116,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1105
1116
|
readonly name: Schema.String;
|
|
1106
1117
|
readonly email: Schema.String;
|
|
1107
1118
|
readonly emailVerified: Schema.Boolean;
|
|
1119
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1108
1120
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1109
1121
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1110
1122
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1158,6 +1170,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1158
1170
|
readonly name: Schema.String;
|
|
1159
1171
|
readonly email: Schema.String;
|
|
1160
1172
|
readonly emailVerified: Schema.Boolean;
|
|
1173
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1161
1174
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1162
1175
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1163
1176
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1211,6 +1224,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1211
1224
|
readonly name: Schema.String;
|
|
1212
1225
|
readonly email: Schema.String;
|
|
1213
1226
|
readonly emailVerified: Schema.Boolean;
|
|
1227
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1214
1228
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1215
1229
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1216
1230
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1259,6 +1273,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1259
1273
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
1260
1274
|
readonly status: Schema.Boolean;
|
|
1261
1275
|
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthConflict | typeof AuthExpectationFailed | typeof AuthTooManyRequests | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateUser", "POST", "/update-user", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
1276
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1262
1277
|
readonly name: Schema.optional<Schema.String>;
|
|
1263
1278
|
readonly image: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
1264
1279
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
@@ -1306,6 +1321,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
1306
1321
|
readonly name: Schema.String;
|
|
1307
1322
|
readonly email: Schema.String;
|
|
1308
1323
|
readonly emailVerified: Schema.Boolean;
|
|
1324
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1309
1325
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1310
1326
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1311
1327
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
package/dist/auth/schema.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const AuthUser: Schema.Struct<{
|
|
|
5
5
|
readonly name: Schema.String;
|
|
6
6
|
readonly email: Schema.String;
|
|
7
7
|
readonly emailVerified: Schema.Boolean;
|
|
8
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
8
9
|
readonly image: Schema.NullOr<Schema.String>;
|
|
9
10
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
10
11
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -79,6 +80,7 @@ export declare const AuthSessionResponse: Schema.Struct<{
|
|
|
79
80
|
readonly name: Schema.String;
|
|
80
81
|
readonly email: Schema.String;
|
|
81
82
|
readonly emailVerified: Schema.Boolean;
|
|
83
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
82
84
|
readonly image: Schema.NullOr<Schema.String>;
|
|
83
85
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
84
86
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -141,6 +143,7 @@ export declare const GetSessionResponse: Schema.NullOr<Schema.Struct<{
|
|
|
141
143
|
readonly name: Schema.String;
|
|
142
144
|
readonly email: Schema.String;
|
|
143
145
|
readonly emailVerified: Schema.Boolean;
|
|
146
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
144
147
|
readonly image: Schema.NullOr<Schema.String>;
|
|
145
148
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
146
149
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -274,6 +277,7 @@ declare const AuthInternalServerError_base: Schema.Class<AuthInternalServerError
|
|
|
274
277
|
export declare class AuthInternalServerError extends AuthInternalServerError_base {
|
|
275
278
|
}
|
|
276
279
|
export declare const UpdateUserPayload: Schema.Struct<{
|
|
280
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
277
281
|
readonly name: Schema.optional<Schema.String>;
|
|
278
282
|
readonly image: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
279
283
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
@@ -325,6 +329,7 @@ export declare const SignInEmailResponse: Schema.Union<readonly [Schema.Struct<{
|
|
|
325
329
|
readonly name: Schema.String;
|
|
326
330
|
readonly email: Schema.String;
|
|
327
331
|
readonly emailVerified: Schema.Boolean;
|
|
332
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
328
333
|
readonly image: Schema.NullOr<Schema.String>;
|
|
329
334
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
330
335
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -385,6 +390,7 @@ export declare const SignInResponse: Schema.Struct<{
|
|
|
385
390
|
readonly name: Schema.String;
|
|
386
391
|
readonly email: Schema.String;
|
|
387
392
|
readonly emailVerified: Schema.Boolean;
|
|
393
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
388
394
|
readonly image: Schema.NullOr<Schema.String>;
|
|
389
395
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
390
396
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -477,6 +483,7 @@ export declare const SocialRedirectResponse: Schema.Struct<{
|
|
|
477
483
|
readonly name: Schema.String;
|
|
478
484
|
readonly email: Schema.String;
|
|
479
485
|
readonly emailVerified: Schema.Boolean;
|
|
486
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
480
487
|
readonly image: Schema.NullOr<Schema.String>;
|
|
481
488
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
482
489
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -537,6 +544,7 @@ export declare const VerifyEmailOtpResponse: Schema.Struct<{
|
|
|
537
544
|
readonly name: Schema.String;
|
|
538
545
|
readonly email: Schema.String;
|
|
539
546
|
readonly emailVerified: Schema.Boolean;
|
|
547
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
540
548
|
readonly image: Schema.NullOr<Schema.String>;
|
|
541
549
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
542
550
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -604,6 +612,7 @@ export declare const ChangePasswordResponse: Schema.Struct<{
|
|
|
604
612
|
readonly name: Schema.String;
|
|
605
613
|
readonly email: Schema.String;
|
|
606
614
|
readonly emailVerified: Schema.Boolean;
|
|
615
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
607
616
|
readonly image: Schema.NullOr<Schema.String>;
|
|
608
617
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
609
618
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1064,6 +1073,7 @@ export declare const OrganizationImpersonateUserResponse: Schema.Struct<{
|
|
|
1064
1073
|
readonly name: Schema.String;
|
|
1065
1074
|
readonly email: Schema.String;
|
|
1066
1075
|
readonly emailVerified: Schema.Boolean;
|
|
1076
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1067
1077
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1068
1078
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1069
1079
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -1189,6 +1199,7 @@ export declare const AdminUserResponse: Schema.Struct<{
|
|
|
1189
1199
|
readonly name: Schema.String;
|
|
1190
1200
|
readonly email: Schema.String;
|
|
1191
1201
|
readonly emailVerified: Schema.Boolean;
|
|
1202
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
1192
1203
|
readonly image: Schema.NullOr<Schema.String>;
|
|
1193
1204
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
1194
1205
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
package/dist/auth/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
2
|
-
import { User, UserMetadata } from "../schema.js";
|
|
2
|
+
import { User, UserLocale, UserMetadata } from "../schema.js";
|
|
3
3
|
const JsonRecord = Schema.Record(Schema.String, Schema.Json);
|
|
4
4
|
const StringArrayRecord = Schema.Record(Schema.String, Schema.Array(Schema.String));
|
|
5
5
|
export const AuthRedirectURLFromString = (origin = "http://localhost") => Schema.String.pipe(Schema.decodeTo(Schema.URL.check(Schema.makeFilter((url) => (url.protocol === "http:" || url.protocol === "https:") &&
|
|
@@ -18,6 +18,7 @@ export const AuthUser = Schema.Struct({
|
|
|
18
18
|
name: Schema.String,
|
|
19
19
|
email: Schema.String,
|
|
20
20
|
emailVerified: Schema.Boolean,
|
|
21
|
+
locale: User.fields.locale,
|
|
21
22
|
image: Schema.NullOr(Schema.String),
|
|
22
23
|
metadata: User.fields.metadata,
|
|
23
24
|
role: Schema.NullOr(Schema.String),
|
|
@@ -141,6 +142,7 @@ export class AuthInternalServerError extends Schema.TaggedError()("AuthInternalS
|
|
|
141
142
|
}) {
|
|
142
143
|
}
|
|
143
144
|
export const UpdateUserPayload = Schema.Struct({
|
|
145
|
+
locale: Schema.optional(UserLocale),
|
|
144
146
|
name: Schema.optional(Schema.String),
|
|
145
147
|
image: Schema.optional(Schema.NullOr(Schema.String)),
|
|
146
148
|
metadata: Schema.optional(Schema.NullOr(UserMetadata)),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
2
2
|
export declare const AUTH_CLIENT_CHANGE_EVENT = "krakstack-auth:change";
|
|
3
3
|
export declare const refreshOnAuthChange: <A>(atom: Atom.Atom<A>) => Atom.Atom<A>;
|
|
4
|
-
export declare const authSessionAtom: (arg: string | undefined) => Atom.
|
|
4
|
+
export declare const authSessionAtom: (arg: string | undefined) => Atom.Writable<AsyncResult.AsyncResult<{
|
|
5
5
|
readonly session: {
|
|
6
6
|
readonly id: string;
|
|
7
7
|
readonly expiresAt: Date;
|
|
@@ -20,6 +20,7 @@ export declare const authSessionAtom: (arg: string | undefined) => Atom.Atom<Asy
|
|
|
20
20
|
readonly name: string;
|
|
21
21
|
readonly email: string;
|
|
22
22
|
readonly emailVerified: boolean;
|
|
23
|
+
readonly locale?: "en" | "fr" | undefined;
|
|
23
24
|
readonly image: string | null;
|
|
24
25
|
readonly metadata?: {
|
|
25
26
|
readonly emails?: readonly {
|
|
@@ -62,7 +63,70 @@ export declare const authSessionAtom: (arg: string | undefined) => Atom.Atom<Asy
|
|
|
62
63
|
readonly createdAt: Date;
|
|
63
64
|
readonly updatedAt: Date;
|
|
64
65
|
};
|
|
65
|
-
} | null, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized
|
|
66
|
+
} | null, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized>, Atom.Atom<AsyncResult.AsyncResult<AsyncResult.AsyncResult<{
|
|
67
|
+
readonly session: {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly expiresAt: Date;
|
|
70
|
+
readonly token: string;
|
|
71
|
+
readonly createdAt: Date;
|
|
72
|
+
readonly updatedAt: Date;
|
|
73
|
+
readonly ipAddress?: string | null | undefined;
|
|
74
|
+
readonly userAgent?: string | null | undefined;
|
|
75
|
+
readonly userId: string;
|
|
76
|
+
readonly impersonatedBy?: string | null | undefined;
|
|
77
|
+
readonly impersonatedByOrganizationId?: string | null | undefined;
|
|
78
|
+
readonly activeOrganizationId?: string | null | undefined;
|
|
79
|
+
};
|
|
80
|
+
readonly user: {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly email: string;
|
|
84
|
+
readonly emailVerified: boolean;
|
|
85
|
+
readonly locale?: "en" | "fr" | undefined;
|
|
86
|
+
readonly image: string | null;
|
|
87
|
+
readonly metadata?: {
|
|
88
|
+
readonly emails?: readonly {
|
|
89
|
+
readonly email: string;
|
|
90
|
+
readonly translations: readonly {
|
|
91
|
+
readonly locale: "en" | "fr";
|
|
92
|
+
readonly label: string;
|
|
93
|
+
}[];
|
|
94
|
+
}[] | undefined;
|
|
95
|
+
readonly phones?: readonly {
|
|
96
|
+
readonly number: string;
|
|
97
|
+
readonly extension?: string | undefined;
|
|
98
|
+
readonly translations: readonly {
|
|
99
|
+
readonly locale: "en" | "fr";
|
|
100
|
+
readonly label: string;
|
|
101
|
+
}[];
|
|
102
|
+
}[] | undefined;
|
|
103
|
+
readonly websites?: readonly {
|
|
104
|
+
readonly url: string;
|
|
105
|
+
readonly translations: readonly {
|
|
106
|
+
readonly locale: "en" | "fr";
|
|
107
|
+
readonly label: string;
|
|
108
|
+
}[];
|
|
109
|
+
}[] | undefined;
|
|
110
|
+
readonly socials?: readonly {
|
|
111
|
+
readonly platform: "facebook" | "github" | "instagram" | "linkedin" | "tiktok" | "x" | "youtube";
|
|
112
|
+
readonly url: string;
|
|
113
|
+
readonly translations: readonly {
|
|
114
|
+
readonly locale: "en" | "fr";
|
|
115
|
+
readonly label: string;
|
|
116
|
+
}[];
|
|
117
|
+
}[] | undefined;
|
|
118
|
+
} | null | undefined;
|
|
119
|
+
readonly role: string | null;
|
|
120
|
+
readonly banned: boolean | null;
|
|
121
|
+
readonly banReason?: string | null | undefined;
|
|
122
|
+
readonly banExpires?: Date | null | undefined;
|
|
123
|
+
readonly twoFactorEnabled?: boolean | undefined;
|
|
124
|
+
readonly lastLoginMethod?: string | null | undefined;
|
|
125
|
+
readonly createdAt: Date;
|
|
126
|
+
readonly updatedAt: Date;
|
|
127
|
+
};
|
|
128
|
+
} | null, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized>, unknown>>>;
|
|
129
|
+
export declare const updateUserLocaleAtom: (arg: string | undefined) => Atom.AtomResultFn<"en" | "fr", void, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError>;
|
|
66
130
|
export declare const authOrganizationsAtom: (arg: string | undefined) => Atom.Atom<AsyncResult.AsyncResult<readonly {
|
|
67
131
|
readonly id: string;
|
|
68
132
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Option } from "effect";
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
2
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
3
|
-
import { authClientApi } from "./auth-client-api.js";
|
|
3
|
+
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
4
4
|
const LAST_LOGIN_METHOD_COOKIE = "krakstack-auth.last_used_login_method";
|
|
5
5
|
export const AUTH_CLIENT_CHANGE_EVENT = "krakstack-auth:change";
|
|
6
6
|
const authRevalidationSignal = Atom.make((get) => {
|
|
@@ -29,7 +29,16 @@ export const authSessionAtom = Atom.family((baseUrl) => Atom.optimistic(authClie
|
|
|
29
29
|
return unauthorized && !result.waiting
|
|
30
30
|
? AsyncResult.success(null)
|
|
31
31
|
: result;
|
|
32
|
-
}))
|
|
32
|
+
}))
|
|
33
|
+
.pipe(refreshOnAuthChange)));
|
|
34
|
+
export const updateUserLocaleAtom = Atom.family((baseUrl) => Atom.optimisticFn(authSessionAtom(baseUrl), {
|
|
35
|
+
reducer: (state, locale) => AsyncResult.map(state, (session) => session ? { ...session, user: { ...session.user, locale } } : session),
|
|
36
|
+
fn: authClientApi(baseUrl).runtime.fn((locale) => Effect.gen(function* () {
|
|
37
|
+
const client = yield* authHttpClient(baseUrl);
|
|
38
|
+
yield* client.auth.updateUser({ payload: { locale } });
|
|
39
|
+
notifyAuthChange();
|
|
40
|
+
})),
|
|
41
|
+
}));
|
|
33
42
|
export const authOrganizationsAtom = Atom.family((baseUrl) => Atom.optimistic(authClientApi(baseUrl).query("auth", "organizationList", {
|
|
34
43
|
timeToLive: "1 minute",
|
|
35
44
|
reactivityKeys: ["auth-organizations"],
|
|
@@ -432,6 +432,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
432
432
|
readonly name: import("effect/Schema").String;
|
|
433
433
|
readonly email: import("effect/Schema").String;
|
|
434
434
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
435
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
435
436
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
436
437
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
437
438
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -496,6 +497,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
496
497
|
readonly name: import("effect/Schema").String;
|
|
497
498
|
readonly email: import("effect/Schema").String;
|
|
498
499
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
500
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
499
501
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
500
502
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
501
503
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -558,6 +560,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
558
560
|
readonly name: import("effect/Schema").String;
|
|
559
561
|
readonly email: import("effect/Schema").String;
|
|
560
562
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
563
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
561
564
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
562
565
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
563
566
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -609,6 +612,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
609
612
|
readonly name: import("effect/Schema").String;
|
|
610
613
|
readonly email: import("effect/Schema").String;
|
|
611
614
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
615
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
612
616
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
613
617
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
614
618
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -706,6 +710,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
706
710
|
readonly name: import("effect/Schema").String;
|
|
707
711
|
readonly email: import("effect/Schema").String;
|
|
708
712
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
713
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
709
714
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
710
715
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
711
716
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -771,6 +776,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
771
776
|
readonly name: import("effect/Schema").String;
|
|
772
777
|
readonly email: import("effect/Schema").String;
|
|
773
778
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
779
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
774
780
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
775
781
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
776
782
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -838,6 +844,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
838
844
|
readonly name: import("effect/Schema").String;
|
|
839
845
|
readonly email: import("effect/Schema").String;
|
|
840
846
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
847
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
841
848
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
842
849
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
843
850
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1076,6 +1083,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1076
1083
|
readonly name: import("effect/Schema").String;
|
|
1077
1084
|
readonly email: import("effect/Schema").String;
|
|
1078
1085
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1086
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1079
1087
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1080
1088
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1081
1089
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1352,6 +1360,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1352
1360
|
readonly name: import("effect/Schema").String;
|
|
1353
1361
|
readonly email: import("effect/Schema").String;
|
|
1354
1362
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1363
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1355
1364
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1356
1365
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1357
1366
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1411,6 +1420,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1411
1420
|
readonly name: import("effect/Schema").String;
|
|
1412
1421
|
readonly email: import("effect/Schema").String;
|
|
1413
1422
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1423
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1414
1424
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1415
1425
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1416
1426
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1488,6 +1498,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1488
1498
|
readonly name: import("effect/Schema").String;
|
|
1489
1499
|
readonly email: import("effect/Schema").String;
|
|
1490
1500
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1501
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1491
1502
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1492
1503
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1493
1504
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1564,6 +1575,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1564
1575
|
readonly name: import("effect/Schema").String;
|
|
1565
1576
|
readonly email: import("effect/Schema").String;
|
|
1566
1577
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1578
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1567
1579
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1568
1580
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1569
1581
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1618,6 +1630,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1618
1630
|
readonly name: import("effect/Schema").String;
|
|
1619
1631
|
readonly email: import("effect/Schema").String;
|
|
1620
1632
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1633
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1621
1634
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1622
1635
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1623
1636
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1672,6 +1685,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1672
1685
|
readonly name: import("effect/Schema").String;
|
|
1673
1686
|
readonly email: import("effect/Schema").String;
|
|
1674
1687
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1688
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1675
1689
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1676
1690
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1677
1691
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -1722,6 +1736,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1722
1736
|
readonly status: import("effect/Schema").Boolean;
|
|
1723
1737
|
}>>, 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>;
|
|
1724
1738
|
readonly updateUser: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"updateUser", "POST", "/api/auth/update-user", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
1739
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1725
1740
|
readonly name: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
1726
1741
|
readonly image: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
1727
1742
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
@@ -1770,6 +1785,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1770
1785
|
readonly name: import("effect/Schema").String;
|
|
1771
1786
|
readonly email: import("effect/Schema").String;
|
|
1772
1787
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
1788
|
+
readonly locale: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["en", "fr"]>>;
|
|
1773
1789
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
1774
1790
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
1775
1791
|
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
@@ -17,6 +17,7 @@ export type KrakstackAuthProviderProps = {
|
|
|
17
17
|
projectId?: string | null | undefined;
|
|
18
18
|
access?: ProjectAccessCatalog | undefined;
|
|
19
19
|
accessLabels?: ProjectAccessLabelCatalog | undefined;
|
|
20
|
+
onLocaleSyncError?: ((cause: typeof Schema.Unknown.Type) => void) | undefined;
|
|
20
21
|
};
|
|
21
22
|
export type KrakstackAuthContextValue = {
|
|
22
23
|
locale: KrakstackAuthLocale;
|
|
@@ -35,7 +36,7 @@ type ProjectConfigState = {
|
|
|
35
36
|
};
|
|
36
37
|
export declare const resolveProjectConfigState: (result: AsyncResult.AsyncResult<ExtraProjectPublicConfig | null, unknown>) => ProjectConfigState;
|
|
37
38
|
export declare const resolveKrakstackAuthLocale: (locale: string) => KrakstackAuthLocale;
|
|
38
|
-
export declare function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
39
|
+
export declare function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, onLocaleSyncError, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
39
40
|
export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
|
|
40
41
|
export declare const useKrakstackAuthProjectConfig: () => {
|
|
41
42
|
readonly projectKey: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAtomValue } from "@effect/atom-react";
|
|
2
|
+
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
3
3
|
import { useRouterState } from "@tanstack/react-router";
|
|
4
4
|
import { Cause, Option, Schema } from "effect";
|
|
5
5
|
import { HttpApiError } from "effect/http-api";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
7
7
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useRef, } from "react";
|
|
9
|
-
import { activeAuthOrganizationAtom, authSessionAtom } from "./auth-atoms.js";
|
|
9
|
+
import { activeAuthOrganizationAtom, authSessionAtom, updateUserLocaleAtom, } from "./auth-atoms.js";
|
|
10
10
|
import { authClientApi } from "./auth-client-api.js";
|
|
11
11
|
import { parseRoleList } from "../roles.js";
|
|
12
12
|
export class KrakstackAuthUnavailableError extends Schema.TaggedError()("KrakstackAuthUnavailableError", {
|
|
@@ -106,7 +106,7 @@ const useProjectConfigState = (baseUrl, providedProjectId) => {
|
|
|
106
106
|
const result = useAtomValue(projectConfigAtom);
|
|
107
107
|
return useMemo(() => resolveProjectConfigState(result), [result]);
|
|
108
108
|
};
|
|
109
|
-
export function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, }) {
|
|
109
|
+
export function KrakstackAuthProvider({ children, baseUrl, projectId, access, accessLabels, onLocaleSyncError, }) {
|
|
110
110
|
const locale = resolveKrakstackAuthLocale(useKrakstackLocale());
|
|
111
111
|
const searchString = useRouterState({
|
|
112
112
|
select: (state) => state.location.searchStr,
|
|
@@ -115,7 +115,33 @@ export function KrakstackAuthProvider({ children, baseUrl, projectId, access, ac
|
|
|
115
115
|
const projectConfigState = useProjectConfigState(baseUrl, projectId);
|
|
116
116
|
const sessionAtom = authSessionAtom(baseUrl);
|
|
117
117
|
const sessionResult = useAtomValue(sessionAtom);
|
|
118
|
+
const saveLocale = useAtomSet(updateUserLocaleAtom(baseUrl), {
|
|
119
|
+
mode: "promise",
|
|
120
|
+
});
|
|
121
|
+
const lastLocaleSyncKey = useRef(null);
|
|
118
122
|
const wasAuthenticated = useRef(false);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!AsyncResult.isSuccess(sessionResult) || sessionResult.waiting)
|
|
125
|
+
return;
|
|
126
|
+
const session = sessionResult.value;
|
|
127
|
+
if (!session ||
|
|
128
|
+
session.session.impersonatedBy ||
|
|
129
|
+
session.session.impersonatedByOrganizationId) {
|
|
130
|
+
lastLocaleSyncKey.current = null;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const key = `${session.user.id}:${locale}`;
|
|
134
|
+
if (lastLocaleSyncKey.current === key)
|
|
135
|
+
return;
|
|
136
|
+
// Keep the key through optimistic updates and rollback to avoid retry loops.
|
|
137
|
+
lastLocaleSyncKey.current = key;
|
|
138
|
+
if (session.user.locale === locale)
|
|
139
|
+
return;
|
|
140
|
+
void saveLocale(locale).catch((cause) => {
|
|
141
|
+
console.error("Failed to sync account language", cause);
|
|
142
|
+
onLocaleSyncError?.(cause);
|
|
143
|
+
});
|
|
144
|
+
}, [locale, sessionResult, saveLocale, onLocaleSyncError]);
|
|
119
145
|
useEffect(() => {
|
|
120
146
|
if (!AsyncResult.isSuccess(sessionResult) || sessionResult.waiting)
|
|
121
147
|
return;
|
package/dist/schema.d.ts
CHANGED
|
@@ -246,11 +246,13 @@ export declare const UserMetadataStandard: import("effect/StandardSchema").Stand
|
|
|
246
246
|
}>>;
|
|
247
247
|
}>>>;
|
|
248
248
|
}>;
|
|
249
|
+
export declare const UserLocale: Schema.Literals<readonly ["en", "fr"]>;
|
|
249
250
|
export declare const User: Schema.Struct<{
|
|
250
251
|
readonly id: Schema.String;
|
|
251
252
|
readonly name: Schema.String;
|
|
252
253
|
readonly email: Schema.String;
|
|
253
254
|
readonly emailVerified: Schema.Boolean;
|
|
255
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
254
256
|
readonly image: Schema.NullOr<Schema.String>;
|
|
255
257
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
256
258
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -450,6 +452,7 @@ export declare const Member: Schema.Struct<{
|
|
|
450
452
|
readonly name: Schema.String;
|
|
451
453
|
readonly email: Schema.String;
|
|
452
454
|
readonly emailVerified: Schema.Boolean;
|
|
455
|
+
readonly locale: Schema.optional<Schema.Literals<readonly ["en", "fr"]>>;
|
|
453
456
|
readonly image: Schema.NullOr<Schema.String>;
|
|
454
457
|
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
455
458
|
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
package/dist/schema.js
CHANGED
|
@@ -212,11 +212,16 @@ const CompatibleUserMetadata = Schema.Unknown.pipe(Schema.decodeTo(UserMetadata,
|
|
|
212
212
|
}),
|
|
213
213
|
encode: SchemaGetter.transform((metadata) => metadata),
|
|
214
214
|
}));
|
|
215
|
+
export const UserLocale = Schema.Literals(["en", "fr"]).annotate({
|
|
216
|
+
identifier: "UserLocale",
|
|
217
|
+
description: "Preferred language for the interface and communications.",
|
|
218
|
+
});
|
|
215
219
|
export const User = Schema.Struct({
|
|
216
220
|
id: Schema.String,
|
|
217
221
|
name: Schema.String,
|
|
218
222
|
email: Schema.String,
|
|
219
223
|
emailVerified: Schema.Boolean,
|
|
224
|
+
locale: Schema.optional(UserLocale),
|
|
220
225
|
image: Schema.NullOr(Schema.String),
|
|
221
226
|
metadata: Schema.optional(Schema.NullOr(CompatibleUserMetadata)),
|
|
222
227
|
role: Schema.NullOr(Schema.String),
|
package/dist/server/actor.js
CHANGED
|
@@ -110,7 +110,18 @@ const matchesConstraint = (actor, constraint) => {
|
|
|
110
110
|
const requiredActor = (access, constraint) => resolveCurrentActor(access).pipe(Effect.flatMap((actor) => matchesConstraint(actor, constraint)
|
|
111
111
|
? Effect.succeed(actor)
|
|
112
112
|
: Effect.fail(new HttpApiError.Forbidden({}))));
|
|
113
|
-
const withCurrentActor = (httpEffect, actor) =>
|
|
113
|
+
const withCurrentActor = (httpEffect, actor) => {
|
|
114
|
+
const roles = actor.actor.type === "user"
|
|
115
|
+
? actor.actor.roles
|
|
116
|
+
: actor.actor.owner.type === "user"
|
|
117
|
+
? actor.actor.owner.roles
|
|
118
|
+
: [];
|
|
119
|
+
// These are verified active-organization roles, never the global user.role.
|
|
120
|
+
return Effect.gen(function* () {
|
|
121
|
+
yield* Effect.annotateCurrentSpan({ "user.roles": roles });
|
|
122
|
+
return yield* httpEffect.pipe(Effect.provideService(CurrentActor, actor), Effect.annotateLogs({ "user.roles": roles }), Effect.annotateSpans({ "user.roles": roles }));
|
|
123
|
+
});
|
|
124
|
+
};
|
|
114
125
|
export function ActorRequired(constraint) {
|
|
115
126
|
if (!constraint)
|
|
116
127
|
return AnyActorRequired;
|