@krak-stack/auth 0.2.1 → 0.2.3
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/dist/api.d.ts +2395 -1151
- package/dist/auth/api.group.d.ts +578 -20
- package/dist/auth/schema.d.ts +489 -30
- package/dist/auth/schema.js +14 -1
- package/dist/components/auth-atoms.d.ts +130 -20
- package/dist/components/auth-client-api.d.ts +578 -20
- package/dist/components/contact-fields.d.ts +40 -0
- package/dist/components/contact-fields.js +86 -0
- package/dist/components/organization-switcher.js +30 -125
- package/dist/components/user-button.d.ts +73 -0
- package/dist/components/user-button.js +148 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +279 -12
- package/dist/schema.js +162 -42
- package/dist/server/api.group.d.ts +128 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/proxy.d.ts +4 -0
- package/dist/server/proxy.js +33 -2
- package/dist/server/schema.d.ts +64 -0
- package/dist/service.d.ts +1412 -40
- package/package.json +1 -1
package/dist/schema.js
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
1
|
import { Option, Schema, SchemaGetter } from "effect";
|
|
2
|
-
export const User = Schema.Struct({
|
|
3
|
-
id: Schema.String,
|
|
4
|
-
name: Schema.String,
|
|
5
|
-
email: Schema.String,
|
|
6
|
-
emailVerified: Schema.Boolean,
|
|
7
|
-
image: Schema.NullOr(Schema.String),
|
|
8
|
-
role: Schema.NullOr(Schema.String),
|
|
9
|
-
banned: Schema.NullOr(Schema.Boolean),
|
|
10
|
-
lastLoginMethod: Schema.optional(Schema.NullOr(Schema.String)),
|
|
11
|
-
createdAt: Schema.Date,
|
|
12
|
-
updatedAt: Schema.Date,
|
|
13
|
-
}).annotate({
|
|
14
|
-
identifier: "User",
|
|
15
|
-
title: "User",
|
|
16
|
-
description: "Stable central auth user record.",
|
|
17
|
-
examples: [
|
|
18
|
-
{
|
|
19
|
-
id: "user_1",
|
|
20
|
-
name: "Ada Lovelace",
|
|
21
|
-
email: "ada@example.com",
|
|
22
|
-
emailVerified: true,
|
|
23
|
-
image: null,
|
|
24
|
-
role: "admin",
|
|
25
|
-
banned: false,
|
|
26
|
-
lastLoginMethod: "email-otp",
|
|
27
|
-
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
28
|
-
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
2
|
export const Session = Schema.Struct({
|
|
33
3
|
id: Schema.String,
|
|
34
4
|
expiresAt: Schema.Date,
|
|
@@ -61,10 +31,16 @@ export const Session = Schema.Struct({
|
|
|
61
31
|
},
|
|
62
32
|
],
|
|
63
33
|
});
|
|
64
|
-
export const
|
|
34
|
+
export const ContactLocale = Schema.Union([
|
|
65
35
|
Schema.Literal("en"),
|
|
66
36
|
Schema.Literal("fr"),
|
|
67
37
|
]).annotate({
|
|
38
|
+
identifier: "ContactLocale",
|
|
39
|
+
title: "Contact locale",
|
|
40
|
+
description: "Supported localized contact-label locale.",
|
|
41
|
+
examples: ["en", "fr"],
|
|
42
|
+
});
|
|
43
|
+
export const OrganizationLocale = ContactLocale.annotate({
|
|
68
44
|
identifier: "OrganizationLocale",
|
|
69
45
|
title: "Organization locale",
|
|
70
46
|
description: "Supported organization translation locale.",
|
|
@@ -74,7 +50,7 @@ export const EmailAddress = Schema.NonEmptyString.check(Schema.isPattern(/^[^\s@
|
|
|
74
50
|
identifier: "EmailAddress",
|
|
75
51
|
title: "Email address",
|
|
76
52
|
});
|
|
77
|
-
export const PhoneNumber = Schema.NonEmptyString.check(Schema.isPattern(
|
|
53
|
+
export const PhoneNumber = Schema.NonEmptyString.check(Schema.isPattern(/^(?=.*\d)\+?[0-9 ()-]{7,}$/)).annotate({
|
|
78
54
|
identifier: "PhoneNumber",
|
|
79
55
|
title: "Phone number",
|
|
80
56
|
});
|
|
@@ -94,43 +70,187 @@ export const SocialPlatform = Schema.Literals([
|
|
|
94
70
|
identifier: "SocialPlatform",
|
|
95
71
|
title: "Social platform",
|
|
96
72
|
});
|
|
97
|
-
export const
|
|
98
|
-
locale:
|
|
73
|
+
export const ContactTranslation = Schema.Struct({
|
|
74
|
+
locale: ContactLocale,
|
|
99
75
|
label: Schema.NonEmptyString.check(Schema.isPattern(/\S/)),
|
|
100
76
|
}).annotate({
|
|
77
|
+
identifier: "ContactTranslation",
|
|
78
|
+
title: "Contact translation",
|
|
79
|
+
});
|
|
80
|
+
export const OrganizationContactTranslation = ContactTranslation.annotate({
|
|
101
81
|
identifier: "OrganizationContactTranslation",
|
|
102
82
|
title: "Organization contact translation",
|
|
103
83
|
});
|
|
104
|
-
export const
|
|
84
|
+
export const ContactEmail = Schema.Struct({
|
|
105
85
|
email: EmailAddress,
|
|
106
|
-
translations: Schema.Array(
|
|
86
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
107
87
|
}).annotate({
|
|
88
|
+
identifier: "ContactEmail",
|
|
89
|
+
title: "Contact email",
|
|
90
|
+
});
|
|
91
|
+
export const OrganizationEmail = ContactEmail.annotate({
|
|
108
92
|
identifier: "OrganizationEmail",
|
|
109
93
|
title: "Organization email",
|
|
110
94
|
});
|
|
111
|
-
export const
|
|
95
|
+
export const ContactPhone = Schema.Struct({
|
|
112
96
|
number: PhoneNumber,
|
|
113
97
|
extension: Schema.optional(Schema.String),
|
|
114
|
-
translations: Schema.Array(
|
|
98
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
115
99
|
}).annotate({
|
|
100
|
+
identifier: "ContactPhone",
|
|
101
|
+
title: "Contact phone",
|
|
102
|
+
});
|
|
103
|
+
export const OrganizationPhone = ContactPhone.annotate({
|
|
116
104
|
identifier: "OrganizationPhone",
|
|
117
105
|
title: "Organization phone",
|
|
118
106
|
});
|
|
119
|
-
export const
|
|
107
|
+
export const ContactWebsite = Schema.Struct({
|
|
120
108
|
url: WebsiteUrl,
|
|
121
|
-
translations: Schema.Array(
|
|
109
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
122
110
|
}).annotate({
|
|
111
|
+
identifier: "ContactWebsite",
|
|
112
|
+
title: "Contact website",
|
|
113
|
+
});
|
|
114
|
+
export const OrganizationWebsite = ContactWebsite.annotate({
|
|
123
115
|
identifier: "OrganizationWebsite",
|
|
124
116
|
title: "Organization website",
|
|
125
117
|
});
|
|
126
|
-
export const
|
|
118
|
+
export const ContactSocial = Schema.Struct({
|
|
127
119
|
platform: SocialPlatform,
|
|
128
120
|
url: WebsiteUrl,
|
|
129
|
-
translations: Schema.Array(
|
|
121
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
130
122
|
}).annotate({
|
|
123
|
+
identifier: "ContactSocial",
|
|
124
|
+
title: "Contact social profile",
|
|
125
|
+
});
|
|
126
|
+
export const OrganizationSocial = ContactSocial.annotate({
|
|
131
127
|
identifier: "OrganizationSocial",
|
|
132
128
|
title: "Organization social profile",
|
|
133
129
|
});
|
|
130
|
+
export const USER_CONTACT_LIMIT = 8;
|
|
131
|
+
export const UserContactEmails = Schema.Array(ContactEmail)
|
|
132
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
133
|
+
.annotate({ identifier: "UserContactEmails" });
|
|
134
|
+
export const UserContactPhones = Schema.Array(ContactPhone)
|
|
135
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
136
|
+
.annotate({ identifier: "UserContactPhones" });
|
|
137
|
+
export const UserContactWebsites = Schema.Array(ContactWebsite)
|
|
138
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
139
|
+
.annotate({ identifier: "UserContactWebsites" });
|
|
140
|
+
export const UserContactSocials = Schema.Array(ContactSocial)
|
|
141
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
142
|
+
.annotate({ identifier: "UserContactSocials" });
|
|
143
|
+
const UserMetadataFields = Schema.Struct({
|
|
144
|
+
emails: Schema.optional(UserContactEmails),
|
|
145
|
+
phones: Schema.optional(UserContactPhones),
|
|
146
|
+
websites: Schema.optional(UserContactWebsites),
|
|
147
|
+
socials: Schema.optional(UserContactSocials),
|
|
148
|
+
});
|
|
149
|
+
const UserMetadataJson = Schema.fromJsonString(UserMetadataFields);
|
|
150
|
+
export const UserMetadata = UserMetadataFields.check(Schema.makeFilter((metadata) => {
|
|
151
|
+
const json = Schema.encodeSync(UserMetadataJson)(metadata);
|
|
152
|
+
return new TextEncoder().encode(json).byteLength <= 2048
|
|
153
|
+
? undefined
|
|
154
|
+
: "User contact metadata must not exceed 2 KB";
|
|
155
|
+
})).annotate({
|
|
156
|
+
identifier: "UserMetadata",
|
|
157
|
+
title: "User metadata",
|
|
158
|
+
description: "Localized contact details stored on a user record.",
|
|
159
|
+
examples: [
|
|
160
|
+
{
|
|
161
|
+
emails: [
|
|
162
|
+
{
|
|
163
|
+
email: "ada@example.com",
|
|
164
|
+
translations: [{ locale: "en", label: "Work" }],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
phones: [
|
|
168
|
+
{
|
|
169
|
+
number: "+1 514 555 0100",
|
|
170
|
+
translations: [{ locale: "en", label: "Mobile" }],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
websites: [
|
|
174
|
+
{
|
|
175
|
+
url: "https://example.com",
|
|
176
|
+
translations: [{ locale: "en", label: "Website" }],
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
socials: [
|
|
180
|
+
{
|
|
181
|
+
platform: "linkedin",
|
|
182
|
+
url: "https://linkedin.com/in/example",
|
|
183
|
+
translations: [{ locale: "en", label: "LinkedIn" }],
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
const MetadataRecord = Schema.Record(Schema.String, Schema.Unknown);
|
|
190
|
+
export const decodeUserMetadata = (metadata) => {
|
|
191
|
+
const value = metadata ?? {};
|
|
192
|
+
const emails = Schema.decodeUnknownOption(UserContactEmails)(value.emails);
|
|
193
|
+
const phones = Schema.decodeUnknownOption(UserContactPhones)(value.phones);
|
|
194
|
+
const websites = Schema.decodeUnknownOption(UserContactWebsites)(value.websites);
|
|
195
|
+
const socials = Schema.decodeUnknownOption(UserContactSocials)(value.socials);
|
|
196
|
+
let metadataValue = {};
|
|
197
|
+
if (Option.isSome(emails))
|
|
198
|
+
metadataValue = { ...metadataValue, emails: emails.value };
|
|
199
|
+
if (Option.isSome(phones))
|
|
200
|
+
metadataValue = { ...metadataValue, phones: phones.value };
|
|
201
|
+
if (Option.isSome(websites))
|
|
202
|
+
metadataValue = { ...metadataValue, websites: websites.value };
|
|
203
|
+
if (Option.isSome(socials))
|
|
204
|
+
metadataValue = { ...metadataValue, socials: socials.value };
|
|
205
|
+
return Option.getOrElse(Schema.decodeUnknownOption(UserMetadata)(metadataValue), () => ({}));
|
|
206
|
+
};
|
|
207
|
+
export const UserMetadataStandard = Schema.toStandardSchemaV1(UserMetadata);
|
|
208
|
+
const CompatibleUserMetadata = Schema.Unknown.pipe(Schema.decodeTo(UserMetadata, {
|
|
209
|
+
decode: SchemaGetter.transform((metadata) => {
|
|
210
|
+
const decoded = Schema.decodeUnknownOption(MetadataRecord)(metadata);
|
|
211
|
+
return decodeUserMetadata(Option.getOrNull(decoded));
|
|
212
|
+
}),
|
|
213
|
+
encode: SchemaGetter.transform((metadata) => metadata),
|
|
214
|
+
}));
|
|
215
|
+
export const User = Schema.Struct({
|
|
216
|
+
id: Schema.String,
|
|
217
|
+
name: Schema.String,
|
|
218
|
+
email: Schema.String,
|
|
219
|
+
emailVerified: Schema.Boolean,
|
|
220
|
+
image: Schema.NullOr(Schema.String),
|
|
221
|
+
metadata: Schema.optional(Schema.NullOr(CompatibleUserMetadata)),
|
|
222
|
+
role: Schema.NullOr(Schema.String),
|
|
223
|
+
banned: Schema.NullOr(Schema.Boolean),
|
|
224
|
+
lastLoginMethod: Schema.optional(Schema.NullOr(Schema.String)),
|
|
225
|
+
createdAt: Schema.Date,
|
|
226
|
+
updatedAt: Schema.Date,
|
|
227
|
+
}).annotate({
|
|
228
|
+
identifier: "User",
|
|
229
|
+
title: "User",
|
|
230
|
+
description: "Stable central auth user record.",
|
|
231
|
+
examples: [
|
|
232
|
+
{
|
|
233
|
+
id: "user_1",
|
|
234
|
+
name: "Ada Lovelace",
|
|
235
|
+
email: "ada@example.com",
|
|
236
|
+
emailVerified: true,
|
|
237
|
+
image: null,
|
|
238
|
+
metadata: {
|
|
239
|
+
websites: [
|
|
240
|
+
{
|
|
241
|
+
url: "https://example.com",
|
|
242
|
+
translations: [{ locale: "en", label: "Website" }],
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
role: "admin",
|
|
247
|
+
banned: false,
|
|
248
|
+
lastLoginMethod: "email-otp",
|
|
249
|
+
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
250
|
+
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
});
|
|
134
254
|
export const PostalAddress = Schema.Struct({
|
|
135
255
|
streetAddress: Schema.optional(Schema.String),
|
|
136
256
|
locality: Schema.optional(Schema.String),
|
|
@@ -7,6 +7,38 @@ export declare const ServerUsersApiGroup: HttpApiGroup.HttpApiGroup<"users", Htt
|
|
|
7
7
|
readonly email: import("effect/Schema").String;
|
|
8
8
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
9
9
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
10
|
+
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
11
|
+
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
12
|
+
readonly email: import("effect/Schema").NonEmptyString;
|
|
13
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
14
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
15
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
16
|
+
}>>;
|
|
17
|
+
}>>>;
|
|
18
|
+
readonly phones: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
19
|
+
readonly number: import("effect/Schema").NonEmptyString;
|
|
20
|
+
readonly extension: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
21
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
22
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
23
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
24
|
+
}>>;
|
|
25
|
+
}>>>;
|
|
26
|
+
readonly websites: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
27
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
28
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
29
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
30
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
31
|
+
}>>;
|
|
32
|
+
}>>>;
|
|
33
|
+
readonly socials: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
34
|
+
readonly platform: import("effect/Schema").Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
35
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
36
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
37
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
38
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
39
|
+
}>>;
|
|
40
|
+
}>>>;
|
|
41
|
+
}>, import("effect/Schema").Unknown, never, never>>>;
|
|
10
42
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
11
43
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
12
44
|
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
@@ -25,6 +57,38 @@ export declare const ServerUsersApiGroup: HttpApiGroup.HttpApiGroup<"users", Htt
|
|
|
25
57
|
readonly email: import("effect/Schema").String;
|
|
26
58
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
27
59
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
60
|
+
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
61
|
+
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
62
|
+
readonly email: import("effect/Schema").NonEmptyString;
|
|
63
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
64
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
65
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
66
|
+
}>>;
|
|
67
|
+
}>>>;
|
|
68
|
+
readonly phones: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
69
|
+
readonly number: import("effect/Schema").NonEmptyString;
|
|
70
|
+
readonly extension: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
71
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
72
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
73
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
74
|
+
}>>;
|
|
75
|
+
}>>>;
|
|
76
|
+
readonly websites: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
77
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
78
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
79
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
80
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
81
|
+
}>>;
|
|
82
|
+
}>>>;
|
|
83
|
+
readonly socials: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
84
|
+
readonly platform: import("effect/Schema").Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
85
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
86
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
87
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
88
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
89
|
+
}>>;
|
|
90
|
+
}>>>;
|
|
91
|
+
}>, import("effect/Schema").Unknown, never, never>>>;
|
|
28
92
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
29
93
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
30
94
|
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
@@ -48,6 +112,38 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"org
|
|
|
48
112
|
readonly email: import("effect/Schema").String;
|
|
49
113
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
50
114
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
115
|
+
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
116
|
+
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
117
|
+
readonly email: import("effect/Schema").NonEmptyString;
|
|
118
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
119
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
120
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
121
|
+
}>>;
|
|
122
|
+
}>>>;
|
|
123
|
+
readonly phones: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
124
|
+
readonly number: import("effect/Schema").NonEmptyString;
|
|
125
|
+
readonly extension: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
126
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
127
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
128
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
129
|
+
}>>;
|
|
130
|
+
}>>>;
|
|
131
|
+
readonly websites: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
132
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
133
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
134
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
135
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
136
|
+
}>>;
|
|
137
|
+
}>>>;
|
|
138
|
+
readonly socials: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
139
|
+
readonly platform: import("effect/Schema").Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
140
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
141
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
142
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
143
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
144
|
+
}>>;
|
|
145
|
+
}>>>;
|
|
146
|
+
}>, import("effect/Schema").Unknown, never, never>>>;
|
|
51
147
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
52
148
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
53
149
|
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
@@ -188,6 +284,38 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"org
|
|
|
188
284
|
readonly email: import("effect/Schema").String;
|
|
189
285
|
readonly emailVerified: import("effect/Schema").Boolean;
|
|
190
286
|
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
287
|
+
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").decodeTo<import("effect/Schema").Struct<{
|
|
288
|
+
readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
289
|
+
readonly email: import("effect/Schema").NonEmptyString;
|
|
290
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
291
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
292
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
293
|
+
}>>;
|
|
294
|
+
}>>>;
|
|
295
|
+
readonly phones: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
296
|
+
readonly number: import("effect/Schema").NonEmptyString;
|
|
297
|
+
readonly extension: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
298
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
299
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
300
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
301
|
+
}>>;
|
|
302
|
+
}>>>;
|
|
303
|
+
readonly websites: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
304
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
305
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
306
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
307
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
308
|
+
}>>;
|
|
309
|
+
}>>>;
|
|
310
|
+
readonly socials: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
311
|
+
readonly platform: import("effect/Schema").Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
312
|
+
readonly url: import("effect/Schema").NonEmptyString;
|
|
313
|
+
readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
314
|
+
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
315
|
+
readonly label: import("effect/Schema").NonEmptyString;
|
|
316
|
+
}>>;
|
|
317
|
+
}>>>;
|
|
318
|
+
}>, import("effect/Schema").Unknown, never, never>>>;
|
|
191
319
|
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
192
320
|
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
193
321
|
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { AuthService } from "../service.js";
|
|
|
2
2
|
export type { AuthSession, AuthSessionWithOrganization, AuthSessionWithUser, AuthSessionWithUserAndOrganization, } from "../service.js";
|
|
3
3
|
export { AuthClientConfig } from "../config.js";
|
|
4
4
|
export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api.group.js";
|
|
5
|
-
export { proxyAuthRequest } from "./proxy.js";
|
|
5
|
+
export { proxyAuthHttpEffect, proxyAuthRequest, proxyAuthRequestEffect, } from "./proxy.js";
|
|
6
6
|
export type { ProxyAuthRequestOptions } from "./proxy.js";
|
|
7
7
|
export { ActorRequired } from "./actor.js";
|
|
8
8
|
export type { ActorConstraint } from "./actor.js";
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AuthService } from "../service.js";
|
|
2
2
|
export { AuthClientConfig } from "../config.js";
|
|
3
3
|
export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api.group.js";
|
|
4
|
-
export { proxyAuthRequest } from "./proxy.js";
|
|
4
|
+
export { proxyAuthHttpEffect, proxyAuthRequest, proxyAuthRequestEffect, } from "./proxy.js";
|
|
5
5
|
export { ActorRequired } from "./actor.js";
|
|
6
6
|
export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware.js";
|
|
7
7
|
export { ServerActiveOrganization, ServerCreateDomainPayload, ServerDomain, ServerDomainHostParams, ServerDomainIdParams, ServerDomainRecordsResponse, ServerMembersResponse, ServerOrganizationChildrenResponse, ServerOrganizationsResponse, ServerUpdateDomainPayload, ServerUsersResponse, } from "./schema.js";
|
package/dist/server/proxy.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpClient, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
1
3
|
export interface ProxyAuthRequestOptions {
|
|
2
4
|
cookieDomain?: string;
|
|
3
5
|
}
|
|
4
6
|
export declare const proxyAuthRequest: (request: Request, baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Promise<Response>;
|
|
7
|
+
export declare const proxyAuthRequestEffect: (request: Request, baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Effect.Effect<HttpServerResponse.HttpServerResponse, import("effect/unstable/http/HttpClientError").HttpClientError, HttpClient.HttpClient>;
|
|
8
|
+
export declare const proxyAuthHttpEffect: (baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Effect.Effect<HttpServerResponse.HttpServerResponse, import("effect/unstable/http/HttpClientError").HttpClientError | import("effect/unstable/http/HttpServerError").RequestError, HttpClient.HttpClient | HttpServerRequest.HttpServerRequest>;
|
package/dist/server/proxy.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Cookies, FetchHttpClient, Headers as HttpHeaders, HttpClient, HttpClientRequest, HttpServerRequest, HttpServerResponse, } from "effect/unstable/http";
|
|
1
3
|
const blockedRequestHeaders = [
|
|
2
4
|
"accept-encoding",
|
|
5
|
+
"b3",
|
|
6
|
+
"baggage",
|
|
3
7
|
"connection",
|
|
4
8
|
"content-length",
|
|
5
9
|
"forwarded",
|
|
@@ -9,11 +13,18 @@ const blockedRequestHeaders = [
|
|
|
9
13
|
"proxy-authorization",
|
|
10
14
|
"te",
|
|
11
15
|
"trailer",
|
|
16
|
+
"traceparent",
|
|
17
|
+
"tracestate",
|
|
12
18
|
"transfer-encoding",
|
|
13
19
|
"upgrade",
|
|
14
20
|
"cdn-loop",
|
|
15
21
|
"x-krakstack-forwarded-host",
|
|
16
22
|
"x-krakstack-forwarded-proto",
|
|
23
|
+
"x-b3-flags",
|
|
24
|
+
"x-b3-parentspanid",
|
|
25
|
+
"x-b3-sampled",
|
|
26
|
+
"x-b3-spanid",
|
|
27
|
+
"x-b3-traceid",
|
|
17
28
|
];
|
|
18
29
|
const hostOnlyCookie = (cookie) => cookie.replace(/;\s*domain=[^;]*/gi, "");
|
|
19
30
|
const normalizedCookieDomain = (domain) => domain
|
|
@@ -75,7 +86,7 @@ const proxyHeaders = (request) => {
|
|
|
75
86
|
}
|
|
76
87
|
return headers;
|
|
77
88
|
};
|
|
78
|
-
|
|
89
|
+
const proxyRequest = (request, baseUrl) => {
|
|
79
90
|
const target = new URL(request.url);
|
|
80
91
|
const authUrl = new URL(baseUrl);
|
|
81
92
|
const init = {
|
|
@@ -89,8 +100,28 @@ export const proxyAuthRequest = async (request, baseUrl, options) => {
|
|
|
89
100
|
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
90
101
|
init.body = request.body;
|
|
91
102
|
}
|
|
92
|
-
|
|
103
|
+
return new Request(target, init);
|
|
104
|
+
};
|
|
105
|
+
export const proxyAuthRequest = async (request, baseUrl, options) => {
|
|
106
|
+
const response = await fetch(proxyRequest(request, baseUrl), {
|
|
93
107
|
redirect: "manual",
|
|
94
108
|
});
|
|
95
109
|
return proxyResponse(request, response, options);
|
|
96
110
|
};
|
|
111
|
+
export const proxyAuthRequestEffect = (request, baseUrl, options) => Effect.gen(function* () {
|
|
112
|
+
const response = yield* HttpClient.execute(HttpClientRequest.fromWeb(proxyRequest(request, baseUrl))).pipe(Effect.provideService(FetchHttpClient.RequestInit, {
|
|
113
|
+
redirect: "manual",
|
|
114
|
+
}));
|
|
115
|
+
const cookieDomain = sharedCookieDomain(request, options);
|
|
116
|
+
const cookies = Cookies.fromSetCookie(Cookies.toSetCookieHeaders(response.cookies).map((cookie) => cookieForDomain(cookie, cookieDomain)));
|
|
117
|
+
return HttpServerResponse.stream(response.stream, {
|
|
118
|
+
status: response.status,
|
|
119
|
+
headers: HttpHeaders.remove(response.headers, "set-cookie"),
|
|
120
|
+
cookies,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
export const proxyAuthHttpEffect = (baseUrl, options) => Effect.gen(function* () {
|
|
124
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
125
|
+
const webRequest = yield* HttpServerRequest.toWeb(request);
|
|
126
|
+
return yield* proxyAuthRequestEffect(webRequest, baseUrl, options);
|
|
127
|
+
});
|
package/dist/server/schema.d.ts
CHANGED
|
@@ -29,6 +29,38 @@ export declare const ServerUsersResponse: Schema.Struct<{
|
|
|
29
29
|
readonly email: Schema.String;
|
|
30
30
|
readonly emailVerified: Schema.Boolean;
|
|
31
31
|
readonly image: Schema.NullOr<Schema.String>;
|
|
32
|
+
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
33
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
34
|
+
readonly email: Schema.NonEmptyString;
|
|
35
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
36
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
37
|
+
readonly label: Schema.NonEmptyString;
|
|
38
|
+
}>>;
|
|
39
|
+
}>>>;
|
|
40
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
41
|
+
readonly number: Schema.NonEmptyString;
|
|
42
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
43
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
44
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
45
|
+
readonly label: Schema.NonEmptyString;
|
|
46
|
+
}>>;
|
|
47
|
+
}>>>;
|
|
48
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
49
|
+
readonly url: Schema.NonEmptyString;
|
|
50
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
51
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
52
|
+
readonly label: Schema.NonEmptyString;
|
|
53
|
+
}>>;
|
|
54
|
+
}>>>;
|
|
55
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
56
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
57
|
+
readonly url: Schema.NonEmptyString;
|
|
58
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
59
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
60
|
+
readonly label: Schema.NonEmptyString;
|
|
61
|
+
}>>;
|
|
62
|
+
}>>>;
|
|
63
|
+
}>, Schema.Unknown, never, never>>>;
|
|
32
64
|
readonly role: Schema.NullOr<Schema.String>;
|
|
33
65
|
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
34
66
|
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
@@ -170,6 +202,38 @@ export declare const ServerMembersResponse: Schema.$Array<Schema.Struct<{
|
|
|
170
202
|
readonly email: Schema.String;
|
|
171
203
|
readonly emailVerified: Schema.Boolean;
|
|
172
204
|
readonly image: Schema.NullOr<Schema.String>;
|
|
205
|
+
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
206
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
207
|
+
readonly email: Schema.NonEmptyString;
|
|
208
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
209
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
210
|
+
readonly label: Schema.NonEmptyString;
|
|
211
|
+
}>>;
|
|
212
|
+
}>>>;
|
|
213
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
214
|
+
readonly number: Schema.NonEmptyString;
|
|
215
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
216
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
217
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
218
|
+
readonly label: Schema.NonEmptyString;
|
|
219
|
+
}>>;
|
|
220
|
+
}>>>;
|
|
221
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
222
|
+
readonly url: Schema.NonEmptyString;
|
|
223
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
224
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
225
|
+
readonly label: Schema.NonEmptyString;
|
|
226
|
+
}>>;
|
|
227
|
+
}>>>;
|
|
228
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
229
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
230
|
+
readonly url: Schema.NonEmptyString;
|
|
231
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
232
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
233
|
+
readonly label: Schema.NonEmptyString;
|
|
234
|
+
}>>;
|
|
235
|
+
}>>>;
|
|
236
|
+
}>, Schema.Unknown, never, never>>>;
|
|
173
237
|
readonly role: Schema.NullOr<Schema.String>;
|
|
174
238
|
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
175
239
|
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|