@lunora/auth 1.0.0-alpha.47 → 1.0.0-alpha.49

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.
@@ -0,0 +1,1576 @@
1
+ import 'better-auth/api';
2
+ import * as z from 'zod';
3
+ import { DBFieldAttribute, RemoveFieldsWithReturnedFalse, FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions } from 'better-auth/db';
4
+ import { DBTransactionAdapter, Awaitable, User, OAuth2Tokens } from 'better-auth';
5
+ import '@better-auth/core';
6
+ type DeprecatedAlgorithmBehavior = "reject" | "warn" | "allow";
7
+ interface AlgorithmValidationOptions {
8
+ onDeprecated?: DeprecatedAlgorithmBehavior;
9
+ allowedSignatureAlgorithms?: string[];
10
+ allowedDigestAlgorithms?: string[];
11
+ allowedKeyEncryptionAlgorithms?: string[];
12
+ allowedDataEncryptionAlgorithms?: string[];
13
+ }
14
+ //#endregion
15
+ //#region src/types.d.ts
16
+ interface OIDCMapping {
17
+ email?: string | undefined;
18
+ emailVerified?: string | undefined;
19
+ name?: string | undefined;
20
+ image?: string | undefined;
21
+ extraFields?: Record<string, string> | undefined;
22
+ }
23
+ interface SAMLMapping {
24
+ email?: string | undefined;
25
+ emailVerified?: string | undefined;
26
+ name?: string | undefined;
27
+ firstName?: string | undefined;
28
+ lastName?: string | undefined;
29
+ extraFields?: Record<string, string> | undefined;
30
+ }
31
+ interface OIDCConfig {
32
+ issuer: string;
33
+ pkce: boolean;
34
+ clientId: string;
35
+ /** Required for client_secret_basic/client_secret_post. Optional for private_key_jwt. */
36
+ clientSecret?: string;
37
+ authorizationEndpoint?: string | undefined;
38
+ discoveryEndpoint: string;
39
+ userInfoEndpoint?: string | undefined;
40
+ scopes?: string[] | undefined;
41
+ overrideUserInfo?: boolean | undefined;
42
+ tokenEndpoint?: string | undefined;
43
+ tokenEndpointAuthentication?: ("client_secret_post" | "client_secret_basic" | "private_key_jwt") | undefined;
44
+ /** Key ID for private_key_jwt key resolution */
45
+ privateKeyId?: string | undefined;
46
+ /** Signing algorithm for private_key_jwt. @default "RS256" */
47
+ privateKeyAlgorithm?: string | undefined;
48
+ jwksEndpoint?: string | undefined;
49
+ mapping?: OIDCMapping | undefined;
50
+ /**
51
+ * Accept callbacks from OIDC providers that initiate the OAuth flow
52
+ * without sending a `state` parameter. When enabled, stateless callbacks
53
+ * restart the OAuth flow server-side with a fresh `state` and PKCE
54
+ * verifier. See the SSO docs for details.
55
+ *
56
+ * @default false
57
+ */
58
+ allowIdpInitiated?: boolean | undefined;
59
+ }
60
+ interface SAMLIdentityProviderMetadataBase {
61
+ /**
62
+ * IdP signing certificate(s). Pass a single PEM string or an array for
63
+ * rolling rotation. Takes precedence over the top-level `cert` when both
64
+ * are set. Omit when `metadata` XML is supplied.
65
+ */
66
+ cert?: string | string[] | undefined;
67
+ privateKey?: string | undefined;
68
+ privateKeyPass?: string | undefined;
69
+ isAssertionEncrypted?: boolean | undefined;
70
+ encPrivateKey?: string | undefined;
71
+ encPrivateKeyPass?: string | undefined;
72
+ singleSignOnService?: Array<{
73
+ Binding: string;
74
+ Location: string;
75
+ }> | undefined;
76
+ singleLogoutService?: Array<{
77
+ Binding: string;
78
+ Location: string;
79
+ }> | undefined;
80
+ }
81
+ /**
82
+ * The trusted identity-provider authority for a SAML connection.
83
+ *
84
+ * Metadata XML carries the IdP entity ID. Manual configurations must declare
85
+ * `entityID` explicitly so the service provider's issuer is never mistaken
86
+ * for the identity provider's authority.
87
+ */
88
+ type SAMLIdentityProviderMetadata = SAMLIdentityProviderMetadataBase & ({
89
+ metadata: string;
90
+ entityID?: string | undefined;
91
+ } | {
92
+ metadata?: undefined;
93
+ entityID: string;
94
+ });
95
+ interface SAMLConfig {
96
+ /**
97
+ * SP Entity ID. Used as the `entityID` in SP metadata when
98
+ * `spMetadata.entityID` is not set. Also used as the expected
99
+ * audience for SAML assertion validation when `audience` is not set.
100
+ */
101
+ issuer: string;
102
+ /**
103
+ * IdP SSO URL. Used as the redirect destination when
104
+ * `idpMetadata.metadata` is not provided. Ignored when
105
+ * IdP metadata XML is set (the SSO URL is extracted from the XML).
106
+ */
107
+ entryPoint: string;
108
+ /**
109
+ * IdP signing certificate(s). Used to verify SAML response signatures when
110
+ * `idpMetadata.metadata` is not provided. Ignored when IdP metadata XML is
111
+ * set (the certificate is extracted from the XML). When both this and
112
+ * `idpMetadata.cert` are set, `idpMetadata.cert` takes precedence. Pass an
113
+ * array of PEM strings for rolling rotation; responses signed by any
114
+ * listed cert are accepted.
115
+ */
116
+ cert?: string | string[];
117
+ audience?: string | undefined;
118
+ /**
119
+ * Provider-level post-auth redirect URL for IdP-initiated or fallback SAML
120
+ * flows when no RelayState callback URL is available.
121
+ */
122
+ callbackUrl?: string | undefined;
123
+ /**
124
+ * Fallback absolute URL or same-origin relative path for IdP-initiated SAML
125
+ * responses when RelayState has no safe callback, including error redirects.
126
+ */
127
+ idpInitiatedCallbackUrl?: string | undefined;
128
+ idpMetadata: SAMLIdentityProviderMetadata;
129
+ /**
130
+ * SP metadata configuration. All fields are optional; when omitted,
131
+ * SP metadata is auto-generated from `issuer`, `wantAssertionsSigned`,
132
+ * `authnRequestsSigned`, and `identifierFormat`.
133
+ */
134
+ spMetadata?: {
135
+ metadata?: string | undefined;
136
+ entityID?: string | undefined;
137
+ binding?: string | undefined;
138
+ privateKey?: string | undefined;
139
+ privateKeyPass?: string | undefined;
140
+ isAssertionEncrypted?: boolean | undefined;
141
+ encPrivateKey?: string | undefined;
142
+ encPrivateKeyPass?: string | undefined;
143
+ };
144
+ /**
145
+ * Request signed assertions from the IdP. When true, the SP metadata
146
+ * advertises `WantAssertionsSigned="true"` and samlify will reject
147
+ * unsigned assertions.
148
+ */
149
+ wantAssertionsSigned?: boolean | undefined;
150
+ authnRequestsSigned?: boolean | undefined;
151
+ signatureAlgorithm?: string | undefined;
152
+ digestAlgorithm?: string | undefined;
153
+ identifierFormat?: string | undefined;
154
+ privateKey?: string | undefined;
155
+ mapping?: SAMLMapping | undefined;
156
+ }
157
+ type BaseSSOProvider = {
158
+ issuer: string;
159
+ oidcConfig?: OIDCConfig | undefined;
160
+ samlConfig?: SAMLConfig | undefined;
161
+ userId: string;
162
+ providerId: string;
163
+ organizationId?: string | undefined;
164
+ domain: string;
165
+ };
166
+ type SSOProviderAdditionalFields<O extends SSOOptions, IsClientSide extends boolean> = O["schema"] extends {
167
+ ssoProvider?: {
168
+ additionalFields: infer Field extends Record<string, DBFieldAttribute>;
169
+ };
170
+ } ? IsClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : FieldAttributeToObject<Field> : {};
171
+ type SSOProviderAdditionalFieldsInput<O extends SSOOptions, IsClientSide extends boolean = true> = InferAdditionalFieldsFromPluginOptions<"ssoProvider", O, IsClientSide>;
172
+ type InferSSOProvider<O extends SSOOptions, IsClientSide extends boolean = true> = (O["domainVerification"] extends {
173
+ enabled: true;
174
+ } ? {
175
+ domainVerified: boolean;
176
+ } & BaseSSOProvider : BaseSSOProvider) & SSOProviderAdditionalFields<O, IsClientSide>;
177
+ type SSOProvider<O extends SSOOptions> = O["domainVerification"] extends {
178
+ enabled: true;
179
+ } ? {
180
+ domainVerified: boolean;
181
+ } & BaseSSOProvider & SSOProviderAdditionalFields<O, false> : BaseSSOProvider & SSOProviderAdditionalFields<O, false>;
182
+ type SSOProviderSchema<O extends SSOOptions> = {
183
+ ssoProvider: {
184
+ modelName: string;
185
+ fields: Record<string, DBFieldAttribute> & (O["schema"] extends {
186
+ ssoProvider?: {
187
+ additionalFields: infer Field extends Record<string, DBFieldAttribute>;
188
+ };
189
+ } ? Field : {});
190
+ };
191
+ };
192
+ /** Decision returned by an SSO user resolver. */
193
+ type SSOUserResolution = {
194
+ action: "continue";
195
+ } | {
196
+ action: "link";
197
+ userId: string;
198
+ profile: "preserve" | "update";
199
+ } | {
200
+ action: "reject";
201
+ code: string;
202
+ message?: string | undefined;
203
+ };
204
+ /** Normalized provider attributes available to an SSO user resolver. */
205
+ type SSOProviderUserProfile = {
206
+ email: string;
207
+ emailVerified: boolean;
208
+ name: string;
209
+ image?: string | null | undefined;
210
+ } & Record<string, unknown>;
211
+ /** OIDC identity and profile data available to an application's SSO resolver. */
212
+ interface SSOUserResolutionInput {
213
+ protocol: "oidc";
214
+ providerId: string;
215
+ accountKey: {
216
+ issuer: string;
217
+ providerAccountId: string;
218
+ };
219
+ providerUser: SSOProviderUserProfile;
220
+ providerClaims: Record<string, unknown>;
221
+ }
222
+ /** Transaction-bound capabilities available while resolving an SSO user. */
223
+ interface SSOUserResolutionContext {
224
+ database: DBTransactionAdapter;
225
+ }
226
+ interface SSOOptions {
227
+ /**
228
+ * Resolve a verified provider identity to a Better Auth user.
229
+ *
230
+ * Currently invoked for OIDC callbacks only.
231
+ *
232
+ * TODO: Invoke this resolver for SAML callbacks after normalizing the verified
233
+ * IdP entity ID as `accountKey.issuer` and the signed NameID as
234
+ * `accountKey.providerAccountId`.
235
+ *
236
+ * `accountKey` is derived from the validated ID Token. Profile fields and raw
237
+ * claims are protocol-accepted provider data and may require application-level
238
+ * validation. The callback runs on every OIDC sign-in inside the same native
239
+ * database transaction as account finalization and session creation.
240
+ */
241
+ resolveUser?: ((input: SSOUserResolutionInput, context: SSOUserResolutionContext) => Awaitable<SSOUserResolution>) | undefined;
242
+ /**
243
+ * custom function to provision a user when they sign in with an SSO provider.
244
+ */
245
+ provisionUser?: ((data: {
246
+ /**
247
+ * The user object from the database
248
+ */
249
+ user: User & Record<string, any>;
250
+ /**
251
+ * The user info object from the provider
252
+ */
253
+ userInfo: Record<string, any>;
254
+ /**
255
+ * The OAuth2 tokens from the provider
256
+ */
257
+ token?: OAuth2Tokens;
258
+ /**
259
+ * The SSO provider
260
+ */
261
+ provider: SSOProvider<SSOOptions>;
262
+ }) => Awaitable<void>) | undefined;
263
+ /**
264
+ * If true, the `provisionUser` callback will be called on every login,
265
+ * not just when a new user is registered. This is useful when you need
266
+ * to sync upstream identity provider profile changes on each sign-in.
267
+ *
268
+ * The `provisionUser` callback should be idempotent when this is enabled.
269
+ *
270
+ * @default false
271
+ */
272
+ provisionUserOnEveryLogin?: boolean;
273
+ /**
274
+ * Organization provisioning options
275
+ */
276
+ organizationProvisioning?: {
277
+ disabled?: boolean;
278
+ defaultRole?: "member" | "admin";
279
+ getRole?: (data: {
280
+ /**
281
+ * The user object from the database
282
+ */
283
+ user: User & Record<string, any>;
284
+ /**
285
+ * The user info object from the provider
286
+ */
287
+ userInfo: Record<string, any>;
288
+ /**
289
+ * The OAuth2 tokens from the provider
290
+ */
291
+ token?: OAuth2Tokens;
292
+ /**
293
+ * The SSO provider
294
+ */
295
+ provider: SSOProvider<SSOOptions>;
296
+ }) => Promise<"member" | "admin">;
297
+ } | undefined;
298
+ /**
299
+ * Default SSO provider configurations for testing.
300
+ * These will take the precedence over the database providers.
301
+ */
302
+ defaultSSO?: Array<{
303
+ /**
304
+ * The domain to match for this default provider.
305
+ * This is only used to match incoming requests to this default provider.
306
+ */
307
+ domain: string;
308
+ /**
309
+ * The provider ID to use
310
+ */
311
+ providerId: string;
312
+ /**
313
+ * SAML configuration
314
+ */
315
+ samlConfig?: SAMLConfig;
316
+ /**
317
+ * OIDC configuration
318
+ */
319
+ oidcConfig?: OIDCConfig;
320
+ /**
321
+ * Private key for `private_key_jwt` authentication.
322
+ * Only used with defaultSSO — not stored in DB.
323
+ */
324
+ privateKey?: {
325
+ privateKeyJwk?: JsonWebKey;
326
+ privateKeyPem?: string;
327
+ };
328
+ }> | undefined;
329
+ /**
330
+ * Override user info with the provider info.
331
+ * @default false
332
+ */
333
+ defaultOverrideUserInfo?: boolean | undefined;
334
+ /**
335
+ * Disable implicit sign up for new users. When set to true for the provider,
336
+ * sign-in need to be called with with requestSignUp as true to create new users.
337
+ */
338
+ disableImplicitSignUp?: boolean | undefined;
339
+ /**
340
+ * The model name for the SSO provider table. Defaults to "ssoProvider".
341
+ */
342
+ modelName?: string;
343
+ /**
344
+ * Map fields
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * {
349
+ * samlConfig: "saml_config"
350
+ * }
351
+ * ```
352
+ */
353
+ fields?: {
354
+ issuer?: string | undefined;
355
+ oidcConfig?: string | undefined;
356
+ samlConfig?: string | undefined;
357
+ userId?: string | undefined;
358
+ providerId?: string | undefined;
359
+ organizationId?: string | undefined;
360
+ domain?: string | undefined;
361
+ };
362
+ /**
363
+ * The schema for the SSO plugin.
364
+ */
365
+ schema?: {
366
+ ssoProvider?: {
367
+ modelName?: string | undefined;
368
+ fields?: {
369
+ issuer?: string | undefined;
370
+ oidcConfig?: string | undefined;
371
+ samlConfig?: string | undefined;
372
+ userId?: string | undefined;
373
+ providerId?: string | undefined;
374
+ organizationId?: string | undefined;
375
+ domain?: string | undefined;
376
+ domainVerified?: string | undefined;
377
+ };
378
+ additionalFields?: { [key in string]: DBFieldAttribute; };
379
+ };
380
+ } | undefined;
381
+ /**
382
+ * Configure the maximum number of SSO providers a user can register.
383
+ * You can also pass a function that returns a number.
384
+ * Set to 0 to disable SSO provider registration.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * providersLimit: async (user) => {
389
+ * const plan = await getUserPlan(user);
390
+ * return plan.name === "pro" ? 10 : 1;
391
+ * }
392
+ * ```
393
+ * @default 10
394
+ */
395
+ providersLimit?: (number | ((user: User) => Awaitable<number>)) | undefined;
396
+ /**
397
+ * Trust the email verified flag from the provider.
398
+ *
399
+ * ⚠️ Use this with caution — it can lead to account takeover if misused. Only enable it if users **cannot freely register new providers**. You can
400
+ * prevent that by using `disabledPaths` or other safeguards to block provider registration from the client.
401
+ *
402
+ * If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
403
+ * providers in the `trustedProviders` list.
404
+ *
405
+ * @default false
406
+ *
407
+ * @deprecated This option is discouraged for new projects. Relying on provider-level `email_verified` is a weaker
408
+ * trust signal compared to using `trustedProviders` in `accountLinking` or enabling `domainVerification` for SSO.
409
+ * Existing configurations will continue to work, but new integrations should use explicit trust mechanisms.
410
+ * This option may be removed in a future major version.
411
+ */
412
+ trustEmailVerified?: boolean | undefined;
413
+ /**
414
+ * Enable domain verification on SSO providers
415
+ *
416
+ * When this option is enabled, new SSO providers will require the associated domain to be verified by the owner
417
+ * prior to allowing sign-ins.
418
+ */
419
+ domainVerification?: {
420
+ /**
421
+ * Enables or disables the domain verification feature
422
+ */
423
+ enabled?: boolean;
424
+ /**
425
+ * Prefix used to generate the domain verification token.
426
+ * An underscore is automatically prepended to follow DNS
427
+ * infrastructure subdomain conventions (RFC 8552), so do
428
+ * not include a leading underscore.
429
+ *
430
+ * @default "better-auth-token"
431
+ */
432
+ tokenPrefix?: string;
433
+ };
434
+ /**
435
+ * A shared redirect URI used by all OIDC providers instead of
436
+ * per-provider callback URLs. Can be a path or a full URL.
437
+ */
438
+ redirectURI?: string;
439
+ /**
440
+ * Callback to resolve private key material for private_key_jwt authentication.
441
+ * Called during token exchange when a provider uses tokenEndpointAuthentication: "private_key_jwt".
442
+ * Keeps private keys out of the database — supports HSM/KMS/Vault integration.
443
+ */
444
+ resolvePrivateKey?: (params: {
445
+ providerId: string;
446
+ keyId?: string;
447
+ issuer: string;
448
+ }) => Promise<{
449
+ privateKeyJwk?: JsonWebKey;
450
+ privateKeyPem?: string;
451
+ kid?: string;
452
+ algorithm?: string;
453
+ }>;
454
+ /**
455
+ * SAML security options for AuthnRequest/InResponseTo validation.
456
+ * This prevents unsolicited responses, replay attacks, and cross-provider injection.
457
+ */
458
+ saml?: {
459
+ /**
460
+ * Enable InResponseTo validation for SP-initiated SAML flows.
461
+ * When enabled, AuthnRequest IDs are tracked and validated against SAML responses.
462
+ *
463
+ * Storage behavior:
464
+ * - Uses `secondaryStorage` (e.g., Redis) if configured in your auth options
465
+ * - Falls back to the verification table in the database otherwise
466
+ *
467
+ * This works correctly in serverless environments without any additional configuration.
468
+ *
469
+ * @default true
470
+ */
471
+ enableInResponseToValidation?: boolean;
472
+ /**
473
+ * Allow IdP-initiated SSO (unsolicited SAML responses).
474
+ * When true, responses without InResponseTo are accepted.
475
+ * When false, all responses must correlate to a stored AuthnRequest.
476
+ *
477
+ * IdP-initiated SSO is a known attack vector — the SAML2Int
478
+ * interoperability profile recommends against it. Only enable
479
+ * this if your IdP requires it and you understand the risks.
480
+ *
481
+ * Only applies when InResponseTo validation is enabled.
482
+ *
483
+ * @default false
484
+ */
485
+ allowIdpInitiated?: boolean;
486
+ /**
487
+ * TTL for AuthnRequest records in milliseconds.
488
+ * Requests older than this will be rejected.
489
+ *
490
+ * Only applies when InResponseTo validation is enabled.
491
+ *
492
+ * @default 300000 (5 minutes)
493
+ */
494
+ requestTTL?: number;
495
+ /**
496
+ * Clock skew tolerance for SAML assertion timestamp validation in milliseconds.
497
+ * Allows for minor time differences between IdP and SP servers.
498
+ *
499
+ * Defaults to 300000 (5 minutes) to accommodate:
500
+ * - Network latency and processing time
501
+ * - Clock synchronization differences (NTP drift)
502
+ * - Distributed systems across timezones
503
+ *
504
+ * For stricter security, reduce to 1-2 minutes (60000-120000).
505
+ * For highly distributed systems, increase up to 10 minutes (600000).
506
+ *
507
+ * @default 300000 (5 minutes)
508
+ */
509
+ clockSkew?: number;
510
+ /**
511
+ * Require timestamp conditions (NotBefore/NotOnOrAfter) in SAML assertions.
512
+ * When enabled, assertions without timestamp conditions will be rejected.
513
+ *
514
+ * When disabled (default), assertions without timestamps are accepted
515
+ * but a warning is logged.
516
+ *
517
+ * **SAML Spec Notes:**
518
+ * - SAML 2.0 Core: Timestamps are OPTIONAL
519
+ * - SAML2Int (enterprise profile): Timestamps are REQUIRED
520
+ *
521
+ * **Recommendation:** Enable for enterprise/production deployments
522
+ * where your IdP follows SAML2Int (Okta, Azure AD, OneLogin, etc.)
523
+ *
524
+ * @default false
525
+ */
526
+ requireTimestamps?: boolean;
527
+ /**
528
+ * Algorithm validation options for SAML responses.
529
+ *
530
+ * Controls behavior when deprecated algorithms (SHA-1, RSA1_5, 3DES)
531
+ * are detected in SAML responses.
532
+ *
533
+ * @example
534
+ * ```ts
535
+ * algorithms: {
536
+ * onDeprecated: "reject" // Reject deprecated algorithms
537
+ * }
538
+ * ```
539
+ */
540
+ algorithms?: AlgorithmValidationOptions;
541
+ /**
542
+ * Maximum allowed size for SAML responses in bytes.
543
+ *
544
+ * @default 262144 (256KB)
545
+ */
546
+ maxResponseSize?: number;
547
+ /**
548
+ * Maximum allowed size for IdP metadata XML in bytes.
549
+ *
550
+ * @default 102400 (100KB)
551
+ */
552
+ maxMetadataSize?: number;
553
+ /**
554
+ * Enable SAML Single Logout
555
+ * @default false
556
+ */
557
+ enableSingleLogout?: boolean;
558
+ /**
559
+ * TTL for LogoutRequest records in milliseconds
560
+ * @default 300000 (5 minutes)
561
+ */
562
+ logoutRequestTTL?: number;
563
+ /**
564
+ * Require signed LogoutRequests from IdP
565
+ * @default false
566
+ */
567
+ wantLogoutRequestSigned?: boolean;
568
+ /**
569
+ * Require signed LogoutResponses from IdP
570
+ * @default false
571
+ */
572
+ wantLogoutResponseSigned?: boolean;
573
+ /**
574
+ * Global fallback absolute URL or same-origin relative path for
575
+ * IdP-initiated SAML responses when the provider has no safe callback.
576
+ */
577
+ idpInitiatedCallbackUrl?: string | undefined;
578
+ };
579
+ }
580
+ //#endregion
581
+ //#region src/routes/domain-verification.d.ts
582
+ declare const requestDomainVerification: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/request-domain-verification", {
583
+ method: "POST";
584
+ body: z.ZodObject<{
585
+ providerId: z.ZodString;
586
+ }, z.core.$strip>;
587
+ metadata: {
588
+ openapi: {
589
+ summary: string;
590
+ description: string;
591
+ responses: {
592
+ "404": {
593
+ description: string;
594
+ };
595
+ "409": {
596
+ description: string;
597
+ };
598
+ "201": {
599
+ description: string;
600
+ };
601
+ };
602
+ };
603
+ };
604
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
605
+ session: {
606
+ session: Record<string, any> & {
607
+ id: string;
608
+ createdAt: Date;
609
+ updatedAt: Date;
610
+ userId: string;
611
+ expiresAt: Date;
612
+ token: string;
613
+ ipAddress?: string | null | undefined;
614
+ userAgent?: string | null | undefined;
615
+ };
616
+ user: Record<string, any> & {
617
+ id: string;
618
+ createdAt: Date;
619
+ updatedAt: Date;
620
+ email: string;
621
+ emailVerified: boolean;
622
+ name: string;
623
+ image?: string | null | undefined;
624
+ };
625
+ };
626
+ }>)[];
627
+ }, {
628
+ domainVerificationToken: string;
629
+ }>;
630
+ declare const verifyDomain: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/verify-domain", {
631
+ method: "POST";
632
+ body: z.ZodObject<{
633
+ providerId: z.ZodString;
634
+ }, z.core.$strip>;
635
+ metadata: {
636
+ openapi: {
637
+ summary: string;
638
+ description: string;
639
+ responses: {
640
+ "404": {
641
+ description: string;
642
+ };
643
+ "409": {
644
+ description: string;
645
+ };
646
+ "502": {
647
+ description: string;
648
+ };
649
+ "204": {
650
+ description: string;
651
+ };
652
+ };
653
+ };
654
+ };
655
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
656
+ session: {
657
+ session: Record<string, any> & {
658
+ id: string;
659
+ createdAt: Date;
660
+ updatedAt: Date;
661
+ userId: string;
662
+ expiresAt: Date;
663
+ token: string;
664
+ ipAddress?: string | null | undefined;
665
+ userAgent?: string | null | undefined;
666
+ };
667
+ user: Record<string, any> & {
668
+ id: string;
669
+ createdAt: Date;
670
+ updatedAt: Date;
671
+ email: string;
672
+ emailVerified: boolean;
673
+ name: string;
674
+ image?: string | null | undefined;
675
+ };
676
+ };
677
+ }>)[];
678
+ }, void>;
679
+ //#endregion
680
+ //#region src/utils.d.ts
681
+ declare function parseCertificate(certPem: string): {
682
+ fingerprintSha256: string;
683
+ notBefore: string;
684
+ notAfter: string;
685
+ publicKeyAlgorithm: string;
686
+ };
687
+ //#endregion
688
+ //#region src/routes/providers.d.ts
689
+ type ParsedCert = ReturnType<typeof parseCertificate>;
690
+ type SanitizedCert = ParsedCert | {
691
+ error: string;
692
+ };
693
+ declare const listSSOProviders: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/providers", {
694
+ method: "GET";
695
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
696
+ session: {
697
+ session: Record<string, any> & {
698
+ id: string;
699
+ createdAt: Date;
700
+ updatedAt: Date;
701
+ userId: string;
702
+ expiresAt: Date;
703
+ token: string;
704
+ ipAddress?: string | null | undefined;
705
+ userAgent?: string | null | undefined;
706
+ };
707
+ user: Record<string, any> & {
708
+ id: string;
709
+ createdAt: Date;
710
+ updatedAt: Date;
711
+ email: string;
712
+ emailVerified: boolean;
713
+ name: string;
714
+ image?: string | null | undefined;
715
+ };
716
+ };
717
+ }>)[];
718
+ metadata: {
719
+ openapi: {
720
+ operationId: string;
721
+ summary: string;
722
+ description: string;
723
+ responses: {
724
+ "200": {
725
+ description: string;
726
+ };
727
+ };
728
+ };
729
+ };
730
+ }, {
731
+ providers: {
732
+ providerId: string;
733
+ type: string;
734
+ issuer: string;
735
+ domain: string;
736
+ organizationId: string | null;
737
+ domainVerified: boolean;
738
+ oidcConfig: {
739
+ discoveryEndpoint: string;
740
+ clientIdLastFour: string;
741
+ pkce: boolean;
742
+ authorizationEndpoint: string | undefined;
743
+ tokenEndpoint: string | undefined;
744
+ userInfoEndpoint: string | undefined;
745
+ jwksEndpoint: string | undefined;
746
+ scopes: string[] | undefined;
747
+ tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | "private_key_jwt" | undefined;
748
+ } | undefined;
749
+ samlConfig: {
750
+ entryPoint: string;
751
+ callbackUrl: string | undefined;
752
+ idpInitiatedCallbackUrl: string | undefined;
753
+ audience: string | undefined;
754
+ wantAssertionsSigned: boolean | undefined;
755
+ authnRequestsSigned: boolean | undefined;
756
+ identifierFormat: string | undefined;
757
+ signatureAlgorithm: string | undefined;
758
+ digestAlgorithm: string | undefined;
759
+ certificate: SanitizedCert[] | undefined;
760
+ } | undefined;
761
+ spMetadataUrl: string;
762
+ }[];
763
+ }>;
764
+ declare const getSSOProvider: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/get-provider", {
765
+ method: "GET";
766
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
767
+ session: {
768
+ session: Record<string, any> & {
769
+ id: string;
770
+ createdAt: Date;
771
+ updatedAt: Date;
772
+ userId: string;
773
+ expiresAt: Date;
774
+ token: string;
775
+ ipAddress?: string | null | undefined;
776
+ userAgent?: string | null | undefined;
777
+ };
778
+ user: Record<string, any> & {
779
+ id: string;
780
+ createdAt: Date;
781
+ updatedAt: Date;
782
+ email: string;
783
+ emailVerified: boolean;
784
+ name: string;
785
+ image?: string | null | undefined;
786
+ };
787
+ };
788
+ }>)[];
789
+ query: z.ZodObject<{
790
+ providerId: z.ZodString;
791
+ }, z.core.$strip>;
792
+ metadata: {
793
+ openapi: {
794
+ operationId: string;
795
+ summary: string;
796
+ description: string;
797
+ responses: {
798
+ "200": {
799
+ description: string;
800
+ };
801
+ "404": {
802
+ description: string;
803
+ };
804
+ "403": {
805
+ description: string;
806
+ };
807
+ };
808
+ };
809
+ };
810
+ }, {
811
+ providerId: string;
812
+ type: string;
813
+ issuer: string;
814
+ domain: string;
815
+ organizationId: string | null;
816
+ domainVerified: boolean;
817
+ oidcConfig: {
818
+ discoveryEndpoint: string;
819
+ clientIdLastFour: string;
820
+ pkce: boolean;
821
+ authorizationEndpoint: string | undefined;
822
+ tokenEndpoint: string | undefined;
823
+ userInfoEndpoint: string | undefined;
824
+ jwksEndpoint: string | undefined;
825
+ scopes: string[] | undefined;
826
+ tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | "private_key_jwt" | undefined;
827
+ } | undefined;
828
+ samlConfig: {
829
+ entryPoint: string;
830
+ callbackUrl: string | undefined;
831
+ idpInitiatedCallbackUrl: string | undefined;
832
+ audience: string | undefined;
833
+ wantAssertionsSigned: boolean | undefined;
834
+ authnRequestsSigned: boolean | undefined;
835
+ identifierFormat: string | undefined;
836
+ signatureAlgorithm: string | undefined;
837
+ digestAlgorithm: string | undefined;
838
+ certificate: SanitizedCert[] | undefined;
839
+ } | undefined;
840
+ spMetadataUrl: string;
841
+ }>;
842
+ declare const updateSSOProvider: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/update-provider", {
843
+ method: "POST";
844
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
845
+ session: {
846
+ session: Record<string, any> & {
847
+ id: string;
848
+ createdAt: Date;
849
+ updatedAt: Date;
850
+ userId: string;
851
+ expiresAt: Date;
852
+ token: string;
853
+ ipAddress?: string | null | undefined;
854
+ userAgent?: string | null | undefined;
855
+ };
856
+ user: Record<string, any> & {
857
+ id: string;
858
+ createdAt: Date;
859
+ updatedAt: Date;
860
+ email: string;
861
+ emailVerified: boolean;
862
+ name: string;
863
+ image?: string | null | undefined;
864
+ };
865
+ };
866
+ }>)[];
867
+ body: z.ZodObject<{
868
+ issuer: z.ZodOptional<z.ZodString>;
869
+ domain: z.ZodOptional<z.ZodString>;
870
+ oidcConfig: z.ZodOptional<z.ZodObject<{
871
+ clientId: z.ZodOptional<z.ZodString>;
872
+ clientSecret: z.ZodOptional<z.ZodOptional<z.ZodString>>;
873
+ authorizationEndpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
874
+ tokenEndpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
875
+ userInfoEndpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
876
+ tokenEndpointAuthentication: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
877
+ client_secret_post: "client_secret_post";
878
+ client_secret_basic: "client_secret_basic";
879
+ private_key_jwt: "private_key_jwt";
880
+ }>>>;
881
+ privateKeyId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
882
+ privateKeyAlgorithm: z.ZodOptional<z.ZodOptional<z.ZodString>>;
883
+ jwksEndpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
884
+ discoveryEndpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
885
+ skipDiscovery: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
886
+ scopes: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
887
+ pkce: z.ZodOptional<z.ZodOptional<z.ZodDefault<z.ZodBoolean>>>;
888
+ overrideUserInfo: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
889
+ mapping: z.ZodOptional<z.ZodOptional<z.ZodObject<{
890
+ email: z.ZodString;
891
+ emailVerified: z.ZodOptional<z.ZodString>;
892
+ name: z.ZodString;
893
+ image: z.ZodOptional<z.ZodString>;
894
+ extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
895
+ }, z.core.$strict>>>;
896
+ }, z.core.$strip>>;
897
+ samlConfig: z.ZodOptional<z.ZodObject<{
898
+ audience: z.ZodOptional<z.ZodOptional<z.ZodString>>;
899
+ cert: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
900
+ entryPoint: z.ZodOptional<z.ZodString>;
901
+ callbackUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
902
+ spMetadata: z.ZodOptional<z.ZodOptional<z.ZodObject<{
903
+ metadata: z.ZodOptional<z.ZodString>;
904
+ entityID: z.ZodOptional<z.ZodString>;
905
+ binding: z.ZodOptional<z.ZodString>;
906
+ privateKey: z.ZodOptional<z.ZodString>;
907
+ privateKeyPass: z.ZodOptional<z.ZodString>;
908
+ isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
909
+ encPrivateKey: z.ZodOptional<z.ZodString>;
910
+ encPrivateKeyPass: z.ZodOptional<z.ZodString>;
911
+ }, z.core.$strip>>>;
912
+ wantAssertionsSigned: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
913
+ authnRequestsSigned: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
914
+ signatureAlgorithm: z.ZodOptional<z.ZodOptional<z.ZodString>>;
915
+ digestAlgorithm: z.ZodOptional<z.ZodOptional<z.ZodString>>;
916
+ identifierFormat: z.ZodOptional<z.ZodOptional<z.ZodString>>;
917
+ privateKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
918
+ mapping: z.ZodOptional<z.ZodOptional<z.ZodObject<{
919
+ email: z.ZodString;
920
+ emailVerified: z.ZodOptional<z.ZodString>;
921
+ name: z.ZodString;
922
+ firstName: z.ZodOptional<z.ZodString>;
923
+ lastName: z.ZodOptional<z.ZodString>;
924
+ extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
925
+ }, z.core.$strict>>>;
926
+ idpInitiatedCallbackUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
927
+ idpMetadata: z.ZodOptional<z.ZodObject<{
928
+ cert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
929
+ privateKey: z.ZodOptional<z.ZodString>;
930
+ privateKeyPass: z.ZodOptional<z.ZodString>;
931
+ isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
932
+ encPrivateKey: z.ZodOptional<z.ZodString>;
933
+ encPrivateKeyPass: z.ZodOptional<z.ZodString>;
934
+ singleSignOnService: z.ZodOptional<z.ZodArray<z.ZodObject<{
935
+ Binding: z.ZodString;
936
+ Location: z.ZodString;
937
+ }, z.core.$strip>>>;
938
+ singleLogoutService: z.ZodOptional<z.ZodArray<z.ZodObject<{
939
+ Binding: z.ZodString;
940
+ Location: z.ZodString;
941
+ }, z.core.$strip>>>;
942
+ metadata: z.ZodOptional<z.ZodString>;
943
+ entityID: z.ZodOptional<z.ZodString>;
944
+ }, z.core.$strip>>;
945
+ }, z.core.$strip>>;
946
+ providerId: z.ZodString;
947
+ }, z.core.$strip>;
948
+ metadata: {
949
+ openapi: {
950
+ operationId: string;
951
+ summary: string;
952
+ description: string;
953
+ responses: {
954
+ "200": {
955
+ description: string;
956
+ };
957
+ "404": {
958
+ description: string;
959
+ };
960
+ "403": {
961
+ description: string;
962
+ };
963
+ };
964
+ };
965
+ };
966
+ }, {
967
+ providerId: string;
968
+ type: string;
969
+ issuer: string;
970
+ domain: string;
971
+ organizationId: string | null;
972
+ domainVerified: boolean;
973
+ oidcConfig: {
974
+ discoveryEndpoint: string;
975
+ clientIdLastFour: string;
976
+ pkce: boolean;
977
+ authorizationEndpoint: string | undefined;
978
+ tokenEndpoint: string | undefined;
979
+ userInfoEndpoint: string | undefined;
980
+ jwksEndpoint: string | undefined;
981
+ scopes: string[] | undefined;
982
+ tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | "private_key_jwt" | undefined;
983
+ } | undefined;
984
+ samlConfig: {
985
+ entryPoint: string;
986
+ callbackUrl: string | undefined;
987
+ idpInitiatedCallbackUrl: string | undefined;
988
+ audience: string | undefined;
989
+ wantAssertionsSigned: boolean | undefined;
990
+ authnRequestsSigned: boolean | undefined;
991
+ identifierFormat: string | undefined;
992
+ signatureAlgorithm: string | undefined;
993
+ digestAlgorithm: string | undefined;
994
+ certificate: SanitizedCert[] | undefined;
995
+ } | undefined;
996
+ spMetadataUrl: string;
997
+ }>;
998
+ declare const deleteSSOProvider: () => import("better-call").StrictEndpoint<"/sso/delete-provider", {
999
+ method: "POST";
1000
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1001
+ session: {
1002
+ session: Record<string, any> & {
1003
+ id: string;
1004
+ createdAt: Date;
1005
+ updatedAt: Date;
1006
+ userId: string;
1007
+ expiresAt: Date;
1008
+ token: string;
1009
+ ipAddress?: string | null | undefined;
1010
+ userAgent?: string | null | undefined;
1011
+ };
1012
+ user: Record<string, any> & {
1013
+ id: string;
1014
+ createdAt: Date;
1015
+ updatedAt: Date;
1016
+ email: string;
1017
+ emailVerified: boolean;
1018
+ name: string;
1019
+ image?: string | null | undefined;
1020
+ };
1021
+ };
1022
+ }>)[];
1023
+ body: z.ZodObject<{
1024
+ providerId: z.ZodString;
1025
+ }, z.core.$strip>;
1026
+ metadata: {
1027
+ openapi: {
1028
+ operationId: string;
1029
+ summary: string;
1030
+ description: string;
1031
+ responses: {
1032
+ "200": {
1033
+ description: string;
1034
+ };
1035
+ "404": {
1036
+ description: string;
1037
+ };
1038
+ "403": {
1039
+ description: string;
1040
+ };
1041
+ };
1042
+ };
1043
+ };
1044
+ }, {
1045
+ success: boolean;
1046
+ }>;
1047
+ //#endregion
1048
+ //#region src/routes/sso.d.ts
1049
+ declare const spMetadata: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/metadata", {
1050
+ method: "GET";
1051
+ query: z.ZodObject<{
1052
+ providerId: z.ZodString;
1053
+ }, z.core.$strip>;
1054
+ metadata: {
1055
+ openapi: {
1056
+ operationId: string;
1057
+ summary: string;
1058
+ description: string;
1059
+ responses: {
1060
+ "200": {
1061
+ description: string;
1062
+ };
1063
+ };
1064
+ };
1065
+ };
1066
+ }, Response>;
1067
+ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => import("better-call").StrictEndpoint<"/sso/register", {
1068
+ method: "POST";
1069
+ body: z.ZodObject<{
1070
+ [x: string]: z.ZodOptional<z.ZodAny>;
1071
+ }, z.core.$strip>;
1072
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1073
+ session: {
1074
+ session: Record<string, any> & {
1075
+ id: string;
1076
+ createdAt: Date;
1077
+ updatedAt: Date;
1078
+ userId: string;
1079
+ expiresAt: Date;
1080
+ token: string;
1081
+ ipAddress?: string | null | undefined;
1082
+ userAgent?: string | null | undefined;
1083
+ };
1084
+ user: Record<string, any> & {
1085
+ id: string;
1086
+ createdAt: Date;
1087
+ updatedAt: Date;
1088
+ email: string;
1089
+ emailVerified: boolean;
1090
+ name: string;
1091
+ image?: string | null | undefined;
1092
+ };
1093
+ };
1094
+ }>)[];
1095
+ metadata: {
1096
+ $Infer: {
1097
+ body: Record<string, any> & SSOProviderAdditionalFieldsInput<O>;
1098
+ };
1099
+ openapi: {
1100
+ operationId: string;
1101
+ summary: string;
1102
+ description: string;
1103
+ responses: {
1104
+ "200": {
1105
+ description: string;
1106
+ content: {
1107
+ "application/json": {
1108
+ schema: {
1109
+ type: "object";
1110
+ properties: {
1111
+ issuer: {
1112
+ type: string;
1113
+ format: string;
1114
+ description: string;
1115
+ };
1116
+ domain: {
1117
+ type: string;
1118
+ description: string;
1119
+ };
1120
+ domainVerified: {
1121
+ type: string;
1122
+ description: string;
1123
+ };
1124
+ domainVerificationToken: {
1125
+ type: string;
1126
+ description: string;
1127
+ };
1128
+ oidcConfig: {
1129
+ type: string;
1130
+ properties: {
1131
+ issuer: {
1132
+ type: string;
1133
+ format: string;
1134
+ description: string;
1135
+ };
1136
+ pkce: {
1137
+ type: string;
1138
+ description: string;
1139
+ };
1140
+ clientId: {
1141
+ type: string;
1142
+ description: string;
1143
+ };
1144
+ clientSecret: {
1145
+ type: string;
1146
+ description: string;
1147
+ };
1148
+ authorizationEndpoint: {
1149
+ type: string;
1150
+ format: string;
1151
+ nullable: boolean;
1152
+ description: string;
1153
+ };
1154
+ discoveryEndpoint: {
1155
+ type: string;
1156
+ format: string;
1157
+ description: string;
1158
+ };
1159
+ userInfoEndpoint: {
1160
+ type: string;
1161
+ format: string;
1162
+ nullable: boolean;
1163
+ description: string;
1164
+ };
1165
+ scopes: {
1166
+ type: string;
1167
+ items: {
1168
+ type: string;
1169
+ };
1170
+ nullable: boolean;
1171
+ description: string;
1172
+ };
1173
+ tokenEndpoint: {
1174
+ type: string;
1175
+ format: string;
1176
+ nullable: boolean;
1177
+ description: string;
1178
+ };
1179
+ tokenEndpointAuthentication: {
1180
+ type: string;
1181
+ enum: string[];
1182
+ nullable: boolean;
1183
+ description: string;
1184
+ };
1185
+ jwksEndpoint: {
1186
+ type: string;
1187
+ format: string;
1188
+ nullable: boolean;
1189
+ description: string;
1190
+ };
1191
+ mapping: {
1192
+ type: string;
1193
+ nullable: boolean;
1194
+ properties: {
1195
+ email: {
1196
+ type: string;
1197
+ description: string;
1198
+ };
1199
+ emailVerified: {
1200
+ type: string;
1201
+ nullable: boolean;
1202
+ description: string;
1203
+ };
1204
+ name: {
1205
+ type: string;
1206
+ description: string;
1207
+ };
1208
+ image: {
1209
+ type: string;
1210
+ nullable: boolean;
1211
+ description: string;
1212
+ };
1213
+ extraFields: {
1214
+ type: string;
1215
+ additionalProperties: {
1216
+ type: string;
1217
+ };
1218
+ nullable: boolean;
1219
+ description: string;
1220
+ };
1221
+ };
1222
+ required: string[];
1223
+ };
1224
+ };
1225
+ required: string[];
1226
+ description: string;
1227
+ };
1228
+ organizationId: {
1229
+ type: string;
1230
+ nullable: boolean;
1231
+ description: string;
1232
+ };
1233
+ userId: {
1234
+ type: string;
1235
+ description: string;
1236
+ };
1237
+ providerId: {
1238
+ type: string;
1239
+ description: string;
1240
+ };
1241
+ redirectURI: {
1242
+ type: string;
1243
+ format: string;
1244
+ description: string;
1245
+ };
1246
+ };
1247
+ required: string[];
1248
+ };
1249
+ };
1250
+ };
1251
+ };
1252
+ };
1253
+ };
1254
+ };
1255
+ }, O["domainVerification"] extends {
1256
+ enabled: true;
1257
+ } ? {
1258
+ redirectURI: string;
1259
+ oidcConfig: OIDCConfig | null;
1260
+ samlConfig: SAMLConfig | null;
1261
+ } & Omit<InferSSOProvider<O>, "samlConfig" | "oidcConfig"> & {
1262
+ domainVerified: boolean;
1263
+ domainVerificationToken: string;
1264
+ } : {
1265
+ redirectURI: string;
1266
+ oidcConfig: OIDCConfig | null;
1267
+ samlConfig: SAMLConfig | null;
1268
+ } & Omit<InferSSOProvider<O>, "samlConfig" | "oidcConfig">>;
1269
+ declare const signInSSO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sign-in/sso", {
1270
+ method: "POST";
1271
+ body: z.ZodObject<{
1272
+ email: z.ZodOptional<z.ZodString>;
1273
+ organizationSlug: z.ZodOptional<z.ZodString>;
1274
+ providerId: z.ZodOptional<z.ZodString>;
1275
+ domain: z.ZodOptional<z.ZodString>;
1276
+ callbackURL: z.ZodString;
1277
+ errorCallbackURL: z.ZodOptional<z.ZodString>;
1278
+ newUserCallbackURL: z.ZodOptional<z.ZodString>;
1279
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1280
+ loginHint: z.ZodOptional<z.ZodString>;
1281
+ additionalParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1282
+ requestSignUp: z.ZodOptional<z.ZodBoolean>;
1283
+ providerType: z.ZodOptional<z.ZodEnum<{
1284
+ saml: "saml";
1285
+ oidc: "oidc";
1286
+ }>>;
1287
+ }, z.core.$strip>;
1288
+ metadata: {
1289
+ openapi: {
1290
+ operationId: string;
1291
+ summary: string;
1292
+ description: string;
1293
+ requestBody: {
1294
+ content: {
1295
+ "application/json": {
1296
+ schema: {
1297
+ type: "object";
1298
+ properties: {
1299
+ email: {
1300
+ type: string;
1301
+ description: string;
1302
+ };
1303
+ organizationSlug: {
1304
+ type: string;
1305
+ description: string;
1306
+ };
1307
+ providerId: {
1308
+ type: string;
1309
+ description: string;
1310
+ };
1311
+ domain: {
1312
+ type: string;
1313
+ description: string;
1314
+ };
1315
+ callbackURL: {
1316
+ type: string;
1317
+ description: string;
1318
+ };
1319
+ errorCallbackURL: {
1320
+ type: string;
1321
+ description: string;
1322
+ };
1323
+ newUserCallbackURL: {
1324
+ type: string;
1325
+ description: string;
1326
+ };
1327
+ scopes: {
1328
+ type: string;
1329
+ items: {
1330
+ type: string;
1331
+ };
1332
+ description: string;
1333
+ };
1334
+ loginHint: {
1335
+ type: string;
1336
+ description: string;
1337
+ };
1338
+ additionalParams: {
1339
+ type: string;
1340
+ additionalProperties: {
1341
+ type: string;
1342
+ };
1343
+ description: string;
1344
+ };
1345
+ requestSignUp: {
1346
+ type: string;
1347
+ description: string;
1348
+ };
1349
+ providerType: {
1350
+ type: string;
1351
+ enum: string[];
1352
+ description: string;
1353
+ };
1354
+ };
1355
+ required: string[];
1356
+ };
1357
+ };
1358
+ };
1359
+ };
1360
+ responses: {
1361
+ "200": {
1362
+ description: string;
1363
+ content: {
1364
+ "application/json": {
1365
+ schema: {
1366
+ type: "object";
1367
+ properties: {
1368
+ url: {
1369
+ type: string;
1370
+ format: string;
1371
+ description: string;
1372
+ };
1373
+ redirect: {
1374
+ type: string;
1375
+ description: string;
1376
+ enum: boolean[];
1377
+ };
1378
+ };
1379
+ required: string[];
1380
+ };
1381
+ };
1382
+ };
1383
+ };
1384
+ };
1385
+ };
1386
+ };
1387
+ }, {
1388
+ url: string;
1389
+ redirect: boolean;
1390
+ }>;
1391
+ declare const callbackSSO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/callback/:providerId", {
1392
+ method: "GET";
1393
+ query: z.ZodObject<{
1394
+ code: z.ZodOptional<z.ZodString>;
1395
+ state: z.ZodOptional<z.ZodString>;
1396
+ error: z.ZodOptional<z.ZodString>;
1397
+ error_description: z.ZodOptional<z.ZodString>;
1398
+ }, z.core.$strip>;
1399
+ allowedMediaTypes: readonly ["application/x-www-form-urlencoded", "application/json"];
1400
+ metadata: {
1401
+ openapi: {
1402
+ operationId: string;
1403
+ summary: string;
1404
+ description: string;
1405
+ responses: {
1406
+ "302": {
1407
+ description: string;
1408
+ };
1409
+ };
1410
+ };
1411
+ scope: "server";
1412
+ };
1413
+ }, void>;
1414
+ /**
1415
+ * Shared OIDC callback endpoint (no `:providerId` in path).
1416
+ * Used when `options.redirectURI` is set — the `providerId` is read from
1417
+ * the OAuth state instead of the URL path.
1418
+ */
1419
+ declare const callbackSSOShared: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/callback", {
1420
+ metadata: {
1421
+ openapi: {
1422
+ operationId: string;
1423
+ summary: string;
1424
+ description: string;
1425
+ responses: {
1426
+ "302": {
1427
+ description: string;
1428
+ };
1429
+ };
1430
+ };
1431
+ scope: "server";
1432
+ };
1433
+ method: "GET";
1434
+ query: z.ZodObject<{
1435
+ code: z.ZodOptional<z.ZodString>;
1436
+ state: z.ZodOptional<z.ZodString>;
1437
+ error: z.ZodOptional<z.ZodString>;
1438
+ error_description: z.ZodOptional<z.ZodString>;
1439
+ }, z.core.$strip>;
1440
+ allowedMediaTypes: readonly ["application/x-www-form-urlencoded", "application/json"];
1441
+ }, void>;
1442
+ declare const acsEndpoint: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
1443
+ method: ("GET" | "POST")[];
1444
+ body: z.ZodOptional<z.ZodObject<{
1445
+ SAMLResponse: z.ZodString;
1446
+ RelayState: z.ZodOptional<z.ZodString>;
1447
+ }, z.core.$strip>>;
1448
+ query: z.ZodOptional<z.ZodObject<{
1449
+ RelayState: z.ZodOptional<z.ZodString>;
1450
+ }, z.core.$strip>>;
1451
+ metadata: {
1452
+ allowedMediaTypes: string[];
1453
+ openapi: {
1454
+ operationId: string;
1455
+ summary: string;
1456
+ description: string;
1457
+ responses: {
1458
+ "302": {
1459
+ description: string;
1460
+ };
1461
+ "400": {
1462
+ description: string;
1463
+ };
1464
+ "404": {
1465
+ description: string;
1466
+ };
1467
+ };
1468
+ };
1469
+ scope: "server";
1470
+ };
1471
+ }, never>;
1472
+ declare const sloEndpoint: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/slo/:providerId", {
1473
+ method: ("GET" | "POST")[];
1474
+ body: z.ZodOptional<z.ZodObject<{
1475
+ SAMLRequest: z.ZodOptional<z.ZodString>;
1476
+ SAMLResponse: z.ZodOptional<z.ZodString>;
1477
+ RelayState: z.ZodOptional<z.ZodString>;
1478
+ SigAlg: z.ZodOptional<z.ZodString>;
1479
+ Signature: z.ZodOptional<z.ZodString>;
1480
+ }, z.core.$strip>>;
1481
+ query: z.ZodOptional<z.ZodObject<{
1482
+ SAMLRequest: z.ZodOptional<z.ZodString>;
1483
+ SAMLResponse: z.ZodOptional<z.ZodString>;
1484
+ RelayState: z.ZodOptional<z.ZodString>;
1485
+ SigAlg: z.ZodOptional<z.ZodString>;
1486
+ Signature: z.ZodOptional<z.ZodString>;
1487
+ }, z.core.$strip>>;
1488
+ metadata: {
1489
+ allowedMediaTypes: string[];
1490
+ scope: "server";
1491
+ };
1492
+ }, void | Response>;
1493
+ declare const initiateSLO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/logout/:providerId", {
1494
+ method: "POST";
1495
+ body: z.ZodObject<{
1496
+ callbackURL: z.ZodOptional<z.ZodString>;
1497
+ }, z.core.$strip>;
1498
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
1499
+ session: {
1500
+ session: Record<string, any> & {
1501
+ id: string;
1502
+ createdAt: Date;
1503
+ updatedAt: Date;
1504
+ userId: string;
1505
+ expiresAt: Date;
1506
+ token: string;
1507
+ ipAddress?: string | null | undefined;
1508
+ userAgent?: string | null | undefined;
1509
+ };
1510
+ user: Record<string, any> & {
1511
+ id: string;
1512
+ createdAt: Date;
1513
+ updatedAt: Date;
1514
+ email: string;
1515
+ emailVerified: boolean;
1516
+ name: string;
1517
+ image?: string | null | undefined;
1518
+ };
1519
+ };
1520
+ }>)[];
1521
+ metadata: {
1522
+ readonly scope: "server";
1523
+ };
1524
+ }, never>;
1525
+ //#endregion
1526
+ //#region src/index.d.ts
1527
+ declare module "@better-auth/core" {
1528
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
1529
+ sso: {
1530
+ creator: typeof sso;
1531
+ };
1532
+ }
1533
+ }
1534
+ type DomainVerificationEndpoints = {
1535
+ requestDomainVerification: ReturnType<typeof requestDomainVerification>;
1536
+ verifyDomain: ReturnType<typeof verifyDomain>;
1537
+ };
1538
+ type SSOEndpoints<O extends SSOOptions> = {
1539
+ spMetadata: ReturnType<typeof spMetadata>;
1540
+ registerSSOProvider: ReturnType<typeof registerSSOProvider<O>>;
1541
+ signInSSO: ReturnType<typeof signInSSO>;
1542
+ callbackSSO: ReturnType<typeof callbackSSO>;
1543
+ callbackSSOShared: ReturnType<typeof callbackSSOShared>;
1544
+ acsEndpoint: ReturnType<typeof acsEndpoint>;
1545
+ sloEndpoint: ReturnType<typeof sloEndpoint>;
1546
+ initiateSLO: ReturnType<typeof initiateSLO>;
1547
+ listSSOProviders: ReturnType<typeof listSSOProviders>;
1548
+ getSSOProvider: ReturnType<typeof getSSOProvider>;
1549
+ updateSSOProvider: ReturnType<typeof updateSSOProvider>;
1550
+ deleteSSOProvider: ReturnType<typeof deleteSSOProvider>;
1551
+ };
1552
+ declare function sso<O extends SSOOptions & {
1553
+ domainVerification?: {
1554
+ enabled: true;
1555
+ };
1556
+ }>(options?: O | undefined): {
1557
+ id: "sso";
1558
+ version: string;
1559
+ endpoints: SSOEndpoints<O> & DomainVerificationEndpoints;
1560
+ schema: SSOProviderSchema<O>;
1561
+ $Infer: {
1562
+ SSOProvider: InferSSOProvider<O>;
1563
+ };
1564
+ options: NoInfer<O>;
1565
+ };
1566
+ declare function sso<O extends SSOOptions>(options?: O | undefined): {
1567
+ id: "sso";
1568
+ version: string;
1569
+ endpoints: SSOEndpoints<O>;
1570
+ schema: SSOProviderSchema<O>;
1571
+ $Infer: {
1572
+ SSOProvider: InferSSOProvider<O>;
1573
+ };
1574
+ options: NoInfer<O>;
1575
+ };
1576
+ export { type OIDCConfig, sso };