@logto/schemas 1.22.0 → 1.23.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 (31) hide show
  1. package/alterations/1.23.0-1732851150-rename-saml-application-constraints.ts +34 -0
  2. package/alterations/1.23.0-1733212543-add-saml-application-type-to-idp-initiated-sso-application-allow-list.ts +30 -0
  3. package/alterations/1.23.0-1735012422-add-saml-application-sessions-table.ts +37 -0
  4. package/alterations-js/1.23.0-1732851150-rename-saml-application-constraints.js +28 -0
  5. package/alterations-js/1.23.0-1733212543-add-saml-application-type-to-idp-initiated-sso-application-allow-list.js +24 -0
  6. package/alterations-js/1.23.0-1735012422-add-saml-application-sessions-table.js +32 -0
  7. package/lib/consts/subscriptions.d.ts +16 -15
  8. package/lib/consts/subscriptions.js +16 -14
  9. package/lib/db-entries/index.d.ts +1 -0
  10. package/lib/db-entries/index.js +1 -0
  11. package/lib/db-entries/saml-application-config.d.ts +24 -1
  12. package/lib/db-entries/saml-application-config.js +37 -1
  13. package/lib/db-entries/saml-application-session.d.ts +40 -0
  14. package/lib/db-entries/saml-application-session.js +53 -0
  15. package/lib/foundations/jsonb-types/index.d.ts +1 -0
  16. package/lib/foundations/jsonb-types/index.js +1 -0
  17. package/lib/foundations/jsonb-types/saml-application-configs.d.ts +3 -3
  18. package/lib/foundations/jsonb-types/saml-application-configs.js +3 -3
  19. package/lib/foundations/jsonb-types/saml-application-sessions.d.ts +45 -0
  20. package/lib/foundations/jsonb-types/saml-application-sessions.js +10 -0
  21. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +9 -1
  22. package/lib/foundations/jsonb-types/sign-in-experience.js +8 -0
  23. package/lib/types/index.d.ts +1 -0
  24. package/lib/types/index.js +1 -0
  25. package/lib/types/saml-application.d.ts +493 -0
  26. package/lib/types/saml-application.js +54 -0
  27. package/package.json +6 -6
  28. package/tables/saml_application_configs.sql +2 -6
  29. package/tables/saml_application_secrets.sql +1 -1
  30. package/tables/saml_application_sessions.sql +23 -0
  31. package/tables/sso_connector_idp_initiated_auth_configs.sql +1 -1
@@ -0,0 +1,34 @@
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 saml_application_configs
9
+ rename constraint application_type
10
+ to saml_application_configs__application_type;
11
+ `);
12
+
13
+ await pool.query(sql`
14
+ alter table saml_application_secrets
15
+ rename constraint application_type
16
+ to saml_application_secrets__application_type;
17
+ `);
18
+ },
19
+ down: async (pool) => {
20
+ await pool.query(sql`
21
+ alter table saml_application_configs
22
+ rename constraint saml_application_configs__application_type
23
+ to application_type;
24
+ `);
25
+
26
+ await pool.query(sql`
27
+ alter table saml_application_secrets
28
+ rename constraint saml_application_secrets__application_type
29
+ to application_type;
30
+ `);
31
+ },
32
+ };
33
+
34
+ export default alteration;
@@ -0,0 +1,30 @@
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
+ drop constraint application_type;`);
10
+
11
+ await pool.query(sql`
12
+ alter table sso_connector_idp_initiated_auth_configs
13
+ add constraint application_type
14
+ check (check_application_type(default_application_id, 'Traditional', 'SPA', 'SAML'));
15
+ `);
16
+ },
17
+ down: async (pool) => {
18
+ await pool.query(sql`
19
+ alter table sso_connector_idp_initiated_auth_configs
20
+ drop constraint application_type;`);
21
+
22
+ await pool.query(sql`
23
+ alter table sso_connector_idp_initiated_auth_configs
24
+ add constraint application_type
25
+ check (check_application_type(default_application_id, 'Traditional', 'SPA'));
26
+ `);
27
+ },
28
+ };
29
+
30
+ export default alteration;
@@ -0,0 +1,37 @@
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 saml_application_sessions (
11
+ tenant_id varchar(21) not null
12
+ references tenants (id) on update cascade on delete cascade,
13
+ id varchar(32) not null,
14
+ application_id varchar(21) not null
15
+ references applications (id) on update cascade on delete cascade,
16
+ saml_request_id varchar(128) not null,
17
+ oidc_state varchar(32),
18
+ relay_state varchar(256),
19
+ raw_auth_request text not null,
20
+ created_at timestamptz not null default(now()),
21
+ expires_at timestamptz not null,
22
+ primary key (tenant_id, id),
23
+ constraint saml_application_sessions__application_type
24
+ check (check_application_type(application_id, 'SAML'))
25
+ );
26
+ `);
27
+ await applyTableRls(pool, 'saml_application_sessions');
28
+ },
29
+ down: async (pool) => {
30
+ await dropTableRls(pool, 'saml_application_sessions');
31
+ await pool.query(sql`
32
+ drop table if exists saml_application_sessions;
33
+ `);
34
+ },
35
+ };
36
+
37
+ export default alteration;
@@ -0,0 +1,28 @@
1
+ import { sql } from '@silverhand/slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ alter table saml_application_configs
6
+ rename constraint application_type
7
+ to saml_application_configs__application_type;
8
+ `);
9
+ await pool.query(sql `
10
+ alter table saml_application_secrets
11
+ rename constraint application_type
12
+ to saml_application_secrets__application_type;
13
+ `);
14
+ },
15
+ down: async (pool) => {
16
+ await pool.query(sql `
17
+ alter table saml_application_configs
18
+ rename constraint saml_application_configs__application_type
19
+ to application_type;
20
+ `);
21
+ await pool.query(sql `
22
+ alter table saml_application_secrets
23
+ rename constraint saml_application_secrets__application_type
24
+ to application_type;
25
+ `);
26
+ },
27
+ };
28
+ export default alteration;
@@ -0,0 +1,24 @@
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
+ drop constraint application_type;`);
7
+ await pool.query(sql `
8
+ alter table sso_connector_idp_initiated_auth_configs
9
+ add constraint application_type
10
+ check (check_application_type(default_application_id, 'Traditional', 'SPA', 'SAML'));
11
+ `);
12
+ },
13
+ down: async (pool) => {
14
+ await pool.query(sql `
15
+ alter table sso_connector_idp_initiated_auth_configs
16
+ drop constraint application_type;`);
17
+ await pool.query(sql `
18
+ alter table sso_connector_idp_initiated_auth_configs
19
+ add constraint application_type
20
+ check (check_application_type(default_application_id, 'Traditional', 'SPA'));
21
+ `);
22
+ },
23
+ };
24
+ export default alteration;
@@ -0,0 +1,32 @@
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 saml_application_sessions (
7
+ tenant_id varchar(21) not null
8
+ references tenants (id) on update cascade on delete cascade,
9
+ id varchar(32) not null,
10
+ application_id varchar(21) not null
11
+ references applications (id) on update cascade on delete cascade,
12
+ saml_request_id varchar(128) not null,
13
+ oidc_state varchar(32),
14
+ relay_state varchar(256),
15
+ raw_auth_request text not null,
16
+ created_at timestamptz not null default(now()),
17
+ expires_at timestamptz not null,
18
+ primary key (tenant_id, id),
19
+ constraint saml_application_sessions__application_type
20
+ check (check_application_type(application_id, 'SAML'))
21
+ );
22
+ `);
23
+ await applyTableRls(pool, 'saml_application_sessions');
24
+ },
25
+ down: async (pool) => {
26
+ await dropTableRls(pool, 'saml_application_sessions');
27
+ await pool.query(sql `
28
+ drop table if exists saml_application_sessions;
29
+ `);
30
+ },
31
+ };
32
+ export default alteration;
@@ -8,26 +8,27 @@ export declare enum ReservedPlanId {
8
8
  Free = "free",
9
9
  /**
10
10
  * @deprecated
11
- * In recent refactoring, the `hobby` plan is now treated as the `pro` plan.
12
- * Only use this plan ID to check if a plan is a `pro` plan or not.
13
- * This plan ID will be renamed to `pro` after legacy Stripe data is migrated by @darcyYe
14
- *
15
- * Todo @darcyYe:
16
- * - LOG-7846: Rename `hobby` to `pro` and `pro` to `legacy-pro`
17
- * - LOG-8339: Migrate legacy Stripe data
11
+ * Grandfathered Pro plan ID deprecated from 2024-11.
12
+ * Use {@link Pro202411} instead.
18
13
  */
19
- Hobby = "hobby",
20
14
  Pro = "pro",
21
- Enterprise = "enterprise",
22
- /**
23
- * @deprecated
24
- * Should not use this plan ID, we only use this tag as a record for the legacy `pro` plan since we will rename the `hobby` plan to be `pro`.
25
- */
26
- GrandfatheredPro = "grandfathered-pro",
27
15
  Development = "dev",
28
16
  /**
29
17
  * This plan ID is reserved for Admin tenant.
30
18
  * In our new pricing model, we plan to add a special plan for Admin tenant, previously, admin tenant is using the `pro` plan, which is not suitable.
31
19
  */
32
- Admin = "admin"
20
+ Admin = "admin",
21
+ /**
22
+ * The latest Pro plan ID applied from 2024-11.
23
+ */
24
+ Pro202411 = "pro-202411"
25
+ }
26
+ /**
27
+ * Tenant subscription related Redis cache keys.
28
+ *
29
+ * We use Redis to cache the tenant subscription data to reduce the number of requests to the Cloud.
30
+ * Both @logto/core and @logto/cloud will need to access the cache, so we define the cache keys here as the SSOT.
31
+ */
32
+ export declare enum SubscriptionRedisCacheKey {
33
+ Subscription = "subscription"
33
34
  }
@@ -9,26 +9,28 @@ export var ReservedPlanId;
9
9
  ReservedPlanId["Free"] = "free";
10
10
  /**
11
11
  * @deprecated
12
- * In recent refactoring, the `hobby` plan is now treated as the `pro` plan.
13
- * Only use this plan ID to check if a plan is a `pro` plan or not.
14
- * This plan ID will be renamed to `pro` after legacy Stripe data is migrated by @darcyYe
15
- *
16
- * Todo @darcyYe:
17
- * - LOG-7846: Rename `hobby` to `pro` and `pro` to `legacy-pro`
18
- * - LOG-8339: Migrate legacy Stripe data
12
+ * Grandfathered Pro plan ID deprecated from 2024-11.
13
+ * Use {@link Pro202411} instead.
19
14
  */
20
- ReservedPlanId["Hobby"] = "hobby";
21
15
  ReservedPlanId["Pro"] = "pro";
22
- ReservedPlanId["Enterprise"] = "enterprise";
23
- /**
24
- * @deprecated
25
- * Should not use this plan ID, we only use this tag as a record for the legacy `pro` plan since we will rename the `hobby` plan to be `pro`.
26
- */
27
- ReservedPlanId["GrandfatheredPro"] = "grandfathered-pro";
28
16
  ReservedPlanId["Development"] = "dev";
29
17
  /**
30
18
  * This plan ID is reserved for Admin tenant.
31
19
  * In our new pricing model, we plan to add a special plan for Admin tenant, previously, admin tenant is using the `pro` plan, which is not suitable.
32
20
  */
33
21
  ReservedPlanId["Admin"] = "admin";
22
+ /**
23
+ * The latest Pro plan ID applied from 2024-11.
24
+ */
25
+ ReservedPlanId["Pro202411"] = "pro-202411";
34
26
  })(ReservedPlanId || (ReservedPlanId = {}));
27
+ /**
28
+ * Tenant subscription related Redis cache keys.
29
+ *
30
+ * We use Redis to cache the tenant subscription data to reduce the number of requests to the Cloud.
31
+ * Both @logto/core and @logto/cloud will need to access the cache, so we define the cache keys here as the SSOT.
32
+ */
33
+ export var SubscriptionRedisCacheKey;
34
+ (function (SubscriptionRedisCacheKey) {
35
+ SubscriptionRedisCacheKey["Subscription"] = "subscription";
36
+ })(SubscriptionRedisCacheKey || (SubscriptionRedisCacheKey = {}));
@@ -44,6 +44,7 @@ export * from './role.js';
44
44
  export * from './roles-scope.js';
45
45
  export * from './saml-application-config.js';
46
46
  export * from './saml-application-secret.js';
47
+ export * from './saml-application-session.js';
47
48
  export * from './scope.js';
48
49
  export * from './sentinel-activity.js';
49
50
  export * from './service-log.js';
@@ -45,6 +45,7 @@ export * from './role.js';
45
45
  export * from './roles-scope.js';
46
46
  export * from './saml-application-config.js';
47
47
  export * from './saml-application-secret.js';
48
+ export * from './saml-application-session.js';
48
49
  export * from './scope.js';
49
50
  export * from './sentinel-activity.js';
50
51
  export * from './service-log.js';
@@ -1 +1,24 @@
1
- export {};
1
+ import { SamlAttributeMapping, SamlAcsUrl, GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * The SAML application config and SAML-type application have a one-to-one correspondence: 1. a SAML-type application can only have one SAML application config. (CANNOT use "semicolon" in comments, since it indicates the end of query.) 2. a SAML application config can only configure one SAML-type application.
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link SamlApplicationConfig} for the original type.
7
+ */
8
+ export type CreateSamlApplicationConfig = {
9
+ applicationId: string;
10
+ tenantId?: string;
11
+ attributeMapping?: SamlAttributeMapping;
12
+ entityId?: string | null;
13
+ acsUrl?: SamlAcsUrl | null;
14
+ };
15
+ /** The SAML application config and SAML-type application have a one-to-one correspondence: 1. a SAML-type application can only have one SAML application config. (CANNOT use "semicolon" in comments, since it indicates the end of query.) 2. a SAML application config can only configure one SAML-type application. */
16
+ export type SamlApplicationConfig = {
17
+ applicationId: string;
18
+ tenantId: string;
19
+ attributeMapping: SamlAttributeMapping;
20
+ entityId: string | null;
21
+ acsUrl: SamlAcsUrl | null;
22
+ };
23
+ export type SamlApplicationConfigKeys = 'applicationId' | 'tenantId' | 'attributeMapping' | 'entityId' | 'acsUrl';
24
+ export declare const SamlApplicationConfigs: GeneratedSchema<SamlApplicationConfigKeys, CreateSamlApplicationConfig, SamlApplicationConfig, 'saml_application_configs', 'saml_application_config'>;
@@ -1,2 +1,38 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
- export {};
2
+ import { z } from 'zod';
3
+ import { samlAttributeMappingGuard, samlAcsUrlGuard } from './../foundations/index.js';
4
+ const createGuard = z.object({
5
+ applicationId: z.string().min(1).max(21),
6
+ tenantId: z.string().max(21).optional(),
7
+ attributeMapping: samlAttributeMappingGuard.optional(),
8
+ entityId: z.string().max(128).nullable().optional(),
9
+ acsUrl: samlAcsUrlGuard.nullable().optional(),
10
+ });
11
+ const guard = z.object({
12
+ applicationId: z.string().min(1).max(21),
13
+ tenantId: z.string().max(21),
14
+ attributeMapping: samlAttributeMappingGuard,
15
+ entityId: z.string().max(128).nullable(),
16
+ acsUrl: samlAcsUrlGuard.nullable(),
17
+ });
18
+ export const SamlApplicationConfigs = Object.freeze({
19
+ table: 'saml_application_configs',
20
+ tableSingular: 'saml_application_config',
21
+ fields: {
22
+ applicationId: 'application_id',
23
+ tenantId: 'tenant_id',
24
+ attributeMapping: 'attribute_mapping',
25
+ entityId: 'entity_id',
26
+ acsUrl: 'acs_url',
27
+ },
28
+ fieldKeys: [
29
+ 'applicationId',
30
+ 'tenantId',
31
+ 'attributeMapping',
32
+ 'entityId',
33
+ 'acsUrl',
34
+ ],
35
+ createGuard,
36
+ guard,
37
+ updateGuard: guard.partial(),
38
+ });
@@ -0,0 +1,40 @@
1
+ import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ *
4
+ * @remarks This is a type for database creation.
5
+ * @see {@link SamlApplicationSession} for the original type.
6
+ */
7
+ export type CreateSamlApplicationSession = {
8
+ tenantId?: string;
9
+ /** The globally unique identifier of the session. */
10
+ id: string;
11
+ applicationId: string;
12
+ /** The identifier of the SAML SSO auth request ID, SAML request ID is pretty long. */
13
+ samlRequestId: string;
14
+ /** The identifier of the OIDC auth request state. */
15
+ oidcState?: string | null;
16
+ /** The relay state of the SAML auth request. */
17
+ relayState?: string | null;
18
+ /** The raw request of the SAML auth request. */
19
+ rawAuthRequest: string;
20
+ createdAt?: number;
21
+ expiresAt: number;
22
+ };
23
+ export type SamlApplicationSession = {
24
+ tenantId: string;
25
+ /** The globally unique identifier of the session. */
26
+ id: string;
27
+ applicationId: string;
28
+ /** The identifier of the SAML SSO auth request ID, SAML request ID is pretty long. */
29
+ samlRequestId: string;
30
+ /** The identifier of the OIDC auth request state. */
31
+ oidcState: string | null;
32
+ /** The relay state of the SAML auth request. */
33
+ relayState: string | null;
34
+ /** The raw request of the SAML auth request. */
35
+ rawAuthRequest: string;
36
+ createdAt: number;
37
+ expiresAt: number;
38
+ };
39
+ export type SamlApplicationSessionKeys = 'tenantId' | 'id' | 'applicationId' | 'samlRequestId' | 'oidcState' | 'relayState' | 'rawAuthRequest' | 'createdAt' | 'expiresAt';
40
+ export declare const SamlApplicationSessions: GeneratedSchema<SamlApplicationSessionKeys, CreateSamlApplicationSession, SamlApplicationSession, 'saml_application_sessions', 'saml_application_session'>;
@@ -0,0 +1,53 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ const createGuard = z.object({
4
+ tenantId: z.string().max(21).optional(),
5
+ id: z.string().min(1).max(32),
6
+ applicationId: z.string().min(1).max(21),
7
+ samlRequestId: z.string().min(1).max(128),
8
+ oidcState: z.string().max(32).nullable().optional(),
9
+ relayState: z.string().max(256).nullable().optional(),
10
+ rawAuthRequest: z.string().min(1),
11
+ createdAt: z.number().optional(),
12
+ expiresAt: z.number(),
13
+ });
14
+ const guard = z.object({
15
+ tenantId: z.string().max(21),
16
+ id: z.string().min(1).max(32),
17
+ applicationId: z.string().min(1).max(21),
18
+ samlRequestId: z.string().min(1).max(128),
19
+ oidcState: z.string().max(32).nullable(),
20
+ relayState: z.string().max(256).nullable(),
21
+ rawAuthRequest: z.string().min(1),
22
+ createdAt: z.number(),
23
+ expiresAt: z.number(),
24
+ });
25
+ export const SamlApplicationSessions = Object.freeze({
26
+ table: 'saml_application_sessions',
27
+ tableSingular: 'saml_application_session',
28
+ fields: {
29
+ tenantId: 'tenant_id',
30
+ id: 'id',
31
+ applicationId: 'application_id',
32
+ samlRequestId: 'saml_request_id',
33
+ oidcState: 'oidc_state',
34
+ relayState: 'relay_state',
35
+ rawAuthRequest: 'raw_auth_request',
36
+ createdAt: 'created_at',
37
+ expiresAt: 'expires_at',
38
+ },
39
+ fieldKeys: [
40
+ 'tenantId',
41
+ 'id',
42
+ 'applicationId',
43
+ 'samlRequestId',
44
+ 'oidcState',
45
+ 'relayState',
46
+ 'rawAuthRequest',
47
+ 'createdAt',
48
+ 'expiresAt',
49
+ ],
50
+ createGuard,
51
+ guard,
52
+ updateGuard: guard.partial(),
53
+ });
@@ -11,5 +11,6 @@ export * from './applications.js';
11
11
  export * from './verification-records.js';
12
12
  export * from './account-centers.js';
13
13
  export * from './saml-application-configs.js';
14
+ export * from './saml-application-sessions.js';
14
15
  export { configurableConnectorMetadataGuard, type ConfigurableConnectorMetadata, jsonGuard, jsonObjectGuard, } from '@logto/connector-kit';
15
16
  export type { Json, JsonObject } from '@withtyped/server';
@@ -11,4 +11,5 @@ export * from './applications.js';
11
11
  export * from './verification-records.js';
12
12
  export * from './account-centers.js';
13
13
  export * from './saml-application-configs.js';
14
+ export * from './saml-application-sessions.js';
14
15
  export { configurableConnectorMetadataGuard, jsonGuard, jsonObjectGuard, } from '@logto/connector-kit';
@@ -2,11 +2,11 @@ import { z } from 'zod';
2
2
  export type SamlAttributeMapping = Record<string, string>;
3
3
  export declare const samlAttributeMappingGuard: z.ZodRecord<z.ZodString, z.ZodString>;
4
4
  export declare enum BindingType {
5
- POST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
6
- REDIRECT = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
5
+ Post = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
6
+ Redirect = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
7
7
  }
8
8
  export type SamlAcsUrl = {
9
- binding?: BindingType;
9
+ binding: BindingType;
10
10
  url: string;
11
11
  };
12
12
  export declare const samlAcsUrlGuard: z.ZodObject<{
@@ -2,10 +2,10 @@ import { z } from 'zod';
2
2
  export const samlAttributeMappingGuard = z.record(z.string());
3
3
  export var BindingType;
4
4
  (function (BindingType) {
5
- BindingType["POST"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
6
- BindingType["REDIRECT"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
5
+ BindingType["Post"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";
6
+ BindingType["Redirect"] = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect";
7
7
  })(BindingType || (BindingType = {}));
8
8
  export const samlAcsUrlGuard = z.object({
9
9
  binding: z.nativeEnum(BindingType),
10
- url: z.string(),
10
+ url: z.string().url(),
11
11
  });
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ export type AuthRequestInfo = {
3
+ issuer: string;
4
+ request: {
5
+ id: string;
6
+ destination: string;
7
+ issueInstant: string;
8
+ assertionConsumerServiceUrl: string;
9
+ };
10
+ };
11
+ export declare const authRequestInfoGuard: z.ZodObject<{
12
+ issuer: z.ZodString;
13
+ request: z.ZodObject<{
14
+ id: z.ZodString;
15
+ destination: z.ZodString;
16
+ issueInstant: z.ZodString;
17
+ assertionConsumerServiceUrl: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
19
+ id: string;
20
+ destination: string;
21
+ issueInstant: string;
22
+ assertionConsumerServiceUrl: string;
23
+ }, {
24
+ id: string;
25
+ destination: string;
26
+ issueInstant: string;
27
+ assertionConsumerServiceUrl: string;
28
+ }>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ issuer: string;
31
+ request: {
32
+ id: string;
33
+ destination: string;
34
+ issueInstant: string;
35
+ assertionConsumerServiceUrl: string;
36
+ };
37
+ }, {
38
+ issuer: string;
39
+ request: {
40
+ id: string;
41
+ destination: string;
42
+ issueInstant: string;
43
+ assertionConsumerServiceUrl: string;
44
+ };
45
+ }>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export const authRequestInfoGuard = z.object({
3
+ issuer: z.string(),
4
+ request: z.object({
5
+ id: z.string(),
6
+ destination: z.string(),
7
+ issueInstant: z.string(),
8
+ assertionConsumerServiceUrl: z.string(),
9
+ }),
10
+ });
@@ -142,8 +142,16 @@ export declare enum MfaFactor {
142
142
  export declare const mfaFactorsGuard: z.ZodArray<z.ZodNativeEnum<typeof MfaFactor>, "many">;
143
143
  export type MfaFactors = z.infer<typeof mfaFactorsGuard>;
144
144
  export declare enum MfaPolicy {
145
+ /** @deprecated, use `PromptAtSignInAndSignUp` instead */
145
146
  UserControlled = "UserControlled",
146
- Mandatory = "Mandatory"
147
+ /** MFA is required for all users */
148
+ Mandatory = "Mandatory",
149
+ /** Ask users to set up MFA on their sign-in after registration (skippable, one-time prompt) */
150
+ PromptOnlyAtSignIn = "PromptOnlyAtSignIn",
151
+ /** Ask users to set up MFA during registration (skippable, one-time prompt) */
152
+ PromptAtSignInAndSignUp = "PromptAtSignInAndSignUp",
153
+ /** Do not ask users to set up MFA */
154
+ NoPrompt = "NoPrompt"
147
155
  }
148
156
  export declare const mfaGuard: z.ZodObject<{
149
157
  factors: z.ZodArray<z.ZodNativeEnum<typeof MfaFactor>, "many">;
@@ -65,8 +65,16 @@ export var MfaFactor;
65
65
  export const mfaFactorsGuard = z.nativeEnum(MfaFactor).array();
66
66
  export var MfaPolicy;
67
67
  (function (MfaPolicy) {
68
+ /** @deprecated, use `PromptAtSignInAndSignUp` instead */
68
69
  MfaPolicy["UserControlled"] = "UserControlled";
70
+ /** MFA is required for all users */
69
71
  MfaPolicy["Mandatory"] = "Mandatory";
72
+ /** Ask users to set up MFA on their sign-in after registration (skippable, one-time prompt) */
73
+ MfaPolicy["PromptOnlyAtSignIn"] = "PromptOnlyAtSignIn";
74
+ /** Ask users to set up MFA during registration (skippable, one-time prompt) */
75
+ MfaPolicy["PromptAtSignInAndSignUp"] = "PromptAtSignInAndSignUp";
76
+ /** Do not ask users to set up MFA */
77
+ MfaPolicy["NoPrompt"] = "NoPrompt";
70
78
  })(MfaPolicy || (MfaPolicy = {}));
71
79
  export const mfaGuard = z.object({
72
80
  factors: mfaFactorsGuard,
@@ -30,3 +30,4 @@ export * from './onboarding.js';
30
30
  export * from './sign-in-experience.js';
31
31
  export * from './subject-token.js';
32
32
  export * from './ssr.js';
33
+ export * from './saml-application.js';
@@ -30,3 +30,4 @@ export * from './onboarding.js';
30
30
  export * from './sign-in-experience.js';
31
31
  export * from './subject-token.js';
32
32
  export * from './ssr.js';
33
+ export * from './saml-application.js';
@@ -0,0 +1,493 @@
1
+ import { z } from 'zod';
2
+ export declare const samlApplicationCreateGuard: z.ZodObject<z.objectUtil.extendShape<Pick<z.objectUtil.extendShape<{
3
+ type: z.ZodOptional<z.ZodType<import("../index.js").ApplicationType, z.ZodTypeDef, import("../index.js").ApplicationType>>;
4
+ name: z.ZodOptional<z.ZodType<string, z.ZodTypeDef, string>>;
5
+ customData: z.ZodOptional<z.ZodOptional<z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>>>;
6
+ description: z.ZodOptional<z.ZodOptional<z.ZodType<string | null, z.ZodTypeDef, string | null>>>;
7
+ oidcClientMetadata: z.ZodOptional<z.ZodType<import("../index.js").OidcClientMetadata, z.ZodTypeDef, import("../index.js").OidcClientMetadata>>;
8
+ customClientMetadata: z.ZodOptional<z.ZodOptional<z.ZodType<{
9
+ corsAllowedOrigins?: string[] | undefined;
10
+ idTokenTtl?: number | undefined;
11
+ refreshTokenTtl?: number | undefined;
12
+ refreshTokenTtlInDays?: number | undefined;
13
+ tenantId?: string | undefined;
14
+ alwaysIssueRefreshToken?: boolean | undefined;
15
+ rotateRefreshToken?: boolean | undefined;
16
+ }, z.ZodTypeDef, {
17
+ corsAllowedOrigins?: string[] | undefined;
18
+ idTokenTtl?: number | undefined;
19
+ refreshTokenTtl?: number | undefined;
20
+ refreshTokenTtlInDays?: number | undefined;
21
+ tenantId?: string | undefined;
22
+ alwaysIssueRefreshToken?: boolean | undefined;
23
+ rotateRefreshToken?: boolean | undefined;
24
+ }>>>;
25
+ protectedAppMetadata: z.ZodOptional<z.ZodOptional<z.ZodType<{
26
+ host: string;
27
+ origin: string;
28
+ sessionDuration: number;
29
+ pageRules: {
30
+ path: string;
31
+ }[];
32
+ customDomains?: {
33
+ status: import("../index.js").DomainStatus;
34
+ domain: string;
35
+ errorMessage: string | null;
36
+ dnsRecords: {
37
+ type: string;
38
+ value: string;
39
+ name: string;
40
+ }[];
41
+ cloudflareData: {
42
+ status: string;
43
+ id: string;
44
+ ssl: {
45
+ status: string;
46
+ validation_errors?: {
47
+ message: string;
48
+ }[] | undefined;
49
+ };
50
+ verification_errors?: string[] | undefined;
51
+ } | null;
52
+ }[] | undefined;
53
+ } | null, z.ZodTypeDef, {
54
+ host: string;
55
+ origin: string;
56
+ sessionDuration: number;
57
+ pageRules: {
58
+ path: string;
59
+ }[];
60
+ customDomains?: {
61
+ status: import("../index.js").DomainStatus;
62
+ domain: string;
63
+ errorMessage: string | null;
64
+ dnsRecords: {
65
+ type: string;
66
+ value: string;
67
+ name: string;
68
+ }[];
69
+ cloudflareData: {
70
+ status: string;
71
+ id: string;
72
+ ssl: {
73
+ status: string;
74
+ validation_errors?: {
75
+ message: string;
76
+ }[] | undefined;
77
+ };
78
+ verification_errors?: string[] | undefined;
79
+ } | null;
80
+ }[] | undefined;
81
+ } | null>>>;
82
+ isThirdParty: z.ZodOptional<z.ZodOptional<z.ZodType<boolean, z.ZodTypeDef, boolean>>>;
83
+ }, Pick<{
84
+ tenantId: z.ZodOptional<z.ZodType<string, z.ZodTypeDef, string>>;
85
+ id: z.ZodType<string, z.ZodTypeDef, string>;
86
+ name: z.ZodType<string, z.ZodTypeDef, string>;
87
+ secret: z.ZodType<string, z.ZodTypeDef, string>;
88
+ description: z.ZodOptional<z.ZodType<string | null, z.ZodTypeDef, string | null>>;
89
+ type: z.ZodType<import("../index.js").ApplicationType, z.ZodTypeDef, import("../index.js").ApplicationType>;
90
+ oidcClientMetadata: z.ZodType<import("../index.js").OidcClientMetadata, z.ZodTypeDef, import("../index.js").OidcClientMetadata>;
91
+ customClientMetadata: z.ZodOptional<z.ZodType<{
92
+ corsAllowedOrigins?: string[] | undefined;
93
+ idTokenTtl?: number | undefined;
94
+ refreshTokenTtl?: number | undefined;
95
+ refreshTokenTtlInDays?: number | undefined;
96
+ tenantId?: string | undefined;
97
+ alwaysIssueRefreshToken?: boolean | undefined;
98
+ rotateRefreshToken?: boolean | undefined;
99
+ }, z.ZodTypeDef, {
100
+ corsAllowedOrigins?: string[] | undefined;
101
+ idTokenTtl?: number | undefined;
102
+ refreshTokenTtl?: number | undefined;
103
+ refreshTokenTtlInDays?: number | undefined;
104
+ tenantId?: string | undefined;
105
+ alwaysIssueRefreshToken?: boolean | undefined;
106
+ rotateRefreshToken?: boolean | undefined;
107
+ }>>;
108
+ protectedAppMetadata: z.ZodOptional<z.ZodType<{
109
+ host: string;
110
+ origin: string;
111
+ sessionDuration: number;
112
+ pageRules: {
113
+ path: string;
114
+ }[];
115
+ customDomains?: {
116
+ status: import("../index.js").DomainStatus;
117
+ domain: string;
118
+ errorMessage: string | null;
119
+ dnsRecords: {
120
+ type: string;
121
+ value: string;
122
+ name: string;
123
+ }[];
124
+ cloudflareData: {
125
+ status: string;
126
+ id: string;
127
+ ssl: {
128
+ status: string;
129
+ validation_errors?: {
130
+ message: string;
131
+ }[] | undefined;
132
+ };
133
+ verification_errors?: string[] | undefined;
134
+ } | null;
135
+ }[] | undefined;
136
+ } | null, z.ZodTypeDef, {
137
+ host: string;
138
+ origin: string;
139
+ sessionDuration: number;
140
+ pageRules: {
141
+ path: string;
142
+ }[];
143
+ customDomains?: {
144
+ status: import("../index.js").DomainStatus;
145
+ domain: string;
146
+ errorMessage: string | null;
147
+ dnsRecords: {
148
+ type: string;
149
+ value: string;
150
+ name: string;
151
+ }[];
152
+ cloudflareData: {
153
+ status: string;
154
+ id: string;
155
+ ssl: {
156
+ status: string;
157
+ validation_errors?: {
158
+ message: string;
159
+ }[] | undefined;
160
+ };
161
+ verification_errors?: string[] | undefined;
162
+ } | null;
163
+ }[] | undefined;
164
+ } | null>>;
165
+ customData: z.ZodOptional<z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>>;
166
+ isThirdParty: z.ZodOptional<z.ZodType<boolean, z.ZodTypeDef, boolean>>;
167
+ createdAt: z.ZodOptional<z.ZodType<number, z.ZodTypeDef, number>>;
168
+ }, "type" | "name">>, "name" | "customData" | "description">, {
169
+ attributeMapping: z.ZodOptional<z.ZodType<import("../index.js").SamlAttributeMapping, z.ZodTypeDef, import("../index.js").SamlAttributeMapping>>;
170
+ entityId: z.ZodOptional<z.ZodType<string | null, z.ZodTypeDef, string | null>>;
171
+ acsUrl: z.ZodOptional<z.ZodType<import("../index.js").SamlAcsUrl | null, z.ZodTypeDef, import("../index.js").SamlAcsUrl | null>>;
172
+ }>, "strip", z.ZodTypeAny, {
173
+ name: string;
174
+ customData?: import("@withtyped/server").JsonObject;
175
+ description?: string | null;
176
+ attributeMapping?: import("../index.js").SamlAttributeMapping | undefined;
177
+ entityId?: string | null | undefined;
178
+ acsUrl?: import("../index.js").SamlAcsUrl | null | undefined;
179
+ }, {
180
+ name: string;
181
+ customData?: import("@withtyped/server").JsonObject;
182
+ description?: string | null;
183
+ attributeMapping?: import("../index.js").SamlAttributeMapping | undefined;
184
+ entityId?: string | null | undefined;
185
+ acsUrl?: import("../index.js").SamlAcsUrl | null | undefined;
186
+ }>;
187
+ export type CreateSamlApplication = z.infer<typeof samlApplicationCreateGuard>;
188
+ export declare const samlApplicationPatchGuard: z.ZodObject<z.objectUtil.extendShape<Pick<Omit<{
189
+ customData: z.ZodOptional<z.ZodOptional<z.ZodOptional<z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>>>>;
190
+ description: z.ZodOptional<z.ZodOptional<z.ZodOptional<z.ZodType<string | null, z.ZodTypeDef, string | null>>>>;
191
+ oidcClientMetadata: z.ZodOptional<z.ZodOptional<z.ZodType<import("../index.js").OidcClientMetadata, z.ZodTypeDef, import("../index.js").OidcClientMetadata>>>;
192
+ customClientMetadata: z.ZodOptional<z.ZodOptional<z.ZodOptional<z.ZodType<{
193
+ corsAllowedOrigins?: string[] | undefined;
194
+ idTokenTtl?: number | undefined;
195
+ refreshTokenTtl?: number | undefined;
196
+ refreshTokenTtlInDays?: number | undefined;
197
+ tenantId?: string | undefined;
198
+ alwaysIssueRefreshToken?: boolean | undefined;
199
+ rotateRefreshToken?: boolean | undefined;
200
+ }, z.ZodTypeDef, {
201
+ corsAllowedOrigins?: string[] | undefined;
202
+ idTokenTtl?: number | undefined;
203
+ refreshTokenTtl?: number | undefined;
204
+ refreshTokenTtlInDays?: number | undefined;
205
+ tenantId?: string | undefined;
206
+ alwaysIssueRefreshToken?: boolean | undefined;
207
+ rotateRefreshToken?: boolean | undefined;
208
+ }>>>>;
209
+ protectedAppMetadata: z.ZodOptional<z.ZodOptional<z.ZodOptional<z.ZodType<{
210
+ host: string;
211
+ origin: string;
212
+ sessionDuration: number;
213
+ pageRules: {
214
+ path: string;
215
+ }[];
216
+ customDomains?: {
217
+ status: import("../index.js").DomainStatus;
218
+ domain: string;
219
+ errorMessage: string | null;
220
+ dnsRecords: {
221
+ type: string;
222
+ value: string;
223
+ name: string;
224
+ }[];
225
+ cloudflareData: {
226
+ status: string;
227
+ id: string;
228
+ ssl: {
229
+ status: string;
230
+ validation_errors?: {
231
+ message: string;
232
+ }[] | undefined;
233
+ };
234
+ verification_errors?: string[] | undefined;
235
+ } | null;
236
+ }[] | undefined;
237
+ } | null, z.ZodTypeDef, {
238
+ host: string;
239
+ origin: string;
240
+ sessionDuration: number;
241
+ pageRules: {
242
+ path: string;
243
+ }[];
244
+ customDomains?: {
245
+ status: import("../index.js").DomainStatus;
246
+ domain: string;
247
+ errorMessage: string | null;
248
+ dnsRecords: {
249
+ type: string;
250
+ value: string;
251
+ name: string;
252
+ }[];
253
+ cloudflareData: {
254
+ status: string;
255
+ id: string;
256
+ ssl: {
257
+ status: string;
258
+ validation_errors?: {
259
+ message: string;
260
+ }[] | undefined;
261
+ };
262
+ verification_errors?: string[] | undefined;
263
+ } | null;
264
+ }[] | undefined;
265
+ } | null>>>>;
266
+ isThirdParty: z.ZodOptional<z.ZodOptional<z.ZodOptional<z.ZodType<boolean, z.ZodTypeDef, boolean>>>>;
267
+ type: z.ZodOptional<z.ZodType<import("../index.js").ApplicationType, z.ZodTypeDef, import("../index.js").ApplicationType>>;
268
+ name: z.ZodOptional<z.ZodType<string, z.ZodTypeDef, string>>;
269
+ }, "type" | "isThirdParty">, "name" | "customData" | "description">, {
270
+ attributeMapping: z.ZodOptional<z.ZodType<import("../index.js").SamlAttributeMapping, z.ZodTypeDef, import("../index.js").SamlAttributeMapping>>;
271
+ entityId: z.ZodOptional<z.ZodType<string | null, z.ZodTypeDef, string | null>>;
272
+ acsUrl: z.ZodOptional<z.ZodType<import("../index.js").SamlAcsUrl | null, z.ZodTypeDef, import("../index.js").SamlAcsUrl | null>>;
273
+ }>, "strip", z.ZodTypeAny, {
274
+ name?: string | undefined;
275
+ customData?: import("@withtyped/server").JsonObject;
276
+ description?: string | null;
277
+ attributeMapping?: import("../index.js").SamlAttributeMapping | undefined;
278
+ entityId?: string | null | undefined;
279
+ acsUrl?: import("../index.js").SamlAcsUrl | null | undefined;
280
+ }, {
281
+ name?: string | undefined;
282
+ customData?: import("@withtyped/server").JsonObject;
283
+ description?: string | null;
284
+ attributeMapping?: import("../index.js").SamlAttributeMapping | undefined;
285
+ entityId?: string | null | undefined;
286
+ acsUrl?: import("../index.js").SamlAcsUrl | null | undefined;
287
+ }>;
288
+ export type PatchSamlApplication = z.infer<typeof samlApplicationPatchGuard>;
289
+ export declare const samlApplicationResponseGuard: z.ZodObject<z.objectUtil.extendShape<Omit<{
290
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
291
+ id: z.ZodType<string, z.ZodTypeDef, string>;
292
+ name: z.ZodType<string, z.ZodTypeDef, string>;
293
+ secret: z.ZodType<string, z.ZodTypeDef, string>;
294
+ description: z.ZodType<string | null, z.ZodTypeDef, string | null>;
295
+ type: z.ZodType<import("../index.js").ApplicationType, z.ZodTypeDef, import("../index.js").ApplicationType>;
296
+ oidcClientMetadata: z.ZodType<import("../index.js").OidcClientMetadata, z.ZodTypeDef, import("../index.js").OidcClientMetadata>;
297
+ customClientMetadata: z.ZodType<{
298
+ corsAllowedOrigins?: string[] | undefined;
299
+ idTokenTtl?: number | undefined;
300
+ refreshTokenTtl?: number | undefined;
301
+ refreshTokenTtlInDays?: number | undefined;
302
+ tenantId?: string | undefined;
303
+ alwaysIssueRefreshToken?: boolean | undefined;
304
+ rotateRefreshToken?: boolean | undefined;
305
+ }, z.ZodTypeDef, {
306
+ corsAllowedOrigins?: string[] | undefined;
307
+ idTokenTtl?: number | undefined;
308
+ refreshTokenTtl?: number | undefined;
309
+ refreshTokenTtlInDays?: number | undefined;
310
+ tenantId?: string | undefined;
311
+ alwaysIssueRefreshToken?: boolean | undefined;
312
+ rotateRefreshToken?: boolean | undefined;
313
+ }>;
314
+ protectedAppMetadata: z.ZodType<{
315
+ host: string;
316
+ origin: string;
317
+ sessionDuration: number;
318
+ pageRules: {
319
+ path: string;
320
+ }[];
321
+ customDomains?: {
322
+ status: import("../index.js").DomainStatus;
323
+ domain: string;
324
+ errorMessage: string | null;
325
+ dnsRecords: {
326
+ type: string;
327
+ value: string;
328
+ name: string;
329
+ }[];
330
+ cloudflareData: {
331
+ status: string;
332
+ id: string;
333
+ ssl: {
334
+ status: string;
335
+ validation_errors?: {
336
+ message: string;
337
+ }[] | undefined;
338
+ };
339
+ verification_errors?: string[] | undefined;
340
+ } | null;
341
+ }[] | undefined;
342
+ } | null, z.ZodTypeDef, {
343
+ host: string;
344
+ origin: string;
345
+ sessionDuration: number;
346
+ pageRules: {
347
+ path: string;
348
+ }[];
349
+ customDomains?: {
350
+ status: import("../index.js").DomainStatus;
351
+ domain: string;
352
+ errorMessage: string | null;
353
+ dnsRecords: {
354
+ type: string;
355
+ value: string;
356
+ name: string;
357
+ }[];
358
+ cloudflareData: {
359
+ status: string;
360
+ id: string;
361
+ ssl: {
362
+ status: string;
363
+ validation_errors?: {
364
+ message: string;
365
+ }[] | undefined;
366
+ };
367
+ verification_errors?: string[] | undefined;
368
+ } | null;
369
+ }[] | undefined;
370
+ } | null>;
371
+ customData: z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>;
372
+ isThirdParty: z.ZodType<boolean, z.ZodTypeDef, boolean>;
373
+ createdAt: z.ZodType<number, z.ZodTypeDef, number>;
374
+ }, "secret" | "oidcClientMetadata" | "customClientMetadata" | "protectedAppMetadata">, Pick<{
375
+ applicationId: z.ZodType<string, z.ZodTypeDef, string>;
376
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
377
+ attributeMapping: z.ZodType<import("../index.js").SamlAttributeMapping, z.ZodTypeDef, import("../index.js").SamlAttributeMapping>;
378
+ entityId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
379
+ acsUrl: z.ZodType<import("../index.js").SamlAcsUrl | null, z.ZodTypeDef, import("../index.js").SamlAcsUrl | null>;
380
+ }, "attributeMapping" | "entityId" | "acsUrl">>, "strip", z.ZodTypeAny, {
381
+ type: import("../index.js").ApplicationType;
382
+ name: string;
383
+ id: string;
384
+ tenantId: string;
385
+ createdAt: number;
386
+ customData: import("@withtyped/server").JsonObject;
387
+ description: string | null;
388
+ isThirdParty: boolean;
389
+ attributeMapping: import("../index.js").SamlAttributeMapping;
390
+ entityId: string | null;
391
+ acsUrl: import("../index.js").SamlAcsUrl | null;
392
+ }, {
393
+ type: import("../index.js").ApplicationType;
394
+ name: string;
395
+ id: string;
396
+ tenantId: string;
397
+ createdAt: number;
398
+ customData: import("@withtyped/server").JsonObject;
399
+ description: string | null;
400
+ isThirdParty: boolean;
401
+ attributeMapping: import("../index.js").SamlAttributeMapping;
402
+ entityId: string | null;
403
+ acsUrl: import("../index.js").SamlAcsUrl | null;
404
+ }>;
405
+ export type SamlApplicationResponse = z.infer<typeof samlApplicationResponseGuard>;
406
+ type FingerprintFormat = {
407
+ formatted: string;
408
+ unformatted: string;
409
+ };
410
+ export type CertificateFingerprints = {
411
+ sha256: FingerprintFormat;
412
+ };
413
+ export declare const certificateFingerprintsGuard: z.ZodObject<{
414
+ sha256: z.ZodObject<{
415
+ formatted: z.ZodString;
416
+ unformatted: z.ZodString;
417
+ }, "strip", z.ZodTypeAny, {
418
+ formatted: string;
419
+ unformatted: string;
420
+ }, {
421
+ formatted: string;
422
+ unformatted: string;
423
+ }>;
424
+ }, "strip", z.ZodTypeAny, {
425
+ sha256: {
426
+ formatted: string;
427
+ unformatted: string;
428
+ };
429
+ }, {
430
+ sha256: {
431
+ formatted: string;
432
+ unformatted: string;
433
+ };
434
+ }>;
435
+ export declare const samlApplicationSecretResponseGuard: z.ZodObject<z.objectUtil.extendShape<Omit<{
436
+ id: z.ZodType<string, z.ZodTypeDef, string>;
437
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
438
+ applicationId: z.ZodType<string, z.ZodTypeDef, string>;
439
+ privateKey: z.ZodType<string, z.ZodTypeDef, string>;
440
+ certificate: z.ZodType<string, z.ZodTypeDef, string>;
441
+ createdAt: z.ZodType<number, z.ZodTypeDef, number>;
442
+ expiresAt: z.ZodType<number, z.ZodTypeDef, number>;
443
+ active: z.ZodType<boolean, z.ZodTypeDef, boolean>;
444
+ }, "applicationId" | "tenantId" | "privateKey">, {
445
+ fingerprints: z.ZodObject<{
446
+ sha256: z.ZodObject<{
447
+ formatted: z.ZodString;
448
+ unformatted: z.ZodString;
449
+ }, "strip", z.ZodTypeAny, {
450
+ formatted: string;
451
+ unformatted: string;
452
+ }, {
453
+ formatted: string;
454
+ unformatted: string;
455
+ }>;
456
+ }, "strip", z.ZodTypeAny, {
457
+ sha256: {
458
+ formatted: string;
459
+ unformatted: string;
460
+ };
461
+ }, {
462
+ sha256: {
463
+ formatted: string;
464
+ unformatted: string;
465
+ };
466
+ }>;
467
+ }>, "strip", z.ZodTypeAny, {
468
+ id: string;
469
+ createdAt: number;
470
+ expiresAt: number;
471
+ certificate: string;
472
+ active: boolean;
473
+ fingerprints: {
474
+ sha256: {
475
+ formatted: string;
476
+ unformatted: string;
477
+ };
478
+ };
479
+ }, {
480
+ id: string;
481
+ createdAt: number;
482
+ expiresAt: number;
483
+ certificate: string;
484
+ active: boolean;
485
+ fingerprints: {
486
+ sha256: {
487
+ formatted: string;
488
+ unformatted: string;
489
+ };
490
+ };
491
+ }>;
492
+ export type SamlApplicationSecretResponse = z.infer<typeof samlApplicationSecretResponseGuard>;
493
+ export {};
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ import { Applications } from '../db-entries/application.js';
3
+ import { SamlApplicationConfigs } from '../db-entries/saml-application-config.js';
4
+ import { SamlApplicationSecrets } from '../db-entries/saml-application-secret.js';
5
+ import { applicationCreateGuard, applicationPatchGuard } from './application.js';
6
+ const samlAppConfigGuard = SamlApplicationConfigs.guard.pick({
7
+ attributeMapping: true,
8
+ entityId: true,
9
+ acsUrl: true,
10
+ });
11
+ export const samlApplicationCreateGuard = applicationCreateGuard
12
+ .pick({
13
+ name: true,
14
+ description: true,
15
+ customData: true,
16
+ })
17
+ // The reason for encapsulating attributeMapping and spMetadata into an object within the config field is that you cannot provide only one of `attributeMapping` or `spMetadata`. Due to the structure of the `saml_application_configs` table, both must be not null.
18
+ .merge(samlAppConfigGuard.partial());
19
+ export const samlApplicationPatchGuard = applicationPatchGuard
20
+ .pick({
21
+ name: true,
22
+ description: true,
23
+ customData: true,
24
+ })
25
+ // The reason for encapsulating attributeMapping and spMetadata into an object within the config field is that you cannot provide only one of `attributeMapping` or `spMetadata`. Due to the structure of the `saml_application_configs` table, both must be not null.
26
+ .merge(samlAppConfigGuard.partial());
27
+ export const samlApplicationResponseGuard = Applications.guard
28
+ .omit({
29
+ secret: true,
30
+ oidcClientMetadata: true,
31
+ customClientMetadata: true,
32
+ protectedAppMetadata: true,
33
+ })
34
+ .merge(
35
+ // Partial to allow the optional fields to be omitted in the response.
36
+ // When starting to create a SAML application, SAML configuration is optional, which can lead to the absence of SAML configuration.
37
+ samlAppConfigGuard);
38
+ const fingerprintFormatGuard = z.object({
39
+ formatted: z.string(),
40
+ unformatted: z.string(),
41
+ });
42
+ export const certificateFingerprintsGuard = z.object({
43
+ sha256: fingerprintFormatGuard,
44
+ });
45
+ // Make sure the `privateKey` is not exposed in the response.
46
+ export const samlApplicationSecretResponseGuard = SamlApplicationSecrets.guard
47
+ .omit({
48
+ tenantId: true,
49
+ applicationId: true,
50
+ privateKey: true,
51
+ })
52
+ .extend({
53
+ fingerprints: certificateFingerprintsGuard,
54
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "@types/inquirer": "^9.0.0",
32
32
  "@types/node": "^20.9.5",
33
33
  "@types/pluralize": "^0.0.33",
34
- "@vitest/coverage-v8": "^2.0.0",
34
+ "@vitest/coverage-v8": "^2.1.8",
35
35
  "camelcase": "^8.0.0",
36
36
  "chalk": "^5.3.0",
37
37
  "eslint": "^8.56.0",
@@ -40,7 +40,7 @@
40
40
  "prettier": "^3.0.0",
41
41
  "roarr": "^7.11.0",
42
42
  "typescript": "^5.5.3",
43
- "vitest": "^2.0.0"
43
+ "vitest": "^2.1.8"
44
44
  },
45
45
  "eslintConfig": {
46
46
  "extends": "@silverhand",
@@ -64,13 +64,13 @@
64
64
  "prettier": "@silverhand/eslint-config/.prettierrc",
65
65
  "dependencies": {
66
66
  "@logto/connector-kit": "^4.1.0",
67
- "@logto/core-kit": "^2.5.0",
67
+ "@logto/core-kit": "^2.5.2",
68
68
  "@logto/language-kit": "^1.1.0",
69
- "@logto/phrases": "^1.15.0",
69
+ "@logto/phrases": "^1.16.0",
70
70
  "@logto/phrases-experience": "^1.9.0",
71
71
  "@logto/shared": "^3.1.2",
72
72
  "@withtyped/server": "^0.14.0",
73
- "nanoid": "^5.0.1"
73
+ "nanoid": "^5.0.9"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "zod": "^3.23.8"
@@ -1,10 +1,6 @@
1
1
  /* init_order = 2 */
2
2
 
3
- /**
4
- * The SAML application config and SAML-type application have a one-to-one correspondence:
5
- * - a SAML-type application can only have one SAML application config
6
- * - a SAML application config can only configure one SAML-type application
7
- */
3
+ /** The SAML application config and SAML-type application have a one-to-one correspondence: 1. a SAML-type application can only have one SAML application config. (CANNOT use "semicolon" in comments, since it indicates the end of query.) 2. a SAML application config can only configure one SAML-type application. */
8
4
  create table saml_application_configs (
9
5
  application_id varchar(21) not null
10
6
  references applications (id) on update cascade on delete cascade,
@@ -14,6 +10,6 @@ create table saml_application_configs (
14
10
  entity_id varchar(128),
15
11
  acs_url jsonb /* @use SamlAcsUrl */,
16
12
  primary key (tenant_id, application_id),
17
- constraint application_type
13
+ constraint saml_application_configs__application_type
18
14
  check (check_application_type(application_id, 'SAML'))
19
15
  );
@@ -12,7 +12,7 @@ create table saml_application_secrets (
12
12
  expires_at timestamptz not null,
13
13
  active boolean not null,
14
14
  primary key (tenant_id, application_id, id),
15
- constraint application_type
15
+ constraint saml_application_secrets__application_type
16
16
  check (check_application_type(application_id, 'SAML'))
17
17
  );
18
18
 
@@ -0,0 +1,23 @@
1
+ /* init_order = 2 */
2
+
3
+ create table saml_application_sessions (
4
+ tenant_id varchar(21) not null
5
+ references tenants (id) on update cascade on delete cascade,
6
+ /** The globally unique identifier of the session. */
7
+ id varchar(32) not null,
8
+ application_id varchar(21) not null
9
+ references applications (id) on update cascade on delete cascade,
10
+ /** The identifier of the SAML SSO auth request ID, SAML request ID is pretty long. */
11
+ saml_request_id varchar(128) not null,
12
+ /** The identifier of the OIDC auth request state. */
13
+ oidc_state varchar(32),
14
+ /** The relay state of the SAML auth request. */
15
+ relay_state varchar(256),
16
+ /** The raw request of the SAML auth request. */
17
+ raw_auth_request text not null,
18
+ created_at timestamptz not null default(now()),
19
+ expires_at timestamptz not null,
20
+ primary key (tenant_id, id),
21
+ constraint saml_application_sessions__application_type
22
+ check (check_application_type(application_id, 'SAML'))
23
+ );
@@ -20,5 +20,5 @@ create table sso_connector_idp_initiated_auth_configs (
20
20
  primary key (tenant_id, connector_id),
21
21
  /** Insure the application type is Traditional or SPA. */
22
22
  constraint application_type
23
- check (check_application_type(default_application_id, 'Traditional', 'SPA'))
23
+ check (check_application_type(default_application_id, 'Traditional', 'SPA', 'SAML'))
24
24
  );