@logto/schemas 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/alterations/1.21.0-1728357690-add-sso-connector-idp-initated-auth-configs-table.ts +40 -0
  2. package/alterations/1.21.0-1728526649-add-idp-initiated-saml-sso-sessions-table.ts +36 -0
  3. package/alterations/1.21.0-1728887713-add-client-idp-initiated-auth-callback-uri-columns.ts +40 -0
  4. package/alterations-js/1.21.0-1728357690-add-sso-connector-idp-initated-auth-configs-table.js +35 -0
  5. package/alterations-js/1.21.0-1728526649-add-idp-initiated-saml-sso-sessions-table.js +31 -0
  6. package/alterations-js/1.21.0-1728887713-add-client-idp-initiated-auth-callback-uri-columns.js +36 -0
  7. package/lib/db-entries/idp-initiated-saml-sso-session.d.ts +32 -0
  8. package/lib/db-entries/idp-initiated-saml-sso-session.js +42 -0
  9. package/lib/db-entries/index.d.ts +2 -0
  10. package/lib/db-entries/index.js +2 -0
  11. package/lib/db-entries/sso-connector-idp-initiated-auth-config.d.ts +42 -0
  12. package/lib/db-entries/sso-connector-idp-initiated-auth-config.js +50 -0
  13. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +3 -0
  14. package/lib/foundations/jsonb-types/sign-in-experience.js +4 -0
  15. package/lib/foundations/jsonb-types/sso-connector.d.ts +49 -0
  16. package/lib/foundations/jsonb-types/sso-connector.js +17 -0
  17. package/lib/types/consent.d.ts +2 -2
  18. package/lib/types/interactions.d.ts +17 -3
  19. package/lib/types/interactions.js +5 -1
  20. package/lib/types/log/interaction.d.ts +1 -1
  21. package/lib/types/sso-connector.d.ts +3 -0
  22. package/lib/types/sso-connector.js +4 -0
  23. package/lib/types/system.d.ts +20 -3
  24. package/lib/types/system.js +13 -0
  25. package/package.json +3 -3
  26. package/tables/idp_initiated_saml_sso_sessions.sql +16 -0
  27. package/tables/sso_connector_idp_initiated_auth_configs.sql +24 -0
@@ -0,0 +1,40 @@
1
+ import { sql } from '@silverhand/slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
6
+
7
+ const alteration: AlterationScript = {
8
+ up: async (pool) => {
9
+ await pool.query(sql`
10
+ create table sso_connector_idp_initiated_auth_configs (
11
+ tenant_id varchar(21) not null
12
+ references tenants (id) on update cascade on delete cascade,
13
+ /** The globally unique identifier of the SSO connector. */
14
+ connector_id varchar(128) not null
15
+ references sso_connectors (id) on update cascade on delete cascade,
16
+ /** The default Logto application id. */
17
+ default_application_id varchar(21) not null
18
+ references applications (id) on update cascade on delete cascade,
19
+ /** OIDC sign-in redirect URI. */
20
+ redirect_uri text,
21
+ /** Additional OIDC auth parameters. */
22
+ auth_parameters jsonb /* @use IdpInitiatedAuthParams */ not null default '{}'::jsonb,
23
+ created_at timestamptz not null default(now()),
24
+ primary key (tenant_id, connector_id),
25
+ /** Insure the application type is Traditional. */
26
+ constraint application_type
27
+ check (check_application_type(default_application_id, 'Traditional'))
28
+ );
29
+ `);
30
+ await applyTableRls(pool, 'sso_connector_idp_initiated_auth_configs');
31
+ },
32
+ down: async (pool) => {
33
+ await dropTableRls(pool, 'sso_connector_idp_initiated_auth_configs');
34
+ await pool.query(sql`
35
+ drop table sso_connector_idp_initiated_auth_configs;
36
+ `);
37
+ },
38
+ };
39
+
40
+ export default alteration;
@@ -0,0 +1,36 @@
1
+ import { sql } from '@silverhand/slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
6
+
7
+ const alteration: AlterationScript = {
8
+ up: async (pool) => {
9
+ await pool.query(sql`
10
+ create table idp_initiated_saml_sso_sessions (
11
+ tenant_id varchar(21) not null
12
+ references tenants (id) on update cascade on delete cascade,
13
+ /** The globally unique identifier of the assertion record. */
14
+ id varchar(21) not null,
15
+ /** The identifier of the SAML SSO connector. */
16
+ connector_id varchar(128) not null
17
+ references sso_connectors (id) on update cascade on delete cascade,
18
+ /** The SAML assertion. */
19
+ assertion_content jsonb /* @use SsoSamlAssertionContent */ not null default '{}'::jsonb,
20
+ created_at timestamptz not null default(now()),
21
+ /** The expiration time of the assertion. */
22
+ expires_at timestamptz not null,
23
+ primary key (tenant_id, id)
24
+ );
25
+ `);
26
+ await applyTableRls(pool, 'idp_initiated_saml_sso_sessions');
27
+ },
28
+ down: async (pool) => {
29
+ await dropTableRls(pool, 'idp_initiated_saml_sso_sessions');
30
+ await pool.query(sql`
31
+ drop table idp_initiated_saml_sso_sessions;
32
+ `);
33
+ },
34
+ };
35
+
36
+ export default alteration;
@@ -0,0 +1,40 @@
1
+ import { sql } from '@silverhand/slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ const alteration: AlterationScript = {
6
+ up: async (pool) => {
7
+ await pool.query(sql`
8
+ alter table sso_connector_idp_initiated_auth_configs
9
+ add column client_idp_initiated_auth_callback_uri text;
10
+
11
+ alter table sso_connector_idp_initiated_auth_configs
12
+ add column auto_send_authorization_request boolean not null default false;
13
+
14
+ alter table sso_connector_idp_initiated_auth_configs
15
+ drop constraint application_type;
16
+
17
+ alter table sso_connector_idp_initiated_auth_configs
18
+ add constraint application_type
19
+ check (check_application_type(default_application_id, 'Traditional', 'SPA'));
20
+ `);
21
+ },
22
+ down: async (pool) => {
23
+ await pool.query(sql`
24
+ alter table sso_connector_idp_initiated_auth_configs
25
+ drop constraint application_type;
26
+
27
+ alter table sso_connector_idp_initiated_auth_configs
28
+ drop column client_idp_initiated_auth_callback_uri;
29
+
30
+ alter table sso_connector_idp_initiated_auth_configs
31
+ drop column auto_send_authorization_request;
32
+
33
+ alter table sso_connector_idp_initiated_auth_configs
34
+ add constraint application_type
35
+ check (check_application_type(default_application_id, 'Traditional'));
36
+ `);
37
+ },
38
+ };
39
+
40
+ export default alteration;
@@ -0,0 +1,35 @@
1
+ import { sql } from '@silverhand/slonik';
2
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
3
+ const alteration = {
4
+ up: async (pool) => {
5
+ await pool.query(sql `
6
+ create table sso_connector_idp_initiated_auth_configs (
7
+ tenant_id varchar(21) not null
8
+ references tenants (id) on update cascade on delete cascade,
9
+ /** The globally unique identifier of the SSO connector. */
10
+ connector_id varchar(128) not null
11
+ references sso_connectors (id) on update cascade on delete cascade,
12
+ /** The default Logto application id. */
13
+ default_application_id varchar(21) not null
14
+ references applications (id) on update cascade on delete cascade,
15
+ /** OIDC sign-in redirect URI. */
16
+ redirect_uri text,
17
+ /** Additional OIDC auth parameters. */
18
+ auth_parameters jsonb /* @use IdpInitiatedAuthParams */ not null default '{}'::jsonb,
19
+ created_at timestamptz not null default(now()),
20
+ primary key (tenant_id, connector_id),
21
+ /** Insure the application type is Traditional. */
22
+ constraint application_type
23
+ check (check_application_type(default_application_id, 'Traditional'))
24
+ );
25
+ `);
26
+ await applyTableRls(pool, 'sso_connector_idp_initiated_auth_configs');
27
+ },
28
+ down: async (pool) => {
29
+ await dropTableRls(pool, 'sso_connector_idp_initiated_auth_configs');
30
+ await pool.query(sql `
31
+ drop table sso_connector_idp_initiated_auth_configs;
32
+ `);
33
+ },
34
+ };
35
+ export default alteration;
@@ -0,0 +1,31 @@
1
+ import { sql } from '@silverhand/slonik';
2
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
3
+ const alteration = {
4
+ up: async (pool) => {
5
+ await pool.query(sql `
6
+ create table idp_initiated_saml_sso_sessions (
7
+ tenant_id varchar(21) not null
8
+ references tenants (id) on update cascade on delete cascade,
9
+ /** The globally unique identifier of the assertion record. */
10
+ id varchar(21) not null,
11
+ /** The identifier of the SAML SSO connector. */
12
+ connector_id varchar(128) not null
13
+ references sso_connectors (id) on update cascade on delete cascade,
14
+ /** The SAML assertion. */
15
+ assertion_content jsonb /* @use SsoSamlAssertionContent */ not null default '{}'::jsonb,
16
+ created_at timestamptz not null default(now()),
17
+ /** The expiration time of the assertion. */
18
+ expires_at timestamptz not null,
19
+ primary key (tenant_id, id)
20
+ );
21
+ `);
22
+ await applyTableRls(pool, 'idp_initiated_saml_sso_sessions');
23
+ },
24
+ down: async (pool) => {
25
+ await dropTableRls(pool, 'idp_initiated_saml_sso_sessions');
26
+ await pool.query(sql `
27
+ drop table idp_initiated_saml_sso_sessions;
28
+ `);
29
+ },
30
+ };
31
+ export default alteration;
@@ -0,0 +1,36 @@
1
+ import { sql } from '@silverhand/slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ alter table sso_connector_idp_initiated_auth_configs
6
+ add column client_idp_initiated_auth_callback_uri text;
7
+
8
+ alter table sso_connector_idp_initiated_auth_configs
9
+ add column auto_send_authorization_request boolean not null default false;
10
+
11
+ alter table sso_connector_idp_initiated_auth_configs
12
+ drop constraint application_type;
13
+
14
+ alter table sso_connector_idp_initiated_auth_configs
15
+ add constraint application_type
16
+ check (check_application_type(default_application_id, 'Traditional', 'SPA'));
17
+ `);
18
+ },
19
+ down: async (pool) => {
20
+ await pool.query(sql `
21
+ alter table sso_connector_idp_initiated_auth_configs
22
+ drop constraint application_type;
23
+
24
+ alter table sso_connector_idp_initiated_auth_configs
25
+ drop column client_idp_initiated_auth_callback_uri;
26
+
27
+ alter table sso_connector_idp_initiated_auth_configs
28
+ drop column auto_send_authorization_request;
29
+
30
+ alter table sso_connector_idp_initiated_auth_configs
31
+ add constraint application_type
32
+ check (check_application_type(default_application_id, 'Traditional'));
33
+ `);
34
+ },
35
+ };
36
+ export default alteration;
@@ -0,0 +1,32 @@
1
+ import { SsoSamlAssertionContent, GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ *
4
+ * @remarks This is a type for database creation.
5
+ * @see {@link IdpInitiatedSamlSsoSession} for the original type.
6
+ */
7
+ export type CreateIdpInitiatedSamlSsoSession = {
8
+ tenantId?: string;
9
+ /** The globally unique identifier of the assertion record. */
10
+ id: string;
11
+ /** The identifier of the SAML SSO connector. */
12
+ connectorId: string;
13
+ /** The SAML assertion. */
14
+ assertionContent?: SsoSamlAssertionContent;
15
+ createdAt?: number;
16
+ /** The expiration time of the assertion. */
17
+ expiresAt: number;
18
+ };
19
+ export type IdpInitiatedSamlSsoSession = {
20
+ tenantId: string;
21
+ /** The globally unique identifier of the assertion record. */
22
+ id: string;
23
+ /** The identifier of the SAML SSO connector. */
24
+ connectorId: string;
25
+ /** The SAML assertion. */
26
+ assertionContent: SsoSamlAssertionContent;
27
+ createdAt: number;
28
+ /** The expiration time of the assertion. */
29
+ expiresAt: number;
30
+ };
31
+ export type IdpInitiatedSamlSsoSessionKeys = 'tenantId' | 'id' | 'connectorId' | 'assertionContent' | 'createdAt' | 'expiresAt';
32
+ export declare const IdpInitiatedSamlSsoSessions: GeneratedSchema<IdpInitiatedSamlSsoSessionKeys, CreateIdpInitiatedSamlSsoSession, IdpInitiatedSamlSsoSession, 'idp_initiated_saml_sso_sessions', 'idp_initiated_saml_sso_session'>;
@@ -0,0 +1,42 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ import { ssoSamlAssertionContentGuard } from './../foundations/index.js';
4
+ const createGuard = z.object({
5
+ tenantId: z.string().max(21).optional(),
6
+ id: z.string().min(1).max(21),
7
+ connectorId: z.string().min(1).max(128),
8
+ assertionContent: ssoSamlAssertionContentGuard.optional(),
9
+ createdAt: z.number().optional(),
10
+ expiresAt: z.number(),
11
+ });
12
+ const guard = z.object({
13
+ tenantId: z.string().max(21),
14
+ id: z.string().min(1).max(21),
15
+ connectorId: z.string().min(1).max(128),
16
+ assertionContent: ssoSamlAssertionContentGuard,
17
+ createdAt: z.number(),
18
+ expiresAt: z.number(),
19
+ });
20
+ export const IdpInitiatedSamlSsoSessions = Object.freeze({
21
+ table: 'idp_initiated_saml_sso_sessions',
22
+ tableSingular: 'idp_initiated_saml_sso_session',
23
+ fields: {
24
+ tenantId: 'tenant_id',
25
+ id: 'id',
26
+ connectorId: 'connector_id',
27
+ assertionContent: 'assertion_content',
28
+ createdAt: 'created_at',
29
+ expiresAt: 'expires_at',
30
+ },
31
+ fieldKeys: [
32
+ 'tenantId',
33
+ 'id',
34
+ 'connectorId',
35
+ 'assertionContent',
36
+ 'createdAt',
37
+ 'expiresAt',
38
+ ],
39
+ createGuard,
40
+ guard,
41
+ updateGuard: guard.partial(),
42
+ });
@@ -18,6 +18,7 @@ export * from './daily-active-user.js';
18
18
  export * from './daily-token-usage.js';
19
19
  export * from './domain.js';
20
20
  export * from './hook.js';
21
+ export * from './idp-initiated-saml-sso-session.js';
21
22
  export * from './log.js';
22
23
  export * from './logto-config.js';
23
24
  export * from './oidc-model-instance.js';
@@ -44,6 +45,7 @@ export * from './scope.js';
44
45
  export * from './sentinel-activity.js';
45
46
  export * from './service-log.js';
46
47
  export * from './sign-in-experience.js';
48
+ export * from './sso-connector-idp-initiated-auth-config.js';
47
49
  export * from './sso-connector.js';
48
50
  export * from './subject-token.js';
49
51
  export * from './system.js';
@@ -19,6 +19,7 @@ export * from './daily-active-user.js';
19
19
  export * from './daily-token-usage.js';
20
20
  export * from './domain.js';
21
21
  export * from './hook.js';
22
+ export * from './idp-initiated-saml-sso-session.js';
22
23
  export * from './log.js';
23
24
  export * from './logto-config.js';
24
25
  export * from './oidc-model-instance.js';
@@ -45,6 +46,7 @@ export * from './scope.js';
45
46
  export * from './sentinel-activity.js';
46
47
  export * from './service-log.js';
47
48
  export * from './sign-in-experience.js';
49
+ export * from './sso-connector-idp-initiated-auth-config.js';
48
50
  export * from './sso-connector.js';
49
51
  export * from './subject-token.js';
50
52
  export * from './system.js';
@@ -0,0 +1,42 @@
1
+ import { IdpInitiatedAuthParams, GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * init_order = 2
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link SsoConnectorIdpInitiatedAuthConfig} for the original type.
7
+ */
8
+ export type CreateSsoConnectorIdpInitiatedAuthConfig = {
9
+ tenantId?: string;
10
+ /** The globally unique identifier of the SSO connector. */
11
+ connectorId: string;
12
+ /** The default Logto application id. */
13
+ defaultApplicationId: string;
14
+ /** OIDC sign-in redirect URI. */
15
+ redirectUri?: string | null;
16
+ /** Additional OIDC auth parameters. */
17
+ authParameters?: IdpInitiatedAuthParams;
18
+ /** Whether to auto-trigger the auth flow on an IdP-initiated auth request. */
19
+ autoSendAuthorizationRequest?: boolean;
20
+ /** The client side callback URI for handling IdP-initiated auth request. */
21
+ clientIdpInitiatedAuthCallbackUri?: string | null;
22
+ createdAt?: number;
23
+ };
24
+ /** init_order = 2 */
25
+ export type SsoConnectorIdpInitiatedAuthConfig = {
26
+ tenantId: string;
27
+ /** The globally unique identifier of the SSO connector. */
28
+ connectorId: string;
29
+ /** The default Logto application id. */
30
+ defaultApplicationId: string;
31
+ /** OIDC sign-in redirect URI. */
32
+ redirectUri: string | null;
33
+ /** Additional OIDC auth parameters. */
34
+ authParameters: IdpInitiatedAuthParams;
35
+ /** Whether to auto-trigger the auth flow on an IdP-initiated auth request. */
36
+ autoSendAuthorizationRequest: boolean;
37
+ /** The client side callback URI for handling IdP-initiated auth request. */
38
+ clientIdpInitiatedAuthCallbackUri: string | null;
39
+ createdAt: number;
40
+ };
41
+ export type SsoConnectorIdpInitiatedAuthConfigKeys = 'tenantId' | 'connectorId' | 'defaultApplicationId' | 'redirectUri' | 'authParameters' | 'autoSendAuthorizationRequest' | 'clientIdpInitiatedAuthCallbackUri' | 'createdAt';
42
+ export declare const SsoConnectorIdpInitiatedAuthConfigs: GeneratedSchema<SsoConnectorIdpInitiatedAuthConfigKeys, CreateSsoConnectorIdpInitiatedAuthConfig, SsoConnectorIdpInitiatedAuthConfig, 'sso_connector_idp_initiated_auth_configs', 'sso_connector_idp_initiated_auth_config'>;
@@ -0,0 +1,50 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ import { idpInitiatedAuthParamsGuard } from './../foundations/index.js';
4
+ const createGuard = z.object({
5
+ tenantId: z.string().max(21).optional(),
6
+ connectorId: z.string().min(1).max(128),
7
+ defaultApplicationId: z.string().min(1).max(21),
8
+ redirectUri: z.string().nullable().optional(),
9
+ authParameters: idpInitiatedAuthParamsGuard.optional(),
10
+ autoSendAuthorizationRequest: z.boolean().optional(),
11
+ clientIdpInitiatedAuthCallbackUri: z.string().nullable().optional(),
12
+ createdAt: z.number().optional(),
13
+ });
14
+ const guard = z.object({
15
+ tenantId: z.string().max(21),
16
+ connectorId: z.string().min(1).max(128),
17
+ defaultApplicationId: z.string().min(1).max(21),
18
+ redirectUri: z.string().nullable(),
19
+ authParameters: idpInitiatedAuthParamsGuard,
20
+ autoSendAuthorizationRequest: z.boolean(),
21
+ clientIdpInitiatedAuthCallbackUri: z.string().nullable(),
22
+ createdAt: z.number(),
23
+ });
24
+ export const SsoConnectorIdpInitiatedAuthConfigs = Object.freeze({
25
+ table: 'sso_connector_idp_initiated_auth_configs',
26
+ tableSingular: 'sso_connector_idp_initiated_auth_config',
27
+ fields: {
28
+ tenantId: 'tenant_id',
29
+ connectorId: 'connector_id',
30
+ defaultApplicationId: 'default_application_id',
31
+ redirectUri: 'redirect_uri',
32
+ authParameters: 'auth_parameters',
33
+ autoSendAuthorizationRequest: 'auto_send_authorization_request',
34
+ clientIdpInitiatedAuthCallbackUri: 'client_idp_initiated_auth_callback_uri',
35
+ createdAt: 'created_at',
36
+ },
37
+ fieldKeys: [
38
+ 'tenantId',
39
+ 'connectorId',
40
+ 'defaultApplicationId',
41
+ 'redirectUri',
42
+ 'authParameters',
43
+ 'autoSendAuthorizationRequest',
44
+ 'clientIdpInitiatedAuthCallbackUri',
45
+ 'createdAt',
46
+ ],
47
+ createGuard,
48
+ guard,
49
+ updateGuard: guard.partial(),
50
+ });
@@ -66,6 +66,9 @@ export declare enum SignInIdentifier {
66
66
  Phone = "phone"
67
67
  }
68
68
  export declare const signInIdentifierGuard: z.ZodNativeEnum<typeof SignInIdentifier>;
69
+ export declare enum AdditionalIdentifier {
70
+ UserId = "userId"
71
+ }
69
72
  export declare const signUpGuard: z.ZodObject<{
70
73
  identifiers: z.ZodArray<z.ZodNativeEnum<typeof SignInIdentifier>, "many">;
71
74
  password: z.ZodBoolean;
@@ -32,6 +32,10 @@ export var SignInIdentifier;
32
32
  SignInIdentifier["Phone"] = "phone";
33
33
  })(SignInIdentifier || (SignInIdentifier = {}));
34
34
  export const signInIdentifierGuard = z.nativeEnum(SignInIdentifier);
35
+ export var AdditionalIdentifier;
36
+ (function (AdditionalIdentifier) {
37
+ AdditionalIdentifier["UserId"] = "userId";
38
+ })(AdditionalIdentifier || (AdditionalIdentifier = {}));
35
39
  export const signUpGuard = z.object({
36
40
  identifiers: z.nativeEnum(SignInIdentifier).array(),
37
41
  password: z.boolean(),
@@ -15,3 +15,52 @@ export declare const ssoBrandingGuard: z.ZodObject<{
15
15
  darkLogo?: string | undefined;
16
16
  }>;
17
17
  export type SsoBranding = z.infer<typeof ssoBrandingGuard>;
18
+ export declare const idpInitiatedAuthParamsGuard: z.ZodObject<{
19
+ scope: z.ZodOptional<z.ZodString>;
20
+ }, "strip", z.ZodString, z.objectOutputType<{
21
+ scope: z.ZodOptional<z.ZodString>;
22
+ }, z.ZodString, "strip">, z.objectInputType<{
23
+ scope: z.ZodOptional<z.ZodString>;
24
+ }, z.ZodString, "strip">>;
25
+ export type IdpInitiatedAuthParams = z.infer<typeof idpInitiatedAuthParamsGuard>;
26
+ export declare const ssoSamlAssertionContentGuard: z.ZodObject<{
27
+ nameID: z.ZodOptional<z.ZodString>;
28
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
29
+ conditions: z.ZodOptional<z.ZodObject<{
30
+ notBefore: z.ZodOptional<z.ZodString>;
31
+ notOnOrAfter: z.ZodOptional<z.ZodString>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ notBefore?: string | undefined;
34
+ notOnOrAfter?: string | undefined;
35
+ }, {
36
+ notBefore?: string | undefined;
37
+ notOnOrAfter?: string | undefined;
38
+ }>>;
39
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
40
+ nameID: z.ZodOptional<z.ZodString>;
41
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
42
+ conditions: z.ZodOptional<z.ZodObject<{
43
+ notBefore: z.ZodOptional<z.ZodString>;
44
+ notOnOrAfter: z.ZodOptional<z.ZodString>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ notBefore?: string | undefined;
47
+ notOnOrAfter?: string | undefined;
48
+ }, {
49
+ notBefore?: string | undefined;
50
+ notOnOrAfter?: string | undefined;
51
+ }>>;
52
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
53
+ nameID: z.ZodOptional<z.ZodString>;
54
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
55
+ conditions: z.ZodOptional<z.ZodObject<{
56
+ notBefore: z.ZodOptional<z.ZodString>;
57
+ notOnOrAfter: z.ZodOptional<z.ZodString>;
58
+ }, "strip", z.ZodTypeAny, {
59
+ notBefore?: string | undefined;
60
+ notOnOrAfter?: string | undefined;
61
+ }, {
62
+ notBefore?: string | undefined;
63
+ notOnOrAfter?: string | undefined;
64
+ }>>;
65
+ }, z.ZodUnknown, "strip">>;
66
+ export type SsoSamlAssertionContent = z.infer<typeof ssoSamlAssertionContentGuard>;
@@ -5,3 +5,20 @@ export const ssoBrandingGuard = z.object({
5
5
  logo: z.string().optional(),
6
6
  darkLogo: z.string().optional(),
7
7
  });
8
+ export const idpInitiatedAuthParamsGuard = z
9
+ .object({
10
+ scope: z.string().optional(),
11
+ })
12
+ .catchall(z.string());
13
+ export const ssoSamlAssertionContentGuard = z
14
+ .object({
15
+ nameID: z.string().optional(),
16
+ attributes: z.record(z.string().or(z.array(z.string()))).optional(),
17
+ conditions: z
18
+ .object({
19
+ notBefore: z.string().optional(),
20
+ notOnOrAfter: z.string().optional(),
21
+ })
22
+ .optional(),
23
+ })
24
+ .catchall(z.unknown());
@@ -882,6 +882,7 @@ export declare const consentInfoResponseGuard: z.ZodObject<{
882
882
  termsOfUseUrl?: string | null | undefined;
883
883
  privacyPolicyUrl?: string | null | undefined;
884
884
  };
885
+ redirectUri: string;
885
886
  user: {
886
887
  name: string | null;
887
888
  id: string;
@@ -890,7 +891,6 @@ export declare const consentInfoResponseGuard: z.ZodObject<{
890
891
  primaryPhone: string | null;
891
892
  avatar: string | null;
892
893
  };
893
- redirectUri: string;
894
894
  organizations?: {
895
895
  name: string;
896
896
  id: string;
@@ -934,6 +934,7 @@ export declare const consentInfoResponseGuard: z.ZodObject<{
934
934
  termsOfUseUrl?: string | null | undefined;
935
935
  privacyPolicyUrl?: string | null | undefined;
936
936
  };
937
+ redirectUri: string;
937
938
  user: {
938
939
  name: string | null;
939
940
  id: string;
@@ -942,7 +943,6 @@ export declare const consentInfoResponseGuard: z.ZodObject<{
942
943
  primaryPhone: string | null;
943
944
  avatar: string | null;
944
945
  };
945
- redirectUri: string;
946
946
  organizations?: {
947
947
  name: string;
948
948
  id: string;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { MfaFactor, SignInIdentifier } from '../foundations/index.js';
2
+ import { AdditionalIdentifier, MfaFactor, SignInIdentifier } from '../foundations/index.js';
3
3
  import type { EmailVerificationCodePayload, PhoneVerificationCodePayload } from './verification-code.js';
4
4
  /**
5
5
  * User interaction events defined in Logto RFC 0004.
@@ -10,6 +10,20 @@ export declare enum InteractionEvent {
10
10
  Register = "Register",
11
11
  ForgotPassword = "ForgotPassword"
12
12
  }
13
+ export type VerificationIdentifier = {
14
+ type: SignInIdentifier | AdditionalIdentifier;
15
+ value: string;
16
+ };
17
+ export declare const verificationIdentifierGuard: z.ZodObject<{
18
+ type: z.ZodUnion<[z.ZodNativeEnum<typeof SignInIdentifier>, z.ZodNativeEnum<typeof AdditionalIdentifier>]>;
19
+ value: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: SignInIdentifier | AdditionalIdentifier;
22
+ value: string;
23
+ }, {
24
+ type: SignInIdentifier | AdditionalIdentifier;
25
+ value: string;
26
+ }>;
13
27
  /** Identifiers that can be used to uniquely identify a user. */
14
28
  export type InteractionIdentifier<T extends SignInIdentifier = SignInIdentifier> = {
15
29
  type: T;
@@ -50,11 +64,11 @@ export declare const socialAuthorizationUrlPayloadGuard: z.ZodObject<{
50
64
  state: z.ZodString;
51
65
  redirectUri: z.ZodString;
52
66
  }, "strip", z.ZodTypeAny, {
53
- state: string;
54
67
  redirectUri: string;
55
- }, {
56
68
  state: string;
69
+ }, {
57
70
  redirectUri: string;
71
+ state: string;
58
72
  }>;
59
73
  /** Payload type for `POST /api/experience/verification/{social|sso}/:connectorId/verify`. */
60
74
  export type SocialVerificationCallbackPayload = {
@@ -1,6 +1,6 @@
1
1
  import { emailRegEx, phoneRegEx, usernameRegEx } from '@logto/core-kit';
2
2
  import { z } from 'zod';
3
- import { MfaFactor, SignInIdentifier, jsonObjectGuard, webAuthnTransportGuard, } from '../foundations/index.js';
3
+ import { AdditionalIdentifier, MfaFactor, SignInIdentifier, jsonObjectGuard, webAuthnTransportGuard, } from '../foundations/index.js';
4
4
  import { emailVerificationCodePayloadGuard, phoneVerificationCodePayloadGuard, } from './verification-code.js';
5
5
  /**
6
6
  * User interaction events defined in Logto RFC 0004.
@@ -12,6 +12,10 @@ export var InteractionEvent;
12
12
  InteractionEvent["Register"] = "Register";
13
13
  InteractionEvent["ForgotPassword"] = "ForgotPassword";
14
14
  })(InteractionEvent || (InteractionEvent = {}));
15
+ export const verificationIdentifierGuard = z.object({
16
+ type: z.union([z.nativeEnum(SignInIdentifier), z.nativeEnum(AdditionalIdentifier)]),
17
+ value: z.string(),
18
+ });
15
19
  export const interactionIdentifierGuard = z.object({
16
20
  type: z.nativeEnum(SignInIdentifier),
17
21
  value: z.string(),
@@ -67,4 +67,4 @@ export declare enum Action {
67
67
  * - When {@link Method} is `VerificationCode`, {@link Action} can be `Create` (generate and send a code) or `Submit` (verify and submit to the identifiers);
68
68
  * - Otherwise, {@link Action} is fixed to `Submit` (other methods can be verified on submitting).
69
69
  */
70
- export type LogKey = `${Prefix}.${Action.Create | Action.End}` | `${Prefix}.${InteractionEvent}.${Action.Create | Action.Update | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Profile}.${Action.Update | Action.Create | Action.Delete}` | `${Prefix}.${Exclude<InteractionEvent, InteractionEvent.ForgotPassword>}.${Field.Identifier}.${Exclude<Method, Method.Password>}.${Action.Create | Action.Submit}` | `${Prefix}.${Exclude<InteractionEvent, InteractionEvent.ForgotPassword>}.${Field.Identifier}.${Method.Password}.${Action.Submit}` | `${Prefix}.${InteractionEvent.ForgotPassword}.${Field.Identifier}.${Method.VerificationCode}.${Action.Create | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.BindMfa}.${MfaFactor}.${Action.Submit | Action.Create}` | `${Prefix}.${InteractionEvent.SignIn}.${Field.Mfa}.${MfaFactor}.${Action.Submit | Action.Create}` | `${Prefix}.${InteractionEvent}.${Field.Verification}.${VerificationType}.${Action}` | `${Prefix}.${InteractionEvent}.${Field.Identifier}.${Action.Submit}`;
70
+ export type LogKey = `${Prefix}.${Action.Create | Action.End}` | `${Prefix}.${InteractionEvent}.${Action.Create | Action.Update | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Profile}.${Action.Update | Action.Create | Action.Delete}` | `${Prefix}.${Exclude<InteractionEvent, InteractionEvent.ForgotPassword>}.${Field.Identifier}.${Exclude<Method, Method.Password>}.${Action.Create | Action.Submit}` | `${Prefix}.${Exclude<InteractionEvent, InteractionEvent.ForgotPassword>}.${Field.Identifier}.${Method.Password}.${Action.Submit}` | `${Prefix}.${InteractionEvent.ForgotPassword}.${Field.Identifier}.${Method.VerificationCode}.${Action.Create | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.BindMfa}.${MfaFactor}.${Action.Submit | Action.Create}` | `${Prefix}.${InteractionEvent.SignIn}.${Field.Mfa}.${MfaFactor}.${Action.Submit | Action.Create}` | `${Prefix}.${InteractionEvent}.${Field.Verification}.${VerificationType}.${Action}` | `${Prefix}.${InteractionEvent}.${Field.Identifier}.${Action.Submit}` | `${Prefix}.${InteractionEvent.SignIn}.${Field.Verification}.IdpInitiatedSso.${Action.Create}`;
@@ -140,4 +140,7 @@ export declare const ssoConnectorWithProviderConfigGuard: z.ZodObject<z.objectUt
140
140
  providerConfig?: Record<string, unknown> | undefined;
141
141
  }>;
142
142
  export type SsoConnectorWithProviderConfig = z.infer<typeof ssoConnectorWithProviderConfigGuard>;
143
+ export declare enum SsoAuthenticationQueryKey {
144
+ SsoConnectorId = "ssoConnectorId"
145
+ }
143
146
  export {};
@@ -69,3 +69,7 @@ z.object({
69
69
  // - SAML: connection config fetched from the metadata url or metadata file.
70
70
  providerConfig: z.record(z.unknown()).optional(),
71
71
  }));
72
+ export var SsoAuthenticationQueryKey;
73
+ (function (SsoAuthenticationQueryKey) {
74
+ SsoAuthenticationQueryKey["SsoConnectorId"] = "ssoConnectorId";
75
+ })(SsoAuthenticationQueryKey || (SsoAuthenticationQueryKey = {}));
@@ -250,8 +250,25 @@ export type CloudflareType = {
250
250
  export declare const cloudflareGuard: Readonly<{
251
251
  [key in CloudflareKey]: ZodType<CloudflareType[key]>;
252
252
  }>;
253
- export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey | CloudflareKey | EmailServiceProviderKey;
254
- export type SystemType = AlterationStateType | StorageProviderType | DemoSocialType | CloudflareType | EmailServiceProviderType;
255
- export type SystemGuard = typeof alterationStateGuard & typeof storageProviderGuard & typeof demoSocialGuard & typeof cloudflareGuard & typeof emailServiceProviderGuard;
253
+ export declare enum FeatureFlagConfigKey {
254
+ NewExperienceFeatureFlag = "newExperienceFeatureFlag"
255
+ }
256
+ export declare const featureFlagConfigGuard: z.ZodObject<{
257
+ percentage: z.ZodNumber;
258
+ }, "strip", z.ZodTypeAny, {
259
+ percentage: number;
260
+ }, {
261
+ percentage: number;
262
+ }>;
263
+ export type FeatureFlagConfig = z.infer<typeof featureFlagConfigGuard>;
264
+ export type FeatureFlagConfigType = {
265
+ [FeatureFlagConfigKey.NewExperienceFeatureFlag]: FeatureFlagConfig;
266
+ };
267
+ export declare const featureFlagConfigsGuard: Readonly<{
268
+ [key in FeatureFlagConfigKey]: ZodType<FeatureFlagConfigType[key]>;
269
+ }>;
270
+ export type SystemKey = AlterationStateKey | StorageProviderKey | DemoSocialKey | CloudflareKey | EmailServiceProviderKey | FeatureFlagConfigKey;
271
+ export type SystemType = AlterationStateType | StorageProviderType | DemoSocialType | CloudflareType | EmailServiceProviderType | FeatureFlagConfigType;
272
+ export type SystemGuard = typeof alterationStateGuard & typeof storageProviderGuard & typeof demoSocialGuard & typeof cloudflareGuard & typeof emailServiceProviderGuard & typeof featureFlagConfigsGuard;
256
273
  export declare const systemKeys: readonly SystemKey[];
257
274
  export declare const systemGuards: SystemGuard;
@@ -145,12 +145,24 @@ export const cloudflareGuard = Object.freeze({
145
145
  [CloudflareKey.ProtectedAppHostnameProvider]: hostnameProviderDataGuard,
146
146
  [CloudflareKey.CustomJwtWorkerConfig]: customJwtWorkerConfigGuard,
147
147
  });
148
+ // A/B Test settings
149
+ export var FeatureFlagConfigKey;
150
+ (function (FeatureFlagConfigKey) {
151
+ FeatureFlagConfigKey["NewExperienceFeatureFlag"] = "newExperienceFeatureFlag";
152
+ })(FeatureFlagConfigKey || (FeatureFlagConfigKey = {}));
153
+ export const featureFlagConfigGuard = z.object({
154
+ percentage: z.number().min(0).max(1),
155
+ });
156
+ export const featureFlagConfigsGuard = Object.freeze({
157
+ [FeatureFlagConfigKey.NewExperienceFeatureFlag]: featureFlagConfigGuard,
158
+ });
148
159
  export const systemKeys = Object.freeze([
149
160
  ...Object.values(AlterationStateKey),
150
161
  ...Object.values(StorageProviderKey),
151
162
  ...Object.values(DemoSocialKey),
152
163
  ...Object.values(CloudflareKey),
153
164
  ...Object.values(EmailServiceProviderKey),
165
+ ...Object.values(FeatureFlagConfigKey),
154
166
  ]);
155
167
  export const systemGuards = Object.freeze({
156
168
  ...alterationStateGuard,
@@ -158,4 +170,5 @@ export const systemGuards = Object.freeze({
158
170
  ...demoSocialGuard,
159
171
  ...cloudflareGuard,
160
172
  ...emailServiceProviderGuard,
173
+ ...featureFlagConfigsGuard,
161
174
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -66,9 +66,9 @@
66
66
  "@logto/connector-kit": "^4.0.0",
67
67
  "@logto/core-kit": "^2.5.0",
68
68
  "@logto/language-kit": "^1.1.0",
69
- "@logto/phrases": "^1.14.0",
69
+ "@logto/phrases": "^1.14.1",
70
70
  "@logto/phrases-experience": "^1.8.0",
71
- "@logto/shared": "^3.1.1",
71
+ "@logto/shared": "^3.1.2",
72
72
  "@withtyped/server": "^0.14.0",
73
73
  "nanoid": "^5.0.1"
74
74
  },
@@ -0,0 +1,16 @@
1
+ /* init_order = 2 */
2
+ create table idp_initiated_saml_sso_sessions (
3
+ tenant_id varchar(21) not null
4
+ references tenants (id) on update cascade on delete cascade,
5
+ /** The globally unique identifier of the assertion record. */
6
+ id varchar(21) not null,
7
+ /** The identifier of the SAML SSO connector. */
8
+ connector_id varchar(128) not null
9
+ references sso_connectors (id) on update cascade on delete cascade,
10
+ /** The SAML assertion. */
11
+ assertion_content jsonb /* @use SsoSamlAssertionContent */ not null default '{}'::jsonb,
12
+ created_at timestamptz not null default(now()),
13
+ /** The expiration time of the assertion. */
14
+ expires_at timestamptz not null,
15
+ primary key (tenant_id, id)
16
+ );
@@ -0,0 +1,24 @@
1
+ /** init_order = 2 */
2
+ create table sso_connector_idp_initiated_auth_configs (
3
+ tenant_id varchar(21) not null
4
+ references tenants (id) on update cascade on delete cascade,
5
+ /** The globally unique identifier of the SSO connector. */
6
+ connector_id varchar(128) not null
7
+ references sso_connectors (id) on update cascade on delete cascade,
8
+ /** The default Logto application id. */
9
+ default_application_id varchar(21) not null
10
+ references applications (id) on update cascade on delete cascade,
11
+ /** OIDC sign-in redirect URI. */
12
+ redirect_uri text,
13
+ /** Additional OIDC auth parameters. */
14
+ auth_parameters jsonb /* @use IdpInitiatedAuthParams */ not null default '{}'::jsonb,
15
+ /** Whether to auto-trigger the auth flow on an IdP-initiated auth request. */
16
+ auto_send_authorization_request boolean not null default false,
17
+ /** The client side callback URI for handling IdP-initiated auth request. */
18
+ client_idp_initiated_auth_callback_uri text,
19
+ created_at timestamptz not null default(now()),
20
+ primary key (tenant_id, connector_id),
21
+ /** Insure the application type is Traditional or SPA. */
22
+ constraint application_type
23
+ check (check_application_type(default_application_id, 'Traditional', 'SPA'))
24
+ );