@better-auth/sso 1.4.0-beta.14 → 1.4.0-beta.15
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 +7 -7
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/{index-CL9gq2xe.d.ts → index-CdeDxbNh.d.ts} +52 -52
- package/dist/{index-N2GvRGik.d.cts → index-DJAIa5j3.d.cts} +52 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +133 -121
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/sso@1.4.0-beta.
|
|
2
|
+
> @better-auth/sso@1.4.0-beta.15 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
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22msrc-BEPbgggK.js [2m49.59 kB[22m [2m│ gzip: 8.54 kB[22m
|
|
17
17
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
18
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-
|
|
20
|
-
[34mℹ[39m [34m[ESM][39m 6 files, total:
|
|
19
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mindex-CdeDxbNh.d.ts[39m [2m22.04 kB[22m [2m│ gzip: 3.15 kB[22m
|
|
20
|
+
[34mℹ[39m [34m[ESM][39m 6 files, total: 72.32 kB
|
|
21
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
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-
|
|
24
|
-
[34mℹ[39m [33m[CJS][39m 3 files, total:
|
|
25
|
-
[32m✔[39m Build complete in [
|
|
23
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mindex-DJAIa5j3.d.cts[39m [2m22.04 kB[22m [2m│ gzip: 3.16 kB[22m
|
|
24
|
+
[34mℹ[39m [33m[CJS][39m 3 files, total: 22.50 kB
|
|
25
|
+
[32m✔[39m Build complete in [32m9377ms[39m
|
package/dist/client.d.cts
CHANGED
package/dist/client.d.ts
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,14 @@ 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
184
|
* @default false
|
|
185
185
|
*/
|
|
186
|
-
trustEmailVerified?: boolean;
|
|
186
|
+
trustEmailVerified?: boolean | undefined;
|
|
187
187
|
}
|
|
188
|
-
declare const sso: (options?: SSOOptions) => {
|
|
188
|
+
declare const sso: (options?: SSOOptions | undefined) => {
|
|
189
189
|
id: "sso";
|
|
190
190
|
endpoints: {
|
|
191
191
|
spMetadata: better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
|
|
@@ -473,7 +473,7 @@ declare const sso: (options?: SSOOptions) => {
|
|
|
473
473
|
issuer: string;
|
|
474
474
|
userId: string;
|
|
475
475
|
providerId: string;
|
|
476
|
-
organizationId?: string;
|
|
476
|
+
organizationId?: string | undefined;
|
|
477
477
|
}>;
|
|
478
478
|
signInSSO: better_call0.StrictEndpoint<"/sign-in/sso", {
|
|
479
479
|
method: "POST";
|
|
@@ -4,43 +4,43 @@ import * as z from "zod/v4";
|
|
|
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,14 @@ 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
184
|
* @default false
|
|
185
185
|
*/
|
|
186
|
-
trustEmailVerified?: boolean;
|
|
186
|
+
trustEmailVerified?: boolean | undefined;
|
|
187
187
|
}
|
|
188
|
-
declare const sso: (options?: SSOOptions) => {
|
|
188
|
+
declare const sso: (options?: SSOOptions | undefined) => {
|
|
189
189
|
id: "sso";
|
|
190
190
|
endpoints: {
|
|
191
191
|
spMetadata: better_call0.StrictEndpoint<"/sso/saml2/sp/metadata", {
|
|
@@ -473,7 +473,7 @@ declare const sso: (options?: SSOOptions) => {
|
|
|
473
473
|
issuer: string;
|
|
474
474
|
userId: string;
|
|
475
475
|
providerId: string;
|
|
476
|
-
organizationId?: string;
|
|
476
|
+
organizationId?: string | undefined;
|
|
477
477
|
}>;
|
|
478
478
|
signInSSO: better_call0.StrictEndpoint<"/sign-in/sso", {
|
|
479
479
|
method: "POST";
|
package/dist/index.d.cts
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-DJAIa5j3.cjs";
|
|
2
2
|
export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
|
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-CdeDxbNh.js";
|
|
2
2
|
export { OIDCConfig, OIDCMapping, SAMLConfig, SAMLMapping, SSOOptions, SSOProvider, sso };
|
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.15",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"homepage": "https://www.better-auth.com/docs/plugins/sso",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/body-parser": "^1.19.6",
|
|
65
|
-
"@types/express": "^5.0.
|
|
65
|
+
"@types/express": "^5.0.5",
|
|
66
66
|
"better-call": "1.0.24",
|
|
67
67
|
"body-parser": "^2.2.0",
|
|
68
68
|
"express": "^5.1.0",
|
|
69
|
-
"tsdown": "^0.15.
|
|
70
|
-
"better-auth": "^1.4.0-beta.
|
|
69
|
+
"tsdown": "^0.15.11",
|
|
70
|
+
"better-auth": "^1.4.0-beta.15"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"better-auth": "1.4.0-beta.
|
|
73
|
+
"better-auth": "1.4.0-beta.15"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"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,17 @@ 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.
|
|
251
263
|
* @default false
|
|
252
264
|
*/
|
|
253
|
-
trustEmailVerified?: boolean;
|
|
265
|
+
trustEmailVerified?: boolean | undefined;
|
|
254
266
|
}
|
|
255
267
|
|
|
256
|
-
export const sso = (options?: SSOOptions) => {
|
|
268
|
+
export const sso = (options?: SSOOptions | undefined) => {
|
|
257
269
|
return {
|
|
258
270
|
id: "sso",
|
|
259
271
|
endpoints: {
|