@better-auth/sso 1.5.0-beta.1 → 1.5.0-beta.10
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 +13 -9
- package/LICENSE.md +15 -12
- package/dist/client.d.mts +7 -2
- package/dist/client.mjs +7 -2
- package/dist/client.mjs.map +1 -0
- package/dist/{index-CvpS40sl.d.mts → index-CBBJTszO.d.mts} +429 -19
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1107 -489
- package/dist/index.mjs.map +1 -0
- package/package.json +17 -14
- package/src/client.ts +5 -1
- package/src/constants.ts +16 -0
- package/src/index.ts +55 -6
- package/src/linking/org-assignment.test.ts +1 -1
- package/src/linking/org-assignment.ts +20 -13
- package/src/oidc.test.ts +113 -1
- package/src/providers.test.ts +1326 -0
- package/src/routes/providers.ts +565 -0
- package/src/routes/schemas.ts +96 -0
- package/src/routes/sso.ts +285 -65
- package/src/saml/algorithms.ts +1 -31
- package/src/saml/assertions.test.ts +239 -0
- package/src/saml/assertions.ts +62 -0
- package/src/saml/index.ts +2 -0
- package/src/saml/parser.ts +56 -0
- package/src/saml-state.ts +78 -0
- package/src/saml.test.ts +2133 -422
- package/src/types.ts +20 -0
- package/src/utils.test.ts +103 -0
- package/src/utils.ts +45 -5
- package/tsconfig.json +3 -0
- package/tsdown.config.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/sso@1.5.0-beta.
|
|
2
|
+
> @better-auth/sso@1.5.0-beta.10 build /home/runner/work/better-auth/better-auth/packages/sso
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.20.1[22m powered by rolldown [2mv1.0.0-rc.1[22m
|
|
6
6
|
[34mℹ[39m config file: [4m/home/runner/work/better-auth/better-auth/packages/sso/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts, src/client.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m
|
|
12
|
-
[34mℹ[39m [2mdist/[
|
|
13
|
-
[34mℹ[39m [2mdist/[
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[
|
|
15
|
-
[34mℹ[39m
|
|
16
|
-
[
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m120.85 kB[22m [2m│ gzip: 24.06 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m 0.28 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22mindex.mjs.map [2m244.11 kB[22m [2m│ gzip: 46.78 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22mclient.mjs.map [2m 0.94 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 1.67 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.mts[22m[39m [2m 0.62 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[32mindex-CBBJTszO.d.mts[39m [2m 56.16 kB[22m [2m│ gzip: 9.96 kB[22m
|
|
17
|
+
[34mℹ[39m 7 files, total: 424.63 kB
|
|
18
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
19
|
+
|
|
20
|
+
[32m✔[39m Build complete in [32m26757ms[39m
|
package/LICENSE.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
Copyright (c) 2024 - present, Bereket Engida
|
|
3
3
|
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
-
and associated documentation files (the
|
|
6
|
-
including without limitation the rights to
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
6
|
+
the Software without restriction, including without limitation the rights to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
9
10
|
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
substantial portions of the Software.
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
12
13
|
|
|
13
|
-
THE SOFTWARE IS PROVIDED
|
|
14
|
-
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
DEALINGS IN THE SOFTWARE.
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SSOPlugin } from "./index-
|
|
1
|
+
import { t as SSOPlugin } from "./index-CBBJTszO.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/client.d.ts
|
|
4
4
|
interface SSOClientOptions {
|
|
@@ -15,6 +15,11 @@ declare const ssoClient: <CO extends SSOClientOptions>(options?: CO | undefined)
|
|
|
15
15
|
} ? true : false;
|
|
16
16
|
};
|
|
17
17
|
}>;
|
|
18
|
+
pathMethods: {
|
|
19
|
+
"/sso/providers": "GET";
|
|
20
|
+
"/sso/providers/:providerId": "GET";
|
|
21
|
+
};
|
|
18
22
|
};
|
|
19
23
|
//#endregion
|
|
20
|
-
export { ssoClient };
|
|
24
|
+
export { ssoClient };
|
|
25
|
+
//# sourceMappingURL=client.d.mts.map
|
package/dist/client.mjs
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
const ssoClient = (options) => {
|
|
3
3
|
return {
|
|
4
4
|
id: "sso-client",
|
|
5
|
-
$InferServerPlugin: {}
|
|
5
|
+
$InferServerPlugin: {},
|
|
6
|
+
pathMethods: {
|
|
7
|
+
"/sso/providers": "GET",
|
|
8
|
+
"/sso/providers/:providerId": "GET"
|
|
9
|
+
}
|
|
6
10
|
};
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
//#endregion
|
|
10
|
-
export { ssoClient };
|
|
14
|
+
export { ssoClient };
|
|
15
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport type { SSOPlugin } from \"./index\";\n\ninterface SSOClientOptions {\n\tdomainVerification?:\n\t\t| {\n\t\t\t\tenabled: boolean;\n\t\t }\n\t\t| undefined;\n}\n\nexport const ssoClient = <CO extends SSOClientOptions>(\n\toptions?: CO | undefined,\n) => {\n\treturn {\n\t\tid: \"sso-client\",\n\t\t$InferServerPlugin: {} as SSOPlugin<{\n\t\t\tdomainVerification: {\n\t\t\t\tenabled: CO[\"domainVerification\"] extends { enabled: true }\n\t\t\t\t\t? true\n\t\t\t\t\t: false;\n\t\t\t};\n\t\t}>,\n\t\tpathMethods: {\n\t\t\t\"/sso/providers\": \"GET\",\n\t\t\t\"/sso/providers/:providerId\": \"GET\",\n\t\t},\n\t} satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";AAWA,MAAa,aACZ,YACI;AACJ,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EAOtB,aAAa;GACZ,kBAAkB;GAClB,8BAA8B;GAC9B;EACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from "better-auth/api";
|
|
2
2
|
import * as z$1 from "zod/v4";
|
|
3
3
|
import z from "zod/v4";
|
|
4
|
-
import { Awaitable, OAuth2Tokens, User } from "better-auth";
|
|
4
|
+
import { Awaitable, BetterAuthPlugin, OAuth2Tokens, User } from "better-auth";
|
|
5
5
|
import * as better_call0 from "better-call";
|
|
6
6
|
|
|
7
7
|
//#region src/saml/algorithms.d.ts
|
|
@@ -109,6 +109,7 @@ interface SAMLConfig {
|
|
|
109
109
|
encPrivateKeyPass?: string | undefined;
|
|
110
110
|
};
|
|
111
111
|
wantAssertionsSigned?: boolean | undefined;
|
|
112
|
+
authnRequestsSigned?: boolean | undefined;
|
|
112
113
|
signatureAlgorithm?: string | undefined;
|
|
113
114
|
digestAlgorithm?: string | undefined;
|
|
114
115
|
identifierFormat?: string | undefined;
|
|
@@ -367,6 +368,18 @@ interface SSOOptions {
|
|
|
367
368
|
* ```
|
|
368
369
|
*/
|
|
369
370
|
algorithms?: AlgorithmValidationOptions;
|
|
371
|
+
/**
|
|
372
|
+
* Maximum allowed size for SAML responses in bytes.
|
|
373
|
+
*
|
|
374
|
+
* @default 262144 (256KB)
|
|
375
|
+
*/
|
|
376
|
+
maxResponseSize?: number;
|
|
377
|
+
/**
|
|
378
|
+
* Maximum allowed size for IdP metadata XML in bytes.
|
|
379
|
+
*
|
|
380
|
+
* @default 102400 (100KB)
|
|
381
|
+
*/
|
|
382
|
+
maxMetadataSize?: number;
|
|
370
383
|
};
|
|
371
384
|
}
|
|
372
385
|
//#endregion
|
|
@@ -469,6 +482,377 @@ declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint
|
|
|
469
482
|
}>)[];
|
|
470
483
|
}, void>;
|
|
471
484
|
//#endregion
|
|
485
|
+
//#region src/routes/providers.d.ts
|
|
486
|
+
declare const listSSOProviders: () => better_call0.StrictEndpoint<"/sso/providers", {
|
|
487
|
+
method: "GET";
|
|
488
|
+
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
489
|
+
session: {
|
|
490
|
+
session: Record<string, any> & {
|
|
491
|
+
id: string;
|
|
492
|
+
createdAt: Date;
|
|
493
|
+
updatedAt: Date;
|
|
494
|
+
userId: string;
|
|
495
|
+
expiresAt: Date;
|
|
496
|
+
token: string;
|
|
497
|
+
ipAddress?: string | null | undefined;
|
|
498
|
+
userAgent?: string | null | undefined;
|
|
499
|
+
};
|
|
500
|
+
user: Record<string, any> & {
|
|
501
|
+
id: string;
|
|
502
|
+
createdAt: Date;
|
|
503
|
+
updatedAt: Date;
|
|
504
|
+
email: string;
|
|
505
|
+
emailVerified: boolean;
|
|
506
|
+
name: string;
|
|
507
|
+
image?: string | null | undefined;
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
}>)[];
|
|
511
|
+
metadata: {
|
|
512
|
+
openapi: {
|
|
513
|
+
operationId: string;
|
|
514
|
+
summary: string;
|
|
515
|
+
description: string;
|
|
516
|
+
responses: {
|
|
517
|
+
"200": {
|
|
518
|
+
description: string;
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
}, {
|
|
524
|
+
providers: {
|
|
525
|
+
providerId: string;
|
|
526
|
+
type: string;
|
|
527
|
+
issuer: string;
|
|
528
|
+
domain: string;
|
|
529
|
+
organizationId: string | null;
|
|
530
|
+
domainVerified: boolean;
|
|
531
|
+
oidcConfig: {
|
|
532
|
+
discoveryEndpoint: string;
|
|
533
|
+
clientIdLastFour: string;
|
|
534
|
+
pkce: boolean;
|
|
535
|
+
authorizationEndpoint: string | undefined;
|
|
536
|
+
tokenEndpoint: string | undefined;
|
|
537
|
+
userInfoEndpoint: string | undefined;
|
|
538
|
+
jwksEndpoint: string | undefined;
|
|
539
|
+
scopes: string[] | undefined;
|
|
540
|
+
tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | undefined;
|
|
541
|
+
} | undefined;
|
|
542
|
+
samlConfig: {
|
|
543
|
+
entryPoint: string;
|
|
544
|
+
callbackUrl: string;
|
|
545
|
+
audience: string | undefined;
|
|
546
|
+
wantAssertionsSigned: boolean | undefined;
|
|
547
|
+
authnRequestsSigned: boolean | undefined;
|
|
548
|
+
identifierFormat: string | undefined;
|
|
549
|
+
signatureAlgorithm: string | undefined;
|
|
550
|
+
digestAlgorithm: string | undefined;
|
|
551
|
+
certificate: {
|
|
552
|
+
fingerprintSha256: string;
|
|
553
|
+
notBefore: string;
|
|
554
|
+
notAfter: string;
|
|
555
|
+
publicKeyAlgorithm: string;
|
|
556
|
+
} | {
|
|
557
|
+
error: string;
|
|
558
|
+
};
|
|
559
|
+
} | undefined;
|
|
560
|
+
spMetadataUrl: string;
|
|
561
|
+
}[];
|
|
562
|
+
}>;
|
|
563
|
+
declare const getSSOProvider: () => better_call0.StrictEndpoint<"/sso/providers/:providerId", {
|
|
564
|
+
method: "GET";
|
|
565
|
+
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
566
|
+
session: {
|
|
567
|
+
session: Record<string, any> & {
|
|
568
|
+
id: string;
|
|
569
|
+
createdAt: Date;
|
|
570
|
+
updatedAt: Date;
|
|
571
|
+
userId: string;
|
|
572
|
+
expiresAt: Date;
|
|
573
|
+
token: string;
|
|
574
|
+
ipAddress?: string | null | undefined;
|
|
575
|
+
userAgent?: string | null | undefined;
|
|
576
|
+
};
|
|
577
|
+
user: Record<string, any> & {
|
|
578
|
+
id: string;
|
|
579
|
+
createdAt: Date;
|
|
580
|
+
updatedAt: Date;
|
|
581
|
+
email: string;
|
|
582
|
+
emailVerified: boolean;
|
|
583
|
+
name: string;
|
|
584
|
+
image?: string | null | undefined;
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
}>)[];
|
|
588
|
+
params: z.ZodObject<{
|
|
589
|
+
providerId: z.ZodString;
|
|
590
|
+
}, z.core.$strip>;
|
|
591
|
+
metadata: {
|
|
592
|
+
openapi: {
|
|
593
|
+
operationId: string;
|
|
594
|
+
summary: string;
|
|
595
|
+
description: string;
|
|
596
|
+
responses: {
|
|
597
|
+
"200": {
|
|
598
|
+
description: string;
|
|
599
|
+
};
|
|
600
|
+
"404": {
|
|
601
|
+
description: string;
|
|
602
|
+
};
|
|
603
|
+
"403": {
|
|
604
|
+
description: string;
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
}, {
|
|
610
|
+
providerId: string;
|
|
611
|
+
type: string;
|
|
612
|
+
issuer: string;
|
|
613
|
+
domain: string;
|
|
614
|
+
organizationId: string | null;
|
|
615
|
+
domainVerified: boolean;
|
|
616
|
+
oidcConfig: {
|
|
617
|
+
discoveryEndpoint: string;
|
|
618
|
+
clientIdLastFour: string;
|
|
619
|
+
pkce: boolean;
|
|
620
|
+
authorizationEndpoint: string | undefined;
|
|
621
|
+
tokenEndpoint: string | undefined;
|
|
622
|
+
userInfoEndpoint: string | undefined;
|
|
623
|
+
jwksEndpoint: string | undefined;
|
|
624
|
+
scopes: string[] | undefined;
|
|
625
|
+
tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | undefined;
|
|
626
|
+
} | undefined;
|
|
627
|
+
samlConfig: {
|
|
628
|
+
entryPoint: string;
|
|
629
|
+
callbackUrl: string;
|
|
630
|
+
audience: string | undefined;
|
|
631
|
+
wantAssertionsSigned: boolean | undefined;
|
|
632
|
+
authnRequestsSigned: boolean | undefined;
|
|
633
|
+
identifierFormat: string | undefined;
|
|
634
|
+
signatureAlgorithm: string | undefined;
|
|
635
|
+
digestAlgorithm: string | undefined;
|
|
636
|
+
certificate: {
|
|
637
|
+
fingerprintSha256: string;
|
|
638
|
+
notBefore: string;
|
|
639
|
+
notAfter: string;
|
|
640
|
+
publicKeyAlgorithm: string;
|
|
641
|
+
} | {
|
|
642
|
+
error: string;
|
|
643
|
+
};
|
|
644
|
+
} | undefined;
|
|
645
|
+
spMetadataUrl: string;
|
|
646
|
+
}>;
|
|
647
|
+
declare const updateSSOProvider: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/providers/:providerId", {
|
|
648
|
+
method: "PATCH";
|
|
649
|
+
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
650
|
+
session: {
|
|
651
|
+
session: Record<string, any> & {
|
|
652
|
+
id: string;
|
|
653
|
+
createdAt: Date;
|
|
654
|
+
updatedAt: Date;
|
|
655
|
+
userId: string;
|
|
656
|
+
expiresAt: Date;
|
|
657
|
+
token: string;
|
|
658
|
+
ipAddress?: string | null | undefined;
|
|
659
|
+
userAgent?: string | null | undefined;
|
|
660
|
+
};
|
|
661
|
+
user: Record<string, any> & {
|
|
662
|
+
id: string;
|
|
663
|
+
createdAt: Date;
|
|
664
|
+
updatedAt: Date;
|
|
665
|
+
email: string;
|
|
666
|
+
emailVerified: boolean;
|
|
667
|
+
name: string;
|
|
668
|
+
image?: string | null | undefined;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
}>)[];
|
|
672
|
+
params: z.ZodObject<{
|
|
673
|
+
providerId: z.ZodString;
|
|
674
|
+
}, z.core.$strip>;
|
|
675
|
+
body: z.ZodObject<{
|
|
676
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
677
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
678
|
+
oidcConfig: z.ZodOptional<z.ZodObject<{
|
|
679
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
680
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
681
|
+
authorizationEndpoint: z.ZodOptional<z.ZodString>;
|
|
682
|
+
tokenEndpoint: z.ZodOptional<z.ZodString>;
|
|
683
|
+
userInfoEndpoint: z.ZodOptional<z.ZodString>;
|
|
684
|
+
tokenEndpointAuthentication: z.ZodOptional<z.ZodEnum<{
|
|
685
|
+
client_secret_post: "client_secret_post";
|
|
686
|
+
client_secret_basic: "client_secret_basic";
|
|
687
|
+
}>>;
|
|
688
|
+
jwksEndpoint: z.ZodOptional<z.ZodString>;
|
|
689
|
+
discoveryEndpoint: z.ZodOptional<z.ZodString>;
|
|
690
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
691
|
+
pkce: z.ZodOptional<z.ZodBoolean>;
|
|
692
|
+
overrideUserInfo: z.ZodOptional<z.ZodBoolean>;
|
|
693
|
+
mapping: z.ZodOptional<z.ZodObject<{
|
|
694
|
+
id: z.ZodOptional<z.ZodString>;
|
|
695
|
+
email: z.ZodOptional<z.ZodString>;
|
|
696
|
+
emailVerified: z.ZodOptional<z.ZodString>;
|
|
697
|
+
name: z.ZodOptional<z.ZodString>;
|
|
698
|
+
image: z.ZodOptional<z.ZodString>;
|
|
699
|
+
extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
700
|
+
}, z.core.$strip>>;
|
|
701
|
+
}, z.core.$strip>>;
|
|
702
|
+
samlConfig: z.ZodOptional<z.ZodObject<{
|
|
703
|
+
entryPoint: z.ZodOptional<z.ZodString>;
|
|
704
|
+
cert: z.ZodOptional<z.ZodString>;
|
|
705
|
+
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
706
|
+
audience: z.ZodOptional<z.ZodString>;
|
|
707
|
+
idpMetadata: z.ZodOptional<z.ZodObject<{
|
|
708
|
+
metadata: z.ZodOptional<z.ZodString>;
|
|
709
|
+
entityID: z.ZodOptional<z.ZodString>;
|
|
710
|
+
cert: z.ZodOptional<z.ZodString>;
|
|
711
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
712
|
+
privateKeyPass: z.ZodOptional<z.ZodString>;
|
|
713
|
+
isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
|
|
714
|
+
encPrivateKey: z.ZodOptional<z.ZodString>;
|
|
715
|
+
encPrivateKeyPass: z.ZodOptional<z.ZodString>;
|
|
716
|
+
singleSignOnService: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
717
|
+
Binding: z.ZodString;
|
|
718
|
+
Location: z.ZodString;
|
|
719
|
+
}, z.core.$strip>>>;
|
|
720
|
+
}, z.core.$strip>>;
|
|
721
|
+
spMetadata: z.ZodOptional<z.ZodObject<{
|
|
722
|
+
metadata: z.ZodOptional<z.ZodString>;
|
|
723
|
+
entityID: z.ZodOptional<z.ZodString>;
|
|
724
|
+
binding: z.ZodOptional<z.ZodString>;
|
|
725
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
726
|
+
privateKeyPass: z.ZodOptional<z.ZodString>;
|
|
727
|
+
isAssertionEncrypted: z.ZodOptional<z.ZodBoolean>;
|
|
728
|
+
encPrivateKey: z.ZodOptional<z.ZodString>;
|
|
729
|
+
encPrivateKeyPass: z.ZodOptional<z.ZodString>;
|
|
730
|
+
}, z.core.$strip>>;
|
|
731
|
+
wantAssertionsSigned: z.ZodOptional<z.ZodBoolean>;
|
|
732
|
+
authnRequestsSigned: z.ZodOptional<z.ZodBoolean>;
|
|
733
|
+
signatureAlgorithm: z.ZodOptional<z.ZodString>;
|
|
734
|
+
digestAlgorithm: z.ZodOptional<z.ZodString>;
|
|
735
|
+
identifierFormat: z.ZodOptional<z.ZodString>;
|
|
736
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
737
|
+
decryptionPvk: z.ZodOptional<z.ZodString>;
|
|
738
|
+
additionalParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
739
|
+
mapping: z.ZodOptional<z.ZodObject<{
|
|
740
|
+
id: z.ZodOptional<z.ZodString>;
|
|
741
|
+
email: z.ZodOptional<z.ZodString>;
|
|
742
|
+
emailVerified: z.ZodOptional<z.ZodString>;
|
|
743
|
+
name: z.ZodOptional<z.ZodString>;
|
|
744
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
745
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
746
|
+
extraFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
747
|
+
}, z.core.$strip>>;
|
|
748
|
+
}, z.core.$strip>>;
|
|
749
|
+
}, z.core.$strip>;
|
|
750
|
+
metadata: {
|
|
751
|
+
openapi: {
|
|
752
|
+
operationId: string;
|
|
753
|
+
summary: string;
|
|
754
|
+
description: string;
|
|
755
|
+
responses: {
|
|
756
|
+
"200": {
|
|
757
|
+
description: string;
|
|
758
|
+
};
|
|
759
|
+
"404": {
|
|
760
|
+
description: string;
|
|
761
|
+
};
|
|
762
|
+
"403": {
|
|
763
|
+
description: string;
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
}, {
|
|
769
|
+
providerId: string;
|
|
770
|
+
type: string;
|
|
771
|
+
issuer: string;
|
|
772
|
+
domain: string;
|
|
773
|
+
organizationId: string | null;
|
|
774
|
+
domainVerified: boolean;
|
|
775
|
+
oidcConfig: {
|
|
776
|
+
discoveryEndpoint: string;
|
|
777
|
+
clientIdLastFour: string;
|
|
778
|
+
pkce: boolean;
|
|
779
|
+
authorizationEndpoint: string | undefined;
|
|
780
|
+
tokenEndpoint: string | undefined;
|
|
781
|
+
userInfoEndpoint: string | undefined;
|
|
782
|
+
jwksEndpoint: string | undefined;
|
|
783
|
+
scopes: string[] | undefined;
|
|
784
|
+
tokenEndpointAuthentication: "client_secret_post" | "client_secret_basic" | undefined;
|
|
785
|
+
} | undefined;
|
|
786
|
+
samlConfig: {
|
|
787
|
+
entryPoint: string;
|
|
788
|
+
callbackUrl: string;
|
|
789
|
+
audience: string | undefined;
|
|
790
|
+
wantAssertionsSigned: boolean | undefined;
|
|
791
|
+
authnRequestsSigned: boolean | undefined;
|
|
792
|
+
identifierFormat: string | undefined;
|
|
793
|
+
signatureAlgorithm: string | undefined;
|
|
794
|
+
digestAlgorithm: string | undefined;
|
|
795
|
+
certificate: {
|
|
796
|
+
fingerprintSha256: string;
|
|
797
|
+
notBefore: string;
|
|
798
|
+
notAfter: string;
|
|
799
|
+
publicKeyAlgorithm: string;
|
|
800
|
+
} | {
|
|
801
|
+
error: string;
|
|
802
|
+
};
|
|
803
|
+
} | undefined;
|
|
804
|
+
spMetadataUrl: string;
|
|
805
|
+
}>;
|
|
806
|
+
declare const deleteSSOProvider: () => better_call0.StrictEndpoint<"/sso/providers/:providerId", {
|
|
807
|
+
method: "DELETE";
|
|
808
|
+
use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
|
|
809
|
+
session: {
|
|
810
|
+
session: Record<string, any> & {
|
|
811
|
+
id: string;
|
|
812
|
+
createdAt: Date;
|
|
813
|
+
updatedAt: Date;
|
|
814
|
+
userId: string;
|
|
815
|
+
expiresAt: Date;
|
|
816
|
+
token: string;
|
|
817
|
+
ipAddress?: string | null | undefined;
|
|
818
|
+
userAgent?: string | null | undefined;
|
|
819
|
+
};
|
|
820
|
+
user: Record<string, any> & {
|
|
821
|
+
id: string;
|
|
822
|
+
createdAt: Date;
|
|
823
|
+
updatedAt: Date;
|
|
824
|
+
email: string;
|
|
825
|
+
emailVerified: boolean;
|
|
826
|
+
name: string;
|
|
827
|
+
image?: string | null | undefined;
|
|
828
|
+
};
|
|
829
|
+
};
|
|
830
|
+
}>)[];
|
|
831
|
+
params: z.ZodObject<{
|
|
832
|
+
providerId: z.ZodString;
|
|
833
|
+
}, z.core.$strip>;
|
|
834
|
+
metadata: {
|
|
835
|
+
openapi: {
|
|
836
|
+
operationId: string;
|
|
837
|
+
summary: string;
|
|
838
|
+
description: string;
|
|
839
|
+
responses: {
|
|
840
|
+
"200": {
|
|
841
|
+
description: string;
|
|
842
|
+
};
|
|
843
|
+
"404": {
|
|
844
|
+
description: string;
|
|
845
|
+
};
|
|
846
|
+
"403": {
|
|
847
|
+
description: string;
|
|
848
|
+
};
|
|
849
|
+
};
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
}, {
|
|
853
|
+
success: boolean;
|
|
854
|
+
}>;
|
|
855
|
+
//#endregion
|
|
472
856
|
//#region src/routes/sso.d.ts
|
|
473
857
|
interface TimestampValidationOptions {
|
|
474
858
|
clockSkew?: number;
|
|
@@ -570,6 +954,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => better_
|
|
|
570
954
|
encPrivateKeyPass: z.ZodOptional<z.ZodString>;
|
|
571
955
|
}, z.core.$strip>;
|
|
572
956
|
wantAssertionsSigned: z.ZodOptional<z.ZodBoolean>;
|
|
957
|
+
authnRequestsSigned: z.ZodOptional<z.ZodBoolean>;
|
|
573
958
|
signatureAlgorithm: z.ZodOptional<z.ZodString>;
|
|
574
959
|
digestAlgorithm: z.ZodOptional<z.ZodString>;
|
|
575
960
|
identifierFormat: z.ZodOptional<z.ZodString>;
|
|
@@ -905,11 +1290,14 @@ declare const callbackSSO: (options?: SSOOptions) => better_call0.StrictEndpoint
|
|
|
905
1290
|
};
|
|
906
1291
|
}, never>;
|
|
907
1292
|
declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/callback/:providerId", {
|
|
908
|
-
method: "POST";
|
|
909
|
-
body: z.ZodObject<{
|
|
1293
|
+
method: ("POST" | "GET")[];
|
|
1294
|
+
body: z.ZodOptional<z.ZodObject<{
|
|
910
1295
|
SAMLResponse: z.ZodString;
|
|
911
1296
|
RelayState: z.ZodOptional<z.ZodString>;
|
|
912
|
-
}, z.core.$strip
|
|
1297
|
+
}, z.core.$strip>>;
|
|
1298
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
1299
|
+
RelayState: z.ZodOptional<z.ZodString>;
|
|
1300
|
+
}, z.core.$strip>>;
|
|
913
1301
|
metadata: {
|
|
914
1302
|
allowedMediaTypes: string[];
|
|
915
1303
|
openapi: {
|
|
@@ -933,9 +1321,6 @@ declare const callbackSSOSAML: (options?: SSOOptions) => better_call0.StrictEndp
|
|
|
933
1321
|
}, never>;
|
|
934
1322
|
declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint<"/sso/saml2/sp/acs/:providerId", {
|
|
935
1323
|
method: "POST";
|
|
936
|
-
params: z.ZodObject<{
|
|
937
|
-
providerId: z.ZodOptional<z.ZodString>;
|
|
938
|
-
}, z.core.$strip>;
|
|
939
1324
|
body: z.ZodObject<{
|
|
940
1325
|
SAMLResponse: z.ZodString;
|
|
941
1326
|
RelayState: z.ZodOptional<z.ZodString>;
|
|
@@ -956,6 +1341,28 @@ declare const acsEndpoint: (options?: SSOOptions) => better_call0.StrictEndpoint
|
|
|
956
1341
|
};
|
|
957
1342
|
}, never>;
|
|
958
1343
|
//#endregion
|
|
1344
|
+
//#region src/constants.d.ts
|
|
1345
|
+
/**
|
|
1346
|
+
* Default clock skew tolerance (5 minutes).
|
|
1347
|
+
* Allows for minor time differences between IdP and SP servers.
|
|
1348
|
+
*
|
|
1349
|
+
* Accommodates:
|
|
1350
|
+
* - Network latency and processing time
|
|
1351
|
+
* - Clock synchronization differences (NTP drift)
|
|
1352
|
+
* - Distributed systems across timezones
|
|
1353
|
+
*/
|
|
1354
|
+
declare const DEFAULT_CLOCK_SKEW_MS: number;
|
|
1355
|
+
/**
|
|
1356
|
+
* Default maximum size for SAML responses (256 KB).
|
|
1357
|
+
* Protects against memory exhaustion from oversized SAML payloads.
|
|
1358
|
+
*/
|
|
1359
|
+
declare const DEFAULT_MAX_SAML_RESPONSE_SIZE: number;
|
|
1360
|
+
/**
|
|
1361
|
+
* Default maximum size for IdP metadata (100 KB).
|
|
1362
|
+
* Protects against oversized metadata documents.
|
|
1363
|
+
*/
|
|
1364
|
+
declare const DEFAULT_MAX_SAML_METADATA_SIZE: number;
|
|
1365
|
+
//#endregion
|
|
959
1366
|
//#region src/oidc/types.d.ts
|
|
960
1367
|
/**
|
|
961
1368
|
* OIDC Discovery Types
|
|
@@ -1031,16 +1438,7 @@ interface OIDCDiscoveryDocument {
|
|
|
1031
1438
|
/**
|
|
1032
1439
|
* Error codes for OIDC discovery operations.
|
|
1033
1440
|
*/
|
|
1034
|
-
type DiscoveryErrorCode = /** Request to discovery endpoint timed out */
|
|
1035
|
-
"discovery_timeout"
|
|
1036
|
-
/** Discovery endpoint returned 404 or similar */ | "discovery_not_found"
|
|
1037
|
-
/** Discovery endpoint returned invalid JSON */ | "discovery_invalid_json"
|
|
1038
|
-
/** Discovery URL is invalid or malformed */ | "discovery_invalid_url"
|
|
1039
|
-
/** Discovery URL is not trusted by the trusted origins configuration */ | "discovery_untrusted_origin"
|
|
1040
|
-
/** Discovery document issuer doesn't match configured issuer */ | "issuer_mismatch"
|
|
1041
|
-
/** Discovery document is missing required fields */ | "discovery_incomplete"
|
|
1042
|
-
/** IdP only advertises token auth methods that Better Auth doesn't currently support */ | "unsupported_token_auth_method"
|
|
1043
|
-
/** Catch-all for unexpected errors */ | "discovery_unexpected_error";
|
|
1441
|
+
type DiscoveryErrorCode = /** Request to discovery endpoint timed out */"discovery_timeout" /** Discovery endpoint returned 404 or similar */ | "discovery_not_found" /** Discovery endpoint returned invalid JSON */ | "discovery_invalid_json" /** Discovery URL is invalid or malformed */ | "discovery_invalid_url" /** Discovery URL is not trusted by the trusted origins configuration */ | "discovery_untrusted_origin" /** Discovery document issuer doesn't match configured issuer */ | "issuer_mismatch" /** Discovery document is missing required fields */ | "discovery_incomplete" /** IdP only advertises token auth methods that Better Auth doesn't currently support */ | "unsupported_token_auth_method" /** Catch-all for unexpected errors */ | "discovery_unexpected_error";
|
|
1044
1442
|
/**
|
|
1045
1443
|
* Custom error class for OIDC discovery failures.
|
|
1046
1444
|
* Can be caught and mapped to APIError at the edge.
|
|
@@ -1215,6 +1613,13 @@ declare function selectTokenEndpointAuthMethod(doc: OIDCDiscoveryDocument, exist
|
|
|
1215
1613
|
declare function needsRuntimeDiscovery(config: Partial<HydratedOIDCConfig> | undefined): boolean;
|
|
1216
1614
|
//#endregion
|
|
1217
1615
|
//#region src/index.d.ts
|
|
1616
|
+
declare module "@better-auth/core" {
|
|
1617
|
+
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
1618
|
+
sso: {
|
|
1619
|
+
creator: typeof sso;
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1218
1623
|
type DomainVerificationEndpoints = {
|
|
1219
1624
|
requestDomainVerification: ReturnType<typeof requestDomainVerification>;
|
|
1220
1625
|
verifyDomain: ReturnType<typeof verifyDomain>;
|
|
@@ -1226,6 +1631,10 @@ type SSOEndpoints<O extends SSOOptions> = {
|
|
|
1226
1631
|
callbackSSO: ReturnType<typeof callbackSSO>;
|
|
1227
1632
|
callbackSSOSAML: ReturnType<typeof callbackSSOSAML>;
|
|
1228
1633
|
acsEndpoint: ReturnType<typeof acsEndpoint>;
|
|
1634
|
+
listSSOProviders: ReturnType<typeof listSSOProviders>;
|
|
1635
|
+
getSSOProvider: ReturnType<typeof getSSOProvider>;
|
|
1636
|
+
updateSSOProvider: ReturnType<typeof updateSSOProvider>;
|
|
1637
|
+
deleteSSOProvider: ReturnType<typeof deleteSSOProvider>;
|
|
1229
1638
|
};
|
|
1230
1639
|
type SSOPlugin<O extends SSOOptions> = {
|
|
1231
1640
|
id: "sso";
|
|
@@ -1242,7 +1651,7 @@ declare function sso<O extends SSOOptions & {
|
|
|
1242
1651
|
}>(options?: O | undefined): {
|
|
1243
1652
|
id: "sso";
|
|
1244
1653
|
endpoints: SSOEndpoints<O> & DomainVerificationEndpoints;
|
|
1245
|
-
schema:
|
|
1654
|
+
schema: NonNullable<BetterAuthPlugin["schema"]>;
|
|
1246
1655
|
options: O;
|
|
1247
1656
|
};
|
|
1248
1657
|
declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
@@ -1250,4 +1659,5 @@ declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
|
1250
1659
|
endpoints: SSOEndpoints<O>;
|
|
1251
1660
|
};
|
|
1252
1661
|
//#endregion
|
|
1253
|
-
export {
|
|
1662
|
+
export { DataEncryptionAlgorithm as A, TimestampValidationOptions as C, SSOOptions as D, SAMLConfig as E, DigestAlgorithm as M, KeyEncryptionAlgorithm as N, SSOProvider as O, SignatureAlgorithm as P, SAMLConditions as S, OIDCConfig as T, REQUIRED_DISCOVERY_FIELDS as _, fetchDiscoveryDocument as a, DEFAULT_MAX_SAML_METADATA_SIZE as b, normalizeUrl as c, validateDiscoveryUrl as d, DiscoverOIDCConfigParams as f, OIDCDiscoveryDocument as g, HydratedOIDCConfig as h, discoverOIDCConfig as i, DeprecatedAlgorithmBehavior as j, AlgorithmValidationOptions 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, validateSAMLTimestamp as w, DEFAULT_MAX_SAML_RESPONSE_SIZE as x, DEFAULT_CLOCK_SKEW_MS as y };
|
|
1663
|
+
//# sourceMappingURL=index-CBBJTszO.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { AlgorithmValidationOptions, 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 DataEncryptionAlgorithm, C as TimestampValidationOptions, D as SSOOptions, E as SAMLConfig, M as DigestAlgorithm, N as KeyEncryptionAlgorithm, O as SSOProvider, P as SignatureAlgorithm, S as SAMLConditions, T as OIDCConfig, _ as REQUIRED_DISCOVERY_FIELDS, a as fetchDiscoveryDocument, b as DEFAULT_MAX_SAML_METADATA_SIZE, c as normalizeUrl, d as validateDiscoveryUrl, f as DiscoverOIDCConfigParams, g as OIDCDiscoveryDocument, h as HydratedOIDCConfig, i as discoverOIDCConfig, j as DeprecatedAlgorithmBehavior, k as AlgorithmValidationOptions, 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 validateSAMLTimestamp, x as DEFAULT_MAX_SAML_RESPONSE_SIZE, y as DEFAULT_CLOCK_SKEW_MS } from "./index-CBBJTszO.mjs";
|
|
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 };
|