@better-auth/sso 1.7.0-rc.0 → 1.7.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts
CHANGED
package/dist/client.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { APIError } from "better-auth/api";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
+
import "@better-fetch/fetch";
|
|
3
4
|
import { DBFieldAttribute, FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, RemoveFieldsWithReturnedFalse } from "better-auth/db";
|
|
4
|
-
import { Awaitable, OAuth2Tokens, User } from "better-auth";
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { Awaitable, DBTransactionAdapter, OAuth2Tokens, User } from "better-auth";
|
|
6
|
+
import "@better-auth/core";
|
|
7
7
|
//#region src/saml/algorithms.d.ts
|
|
8
8
|
declare const SignatureAlgorithm: {
|
|
9
9
|
readonly RSA_SHA1: "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
|
@@ -45,7 +45,6 @@ interface AlgorithmValidationOptions {
|
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region src/types.d.ts
|
|
47
47
|
interface OIDCMapping {
|
|
48
|
-
id?: string | undefined;
|
|
49
48
|
email?: string | undefined;
|
|
50
49
|
emailVerified?: string | undefined;
|
|
51
50
|
name?: string | undefined;
|
|
@@ -53,7 +52,6 @@ interface OIDCMapping {
|
|
|
53
52
|
extraFields?: Record<string, string> | undefined;
|
|
54
53
|
}
|
|
55
54
|
interface SAMLMapping {
|
|
56
|
-
id?: string | undefined;
|
|
57
55
|
email?: string | undefined;
|
|
58
56
|
emailVerified?: string | undefined;
|
|
59
57
|
name?: string | undefined;
|
|
@@ -90,6 +88,41 @@ interface OIDCConfig {
|
|
|
90
88
|
*/
|
|
91
89
|
allowIdpInitiated?: boolean | undefined;
|
|
92
90
|
}
|
|
91
|
+
interface SAMLIdentityProviderMetadataBase {
|
|
92
|
+
/**
|
|
93
|
+
* IdP signing certificate(s). Pass a single PEM string or an array for
|
|
94
|
+
* rolling rotation. Takes precedence over the top-level `cert` when both
|
|
95
|
+
* are set. Omit when `metadata` XML is supplied.
|
|
96
|
+
*/
|
|
97
|
+
cert?: string | string[] | undefined;
|
|
98
|
+
privateKey?: string | undefined;
|
|
99
|
+
privateKeyPass?: string | undefined;
|
|
100
|
+
isAssertionEncrypted?: boolean | undefined;
|
|
101
|
+
encPrivateKey?: string | undefined;
|
|
102
|
+
encPrivateKeyPass?: string | undefined;
|
|
103
|
+
singleSignOnService?: Array<{
|
|
104
|
+
Binding: string;
|
|
105
|
+
Location: string;
|
|
106
|
+
}> | undefined;
|
|
107
|
+
singleLogoutService?: Array<{
|
|
108
|
+
Binding: string;
|
|
109
|
+
Location: string;
|
|
110
|
+
}> | undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The trusted identity-provider authority for a SAML connection.
|
|
114
|
+
*
|
|
115
|
+
* Metadata XML carries the IdP entity ID. Manual configurations must declare
|
|
116
|
+
* `entityID` explicitly so the service provider's issuer is never mistaken
|
|
117
|
+
* for the identity provider's authority.
|
|
118
|
+
*/
|
|
119
|
+
type SAMLIdentityProviderMetadata = SAMLIdentityProviderMetadataBase & ({
|
|
120
|
+
metadata: string;
|
|
121
|
+
entityID?: string | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
metadata?: undefined;
|
|
124
|
+
entityID: string;
|
|
125
|
+
});
|
|
93
126
|
interface SAMLConfig {
|
|
94
127
|
/**
|
|
95
128
|
* SP Entity ID. Used as the `entityID` in SP metadata when
|
|
@@ -118,29 +151,12 @@ interface SAMLConfig {
|
|
|
118
151
|
* flows when no RelayState callback URL is available.
|
|
119
152
|
*/
|
|
120
153
|
callbackUrl?: string | undefined;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
* when both are set. Omit when `metadata` XML is supplied.
|
|
128
|
-
*/
|
|
129
|
-
cert?: string | string[];
|
|
130
|
-
privateKey?: string;
|
|
131
|
-
privateKeyPass?: string;
|
|
132
|
-
isAssertionEncrypted?: boolean;
|
|
133
|
-
encPrivateKey?: string;
|
|
134
|
-
encPrivateKeyPass?: string;
|
|
135
|
-
singleSignOnService?: Array<{
|
|
136
|
-
Binding: string;
|
|
137
|
-
Location: string;
|
|
138
|
-
}>;
|
|
139
|
-
singleLogoutService?: Array<{
|
|
140
|
-
Binding: string;
|
|
141
|
-
Location: string;
|
|
142
|
-
}>;
|
|
143
|
-
} | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Fallback absolute URL or same-origin relative path for IdP-initiated SAML
|
|
156
|
+
* responses when RelayState has no safe callback, including error redirects.
|
|
157
|
+
*/
|
|
158
|
+
idpInitiatedCallbackUrl?: string | undefined;
|
|
159
|
+
idpMetadata: SAMLIdentityProviderMetadata;
|
|
144
160
|
/**
|
|
145
161
|
* SP metadata configuration. All fields are optional; when omitted,
|
|
146
162
|
* SP metadata is auto-generated from `issuer`, `wantAssertionsSigned`,
|
|
@@ -204,7 +220,56 @@ type SSOProviderSchema<O extends SSOOptions> = {
|
|
|
204
220
|
} ? Field : {});
|
|
205
221
|
};
|
|
206
222
|
};
|
|
223
|
+
/** Decision returned by an SSO user resolver. */
|
|
224
|
+
type SSOUserResolution = {
|
|
225
|
+
action: "continue";
|
|
226
|
+
} | {
|
|
227
|
+
action: "link";
|
|
228
|
+
userId: string;
|
|
229
|
+
profile: "preserve" | "update";
|
|
230
|
+
} | {
|
|
231
|
+
action: "reject";
|
|
232
|
+
code: string;
|
|
233
|
+
message?: string | undefined;
|
|
234
|
+
};
|
|
235
|
+
/** Normalized provider attributes available to an SSO user resolver. */
|
|
236
|
+
type SSOProviderUserProfile = {
|
|
237
|
+
email: string;
|
|
238
|
+
emailVerified: boolean;
|
|
239
|
+
name: string;
|
|
240
|
+
image?: string | null | undefined;
|
|
241
|
+
} & Record<string, unknown>;
|
|
242
|
+
/** OIDC identity and profile data available to an application's SSO resolver. */
|
|
243
|
+
interface SSOUserResolutionInput {
|
|
244
|
+
protocol: "oidc";
|
|
245
|
+
providerId: string;
|
|
246
|
+
accountKey: {
|
|
247
|
+
issuer: string;
|
|
248
|
+
providerAccountId: string;
|
|
249
|
+
};
|
|
250
|
+
providerUser: SSOProviderUserProfile;
|
|
251
|
+
providerClaims: Record<string, unknown>;
|
|
252
|
+
}
|
|
253
|
+
/** Transaction-bound capabilities available while resolving an SSO user. */
|
|
254
|
+
interface SSOUserResolutionContext {
|
|
255
|
+
database: DBTransactionAdapter;
|
|
256
|
+
}
|
|
207
257
|
interface SSOOptions {
|
|
258
|
+
/**
|
|
259
|
+
* Resolve a verified provider identity to a Better Auth user.
|
|
260
|
+
*
|
|
261
|
+
* Currently invoked for OIDC callbacks only.
|
|
262
|
+
*
|
|
263
|
+
* TODO: Invoke this resolver for SAML callbacks after normalizing the verified
|
|
264
|
+
* IdP entity ID as `accountKey.issuer` and the signed NameID as
|
|
265
|
+
* `accountKey.providerAccountId`.
|
|
266
|
+
*
|
|
267
|
+
* `accountKey` is derived from the validated ID Token. Profile fields and raw
|
|
268
|
+
* claims are protocol-accepted provider data and may require application-level
|
|
269
|
+
* validation. The callback runs on every OIDC sign-in inside the same native
|
|
270
|
+
* database transaction as account finalization and session creation.
|
|
271
|
+
*/
|
|
272
|
+
resolveUser?: ((input: SSOUserResolutionInput, context: SSOUserResolutionContext) => Awaitable<SSOUserResolution>) | undefined;
|
|
208
273
|
/**
|
|
209
274
|
* custom function to provision a user when they sign in with an SSO provider.
|
|
210
275
|
*/
|
|
@@ -341,7 +406,7 @@ interface SSOOptions {
|
|
|
341
406
|
domain?: string | undefined;
|
|
342
407
|
domainVerified?: string | undefined;
|
|
343
408
|
};
|
|
344
|
-
additionalFields?: { [key in string]: DBFieldAttribute };
|
|
409
|
+
additionalFields?: { [key in string]: DBFieldAttribute; };
|
|
345
410
|
};
|
|
346
411
|
} | undefined;
|
|
347
412
|
/**
|
|
@@ -536,11 +601,16 @@ interface SSOOptions {
|
|
|
536
601
|
* @default false
|
|
537
602
|
*/
|
|
538
603
|
wantLogoutResponseSigned?: boolean;
|
|
604
|
+
/**
|
|
605
|
+
* Global fallback absolute URL or same-origin relative path for
|
|
606
|
+
* IdP-initiated SAML responses when the provider has no safe callback.
|
|
607
|
+
*/
|
|
608
|
+
idpInitiatedCallbackUrl?: string | undefined;
|
|
539
609
|
};
|
|
540
610
|
}
|
|
541
611
|
//#endregion
|
|
542
612
|
//#region src/routes/domain-verification.d.ts
|
|
543
|
-
declare const requestDomainVerification: (options: SSOOptions) =>
|
|
613
|
+
declare const requestDomainVerification: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/request-domain-verification", {
|
|
544
614
|
method: "POST";
|
|
545
615
|
body: z.ZodObject<{
|
|
546
616
|
providerId: z.ZodString;
|
|
@@ -562,7 +632,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
|
|
|
562
632
|
};
|
|
563
633
|
};
|
|
564
634
|
};
|
|
565
|
-
use: ((inputContext:
|
|
635
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
566
636
|
session: {
|
|
567
637
|
session: Record<string, any> & {
|
|
568
638
|
id: string;
|
|
@@ -588,7 +658,7 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
|
|
|
588
658
|
}, {
|
|
589
659
|
domainVerificationToken: string;
|
|
590
660
|
}>;
|
|
591
|
-
declare const verifyDomain: (options: SSOOptions) =>
|
|
661
|
+
declare const verifyDomain: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/verify-domain", {
|
|
592
662
|
method: "POST";
|
|
593
663
|
body: z.ZodObject<{
|
|
594
664
|
providerId: z.ZodString;
|
|
@@ -613,7 +683,7 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
|
|
|
613
683
|
};
|
|
614
684
|
};
|
|
615
685
|
};
|
|
616
|
-
use: ((inputContext:
|
|
686
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
617
687
|
session: {
|
|
618
688
|
session: Record<string, any> & {
|
|
619
689
|
id: string;
|
|
@@ -651,9 +721,9 @@ type ParsedCert = ReturnType<typeof parseCertificate>;
|
|
|
651
721
|
type SanitizedCert = ParsedCert | {
|
|
652
722
|
error: string;
|
|
653
723
|
};
|
|
654
|
-
declare const listSSOProviders: (options?: SSOOptions) =>
|
|
724
|
+
declare const listSSOProviders: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/providers", {
|
|
655
725
|
method: "GET";
|
|
656
|
-
use: ((inputContext:
|
|
726
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
657
727
|
session: {
|
|
658
728
|
session: Record<string, any> & {
|
|
659
729
|
id: string;
|
|
@@ -709,6 +779,8 @@ declare const listSSOProviders: (options?: SSOOptions) => better_call0.StrictEnd
|
|
|
709
779
|
} | undefined;
|
|
710
780
|
samlConfig: {
|
|
711
781
|
entryPoint: string;
|
|
782
|
+
callbackUrl: string | undefined;
|
|
783
|
+
idpInitiatedCallbackUrl: string | undefined;
|
|
712
784
|
audience: string | undefined;
|
|
713
785
|
wantAssertionsSigned: boolean | undefined;
|
|
714
786
|
authnRequestsSigned: boolean | undefined;
|
|
@@ -720,9 +792,9 @@ declare const listSSOProviders: (options?: SSOOptions) => better_call0.StrictEnd
|
|
|
720
792
|
spMetadataUrl: string;
|
|
721
793
|
}[];
|
|
722
794
|
}>;
|
|
723
|
-
declare const getSSOProvider: (options?: SSOOptions) =>
|
|
795
|
+
declare const getSSOProvider: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/get-provider", {
|
|
724
796
|
method: "GET";
|
|
725
|
-
use: ((inputContext:
|
|
797
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
726
798
|
session: {
|
|
727
799
|
session: Record<string, any> & {
|
|
728
800
|
id: string;
|
|
@@ -786,6 +858,8 @@ declare const getSSOProvider: (options?: SSOOptions) => better_call0.StrictEndpo
|
|
|
786
858
|
} | undefined;
|
|
787
859
|
samlConfig: {
|
|
788
860
|
entryPoint: string;
|
|
861
|
+
callbackUrl: string | undefined;
|
|
862
|
+
idpInitiatedCallbackUrl: string | undefined;
|
|
789
863
|
audience: string | undefined;
|
|
790
864
|
wantAssertionsSigned: boolean | undefined;
|
|
791
865
|
authnRequestsSigned: boolean | undefined;
|
|
@@ -796,9 +870,9 @@ declare const getSSOProvider: (options?: SSOOptions) => better_call0.StrictEndpo
|
|
|
796
870
|
} | undefined;
|
|
797
871
|
spMetadataUrl: string;
|
|
798
872
|
}>;
|
|
799
|
-
declare const updateSSOProvider: (options: SSOOptions) =>
|
|
873
|
+
declare const updateSSOProvider: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/update-provider", {
|
|
800
874
|
method: "POST";
|
|
801
|
-
use: ((inputContext:
|
|
875
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
802
876
|
session: {
|
|
803
877
|
session: Record<string, any> & {
|
|
804
878
|
id: string;
|
|
@@ -844,37 +918,18 @@ declare const updateSSOProvider: (options: SSOOptions) => better_call0.StrictEnd
|
|
|
844
918
|
pkce: z.ZodOptional<z.ZodOptional<z.ZodDefault<z.ZodBoolean>>>;
|
|
845
919
|
overrideUserInfo: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
846
920
|
mapping: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
847
|
-
id: z.ZodString;
|
|
848
921
|
email: z.ZodString;
|
|
849
922
|
emailVerified: z.ZodOptional<z.ZodString>;
|
|
850
923
|
name: z.ZodString;
|
|
851
924
|
image: z.ZodOptional<z.ZodString>;
|
|
852
925
|
extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
853
|
-
}, z.core.$
|
|
926
|
+
}, z.core.$strict>>>;
|
|
854
927
|
}, z.core.$strip>>;
|
|
855
928
|
samlConfig: z.ZodOptional<z.ZodObject<{
|
|
856
|
-
entryPoint: z.ZodOptional<z.ZodString>;
|
|
857
|
-
cert: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
858
929
|
audience: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
930
|
+
cert: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
931
|
+
entryPoint: z.ZodOptional<z.ZodString>;
|
|
859
932
|
callbackUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
860
|
-
idpMetadata: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
861
|
-
metadata: z.ZodOptional<z.ZodString>;
|
|
862
|
-
entityID: z.ZodOptional<z.ZodString>;
|
|
863
|
-
cert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
864
|
-
privateKey: z.ZodOptional<z.ZodString>;
|
|
865
|
-
privateKeyPass: z.ZodOptional<z.ZodString>;
|
|
866
|
-
isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
|
|
867
|
-
encPrivateKey: z.ZodOptional<z.ZodString>;
|
|
868
|
-
encPrivateKeyPass: z.ZodOptional<z.ZodString>;
|
|
869
|
-
singleSignOnService: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
870
|
-
Binding: z.ZodString;
|
|
871
|
-
Location: z.ZodString;
|
|
872
|
-
}, z.core.$strip>>>;
|
|
873
|
-
singleLogoutService: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
874
|
-
Binding: z.ZodString;
|
|
875
|
-
Location: z.ZodString;
|
|
876
|
-
}, z.core.$strip>>>;
|
|
877
|
-
}, z.core.$strip>>>;
|
|
878
933
|
spMetadata: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
879
934
|
metadata: z.ZodOptional<z.ZodString>;
|
|
880
935
|
entityID: z.ZodOptional<z.ZodString>;
|
|
@@ -892,14 +947,32 @@ declare const updateSSOProvider: (options: SSOOptions) => better_call0.StrictEnd
|
|
|
892
947
|
identifierFormat: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
893
948
|
privateKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
894
949
|
mapping: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
895
|
-
id: z.ZodString;
|
|
896
950
|
email: z.ZodString;
|
|
897
951
|
emailVerified: z.ZodOptional<z.ZodString>;
|
|
898
952
|
name: z.ZodString;
|
|
899
953
|
firstName: z.ZodOptional<z.ZodString>;
|
|
900
954
|
lastName: z.ZodOptional<z.ZodString>;
|
|
901
955
|
extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
902
|
-
}, z.core.$
|
|
956
|
+
}, z.core.$strict>>>;
|
|
957
|
+
idpInitiatedCallbackUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
958
|
+
idpMetadata: z.ZodOptional<z.ZodObject<{
|
|
959
|
+
cert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
960
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
961
|
+
privateKeyPass: z.ZodOptional<z.ZodString>;
|
|
962
|
+
isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
|
|
963
|
+
encPrivateKey: z.ZodOptional<z.ZodString>;
|
|
964
|
+
encPrivateKeyPass: z.ZodOptional<z.ZodString>;
|
|
965
|
+
singleSignOnService: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
966
|
+
Binding: z.ZodString;
|
|
967
|
+
Location: z.ZodString;
|
|
968
|
+
}, z.core.$strip>>>;
|
|
969
|
+
singleLogoutService: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
970
|
+
Binding: z.ZodString;
|
|
971
|
+
Location: z.ZodString;
|
|
972
|
+
}, z.core.$strip>>>;
|
|
973
|
+
metadata: z.ZodOptional<z.ZodString>;
|
|
974
|
+
entityID: z.ZodOptional<z.ZodString>;
|
|
975
|
+
}, z.core.$strip>>;
|
|
903
976
|
}, z.core.$strip>>;
|
|
904
977
|
providerId: z.ZodString;
|
|
905
978
|
}, z.core.$strip>;
|
|
@@ -941,6 +1014,8 @@ declare const updateSSOProvider: (options: SSOOptions) => better_call0.StrictEnd
|
|
|
941
1014
|
} | undefined;
|
|
942
1015
|
samlConfig: {
|
|
943
1016
|
entryPoint: string;
|
|
1017
|
+
callbackUrl: string | undefined;
|
|
1018
|
+
idpInitiatedCallbackUrl: string | undefined;
|
|
944
1019
|
audience: string | undefined;
|
|
945
1020
|
wantAssertionsSigned: boolean | undefined;
|
|
946
1021
|
authnRequestsSigned: boolean | undefined;
|
|
@@ -951,9 +1026,9 @@ declare const updateSSOProvider: (options: SSOOptions) => better_call0.StrictEnd
|
|
|
951
1026
|
} | undefined;
|
|
952
1027
|
spMetadataUrl: string;
|
|
953
1028
|
}>;
|
|
954
|
-
declare const deleteSSOProvider: () =>
|
|
1029
|
+
declare const deleteSSOProvider: () => import("better-call").StrictEndpoint<"/sso/delete-provider", {
|
|
955
1030
|
method: "POST";
|
|
956
|
-
use: ((inputContext:
|
|
1031
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
957
1032
|
session: {
|
|
958
1033
|
session: Record<string, any> & {
|
|
959
1034
|
id: string;
|
|
@@ -1002,7 +1077,7 @@ declare const deleteSSOProvider: () => better_call0.StrictEndpoint<"/sso/delete-
|
|
|
1002
1077
|
}>;
|
|
1003
1078
|
//#endregion
|
|
1004
1079
|
//#region src/routes/sso.d.ts
|
|
1005
|
-
declare const spMetadata: (options?: SSOOptions) =>
|
|
1080
|
+
declare const spMetadata: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/metadata", {
|
|
1006
1081
|
method: "GET";
|
|
1007
1082
|
query: z.ZodObject<{
|
|
1008
1083
|
providerId: z.ZodString;
|
|
@@ -1020,12 +1095,12 @@ declare const spMetadata: (options?: SSOOptions) => better_call0.StrictEndpoint<
|
|
|
1020
1095
|
};
|
|
1021
1096
|
};
|
|
1022
1097
|
}, Response>;
|
|
1023
|
-
declare const registerSSOProvider: <O extends SSOOptions>(options: O) =>
|
|
1098
|
+
declare const registerSSOProvider: <O extends SSOOptions>(options: O) => import("better-call").StrictEndpoint<"/sso/register", {
|
|
1024
1099
|
method: "POST";
|
|
1025
1100
|
body: z.ZodObject<{
|
|
1026
1101
|
[x: string]: z.ZodOptional<z.ZodAny>;
|
|
1027
1102
|
}, z.core.$strip>;
|
|
1028
|
-
use: ((inputContext:
|
|
1103
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1029
1104
|
session: {
|
|
1030
1105
|
session: Record<string, any> & {
|
|
1031
1106
|
id: string;
|
|
@@ -1148,10 +1223,6 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
|
|
|
1148
1223
|
type: string;
|
|
1149
1224
|
nullable: boolean;
|
|
1150
1225
|
properties: {
|
|
1151
|
-
id: {
|
|
1152
|
-
type: string;
|
|
1153
|
-
description: string;
|
|
1154
|
-
};
|
|
1155
1226
|
email: {
|
|
1156
1227
|
type: string;
|
|
1157
1228
|
description: string;
|
|
@@ -1218,15 +1289,15 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
|
|
|
1218
1289
|
redirectURI: string;
|
|
1219
1290
|
oidcConfig: OIDCConfig | null;
|
|
1220
1291
|
samlConfig: SAMLConfig | null;
|
|
1221
|
-
} & Omit<InferSSOProvider<O>, "
|
|
1292
|
+
} & Omit<InferSSOProvider<O>, "samlConfig" | "oidcConfig"> & {
|
|
1222
1293
|
domainVerified: boolean;
|
|
1223
1294
|
domainVerificationToken: string;
|
|
1224
1295
|
} : {
|
|
1225
1296
|
redirectURI: string;
|
|
1226
1297
|
oidcConfig: OIDCConfig | null;
|
|
1227
1298
|
samlConfig: SAMLConfig | null;
|
|
1228
|
-
} & Omit<InferSSOProvider<O>, "
|
|
1229
|
-
declare const signInSSO: (options?: SSOOptions) =>
|
|
1299
|
+
} & Omit<InferSSOProvider<O>, "samlConfig" | "oidcConfig">>;
|
|
1300
|
+
declare const signInSSO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sign-in/sso", {
|
|
1230
1301
|
method: "POST";
|
|
1231
1302
|
body: z.ZodObject<{
|
|
1232
1303
|
email: z.ZodOptional<z.ZodString>;
|
|
@@ -1348,7 +1419,7 @@ declare const signInSSO: (options?: SSOOptions) => better_call0.StrictEndpoint<"
|
|
|
1348
1419
|
url: string;
|
|
1349
1420
|
redirect: boolean;
|
|
1350
1421
|
}>;
|
|
1351
|
-
declare const callbackSSO: (options?: SSOOptions) =>
|
|
1422
|
+
declare const callbackSSO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/callback/:providerId", {
|
|
1352
1423
|
method: "GET";
|
|
1353
1424
|
query: z.ZodObject<{
|
|
1354
1425
|
code: z.ZodOptional<z.ZodString>;
|
|
@@ -1376,7 +1447,7 @@ declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint
|
|
|
1376
1447
|
* Used when `options.redirectURI` is set — the `providerId` is read from
|
|
1377
1448
|
* the OAuth state instead of the URL path.
|
|
1378
1449
|
*/
|
|
1379
|
-
declare const callbackSSOShared: (options?: SSOOptions) =>
|
|
1450
|
+
declare const callbackSSOShared: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/callback", {
|
|
1380
1451
|
metadata: {
|
|
1381
1452
|
openapi: {
|
|
1382
1453
|
operationId: string;
|
|
@@ -1399,7 +1470,7 @@ declare const callbackSSOShared: (options?: SSOOptions) => better_call0.StrictEn
|
|
|
1399
1470
|
}, z.core.$strip>;
|
|
1400
1471
|
allowedMediaTypes: readonly ["application/x-www-form-urlencoded", "application/json"];
|
|
1401
1472
|
}, void>;
|
|
1402
|
-
declare const acsEndpoint: (options?: SSOOptions) =>
|
|
1473
|
+
declare const acsEndpoint: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
|
|
1403
1474
|
method: ("GET" | "POST")[];
|
|
1404
1475
|
body: z.ZodOptional<z.ZodObject<{
|
|
1405
1476
|
SAMLResponse: z.ZodString;
|
|
@@ -1429,7 +1500,7 @@ declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint
|
|
|
1429
1500
|
scope: "server";
|
|
1430
1501
|
};
|
|
1431
1502
|
}, never>;
|
|
1432
|
-
declare const sloEndpoint: (options?: SSOOptions) =>
|
|
1503
|
+
declare const sloEndpoint: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/sp/slo/:providerId", {
|
|
1433
1504
|
method: ("GET" | "POST")[];
|
|
1434
1505
|
body: z.ZodOptional<z.ZodObject<{
|
|
1435
1506
|
SAMLRequest: z.ZodOptional<z.ZodString>;
|
|
@@ -1450,12 +1521,12 @@ declare const sloEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint
|
|
|
1450
1521
|
scope: "server";
|
|
1451
1522
|
};
|
|
1452
1523
|
}, void | Response>;
|
|
1453
|
-
declare const initiateSLO: (options?: SSOOptions) =>
|
|
1524
|
+
declare const initiateSLO: (options?: SSOOptions) => import("better-call").StrictEndpoint<"/sso/saml2/logout/:providerId", {
|
|
1454
1525
|
method: "POST";
|
|
1455
1526
|
body: z.ZodObject<{
|
|
1456
1527
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
1457
1528
|
}, z.core.$strip>;
|
|
1458
|
-
use: ((inputContext:
|
|
1529
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1459
1530
|
session: {
|
|
1460
1531
|
session: Record<string, any> & {
|
|
1461
1532
|
id: string;
|
|
@@ -1600,7 +1671,29 @@ interface OIDCDiscoveryDocument {
|
|
|
1600
1671
|
/**
|
|
1601
1672
|
* Error codes for OIDC discovery operations.
|
|
1602
1673
|
*/
|
|
1603
|
-
type DiscoveryErrorCode =
|
|
1674
|
+
type DiscoveryErrorCode =
|
|
1675
|
+
/** Request to discovery endpoint timed out */
|
|
1676
|
+
"discovery_timeout" |
|
|
1677
|
+
/** Discovery endpoint returned 404 or similar */
|
|
1678
|
+
"discovery_not_found" |
|
|
1679
|
+
/** Discovery endpoint returned invalid JSON */
|
|
1680
|
+
"discovery_invalid_json" |
|
|
1681
|
+
/** OIDC endpoint URL (discovery or per-endpoint: authorization, token, userinfo, jwks) is invalid, malformed, or uses a non-`http(s)` scheme */
|
|
1682
|
+
"discovery_invalid_url" |
|
|
1683
|
+
/** OIDC endpoint URL is not trusted by the trusted origins configuration */
|
|
1684
|
+
"discovery_untrusted_origin" |
|
|
1685
|
+
/** OIDC endpoint URL (discovery or per-endpoint) points to a host that is not publicly routable (loopback, RFC 1918, link-local, cloud metadata FQDN, etc.) */
|
|
1686
|
+
"discovery_private_host" |
|
|
1687
|
+
/** Server-side OIDC endpoint fetch received an HTTP redirect response */
|
|
1688
|
+
"oidc_endpoint_redirect" |
|
|
1689
|
+
/** Discovery document issuer doesn't match configured issuer */
|
|
1690
|
+
"issuer_mismatch" |
|
|
1691
|
+
/** Discovery document is missing required fields */
|
|
1692
|
+
"discovery_incomplete" |
|
|
1693
|
+
/** IdP only advertises token auth methods that Better Auth doesn't currently support */
|
|
1694
|
+
"unsupported_token_auth_method" |
|
|
1695
|
+
/** Catch-all for unexpected errors */
|
|
1696
|
+
"discovery_unexpected_error";
|
|
1604
1697
|
/**
|
|
1605
1698
|
* Custom error class for OIDC discovery failures.
|
|
1606
1699
|
* Can be caught and mapped to APIError at the edge.
|
|
@@ -1837,4 +1930,4 @@ declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
|
1837
1930
|
options: NoInfer<O>;
|
|
1838
1931
|
};
|
|
1839
1932
|
//#endregion
|
|
1840
|
-
export {
|
|
1933
|
+
export { SSOProviderUserProfile as A, DEFAULT_MAX_SAML_METADATA_SIZE as C, SAMLIdentityProviderMetadata as D, SAMLConfig as E, DataEncryptionAlgorithm as F, DeprecatedAlgorithmBehavior as I, DigestAlgorithm as L, SSOUserResolutionContext as M, SSOUserResolutionInput as N, SSOOptions as O, AlgorithmValidationOptions as P, KeyEncryptionAlgorithm as R, DEFAULT_CLOCK_SKEW_MS as S, OIDCConfig as T, REQUIRED_DISCOVERY_FIELDS as _, fetchDiscoveryDocument as a, TimestampValidationOptions as b, normalizeUrl as c, validateDiscoveryUrl as d, DiscoverOIDCConfigParams as f, OIDCDiscoveryDocument as g, HydratedOIDCConfig as h, discoverOIDCConfig as i, SSOUserResolution as j, SSOProvider as k, selectTokenEndpointAuthMethod as l, DiscoveryErrorCode as m, sso as n, needsRuntimeDiscovery as o, DiscoveryError as p, computeDiscoveryUrl as r, normalizeDiscoveryUrls as s, SSOPlugin as t, validateDiscoveryDocument as u, RequiredDiscoveryField as v, DEFAULT_MAX_SAML_RESPONSE_SIZE as w, validateSAMLTimestamp as x, SAMLConditions as y, SignatureAlgorithm as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { AlgorithmValidationOptions, DEFAULT_CLOCK_SKEW_MS, DEFAULT_MAX_SAML_METADATA_SIZE, DEFAULT_MAX_SAML_RESPONSE_SIZE, DataEncryptionAlgorithm, DeprecatedAlgorithmBehavior, DigestAlgorithm, DiscoverOIDCConfigParams, DiscoveryError, DiscoveryErrorCode, HydratedOIDCConfig, KeyEncryptionAlgorithm, OIDCConfig, OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, RequiredDiscoveryField, SAMLConditions, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, SignatureAlgorithm, TimestampValidationOptions, computeDiscoveryUrl, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };
|
|
1
|
+
import { A as SSOProviderUserProfile, C as DEFAULT_MAX_SAML_METADATA_SIZE, D as SAMLIdentityProviderMetadata, E as SAMLConfig, F as DataEncryptionAlgorithm, I as DeprecatedAlgorithmBehavior, L as DigestAlgorithm, M as SSOUserResolutionContext, N as SSOUserResolutionInput, O as SSOOptions, P as AlgorithmValidationOptions, R as KeyEncryptionAlgorithm, S as DEFAULT_CLOCK_SKEW_MS, T as OIDCConfig, _ as REQUIRED_DISCOVERY_FIELDS, a as fetchDiscoveryDocument, b as TimestampValidationOptions, c as normalizeUrl, d as validateDiscoveryUrl, f as DiscoverOIDCConfigParams, g as OIDCDiscoveryDocument, h as HydratedOIDCConfig, i as discoverOIDCConfig, j as SSOUserResolution, k as SSOProvider, l as selectTokenEndpointAuthMethod, m as DiscoveryErrorCode, n as sso, o as needsRuntimeDiscovery, p as DiscoveryError, r as computeDiscoveryUrl, s as normalizeDiscoveryUrls, t as SSOPlugin, u as validateDiscoveryDocument, v as RequiredDiscoveryField, w as DEFAULT_MAX_SAML_RESPONSE_SIZE, x as validateSAMLTimestamp, y as SAMLConditions, z as SignatureAlgorithm } from "./index-D1yk91me.mjs";
|
|
2
|
+
export { type AlgorithmValidationOptions, DEFAULT_CLOCK_SKEW_MS, DEFAULT_MAX_SAML_METADATA_SIZE, DEFAULT_MAX_SAML_RESPONSE_SIZE, DataEncryptionAlgorithm, type DeprecatedAlgorithmBehavior, DigestAlgorithm, type DiscoverOIDCConfigParams, DiscoveryError, type DiscoveryErrorCode, type HydratedOIDCConfig, KeyEncryptionAlgorithm, type OIDCConfig, type OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, type RequiredDiscoveryField, type SAMLConditions, type SAMLConfig, type SAMLIdentityProviderMetadata, type SSOOptions, SSOPlugin, type SSOProvider, type SSOProviderUserProfile, type SSOUserResolution, type SSOUserResolutionContext, type SSOUserResolutionInput, SignatureAlgorithm, type TimestampValidationOptions, computeDiscoveryUrl, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };
|