@better-auth/sso 1.4.0-beta.14 → 1.4.0-beta.16
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/.turbo/turbo-build.log +10 -18
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/{index-CL9gq2xe.d.ts → index-U95aRHHN.d.ts} +58 -52
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-BEPbgggK.js → src-BrnaMP1W.js} +1 -1
- package/package.json +8 -10
- package/src/index.ts +140 -122
- package/tsdown.config.ts +1 -1
- package/dist/client.cjs +0 -12
- package/dist/client.d.cts +0 -9
- package/dist/index-N2GvRGik.d.cts +0 -688
- package/dist/index.cjs +0 -3
- package/dist/index.d.cts +0 -2
- package/dist/src-BsLnNXTo.cjs +0 -1256
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/sso@1.4.0-beta.
|
|
2
|
+
> @better-auth/sso@1.4.0-beta.16 build /home/runner/work/better-auth/better-auth/packages/sso
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.15.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.15.11[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
6
6
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/better-auth/better-auth/packages/sso/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/client.ts, src/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [
|
|
11
|
-
[34mℹ[39m [
|
|
12
|
-
[34mℹ[39m [
|
|
13
|
-
[34mℹ[39m [
|
|
14
|
-
[34mℹ[39m [
|
|
15
|
-
[34mℹ[39m [
|
|
16
|
-
[34mℹ[39m
|
|
17
|
-
[
|
|
18
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mclient.d.ts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
19
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mindex-CL9gq2xe.d.ts[39m [2m21.42 kB[22m [2m│ gzip: 3.10 kB[22m
|
|
20
|
-
[34mℹ[39m [34m[ESM][39m 6 files, total: 71.70 kB
|
|
21
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
22
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mclient.d.cts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
23
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mindex-N2GvRGik.d.cts[39m [2m21.42 kB[22m [2m│ gzip: 3.10 kB[22m
|
|
24
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total: 21.88 kB
|
|
25
|
-
[32m✔[39m Build complete in [32m8609ms[39m
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mclient.js[22m [2m 0.18 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 0.06 kB[22m [2m│ gzip: 0.07 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22msrc-BrnaMP1W.js [2m49.60 kB[22m [2m│ gzip: 8.54 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.ts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[32mindex-U95aRHHN.d.ts[39m [2m22.51 kB[22m [2m│ gzip: 3.39 kB[22m
|
|
16
|
+
[34mℹ[39m 6 files, total: 72.81 kB
|
|
17
|
+
[32m✔[39m Build complete in [32m11363ms[39m
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -4,43 +4,43 @@ import * as better_call0 from "better-call";
|
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
interface OIDCMapping {
|
|
7
|
-
id?: string;
|
|
8
|
-
email?: string;
|
|
9
|
-
emailVerified?: string;
|
|
10
|
-
name?: string;
|
|
11
|
-
image?: string;
|
|
12
|
-
extraFields?: Record<string, string
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
email?: string | undefined;
|
|
9
|
+
emailVerified?: string | undefined;
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
image?: string | undefined;
|
|
12
|
+
extraFields?: Record<string, string> | undefined;
|
|
13
13
|
}
|
|
14
14
|
interface SAMLMapping {
|
|
15
|
-
id?: string;
|
|
16
|
-
email?: string;
|
|
17
|
-
emailVerified?: string;
|
|
18
|
-
name?: string;
|
|
19
|
-
firstName?: string;
|
|
20
|
-
lastName?: string;
|
|
21
|
-
extraFields?: Record<string, string
|
|
15
|
+
id?: string | undefined;
|
|
16
|
+
email?: string | undefined;
|
|
17
|
+
emailVerified?: string | undefined;
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
firstName?: string | undefined;
|
|
20
|
+
lastName?: string | undefined;
|
|
21
|
+
extraFields?: Record<string, string> | undefined;
|
|
22
22
|
}
|
|
23
23
|
interface OIDCConfig {
|
|
24
24
|
issuer: string;
|
|
25
25
|
pkce: boolean;
|
|
26
26
|
clientId: string;
|
|
27
27
|
clientSecret: string;
|
|
28
|
-
authorizationEndpoint?: string;
|
|
28
|
+
authorizationEndpoint?: string | undefined;
|
|
29
29
|
discoveryEndpoint: string;
|
|
30
|
-
userInfoEndpoint?: string;
|
|
31
|
-
scopes?: string[];
|
|
32
|
-
overrideUserInfo?: boolean;
|
|
33
|
-
tokenEndpoint?: string;
|
|
34
|
-
tokenEndpointAuthentication?: "client_secret_post" | "client_secret_basic";
|
|
35
|
-
jwksEndpoint?: string;
|
|
36
|
-
mapping?: OIDCMapping;
|
|
30
|
+
userInfoEndpoint?: string | undefined;
|
|
31
|
+
scopes?: string[] | undefined;
|
|
32
|
+
overrideUserInfo?: boolean | undefined;
|
|
33
|
+
tokenEndpoint?: string | undefined;
|
|
34
|
+
tokenEndpointAuthentication?: ("client_secret_post" | "client_secret_basic") | undefined;
|
|
35
|
+
jwksEndpoint?: string | undefined;
|
|
36
|
+
mapping?: OIDCMapping | undefined;
|
|
37
37
|
}
|
|
38
38
|
interface SAMLConfig {
|
|
39
39
|
issuer: string;
|
|
40
40
|
entryPoint: string;
|
|
41
41
|
cert: string;
|
|
42
42
|
callbackUrl: string;
|
|
43
|
-
audience?: string;
|
|
43
|
+
audience?: string | undefined;
|
|
44
44
|
idpMetadata?: {
|
|
45
45
|
metadata?: string;
|
|
46
46
|
entityID?: string;
|
|
@@ -56,39 +56,39 @@ interface SAMLConfig {
|
|
|
56
56
|
Binding: string;
|
|
57
57
|
Location: string;
|
|
58
58
|
}>;
|
|
59
|
-
};
|
|
59
|
+
} | undefined;
|
|
60
60
|
spMetadata: {
|
|
61
|
-
metadata?: string;
|
|
62
|
-
entityID?: string;
|
|
63
|
-
binding?: string;
|
|
64
|
-
privateKey?: string;
|
|
65
|
-
privateKeyPass?: string;
|
|
66
|
-
isAssertionEncrypted?: boolean;
|
|
67
|
-
encPrivateKey?: string;
|
|
68
|
-
encPrivateKeyPass?: string;
|
|
61
|
+
metadata?: string | undefined;
|
|
62
|
+
entityID?: string | undefined;
|
|
63
|
+
binding?: string | undefined;
|
|
64
|
+
privateKey?: string | undefined;
|
|
65
|
+
privateKeyPass?: string | undefined;
|
|
66
|
+
isAssertionEncrypted?: boolean | undefined;
|
|
67
|
+
encPrivateKey?: string | undefined;
|
|
68
|
+
encPrivateKeyPass?: string | undefined;
|
|
69
69
|
};
|
|
70
|
-
wantAssertionsSigned?: boolean;
|
|
71
|
-
signatureAlgorithm?: string;
|
|
72
|
-
digestAlgorithm?: string;
|
|
73
|
-
identifierFormat?: string;
|
|
74
|
-
privateKey?: string;
|
|
75
|
-
decryptionPvk?: string;
|
|
76
|
-
additionalParams?: Record<string, any
|
|
77
|
-
mapping?: SAMLMapping;
|
|
70
|
+
wantAssertionsSigned?: boolean | undefined;
|
|
71
|
+
signatureAlgorithm?: string | undefined;
|
|
72
|
+
digestAlgorithm?: string | undefined;
|
|
73
|
+
identifierFormat?: string | undefined;
|
|
74
|
+
privateKey?: string | undefined;
|
|
75
|
+
decryptionPvk?: string | undefined;
|
|
76
|
+
additionalParams?: Record<string, any> | undefined;
|
|
77
|
+
mapping?: SAMLMapping | undefined;
|
|
78
78
|
}
|
|
79
79
|
interface SSOProvider {
|
|
80
80
|
issuer: string;
|
|
81
|
-
oidcConfig?: OIDCConfig;
|
|
82
|
-
samlConfig?: SAMLConfig;
|
|
81
|
+
oidcConfig?: OIDCConfig | undefined;
|
|
82
|
+
samlConfig?: SAMLConfig | undefined;
|
|
83
83
|
userId: string;
|
|
84
84
|
providerId: string;
|
|
85
|
-
organizationId?: string;
|
|
85
|
+
organizationId?: string | undefined;
|
|
86
86
|
}
|
|
87
87
|
interface SSOOptions {
|
|
88
88
|
/**
|
|
89
89
|
* custom function to provision a user when they sign in with an SSO provider.
|
|
90
90
|
*/
|
|
91
|
-
provisionUser?: (data: {
|
|
91
|
+
provisionUser?: ((data: {
|
|
92
92
|
/**
|
|
93
93
|
* The user object from the database
|
|
94
94
|
*/
|
|
@@ -105,7 +105,7 @@ interface SSOOptions {
|
|
|
105
105
|
* The SSO provider
|
|
106
106
|
*/
|
|
107
107
|
provider: SSOProvider;
|
|
108
|
-
}) => Promise<void
|
|
108
|
+
}) => Promise<void>) | undefined;
|
|
109
109
|
/**
|
|
110
110
|
* Organization provisioning options
|
|
111
111
|
*/
|
|
@@ -130,7 +130,7 @@ interface SSOOptions {
|
|
|
130
130
|
*/
|
|
131
131
|
provider: SSOProvider;
|
|
132
132
|
}) => Promise<"member" | "admin">;
|
|
133
|
-
};
|
|
133
|
+
} | undefined;
|
|
134
134
|
/**
|
|
135
135
|
* Default SSO provider configurations for testing.
|
|
136
136
|
* These will take the precedence over the database providers.
|
|
@@ -153,17 +153,17 @@ interface SSOOptions {
|
|
|
153
153
|
* OIDC configuration
|
|
154
154
|
*/
|
|
155
155
|
oidcConfig?: OIDCConfig;
|
|
156
|
-
}
|
|
156
|
+
}> | undefined;
|
|
157
157
|
/**
|
|
158
158
|
* Override user info with the provider info.
|
|
159
159
|
* @default false
|
|
160
160
|
*/
|
|
161
|
-
defaultOverrideUserInfo?: boolean;
|
|
161
|
+
defaultOverrideUserInfo?: boolean | undefined;
|
|
162
162
|
/**
|
|
163
163
|
* Disable implicit sign up for new users. When set to true for the provider,
|
|
164
164
|
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
165
165
|
*/
|
|
166
|
-
disableImplicitSignUp?: boolean;
|
|
166
|
+
disableImplicitSignUp?: boolean | undefined;
|
|
167
167
|
/**
|
|
168
168
|
* Configure the maximum number of SSO providers a user can register.
|
|
169
169
|
* You can also pass a function that returns a number.
|
|
@@ -178,14 +178,20 @@ interface SSOOptions {
|
|
|
178
178
|
* ```
|
|
179
179
|
* @default 10
|
|
180
180
|
*/
|
|
181
|
-
providersLimit?: number | ((user: User) => Promise<number> | number);
|
|
181
|
+
providersLimit?: (number | ((user: User) => Promise<number> | number)) | undefined;
|
|
182
182
|
/**
|
|
183
183
|
* Trust the email verified flag from the provider.
|
|
184
|
+
*
|
|
185
|
+
* ⚠️ Use this with caution — it can lead to account takeover if misused. Only enable it if users **cannot freely register new providers**. You can
|
|
186
|
+
* prevent that by using `disabledPaths` or other safeguards to block provider registration from the client.
|
|
187
|
+
*
|
|
188
|
+
* If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
|
|
189
|
+
* providers in the `trustedProviders` list.
|
|
184
190
|
* @default false
|
|
185
191
|
*/
|
|
186
|
-
trustEmailVerified?: boolean;
|
|
192
|
+
trustEmailVerified?: boolean | undefined;
|
|
187
193
|
}
|
|
188
|
-
declare const sso: (options?: SSOOptions) => {
|
|
194
|
+
declare const sso: (options?: SSOOptions | undefined) => {
|
|
189
195
|
id: "sso";
|
|
190
196
|
endpoints: {
|
|
191
197
|
spMetadata: better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
|
|
@@ -473,7 +479,7 @@ declare const sso: (options?: SSOOptions) => {
|
|
|
473
479
|
issuer: string;
|
|
474
480
|
userId: string;
|
|
475
481
|
providerId: string;
|
|
476
|
-
organizationId?: string;
|
|
482
|
+
organizationId?: string | undefined;
|
|
477
483
|
}>;
|
|
478
484
|
signInSSO: better_call0.StrictEndpoint<"/sign-in/sso", {
|
|
479
485
|
method: "POST";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SSOOptions, i as SAMLMapping, n as OIDCMapping, o as SSOProvider, r as SAMLConfig, s as sso, t as OIDCConfig } from "./index-
|
|
1
|
+
import { a as SSOOptions, i as SAMLMapping, n as OIDCMapping, o as SSOProvider, r as SAMLConfig, s as sso, t as OIDCConfig } from "./index-U95aRHHN.js";
|
|
2
2
|
export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
|
package/dist/index.js
CHANGED
|
@@ -504,7 +504,7 @@ const sso = (options) => {
|
|
|
504
504
|
if (body.providerType === "saml" && !provider.samlConfig) throw new APIError("BAD_REQUEST", { message: "SAML provider is not configured" });
|
|
505
505
|
}
|
|
506
506
|
if (provider.oidcConfig && body.providerType !== "saml") {
|
|
507
|
-
const state = await generateState(ctx);
|
|
507
|
+
const state = await generateState(ctx, void 0, false);
|
|
508
508
|
const redirectURI = `${ctx.context.baseURL}/sso/callback/${provider.providerId}`;
|
|
509
509
|
const authorizationURL = await createAuthorizationURL({
|
|
510
510
|
id: provider.issuer,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/sso",
|
|
3
3
|
"author": "Bereket Engida",
|
|
4
|
-
"version": "1.4.0-beta.
|
|
4
|
+
"version": "1.4.0-beta.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"homepage": "https://www.better-auth.com/docs/plugins/sso",
|
|
@@ -32,14 +32,12 @@
|
|
|
32
32
|
".": {
|
|
33
33
|
"better-auth-dev-source": "./src/index.ts",
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
|
-
"
|
|
36
|
-
"require": "./dist/index.cjs"
|
|
35
|
+
"default": "./dist/index.js"
|
|
37
36
|
},
|
|
38
37
|
"./client": {
|
|
39
38
|
"better-auth-dev-source": "./src/client.ts",
|
|
40
39
|
"types": "./dist/client.d.ts",
|
|
41
|
-
"
|
|
42
|
-
"require": "./dist/client.cjs"
|
|
40
|
+
"default": "./dist/client.js"
|
|
43
41
|
}
|
|
44
42
|
},
|
|
45
43
|
"typesVersions": {
|
|
@@ -56,21 +54,21 @@
|
|
|
56
54
|
"@better-fetch/fetch": "1.1.18",
|
|
57
55
|
"fast-xml-parser": "^5.2.5",
|
|
58
56
|
"jose": "^6.1.0",
|
|
59
|
-
"oauth2-mock-server": "^7.2.1",
|
|
60
57
|
"samlify": "^2.10.1",
|
|
61
58
|
"zod": "^4.1.5"
|
|
62
59
|
},
|
|
63
60
|
"devDependencies": {
|
|
64
61
|
"@types/body-parser": "^1.19.6",
|
|
65
|
-
"@types/express": "^5.0.
|
|
62
|
+
"@types/express": "^5.0.5",
|
|
66
63
|
"better-call": "1.0.24",
|
|
67
64
|
"body-parser": "^2.2.0",
|
|
68
65
|
"express": "^5.1.0",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
66
|
+
"oauth2-mock-server": "^7.2.1",
|
|
67
|
+
"tsdown": "^0.15.11",
|
|
68
|
+
"better-auth": "^1.4.0-beta.16"
|
|
71
69
|
},
|
|
72
70
|
"peerDependencies": {
|
|
73
|
-
"better-auth": "1.4.0-beta.
|
|
71
|
+
"better-auth": "1.4.0-beta.16"
|
|
74
72
|
},
|
|
75
73
|
"scripts": {
|
|
76
74
|
"test": "vitest",
|
package/src/index.ts
CHANGED
|
@@ -66,22 +66,22 @@ function safeJsonParse<T>(value: string | T | null | undefined): T | null {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface OIDCMapping {
|
|
69
|
-
id?: string;
|
|
70
|
-
email?: string;
|
|
71
|
-
emailVerified?: string;
|
|
72
|
-
name?: string;
|
|
73
|
-
image?: string;
|
|
74
|
-
extraFields?: Record<string, string
|
|
69
|
+
id?: string | undefined;
|
|
70
|
+
email?: string | undefined;
|
|
71
|
+
emailVerified?: string | undefined;
|
|
72
|
+
name?: string | undefined;
|
|
73
|
+
image?: string | undefined;
|
|
74
|
+
extraFields?: Record<string, string> | undefined;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface SAMLMapping {
|
|
78
|
-
id?: string;
|
|
79
|
-
email?: string;
|
|
80
|
-
emailVerified?: string;
|
|
81
|
-
name?: string;
|
|
82
|
-
firstName?: string;
|
|
83
|
-
lastName?: string;
|
|
84
|
-
extraFields?: Record<string, string
|
|
78
|
+
id?: string | undefined;
|
|
79
|
+
email?: string | undefined;
|
|
80
|
+
emailVerified?: string | undefined;
|
|
81
|
+
name?: string | undefined;
|
|
82
|
+
firstName?: string | undefined;
|
|
83
|
+
lastName?: string | undefined;
|
|
84
|
+
extraFields?: Record<string, string> | undefined;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export interface OIDCConfig {
|
|
@@ -89,15 +89,17 @@ export interface OIDCConfig {
|
|
|
89
89
|
pkce: boolean;
|
|
90
90
|
clientId: string;
|
|
91
91
|
clientSecret: string;
|
|
92
|
-
authorizationEndpoint?: string;
|
|
92
|
+
authorizationEndpoint?: string | undefined;
|
|
93
93
|
discoveryEndpoint: string;
|
|
94
|
-
userInfoEndpoint?: string;
|
|
95
|
-
scopes?: string[];
|
|
96
|
-
overrideUserInfo?: boolean;
|
|
97
|
-
tokenEndpoint?: string;
|
|
98
|
-
tokenEndpointAuthentication?:
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
userInfoEndpoint?: string | undefined;
|
|
95
|
+
scopes?: string[] | undefined;
|
|
96
|
+
overrideUserInfo?: boolean | undefined;
|
|
97
|
+
tokenEndpoint?: string | undefined;
|
|
98
|
+
tokenEndpointAuthentication?:
|
|
99
|
+
| ("client_secret_post" | "client_secret_basic")
|
|
100
|
+
| undefined;
|
|
101
|
+
jwksEndpoint?: string | undefined;
|
|
102
|
+
mapping?: OIDCMapping | undefined;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
export interface SAMLConfig {
|
|
@@ -105,132 +107,140 @@ export interface SAMLConfig {
|
|
|
105
107
|
entryPoint: string;
|
|
106
108
|
cert: string;
|
|
107
109
|
callbackUrl: string;
|
|
108
|
-
audience?: string;
|
|
109
|
-
idpMetadata?:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
audience?: string | undefined;
|
|
111
|
+
idpMetadata?:
|
|
112
|
+
| {
|
|
113
|
+
metadata?: string;
|
|
114
|
+
entityID?: string;
|
|
115
|
+
entityURL?: string;
|
|
116
|
+
redirectURL?: string;
|
|
117
|
+
cert?: string;
|
|
118
|
+
privateKey?: string;
|
|
119
|
+
privateKeyPass?: string;
|
|
120
|
+
isAssertionEncrypted?: boolean;
|
|
121
|
+
encPrivateKey?: string;
|
|
122
|
+
encPrivateKeyPass?: string;
|
|
123
|
+
singleSignOnService?: Array<{
|
|
124
|
+
Binding: string;
|
|
125
|
+
Location: string;
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
| undefined;
|
|
125
129
|
spMetadata: {
|
|
126
|
-
metadata?: string;
|
|
127
|
-
entityID?: string;
|
|
128
|
-
binding?: string;
|
|
129
|
-
privateKey?: string;
|
|
130
|
-
privateKeyPass?: string;
|
|
131
|
-
isAssertionEncrypted?: boolean;
|
|
132
|
-
encPrivateKey?: string;
|
|
133
|
-
encPrivateKeyPass?: string;
|
|
130
|
+
metadata?: string | undefined;
|
|
131
|
+
entityID?: string | undefined;
|
|
132
|
+
binding?: string | undefined;
|
|
133
|
+
privateKey?: string | undefined;
|
|
134
|
+
privateKeyPass?: string | undefined;
|
|
135
|
+
isAssertionEncrypted?: boolean | undefined;
|
|
136
|
+
encPrivateKey?: string | undefined;
|
|
137
|
+
encPrivateKeyPass?: string | undefined;
|
|
134
138
|
};
|
|
135
|
-
wantAssertionsSigned?: boolean;
|
|
136
|
-
signatureAlgorithm?: string;
|
|
137
|
-
digestAlgorithm?: string;
|
|
138
|
-
identifierFormat?: string;
|
|
139
|
-
privateKey?: string;
|
|
140
|
-
decryptionPvk?: string;
|
|
141
|
-
additionalParams?: Record<string, any
|
|
142
|
-
mapping?: SAMLMapping;
|
|
139
|
+
wantAssertionsSigned?: boolean | undefined;
|
|
140
|
+
signatureAlgorithm?: string | undefined;
|
|
141
|
+
digestAlgorithm?: string | undefined;
|
|
142
|
+
identifierFormat?: string | undefined;
|
|
143
|
+
privateKey?: string | undefined;
|
|
144
|
+
decryptionPvk?: string | undefined;
|
|
145
|
+
additionalParams?: Record<string, any> | undefined;
|
|
146
|
+
mapping?: SAMLMapping | undefined;
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
export interface SSOProvider {
|
|
146
150
|
issuer: string;
|
|
147
|
-
oidcConfig?: OIDCConfig;
|
|
148
|
-
samlConfig?: SAMLConfig;
|
|
151
|
+
oidcConfig?: OIDCConfig | undefined;
|
|
152
|
+
samlConfig?: SAMLConfig | undefined;
|
|
149
153
|
userId: string;
|
|
150
154
|
providerId: string;
|
|
151
|
-
organizationId?: string;
|
|
155
|
+
organizationId?: string | undefined;
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
export interface SSOOptions {
|
|
155
159
|
/**
|
|
156
160
|
* custom function to provision a user when they sign in with an SSO provider.
|
|
157
161
|
*/
|
|
158
|
-
provisionUser?:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
provisionUser?:
|
|
163
|
+
| ((data: {
|
|
164
|
+
/**
|
|
165
|
+
* The user object from the database
|
|
166
|
+
*/
|
|
167
|
+
user: User & Record<string, any>;
|
|
168
|
+
/**
|
|
169
|
+
* The user info object from the provider
|
|
170
|
+
*/
|
|
171
|
+
userInfo: Record<string, any>;
|
|
172
|
+
/**
|
|
173
|
+
* The OAuth2 tokens from the provider
|
|
174
|
+
*/
|
|
175
|
+
token?: OAuth2Tokens;
|
|
176
|
+
/**
|
|
177
|
+
* The SSO provider
|
|
178
|
+
*/
|
|
179
|
+
provider: SSOProvider;
|
|
180
|
+
}) => Promise<void>)
|
|
181
|
+
| undefined;
|
|
176
182
|
/**
|
|
177
183
|
* Organization provisioning options
|
|
178
184
|
*/
|
|
179
|
-
organizationProvisioning?:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
organizationProvisioning?:
|
|
186
|
+
| {
|
|
187
|
+
disabled?: boolean;
|
|
188
|
+
defaultRole?: "member" | "admin";
|
|
189
|
+
getRole?: (data: {
|
|
190
|
+
/**
|
|
191
|
+
* The user object from the database
|
|
192
|
+
*/
|
|
193
|
+
user: User & Record<string, any>;
|
|
194
|
+
/**
|
|
195
|
+
* The user info object from the provider
|
|
196
|
+
*/
|
|
197
|
+
userInfo: Record<string, any>;
|
|
198
|
+
/**
|
|
199
|
+
* The OAuth2 tokens from the provider
|
|
200
|
+
*/
|
|
201
|
+
token?: OAuth2Tokens;
|
|
202
|
+
/**
|
|
203
|
+
* The SSO provider
|
|
204
|
+
*/
|
|
205
|
+
provider: SSOProvider;
|
|
206
|
+
}) => Promise<"member" | "admin">;
|
|
207
|
+
}
|
|
208
|
+
| undefined;
|
|
201
209
|
/**
|
|
202
210
|
* Default SSO provider configurations for testing.
|
|
203
211
|
* These will take the precedence over the database providers.
|
|
204
212
|
*/
|
|
205
|
-
defaultSSO?:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
213
|
+
defaultSSO?:
|
|
214
|
+
| Array<{
|
|
215
|
+
/**
|
|
216
|
+
* The domain to match for this default provider.
|
|
217
|
+
* This is only used to match incoming requests to this default provider.
|
|
218
|
+
*/
|
|
219
|
+
domain: string;
|
|
220
|
+
/**
|
|
221
|
+
* The provider ID to use
|
|
222
|
+
*/
|
|
223
|
+
providerId: string;
|
|
224
|
+
/**
|
|
225
|
+
* SAML configuration
|
|
226
|
+
*/
|
|
227
|
+
samlConfig?: SAMLConfig;
|
|
228
|
+
/**
|
|
229
|
+
* OIDC configuration
|
|
230
|
+
*/
|
|
231
|
+
oidcConfig?: OIDCConfig;
|
|
232
|
+
}>
|
|
233
|
+
| undefined;
|
|
224
234
|
/**
|
|
225
235
|
* Override user info with the provider info.
|
|
226
236
|
* @default false
|
|
227
237
|
*/
|
|
228
|
-
defaultOverrideUserInfo?: boolean;
|
|
238
|
+
defaultOverrideUserInfo?: boolean | undefined;
|
|
229
239
|
/**
|
|
230
240
|
* Disable implicit sign up for new users. When set to true for the provider,
|
|
231
241
|
* sign-in need to be called with with requestSignUp as true to create new users.
|
|
232
242
|
*/
|
|
233
|
-
disableImplicitSignUp?: boolean;
|
|
243
|
+
disableImplicitSignUp?: boolean | undefined;
|
|
234
244
|
/**
|
|
235
245
|
* Configure the maximum number of SSO providers a user can register.
|
|
236
246
|
* You can also pass a function that returns a number.
|
|
@@ -245,15 +255,23 @@ export interface SSOOptions {
|
|
|
245
255
|
* ```
|
|
246
256
|
* @default 10
|
|
247
257
|
*/
|
|
248
|
-
providersLimit?:
|
|
258
|
+
providersLimit?:
|
|
259
|
+
| (number | ((user: User) => Promise<number> | number))
|
|
260
|
+
| undefined;
|
|
249
261
|
/**
|
|
250
262
|
* Trust the email verified flag from the provider.
|
|
263
|
+
*
|
|
264
|
+
* ⚠️ Use this with caution — it can lead to account takeover if misused. Only enable it if users **cannot freely register new providers**. You can
|
|
265
|
+
* prevent that by using `disabledPaths` or other safeguards to block provider registration from the client.
|
|
266
|
+
*
|
|
267
|
+
* If you want to allow account linking for specific trusted providers, enable the `accountLinking` option in your auth config and specify those
|
|
268
|
+
* providers in the `trustedProviders` list.
|
|
251
269
|
* @default false
|
|
252
270
|
*/
|
|
253
|
-
trustEmailVerified?: boolean;
|
|
271
|
+
trustEmailVerified?: boolean | undefined;
|
|
254
272
|
}
|
|
255
273
|
|
|
256
|
-
export const sso = (options?: SSOOptions) => {
|
|
274
|
+
export const sso = (options?: SSOOptions | undefined) => {
|
|
257
275
|
return {
|
|
258
276
|
id: "sso",
|
|
259
277
|
endpoints: {
|
|
@@ -1137,7 +1155,7 @@ export const sso = (options?: SSOOptions) => {
|
|
|
1137
1155
|
}
|
|
1138
1156
|
}
|
|
1139
1157
|
if (provider.oidcConfig && body.providerType !== "saml") {
|
|
1140
|
-
const state = await generateState(ctx);
|
|
1158
|
+
const state = await generateState(ctx, undefined, false);
|
|
1141
1159
|
const redirectURI = `${ctx.context.baseURL}/sso/callback/${provider.providerId}`;
|
|
1142
1160
|
const authorizationURL = await createAuthorizationURL({
|
|
1143
1161
|
id: provider.issuer,
|
package/tsdown.config.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { defineConfig } from "tsdown";
|
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
dts: { build: true, incremental: true },
|
|
5
|
-
format: ["esm"
|
|
5
|
+
format: ["esm"],
|
|
6
6
|
entry: ["./src/index.ts", "./src/client.ts"],
|
|
7
7
|
external: ["better-auth", "better-call", "@better-fetch/fetch", "stripe"],
|
|
8
8
|
});
|