@logto/schemas 1.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +373 -0
  2. package/alterations/1.0.0_beta.10-1-logto-config.ts +20 -0
  3. package/alterations/1.0.0_beta.10-1663923211-machine-to-machine-app.ts +31 -0
  4. package/alterations/1.0.0_beta.10-1664265197-custom-phrases.ts +22 -0
  5. package/alterations/1.0.0_beta.11-1664347703-rename-language-key-to-tag.ts +14 -0
  6. package/alterations/1.0.0_beta.11-1664356000-add-created-at-column-to-users.ts +20 -0
  7. package/alterations/1.0.0_beta.11-1664462389-correct-user-created-at-column-by-user-logs.ts +25 -0
  8. package/alterations/README.md +42 -0
  9. package/lib/api/error.d.ts +12 -0
  10. package/lib/api/error.js +2 -0
  11. package/lib/api/index.d.ts +1 -0
  12. package/lib/api/index.js +17 -0
  13. package/lib/db-entries/application.d.ts +25 -0
  14. package/lib/db-entries/application.js +57 -0
  15. package/lib/db-entries/connector.d.ts +14 -0
  16. package/lib/db-entries/connector.js +31 -0
  17. package/lib/db-entries/custom-phrase.d.ts +10 -0
  18. package/lib/db-entries/custom-phrase.js +25 -0
  19. package/lib/db-entries/custom-types.d.ts +19 -0
  20. package/lib/db-entries/custom-types.js +27 -0
  21. package/lib/db-entries/index.d.ts +13 -0
  22. package/lib/db-entries/index.js +30 -0
  23. package/lib/db-entries/log.d.ts +14 -0
  24. package/lib/db-entries/log.js +31 -0
  25. package/lib/db-entries/logto-config.d.ts +10 -0
  26. package/lib/db-entries/logto-config.js +25 -0
  27. package/lib/db-entries/oidc-model-instance.d.ts +16 -0
  28. package/lib/db-entries/oidc-model-instance.js +34 -0
  29. package/lib/db-entries/passcode.d.ts +25 -0
  30. package/lib/db-entries/passcode.js +56 -0
  31. package/lib/db-entries/resource.d.ts +14 -0
  32. package/lib/db-entries/resource.js +30 -0
  33. package/lib/db-entries/role.d.ts +10 -0
  34. package/lib/db-entries/role.js +24 -0
  35. package/lib/db-entries/setting.d.ts +10 -0
  36. package/lib/db-entries/setting.js +25 -0
  37. package/lib/db-entries/sign-in-experience.d.ts +23 -0
  38. package/lib/db-entries/sign-in-experience.js +53 -0
  39. package/lib/db-entries/user.d.ts +35 -0
  40. package/lib/db-entries/user.js +77 -0
  41. package/lib/foundations/index.d.ts +2 -0
  42. package/lib/foundations/index.js +18 -0
  43. package/lib/foundations/jsonb-types.d.ts +221 -0
  44. package/lib/foundations/jsonb-types.js +135 -0
  45. package/lib/foundations/schemas.d.ts +24 -0
  46. package/lib/foundations/schemas.js +2 -0
  47. package/lib/index.d.ts +5 -0
  48. package/lib/index.js +34 -0
  49. package/lib/seeds/application.d.ts +9 -0
  50. package/lib/seeds/application.js +20 -0
  51. package/lib/seeds/index.d.ts +5 -0
  52. package/lib/seeds/index.js +21 -0
  53. package/lib/seeds/resource.d.ts +2 -0
  54. package/lib/seeds/resource.js +13 -0
  55. package/lib/seeds/roles.d.ts +5 -0
  56. package/lib/seeds/roles.js +11 -0
  57. package/lib/seeds/setting.d.ts +3 -0
  58. package/lib/seeds/setting.js +19 -0
  59. package/lib/seeds/sign-in-experience.d.ts +3 -0
  60. package/lib/seeds/sign-in-experience.js +47 -0
  61. package/lib/types/alteration.d.ts +5 -0
  62. package/lib/types/alteration.js +2 -0
  63. package/lib/types/connector.d.ts +5 -0
  64. package/lib/types/connector.js +6 -0
  65. package/lib/types/index.d.ts +5 -0
  66. package/lib/types/index.js +21 -0
  67. package/lib/types/log.d.ts +577 -0
  68. package/lib/types/log.js +144 -0
  69. package/lib/types/logto-config.d.ts +32 -0
  70. package/lib/types/logto-config.js +40 -0
  71. package/lib/types/oidc-config.d.ts +12 -0
  72. package/lib/types/oidc-config.js +9 -0
  73. package/lib/types/user.d.ts +6 -0
  74. package/lib/types/user.js +21 -0
  75. package/package.json +74 -0
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Users = void 0;
5
+ const zod_1 = require("zod");
6
+ const foundations_1 = require("../foundations");
7
+ const custom_types_1 = require("./custom-types");
8
+ const createGuard = zod_1.z.object({
9
+ id: zod_1.z.string().max(12),
10
+ username: zod_1.z.string().max(128).nullable().optional(),
11
+ primaryEmail: zod_1.z.string().max(128).nullable().optional(),
12
+ primaryPhone: zod_1.z.string().max(128).nullable().optional(),
13
+ passwordEncrypted: zod_1.z.string().max(128).nullable().optional(),
14
+ passwordEncryptionMethod: zod_1.z.nativeEnum(custom_types_1.UsersPasswordEncryptionMethod).nullable().optional(),
15
+ name: zod_1.z.string().max(128).nullable().optional(),
16
+ avatar: zod_1.z.string().max(2048).nullable().optional(),
17
+ applicationId: zod_1.z.string().max(21).nullable().optional(),
18
+ roleNames: foundations_1.roleNamesGuard.optional(),
19
+ identities: foundations_1.identitiesGuard.optional(),
20
+ customData: foundations_1.arbitraryObjectGuard.optional(),
21
+ lastSignInAt: zod_1.z.number().nullable().optional(),
22
+ createdAt: zod_1.z.number().optional(),
23
+ });
24
+ const guard = zod_1.z.object({
25
+ id: zod_1.z.string().max(12),
26
+ username: zod_1.z.string().max(128).nullable(),
27
+ primaryEmail: zod_1.z.string().max(128).nullable(),
28
+ primaryPhone: zod_1.z.string().max(128).nullable(),
29
+ passwordEncrypted: zod_1.z.string().max(128).nullable(),
30
+ passwordEncryptionMethod: zod_1.z.nativeEnum(custom_types_1.UsersPasswordEncryptionMethod).nullable(),
31
+ name: zod_1.z.string().max(128).nullable(),
32
+ avatar: zod_1.z.string().max(2048).nullable(),
33
+ applicationId: zod_1.z.string().max(21).nullable(),
34
+ roleNames: foundations_1.roleNamesGuard,
35
+ identities: foundations_1.identitiesGuard,
36
+ customData: foundations_1.arbitraryObjectGuard,
37
+ lastSignInAt: zod_1.z.number().nullable(),
38
+ createdAt: zod_1.z.number(),
39
+ });
40
+ exports.Users = Object.freeze({
41
+ table: 'users',
42
+ tableSingular: 'user',
43
+ fields: {
44
+ id: 'id',
45
+ username: 'username',
46
+ primaryEmail: 'primary_email',
47
+ primaryPhone: 'primary_phone',
48
+ passwordEncrypted: 'password_encrypted',
49
+ passwordEncryptionMethod: 'password_encryption_method',
50
+ name: 'name',
51
+ avatar: 'avatar',
52
+ applicationId: 'application_id',
53
+ roleNames: 'role_names',
54
+ identities: 'identities',
55
+ customData: 'custom_data',
56
+ lastSignInAt: 'last_sign_in_at',
57
+ createdAt: 'created_at',
58
+ },
59
+ fieldKeys: [
60
+ 'id',
61
+ 'username',
62
+ 'primaryEmail',
63
+ 'primaryPhone',
64
+ 'passwordEncrypted',
65
+ 'passwordEncryptionMethod',
66
+ 'name',
67
+ 'avatar',
68
+ 'applicationId',
69
+ 'roleNames',
70
+ 'identities',
71
+ 'customData',
72
+ 'lastSignInAt',
73
+ 'createdAt',
74
+ ],
75
+ createGuard,
76
+ guard,
77
+ });
@@ -0,0 +1,2 @@
1
+ export * from './schemas';
2
+ export * from './jsonb-types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schemas"), exports);
18
+ __exportStar(require("./jsonb-types"), exports);
@@ -0,0 +1,221 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Commonly Used
4
+ */
5
+ export declare const arbitraryObjectGuard: z.ZodUnion<[z.ZodObject<{}, "strip", z.ZodUnknown, {
6
+ [x: string]: unknown;
7
+ }, {
8
+ [x: string]: unknown;
9
+ }>, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>;
10
+ export declare type ArbitraryObject = z.infer<typeof arbitraryObjectGuard>;
11
+ /**
12
+ * OIDC Model Instances
13
+ */
14
+ export declare const oidcModelInstancePayloadGuard: z.ZodObject<{
15
+ userCode: z.ZodOptional<z.ZodString>;
16
+ uid: z.ZodOptional<z.ZodString>;
17
+ grantId: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodUnknown, {
19
+ [x: string]: unknown;
20
+ userCode?: string | undefined;
21
+ uid?: string | undefined;
22
+ grantId?: string | undefined;
23
+ }, {
24
+ [x: string]: unknown;
25
+ userCode?: string | undefined;
26
+ uid?: string | undefined;
27
+ grantId?: string | undefined;
28
+ }>;
29
+ export declare type OidcModelInstancePayload = z.infer<typeof oidcModelInstancePayloadGuard>;
30
+ export declare const webRedirectUriProtocolRegEx: RegExp;
31
+ export declare const mobileUriSchemeProtocolRegEx: RegExp;
32
+ export declare const validateRedirectUrl: (urlString: string, type: 'web' | 'mobile') => boolean;
33
+ export declare const oidcClientMetadataGuard: z.ZodObject<{
34
+ redirectUris: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, "many">;
35
+ postLogoutRedirectUris: z.ZodArray<z.ZodString, "many">;
36
+ logoUri: z.ZodOptional<z.ZodString>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ logoUri?: string | undefined;
39
+ redirectUris: string[];
40
+ postLogoutRedirectUris: string[];
41
+ }, {
42
+ logoUri?: string | undefined;
43
+ redirectUris: string[];
44
+ postLogoutRedirectUris: string[];
45
+ }>;
46
+ export declare type OidcClientMetadata = z.infer<typeof oidcClientMetadataGuard>;
47
+ export declare enum CustomClientMetadataKey {
48
+ CorsAllowedOrigins = "corsAllowedOrigins",
49
+ IdTokenTtl = "idTokenTtl",
50
+ RefreshTokenTtl = "refreshTokenTtl"
51
+ }
52
+ export declare const customClientMetadataGuard: z.ZodObject<{
53
+ corsAllowedOrigins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
+ idTokenTtl: z.ZodOptional<z.ZodNumber>;
55
+ refreshTokenTtl: z.ZodOptional<z.ZodNumber>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ corsAllowedOrigins?: string[] | undefined;
58
+ idTokenTtl?: number | undefined;
59
+ refreshTokenTtl?: number | undefined;
60
+ }, {
61
+ corsAllowedOrigins?: string[] | undefined;
62
+ idTokenTtl?: number | undefined;
63
+ refreshTokenTtl?: number | undefined;
64
+ }>;
65
+ export declare type CustomClientMetadata = z.infer<typeof customClientMetadataGuard>;
66
+ /**
67
+ * Users
68
+ */
69
+ export declare const roleNamesGuard: z.ZodArray<z.ZodString, "many">;
70
+ export declare type RoleNames = z.infer<typeof roleNamesGuard>;
71
+ declare const identityGuard: z.ZodObject<{
72
+ userId: z.ZodString;
73
+ details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ details?: {} | undefined;
76
+ userId: string;
77
+ }, {
78
+ details?: {} | undefined;
79
+ userId: string;
80
+ }>;
81
+ export declare const identitiesGuard: z.ZodRecord<z.ZodString, z.ZodObject<{
82
+ userId: z.ZodString;
83
+ details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ details?: {} | undefined;
86
+ userId: string;
87
+ }, {
88
+ details?: {} | undefined;
89
+ userId: string;
90
+ }>>;
91
+ export declare type Identity = z.infer<typeof identityGuard>;
92
+ export declare type Identities = z.infer<typeof identitiesGuard>;
93
+ /**
94
+ * SignIn Experiences
95
+ */
96
+ export declare const colorGuard: z.ZodObject<{
97
+ primaryColor: z.ZodString;
98
+ isDarkModeEnabled: z.ZodBoolean;
99
+ darkPrimaryColor: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ primaryColor: string;
102
+ isDarkModeEnabled: boolean;
103
+ darkPrimaryColor: string;
104
+ }, {
105
+ primaryColor: string;
106
+ isDarkModeEnabled: boolean;
107
+ darkPrimaryColor: string;
108
+ }>;
109
+ export declare type Color = z.infer<typeof colorGuard>;
110
+ export declare enum BrandingStyle {
111
+ Logo = "Logo",
112
+ Logo_Slogan = "Logo_Slogan"
113
+ }
114
+ export declare const brandingGuard: z.ZodObject<{
115
+ style: z.ZodNativeEnum<typeof BrandingStyle>;
116
+ logoUrl: z.ZodString;
117
+ darkLogoUrl: z.ZodOptional<z.ZodString>;
118
+ slogan: z.ZodOptional<z.ZodString>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ darkLogoUrl?: string | undefined;
121
+ slogan?: string | undefined;
122
+ style: BrandingStyle;
123
+ logoUrl: string;
124
+ }, {
125
+ darkLogoUrl?: string | undefined;
126
+ slogan?: string | undefined;
127
+ style: BrandingStyle;
128
+ logoUrl: string;
129
+ }>;
130
+ export declare type Branding = z.infer<typeof brandingGuard>;
131
+ export declare const termsOfUseGuard: z.ZodObject<{
132
+ enabled: z.ZodBoolean;
133
+ contentUrl: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
134
+ }, "strip", z.ZodTypeAny, {
135
+ contentUrl?: string | undefined;
136
+ enabled: boolean;
137
+ }, {
138
+ contentUrl?: string | undefined;
139
+ enabled: boolean;
140
+ }>;
141
+ export declare type TermsOfUse = z.infer<typeof termsOfUseGuard>;
142
+ export declare const languageInfoGuard: z.ZodObject<{
143
+ autoDetect: z.ZodBoolean;
144
+ fallbackLanguage: z.ZodType<"af-ZA" | "am-ET" | "ar-AR" | "as-IN" | "az-AZ" | "be-BY" | "bg-BG" | "bn-IN" | "br-FR" | "bs-BA" | "ca-ES" | "cb-IQ" | "co-FR" | "cs-CZ" | "cx-PH" | "cy-GB" | "da-DK" | "de-DE" | "el-GR" | "en" | "en-GB" | "en-US" | "eo-EO" | "es-ES" | "es-LA" | "et-EE" | "eu-ES" | "fa-IR" | "ff-NG" | "fi-FI" | "fo-FO" | "fr" | "fr-CA" | "fr-FR" | "fy-NL" | "ga-IE" | "gl-ES" | "gn-PY" | "gu-IN" | "ha-NG" | "he-IL" | "hi-IN" | "hr-HR" | "ht-HT" | "hu-HU" | "hy-AM" | "id-ID" | "ik-US" | "is-IS" | "it-IT" | "iu-CA" | "ja" | "ja-KS" | "jv-ID" | "ka-GE" | "kk-KZ" | "km-KH" | "kn-IN" | "ko-KR" | "ku-TR" | "ky-KG" | "lo-LA" | "lt-LT" | "lv-LV" | "mg-MG" | "mk-MK" | "ml-IN" | "mn-MN" | "mr-IN" | "ms-MY" | "mt-MT" | "my-MM" | "nb-NO" | "ne-NP" | "nl-BE" | "nl-NL" | "nn-NO" | "or-IN" | "pa-IN" | "pl-PL" | "ps-AF" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "rw-RW" | "sc-IT" | "si-LK" | "sk-SK" | "sl-SI" | "sn-ZW" | "sq-AL" | "sr-RS" | "sv-SE" | "sw-KE" | "sy-SY" | "sz-PL" | "ta-IN" | "te-IN" | "tg-TJ" | "th-TH" | "tl-PH" | "tr-TR" | "tt-RU" | "tz-MA" | "uk-UA" | "ur-PK" | "uz-UZ" | "vi-VN" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-TW" | "zz-TR", z.ZodTypeDef, "af-ZA" | "am-ET" | "ar-AR" | "as-IN" | "az-AZ" | "be-BY" | "bg-BG" | "bn-IN" | "br-FR" | "bs-BA" | "ca-ES" | "cb-IQ" | "co-FR" | "cs-CZ" | "cx-PH" | "cy-GB" | "da-DK" | "de-DE" | "el-GR" | "en" | "en-GB" | "en-US" | "eo-EO" | "es-ES" | "es-LA" | "et-EE" | "eu-ES" | "fa-IR" | "ff-NG" | "fi-FI" | "fo-FO" | "fr" | "fr-CA" | "fr-FR" | "fy-NL" | "ga-IE" | "gl-ES" | "gn-PY" | "gu-IN" | "ha-NG" | "he-IL" | "hi-IN" | "hr-HR" | "ht-HT" | "hu-HU" | "hy-AM" | "id-ID" | "ik-US" | "is-IS" | "it-IT" | "iu-CA" | "ja" | "ja-KS" | "jv-ID" | "ka-GE" | "kk-KZ" | "km-KH" | "kn-IN" | "ko-KR" | "ku-TR" | "ky-KG" | "lo-LA" | "lt-LT" | "lv-LV" | "mg-MG" | "mk-MK" | "ml-IN" | "mn-MN" | "mr-IN" | "ms-MY" | "mt-MT" | "my-MM" | "nb-NO" | "ne-NP" | "nl-BE" | "nl-NL" | "nn-NO" | "or-IN" | "pa-IN" | "pl-PL" | "ps-AF" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "rw-RW" | "sc-IT" | "si-LK" | "sk-SK" | "sl-SI" | "sn-ZW" | "sq-AL" | "sr-RS" | "sv-SE" | "sw-KE" | "sy-SY" | "sz-PL" | "ta-IN" | "te-IN" | "tg-TJ" | "th-TH" | "tl-PH" | "tr-TR" | "tt-RU" | "tz-MA" | "uk-UA" | "ur-PK" | "uz-UZ" | "vi-VN" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-TW" | "zz-TR">;
145
+ }, "strip", z.ZodTypeAny, {
146
+ autoDetect: boolean;
147
+ fallbackLanguage: "af-ZA" | "am-ET" | "ar-AR" | "as-IN" | "az-AZ" | "be-BY" | "bg-BG" | "bn-IN" | "br-FR" | "bs-BA" | "ca-ES" | "cb-IQ" | "co-FR" | "cs-CZ" | "cx-PH" | "cy-GB" | "da-DK" | "de-DE" | "el-GR" | "en" | "en-GB" | "en-US" | "eo-EO" | "es-ES" | "es-LA" | "et-EE" | "eu-ES" | "fa-IR" | "ff-NG" | "fi-FI" | "fo-FO" | "fr" | "fr-CA" | "fr-FR" | "fy-NL" | "ga-IE" | "gl-ES" | "gn-PY" | "gu-IN" | "ha-NG" | "he-IL" | "hi-IN" | "hr-HR" | "ht-HT" | "hu-HU" | "hy-AM" | "id-ID" | "ik-US" | "is-IS" | "it-IT" | "iu-CA" | "ja" | "ja-KS" | "jv-ID" | "ka-GE" | "kk-KZ" | "km-KH" | "kn-IN" | "ko-KR" | "ku-TR" | "ky-KG" | "lo-LA" | "lt-LT" | "lv-LV" | "mg-MG" | "mk-MK" | "ml-IN" | "mn-MN" | "mr-IN" | "ms-MY" | "mt-MT" | "my-MM" | "nb-NO" | "ne-NP" | "nl-BE" | "nl-NL" | "nn-NO" | "or-IN" | "pa-IN" | "pl-PL" | "ps-AF" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "rw-RW" | "sc-IT" | "si-LK" | "sk-SK" | "sl-SI" | "sn-ZW" | "sq-AL" | "sr-RS" | "sv-SE" | "sw-KE" | "sy-SY" | "sz-PL" | "ta-IN" | "te-IN" | "tg-TJ" | "th-TH" | "tl-PH" | "tr-TR" | "tt-RU" | "tz-MA" | "uk-UA" | "ur-PK" | "uz-UZ" | "vi-VN" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-TW" | "zz-TR";
148
+ }, {
149
+ autoDetect: boolean;
150
+ fallbackLanguage: "af-ZA" | "am-ET" | "ar-AR" | "as-IN" | "az-AZ" | "be-BY" | "bg-BG" | "bn-IN" | "br-FR" | "bs-BA" | "ca-ES" | "cb-IQ" | "co-FR" | "cs-CZ" | "cx-PH" | "cy-GB" | "da-DK" | "de-DE" | "el-GR" | "en" | "en-GB" | "en-US" | "eo-EO" | "es-ES" | "es-LA" | "et-EE" | "eu-ES" | "fa-IR" | "ff-NG" | "fi-FI" | "fo-FO" | "fr" | "fr-CA" | "fr-FR" | "fy-NL" | "ga-IE" | "gl-ES" | "gn-PY" | "gu-IN" | "ha-NG" | "he-IL" | "hi-IN" | "hr-HR" | "ht-HT" | "hu-HU" | "hy-AM" | "id-ID" | "ik-US" | "is-IS" | "it-IT" | "iu-CA" | "ja" | "ja-KS" | "jv-ID" | "ka-GE" | "kk-KZ" | "km-KH" | "kn-IN" | "ko-KR" | "ku-TR" | "ky-KG" | "lo-LA" | "lt-LT" | "lv-LV" | "mg-MG" | "mk-MK" | "ml-IN" | "mn-MN" | "mr-IN" | "ms-MY" | "mt-MT" | "my-MM" | "nb-NO" | "ne-NP" | "nl-BE" | "nl-NL" | "nn-NO" | "or-IN" | "pa-IN" | "pl-PL" | "ps-AF" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "rw-RW" | "sc-IT" | "si-LK" | "sk-SK" | "sl-SI" | "sn-ZW" | "sq-AL" | "sr-RS" | "sv-SE" | "sw-KE" | "sy-SY" | "sz-PL" | "ta-IN" | "te-IN" | "tg-TJ" | "th-TH" | "tl-PH" | "tr-TR" | "tt-RU" | "tz-MA" | "uk-UA" | "ur-PK" | "uz-UZ" | "vi-VN" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-TW" | "zz-TR";
151
+ }>;
152
+ export declare type LanguageInfo = z.infer<typeof languageInfoGuard>;
153
+ export declare enum SignInMethodKey {
154
+ Username = "username",
155
+ Email = "email",
156
+ Sms = "sms",
157
+ Social = "social"
158
+ }
159
+ export declare enum SignInMethodState {
160
+ Primary = "primary",
161
+ Secondary = "secondary",
162
+ Disabled = "disabled"
163
+ }
164
+ export declare const signInMethodsGuard: z.ZodObject<{
165
+ username: z.ZodNativeEnum<typeof SignInMethodState>;
166
+ email: z.ZodNativeEnum<typeof SignInMethodState>;
167
+ sms: z.ZodNativeEnum<typeof SignInMethodState>;
168
+ social: z.ZodNativeEnum<typeof SignInMethodState>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ username: SignInMethodState;
171
+ email: SignInMethodState;
172
+ sms: SignInMethodState;
173
+ social: SignInMethodState;
174
+ }, {
175
+ username: SignInMethodState;
176
+ email: SignInMethodState;
177
+ sms: SignInMethodState;
178
+ social: SignInMethodState;
179
+ }>;
180
+ export declare type SignInMethods = z.infer<typeof signInMethodsGuard>;
181
+ export declare const connectorTargetsGuard: z.ZodArray<z.ZodString, "many">;
182
+ export declare type ConnectorTargets = z.infer<typeof connectorTargetsGuard>;
183
+ /**
184
+ * Settings
185
+ */
186
+ export declare enum AppearanceMode {
187
+ SyncWithSystem = "system",
188
+ LightMode = "light",
189
+ DarkMode = "dark"
190
+ }
191
+ export declare const adminConsoleConfigGuard: z.ZodObject<{
192
+ demoChecked: z.ZodBoolean;
193
+ applicationCreated: z.ZodBoolean;
194
+ signInExperienceCustomized: z.ZodBoolean;
195
+ passwordlessConfigured: z.ZodBoolean;
196
+ socialSignInConfigured: z.ZodBoolean;
197
+ furtherReadingsChecked: z.ZodBoolean;
198
+ }, "strip", z.ZodTypeAny, {
199
+ demoChecked: boolean;
200
+ applicationCreated: boolean;
201
+ signInExperienceCustomized: boolean;
202
+ passwordlessConfigured: boolean;
203
+ socialSignInConfigured: boolean;
204
+ furtherReadingsChecked: boolean;
205
+ }, {
206
+ demoChecked: boolean;
207
+ applicationCreated: boolean;
208
+ signInExperienceCustomized: boolean;
209
+ passwordlessConfigured: boolean;
210
+ socialSignInConfigured: boolean;
211
+ furtherReadingsChecked: boolean;
212
+ }>;
213
+ export declare type AdminConsoleConfig = z.infer<typeof adminConsoleConfigGuard>;
214
+ /**
215
+ * Phrases
216
+ */
217
+ export declare type Translation = {
218
+ [key: string]: string | Translation;
219
+ };
220
+ export declare const translationGuard: z.ZodType<Translation>;
221
+ export {};
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translationGuard = exports.adminConsoleConfigGuard = exports.AppearanceMode = exports.connectorTargetsGuard = exports.signInMethodsGuard = exports.SignInMethodState = exports.SignInMethodKey = exports.languageInfoGuard = exports.termsOfUseGuard = exports.brandingGuard = exports.BrandingStyle = exports.colorGuard = exports.identitiesGuard = exports.roleNamesGuard = exports.customClientMetadataGuard = exports.CustomClientMetadataKey = exports.oidcClientMetadataGuard = exports.validateRedirectUrl = exports.mobileUriSchemeProtocolRegEx = exports.webRedirectUriProtocolRegEx = exports.oidcModelInstancePayloadGuard = exports.arbitraryObjectGuard = void 0;
4
+ const core_kit_1 = require("@logto/core-kit");
5
+ const language_kit_1 = require("@logto/language-kit");
6
+ const zod_1 = require("zod");
7
+ /**
8
+ * Commonly Used
9
+ */
10
+ // Cannot declare `z.object({}).catchall(z.unknown().optional())` to guard `{ [key: string]?: unknown }` (invalid type),
11
+ // so do it another way to guard `{ [x: string]: unknown; } | {}`.
12
+ exports.arbitraryObjectGuard = zod_1.z.union([zod_1.z.object({}).catchall(zod_1.z.unknown()), zod_1.z.object({})]);
13
+ /**
14
+ * OIDC Model Instances
15
+ */
16
+ exports.oidcModelInstancePayloadGuard = zod_1.z
17
+ .object({
18
+ userCode: zod_1.z.string().optional(),
19
+ uid: zod_1.z.string().optional(),
20
+ grantId: zod_1.z.string().optional(),
21
+ })
22
+ /**
23
+ * Try to use `.passthrough()` if type has been fixed.
24
+ * https://github.com/colinhacks/zod/issues/452
25
+ */
26
+ .catchall(zod_1.z.unknown());
27
+ // Import from @logto/core-kit later, pending for new version publish
28
+ exports.webRedirectUriProtocolRegEx = /^https?:$/;
29
+ exports.mobileUriSchemeProtocolRegEx = /^[a-z][\d_a-z]*(\.[\d_a-z]+)+:$/;
30
+ const validateRedirectUrl = (urlString, type) => {
31
+ try {
32
+ const { protocol } = new URL(urlString);
33
+ const protocolRegEx = type === 'mobile' ? exports.mobileUriSchemeProtocolRegEx : exports.webRedirectUriProtocolRegEx;
34
+ return protocolRegEx.test(protocol);
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ };
40
+ exports.validateRedirectUrl = validateRedirectUrl;
41
+ exports.oidcClientMetadataGuard = zod_1.z.object({
42
+ redirectUris: zod_1.z
43
+ .string()
44
+ .refine((url) => (0, exports.validateRedirectUrl)(url, 'web'))
45
+ .or(zod_1.z.string().refine((url) => (0, exports.validateRedirectUrl)(url, 'mobile')))
46
+ .array(),
47
+ postLogoutRedirectUris: zod_1.z.string().url().array(),
48
+ logoUri: zod_1.z.string().optional(),
49
+ });
50
+ var CustomClientMetadataKey;
51
+ (function (CustomClientMetadataKey) {
52
+ CustomClientMetadataKey["CorsAllowedOrigins"] = "corsAllowedOrigins";
53
+ CustomClientMetadataKey["IdTokenTtl"] = "idTokenTtl";
54
+ CustomClientMetadataKey["RefreshTokenTtl"] = "refreshTokenTtl";
55
+ })(CustomClientMetadataKey = exports.CustomClientMetadataKey || (exports.CustomClientMetadataKey = {}));
56
+ exports.customClientMetadataGuard = zod_1.z.object({
57
+ [CustomClientMetadataKey.CorsAllowedOrigins]: zod_1.z.string().url().array().optional(),
58
+ [CustomClientMetadataKey.IdTokenTtl]: zod_1.z.number().optional(),
59
+ [CustomClientMetadataKey.RefreshTokenTtl]: zod_1.z.number().optional(),
60
+ });
61
+ /**
62
+ * Users
63
+ */
64
+ exports.roleNamesGuard = zod_1.z.string().array();
65
+ const identityGuard = zod_1.z.object({
66
+ userId: zod_1.z.string(),
67
+ details: zod_1.z.object({}).optional(), // Connector's userinfo details, schemaless
68
+ });
69
+ exports.identitiesGuard = zod_1.z.record(identityGuard);
70
+ /**
71
+ * SignIn Experiences
72
+ */
73
+ exports.colorGuard = zod_1.z.object({
74
+ primaryColor: zod_1.z.string().regex(core_kit_1.hexColorRegEx),
75
+ isDarkModeEnabled: zod_1.z.boolean(),
76
+ darkPrimaryColor: zod_1.z.string().regex(core_kit_1.hexColorRegEx),
77
+ });
78
+ var BrandingStyle;
79
+ (function (BrandingStyle) {
80
+ BrandingStyle["Logo"] = "Logo";
81
+ BrandingStyle["Logo_Slogan"] = "Logo_Slogan";
82
+ })(BrandingStyle = exports.BrandingStyle || (exports.BrandingStyle = {}));
83
+ exports.brandingGuard = zod_1.z.object({
84
+ style: zod_1.z.nativeEnum(BrandingStyle),
85
+ logoUrl: zod_1.z.string().url(),
86
+ darkLogoUrl: zod_1.z.string().url().optional(),
87
+ slogan: zod_1.z.string().optional(),
88
+ });
89
+ exports.termsOfUseGuard = zod_1.z.object({
90
+ enabled: zod_1.z.boolean(),
91
+ contentUrl: zod_1.z.string().url().optional().or(zod_1.z.literal('')),
92
+ });
93
+ exports.languageInfoGuard = zod_1.z.object({
94
+ autoDetect: zod_1.z.boolean(),
95
+ fallbackLanguage: language_kit_1.languageTagGuard,
96
+ });
97
+ var SignInMethodKey;
98
+ (function (SignInMethodKey) {
99
+ SignInMethodKey["Username"] = "username";
100
+ SignInMethodKey["Email"] = "email";
101
+ SignInMethodKey["Sms"] = "sms";
102
+ SignInMethodKey["Social"] = "social";
103
+ })(SignInMethodKey = exports.SignInMethodKey || (exports.SignInMethodKey = {}));
104
+ var SignInMethodState;
105
+ (function (SignInMethodState) {
106
+ SignInMethodState["Primary"] = "primary";
107
+ SignInMethodState["Secondary"] = "secondary";
108
+ SignInMethodState["Disabled"] = "disabled";
109
+ })(SignInMethodState = exports.SignInMethodState || (exports.SignInMethodState = {}));
110
+ exports.signInMethodsGuard = zod_1.z.object({
111
+ [SignInMethodKey.Username]: zod_1.z.nativeEnum(SignInMethodState),
112
+ [SignInMethodKey.Email]: zod_1.z.nativeEnum(SignInMethodState),
113
+ [SignInMethodKey.Sms]: zod_1.z.nativeEnum(SignInMethodState),
114
+ [SignInMethodKey.Social]: zod_1.z.nativeEnum(SignInMethodState),
115
+ });
116
+ exports.connectorTargetsGuard = zod_1.z.string().array();
117
+ /**
118
+ * Settings
119
+ */
120
+ var AppearanceMode;
121
+ (function (AppearanceMode) {
122
+ AppearanceMode["SyncWithSystem"] = "system";
123
+ AppearanceMode["LightMode"] = "light";
124
+ AppearanceMode["DarkMode"] = "dark";
125
+ })(AppearanceMode = exports.AppearanceMode || (exports.AppearanceMode = {}));
126
+ exports.adminConsoleConfigGuard = zod_1.z.object({
127
+ // Get started challenges
128
+ demoChecked: zod_1.z.boolean(),
129
+ applicationCreated: zod_1.z.boolean(),
130
+ signInExperienceCustomized: zod_1.z.boolean(),
131
+ passwordlessConfigured: zod_1.z.boolean(),
132
+ socialSignInConfigured: zod_1.z.boolean(),
133
+ furtherReadingsChecked: zod_1.z.boolean(),
134
+ });
135
+ exports.translationGuard = zod_1.z.lazy(() => zod_1.z.record(zod_1.z.string().or(exports.translationGuard)));
@@ -0,0 +1,24 @@
1
+ import { ZodObject, ZodType, ZodOptional } from 'zod';
2
+ declare type ParseOptional<K> = undefined extends K ? ZodOptional<ZodType<Exclude<K, undefined>>> : ZodType<K>;
3
+ export declare type CreateGuard<T extends Record<string, unknown>> = ZodObject<{
4
+ [key in keyof T]-?: ParseOptional<T[key]>;
5
+ }>;
6
+ export declare type Guard<T extends Record<string, unknown>> = ZodObject<{
7
+ [key in keyof T]: ZodType<T[key]>;
8
+ }>;
9
+ export declare type SchemaValuePrimitive = string | number | boolean | undefined;
10
+ export declare type SchemaValue = SchemaValuePrimitive | Record<string, unknown> | unknown[] | null;
11
+ export declare type SchemaLike<Key extends string = string> = {
12
+ [key in Key]: SchemaValue;
13
+ };
14
+ export declare type GeneratedSchema<Schema extends SchemaLike> = keyof Schema extends string ? Readonly<{
15
+ table: string;
16
+ tableSingular: string;
17
+ fields: {
18
+ [key in keyof Required<Schema>]: string;
19
+ };
20
+ fieldKeys: ReadonlyArray<keyof Schema>;
21
+ createGuard: CreateGuard<Schema>;
22
+ guard: Guard<Schema>;
23
+ }> : never;
24
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './foundations';
2
+ export * from './db-entries';
3
+ export * from './types';
4
+ export * from './api';
5
+ export * as seeds from './seeds';
package/lib/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.seeds = void 0;
30
+ __exportStar(require("./foundations"), exports);
31
+ __exportStar(require("./db-entries"), exports);
32
+ __exportStar(require("./types"), exports);
33
+ __exportStar(require("./api"), exports);
34
+ exports.seeds = __importStar(require("./seeds"));
@@ -0,0 +1,9 @@
1
+ import { CreateApplication } from '../db-entries';
2
+ /**
3
+ * The fixed application ID for Admin Console.
4
+ *
5
+ * This built-in application does not belong to any tenant in the OSS version.
6
+ */
7
+ export declare const adminConsoleApplicationId = "admin-console";
8
+ export declare const demoAppApplicationId = "demo-app";
9
+ export declare const createDemoAppApplication: (secret: string) => Readonly<CreateApplication>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDemoAppApplication = exports.demoAppApplicationId = exports.adminConsoleApplicationId = void 0;
4
+ const db_entries_1 = require("../db-entries");
5
+ /**
6
+ * The fixed application ID for Admin Console.
7
+ *
8
+ * This built-in application does not belong to any tenant in the OSS version.
9
+ */
10
+ exports.adminConsoleApplicationId = 'admin-console';
11
+ exports.demoAppApplicationId = 'demo-app';
12
+ const createDemoAppApplication = (secret) => ({
13
+ id: exports.demoAppApplicationId,
14
+ secret,
15
+ name: 'Demo App',
16
+ description: 'Logto demo app.',
17
+ type: db_entries_1.ApplicationType.SPA,
18
+ oidcClientMetadata: { redirectUris: [], postLogoutRedirectUris: [] },
19
+ });
20
+ exports.createDemoAppApplication = createDemoAppApplication;
@@ -0,0 +1,5 @@
1
+ export * from './application';
2
+ export * from './resource';
3
+ export * from './setting';
4
+ export * from './sign-in-experience';
5
+ export * from './roles';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./application"), exports);
18
+ __exportStar(require("./resource"), exports);
19
+ __exportStar(require("./setting"), exports);
20
+ __exportStar(require("./sign-in-experience"), exports);
21
+ __exportStar(require("./roles"), exports);
@@ -0,0 +1,2 @@
1
+ import { CreateResource } from '../db-entries';
2
+ export declare const managementResource: Readonly<CreateResource>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.managementResource = void 0;
4
+ exports.managementResource = Object.freeze({
5
+ id: 'management-api',
6
+ /**
7
+ * The fixed resource indicator for Management APIs.
8
+ *
9
+ * Admin Console requires the access token of this resource to be functional.
10
+ */
11
+ indicator: 'https://api.logto.io',
12
+ name: 'Logto Management API',
13
+ });
@@ -0,0 +1,5 @@
1
+ import { CreateRole } from '../db-entries';
2
+ /**
3
+ * Default Admin Role for Admin Console.
4
+ */
5
+ export declare const defaultRole: Readonly<CreateRole>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultRole = void 0;
4
+ const types_1 = require("../types");
5
+ /**
6
+ * Default Admin Role for Admin Console.
7
+ */
8
+ exports.defaultRole = {
9
+ name: types_1.UserRole.Admin,
10
+ description: 'Admin role for Logto.',
11
+ };
@@ -0,0 +1,3 @@
1
+ import { CreateSetting } from '../db-entries';
2
+ export declare const defaultSettingId = "default";
3
+ export declare const createDefaultSetting: () => Readonly<CreateSetting>;