better-auth 0.3.6 → 0.4.1
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/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +43 -54
- package/dist/client/plugins.d.ts +200 -8
- package/dist/client/plugins.js +9 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +0 -5
- package/dist/{index-Bh0h0nFa.d.ts → index-C6jmDLjB.d.ts} +25 -54
- package/dist/{index-DI8FMfhr.d.ts → index-DCBFTxDp.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +52 -66
- package/dist/next-js.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +43 -54
- package/dist/react.d.ts +1 -1
- package/dist/react.js +0 -5
- package/dist/social.js +6 -4
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/solid.js +0 -5
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +0 -5
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +0 -5
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -198,7 +198,7 @@ function generateCodeChallenge(codeVerifier) {
|
|
|
198
198
|
includePadding: false
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes) {
|
|
201
|
+
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes, disablePkce) {
|
|
202
202
|
const url = new URL(authorizationEndpoint);
|
|
203
203
|
url.searchParams.set("response_type", "code");
|
|
204
204
|
url.searchParams.set("client_id", options.clientId);
|
|
@@ -208,9 +208,11 @@ function createAuthorizationURL(id, options, authorizationEndpoint, state, codeV
|
|
|
208
208
|
"redirect_uri",
|
|
209
209
|
options.redirectURI || getRedirectURI(id)
|
|
210
210
|
);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
if (!disablePkce) {
|
|
212
|
+
const codeChallenge = generateCodeChallenge(codeVerifier);
|
|
213
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
214
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
215
|
+
}
|
|
214
216
|
return url;
|
|
215
217
|
}
|
|
216
218
|
|
|
@@ -778,14 +780,12 @@ var oAuthProviderList = Object.keys(oAuthProviders);
|
|
|
778
780
|
// src/utils/state.ts
|
|
779
781
|
import { generateState as generateStateOAuth } from "oslo/oauth2";
|
|
780
782
|
import { z as z2 } from "zod";
|
|
781
|
-
function generateState(callbackURL, currentURL
|
|
783
|
+
function generateState(callbackURL, currentURL) {
|
|
782
784
|
const code = generateStateOAuth();
|
|
783
785
|
const state = JSON.stringify({
|
|
784
786
|
code,
|
|
785
787
|
callbackURL,
|
|
786
|
-
currentURL
|
|
787
|
-
dontRememberMe,
|
|
788
|
-
additionalFields
|
|
788
|
+
currentURL
|
|
789
789
|
});
|
|
790
790
|
return { state, code };
|
|
791
791
|
}
|
|
@@ -793,9 +793,7 @@ function parseState(state) {
|
|
|
793
793
|
const data = z2.object({
|
|
794
794
|
code: z2.string(),
|
|
795
795
|
callbackURL: z2.string().optional(),
|
|
796
|
-
currentURL: z2.string().optional()
|
|
797
|
-
dontRememberMe: z2.boolean().optional(),
|
|
798
|
-
additionalFields: z2.record(z2.string()).optional()
|
|
796
|
+
currentURL: z2.string().optional()
|
|
799
797
|
}).safeParse(JSON.parse(state));
|
|
800
798
|
return data;
|
|
801
799
|
}
|
|
@@ -816,7 +814,7 @@ function getCookies(options) {
|
|
|
816
814
|
const secureCookiePrefix = secure ? "__Secure-" : "";
|
|
817
815
|
const cookiePrefix = "better-auth";
|
|
818
816
|
const sessionMaxAge = new TimeSpan(7, "d").seconds();
|
|
819
|
-
const crossSubdomainEnabled = options.advanced?.crossSubDomainCookies?.enabled;
|
|
817
|
+
const crossSubdomainEnabled = !!options.advanced?.crossSubDomainCookies?.enabled;
|
|
820
818
|
const domain = crossSubdomainEnabled ? options.advanced?.crossSubDomainCookies?.domain || (options.baseURL ? new URL(options.baseURL).hostname : void 0) : void 0;
|
|
821
819
|
if (crossSubdomainEnabled && !domain) {
|
|
822
820
|
throw new BetterAuthError(
|
|
@@ -833,7 +831,7 @@ function getCookies(options) {
|
|
|
833
831
|
path: "/",
|
|
834
832
|
secure: !!secureCookiePrefix,
|
|
835
833
|
maxAge: sessionMaxAge,
|
|
836
|
-
...crossSubdomainEnabled
|
|
834
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
837
835
|
}
|
|
838
836
|
},
|
|
839
837
|
csrfToken: {
|
|
@@ -844,7 +842,7 @@ function getCookies(options) {
|
|
|
844
842
|
path: "/",
|
|
845
843
|
secure: !!secureCookiePrefix,
|
|
846
844
|
maxAge: 60 * 60 * 24 * 7,
|
|
847
|
-
...crossSubdomainEnabled
|
|
845
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
848
846
|
}
|
|
849
847
|
},
|
|
850
848
|
state: {
|
|
@@ -855,8 +853,7 @@ function getCookies(options) {
|
|
|
855
853
|
path: "/",
|
|
856
854
|
secure: !!secureCookiePrefix,
|
|
857
855
|
maxAge: 60 * 15,
|
|
858
|
-
|
|
859
|
-
...crossSubdomainEnabled && { domain }
|
|
856
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
860
857
|
}
|
|
861
858
|
},
|
|
862
859
|
pkCodeVerifier: {
|
|
@@ -867,8 +864,7 @@ function getCookies(options) {
|
|
|
867
864
|
path: "/",
|
|
868
865
|
secure: !!secureCookiePrefix,
|
|
869
866
|
maxAge: 60 * 15,
|
|
870
|
-
|
|
871
|
-
...crossSubdomainEnabled && { domain }
|
|
867
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
872
868
|
}
|
|
873
869
|
},
|
|
874
870
|
dontRememberToken: {
|
|
@@ -879,7 +875,7 @@ function getCookies(options) {
|
|
|
879
875
|
path: "/",
|
|
880
876
|
secure: !!secureCookiePrefix,
|
|
881
877
|
//no max age so it expires when the browser closes
|
|
882
|
-
...crossSubdomainEnabled
|
|
878
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
883
879
|
}
|
|
884
880
|
},
|
|
885
881
|
nonce: {
|
|
@@ -890,14 +886,13 @@ function getCookies(options) {
|
|
|
890
886
|
path: "/",
|
|
891
887
|
secure: !!secureCookiePrefix,
|
|
892
888
|
maxAge: 60 * 15,
|
|
893
|
-
|
|
894
|
-
...crossSubdomainEnabled && { domain }
|
|
889
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
895
890
|
}
|
|
896
891
|
}
|
|
897
892
|
};
|
|
898
893
|
}
|
|
899
894
|
function createCookieGetter(options) {
|
|
900
|
-
const secure =
|
|
895
|
+
const secure = options.advanced?.useSecureCookies !== void 0 ? options.advanced?.useSecureCookies : options.baseURL?.startsWith("https://") || process.env.NODE_ENV === "production";
|
|
901
896
|
const secureCookiePrefix = secure ? "__Secure-" : "";
|
|
902
897
|
const cookiePrefix = "better-auth";
|
|
903
898
|
const domain = options.advanced?.crossSubDomainCookies?.domain || (options.baseURL ? new URL(options.baseURL).hostname : void 0);
|
|
@@ -914,7 +909,7 @@ function createCookieGetter(options) {
|
|
|
914
909
|
maxAge: 60 * 15,
|
|
915
910
|
// 15 minutes in seconds
|
|
916
911
|
...opts,
|
|
917
|
-
...crossSubdomainEnabled
|
|
912
|
+
...crossSubdomainEnabled ? { domain } : {}
|
|
918
913
|
}
|
|
919
914
|
};
|
|
920
915
|
}
|
|
@@ -1129,11 +1124,7 @@ var signInOAuth = createAuthEndpoint(
|
|
|
1129
1124
|
/**
|
|
1130
1125
|
* OAuth2 provider to use`
|
|
1131
1126
|
*/
|
|
1132
|
-
provider: z4.enum(oAuthProviderList)
|
|
1133
|
-
/**
|
|
1134
|
-
* If this is true the session will only be valid for the current browser session
|
|
1135
|
-
*/
|
|
1136
|
-
dontRememberMe: z4.boolean().default(false).optional()
|
|
1127
|
+
provider: z4.enum(oAuthProviderList)
|
|
1137
1128
|
})
|
|
1138
1129
|
},
|
|
1139
1130
|
async (c) => {
|
|
@@ -1158,37 +1149,33 @@ var signInOAuth = createAuthEndpoint(
|
|
|
1158
1149
|
callbackURL || currentURL?.origin || c.context.baseURL,
|
|
1159
1150
|
c.query?.currentURL
|
|
1160
1151
|
);
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
};
|
|
1189
|
-
} catch (e) {
|
|
1190
|
-
throw new APIError3("INTERNAL_SERVER_ERROR");
|
|
1191
|
-
}
|
|
1152
|
+
await c.setSignedCookie(
|
|
1153
|
+
cookie.state.name,
|
|
1154
|
+
state.code,
|
|
1155
|
+
c.context.secret,
|
|
1156
|
+
cookie.state.options
|
|
1157
|
+
);
|
|
1158
|
+
const codeVerifier = generateCodeVerifier();
|
|
1159
|
+
await c.setSignedCookie(
|
|
1160
|
+
cookie.pkCodeVerifier.name,
|
|
1161
|
+
codeVerifier,
|
|
1162
|
+
c.context.secret,
|
|
1163
|
+
cookie.pkCodeVerifier.options
|
|
1164
|
+
);
|
|
1165
|
+
const url = provider.createAuthorizationURL({
|
|
1166
|
+
state: state.state,
|
|
1167
|
+
codeVerifier
|
|
1168
|
+
});
|
|
1169
|
+
url.searchParams.set(
|
|
1170
|
+
"redirect_uri",
|
|
1171
|
+
`${c.context.baseURL}/callback/${c.body.provider}`
|
|
1172
|
+
);
|
|
1173
|
+
return c.json({
|
|
1174
|
+
url: url.toString(),
|
|
1175
|
+
state: state.state,
|
|
1176
|
+
codeVerifier,
|
|
1177
|
+
redirect: true
|
|
1178
|
+
});
|
|
1192
1179
|
}
|
|
1193
1180
|
);
|
|
1194
1181
|
var signInEmail = createAuthEndpoint(
|
|
@@ -1482,14 +1469,14 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1482
1469
|
);
|
|
1483
1470
|
}
|
|
1484
1471
|
const {
|
|
1485
|
-
data: { callbackURL, currentURL,
|
|
1472
|
+
data: { callbackURL, currentURL, code: stateCode }
|
|
1486
1473
|
} = parsedState;
|
|
1487
|
-
const
|
|
1474
|
+
const storedState = await c.getSignedCookie(
|
|
1488
1475
|
c.context.authCookies.state.name,
|
|
1489
1476
|
c.context.secret
|
|
1490
1477
|
);
|
|
1491
|
-
if (
|
|
1492
|
-
logger.error("
|
|
1478
|
+
if (storedState !== stateCode) {
|
|
1479
|
+
logger.error("OAuth state mismatch", storedState, stateCode);
|
|
1493
1480
|
throw c.redirect(
|
|
1494
1481
|
`${c.context.baseURL}/error?error=please_restart_the_process`
|
|
1495
1482
|
);
|
|
@@ -1595,8 +1582,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1595
1582
|
try {
|
|
1596
1583
|
const session = await c.context.internalAdapter.createSession(
|
|
1597
1584
|
userId || id,
|
|
1598
|
-
c.request
|
|
1599
|
-
dontRememberMe
|
|
1585
|
+
c.request
|
|
1600
1586
|
);
|
|
1601
1587
|
if (!session) {
|
|
1602
1588
|
const url = new URL(currentURL || callbackURL);
|
|
@@ -1604,7 +1590,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1604
1590
|
throw c.redirect(url.toString());
|
|
1605
1591
|
}
|
|
1606
1592
|
try {
|
|
1607
|
-
await setSessionCookie(c, session.id
|
|
1593
|
+
await setSessionCookie(c, session.id);
|
|
1608
1594
|
} catch (e) {
|
|
1609
1595
|
c.context.logger.error("Unable to set session cookie", e);
|
|
1610
1596
|
const url = new URL(currentURL || callbackURL);
|
package/dist/next-js.d.ts
CHANGED
package/dist/node.d.ts
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-
|
|
1
|
+
export { A as AnonymousOptions, O as OrganizationOptions, b as Passkey, P as PasskeyOptions, U as UserWithPhoneNumber, f as UserWithRole, i as admin, h as adminMiddleware, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-DCBFTxDp.js';
|
|
2
2
|
export { i as ac } from './index-DfAHOgpj.js';
|
|
3
|
-
import { H as HookEndpointContext } from './index-
|
|
4
|
-
export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-
|
|
3
|
+
import { H as HookEndpointContext } from './index-C6jmDLjB.js';
|
|
4
|
+
export { e as AuthEndpoint, f as AuthMiddleware, b as BetterAuthPlugin, P as PluginSchema, d as createAuthEndpoint, c as createAuthMiddleware, o as optionsMiddleware } from './index-C6jmDLjB.js';
|
|
5
5
|
import './types-Bs23H3QM.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'arctic';
|
package/dist/plugins.js
CHANGED
|
@@ -138,7 +138,7 @@ function generateCodeChallenge(codeVerifier) {
|
|
|
138
138
|
includePadding: false
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes) {
|
|
141
|
+
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes, disablePkce) {
|
|
142
142
|
const url = new URL(authorizationEndpoint);
|
|
143
143
|
url.searchParams.set("response_type", "code");
|
|
144
144
|
url.searchParams.set("client_id", options.clientId);
|
|
@@ -148,9 +148,11 @@ function createAuthorizationURL(id, options, authorizationEndpoint, state, codeV
|
|
|
148
148
|
"redirect_uri",
|
|
149
149
|
options.redirectURI || getRedirectURI(id)
|
|
150
150
|
);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
if (!disablePkce) {
|
|
152
|
+
const codeChallenge = generateCodeChallenge(codeVerifier);
|
|
153
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
154
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
155
|
+
}
|
|
154
156
|
return url;
|
|
155
157
|
}
|
|
156
158
|
|
|
@@ -718,14 +720,12 @@ var oAuthProviderList = Object.keys(oAuthProviders);
|
|
|
718
720
|
// src/utils/state.ts
|
|
719
721
|
import { generateState as generateStateOAuth } from "oslo/oauth2";
|
|
720
722
|
import { z } from "zod";
|
|
721
|
-
function generateState(callbackURL, currentURL
|
|
723
|
+
function generateState(callbackURL, currentURL) {
|
|
722
724
|
const code = generateStateOAuth();
|
|
723
725
|
const state = JSON.stringify({
|
|
724
726
|
code,
|
|
725
727
|
callbackURL,
|
|
726
|
-
currentURL
|
|
727
|
-
dontRememberMe,
|
|
728
|
-
additionalFields
|
|
728
|
+
currentURL
|
|
729
729
|
});
|
|
730
730
|
return { state, code };
|
|
731
731
|
}
|
|
@@ -733,9 +733,7 @@ function parseState(state) {
|
|
|
733
733
|
const data = z.object({
|
|
734
734
|
code: z.string(),
|
|
735
735
|
callbackURL: z.string().optional(),
|
|
736
|
-
currentURL: z.string().optional()
|
|
737
|
-
dontRememberMe: z.boolean().optional(),
|
|
738
|
-
additionalFields: z.record(z.string()).optional()
|
|
736
|
+
currentURL: z.string().optional()
|
|
739
737
|
}).safeParse(JSON.parse(state));
|
|
740
738
|
return data;
|
|
741
739
|
}
|
|
@@ -941,11 +939,7 @@ var signInOAuth = createAuthEndpoint(
|
|
|
941
939
|
/**
|
|
942
940
|
* OAuth2 provider to use`
|
|
943
941
|
*/
|
|
944
|
-
provider: z3.enum(oAuthProviderList)
|
|
945
|
-
/**
|
|
946
|
-
* If this is true the session will only be valid for the current browser session
|
|
947
|
-
*/
|
|
948
|
-
dontRememberMe: z3.boolean().default(false).optional()
|
|
942
|
+
provider: z3.enum(oAuthProviderList)
|
|
949
943
|
})
|
|
950
944
|
},
|
|
951
945
|
async (c) => {
|
|
@@ -970,37 +964,33 @@ var signInOAuth = createAuthEndpoint(
|
|
|
970
964
|
callbackURL || currentURL?.origin || c.context.baseURL,
|
|
971
965
|
c.query?.currentURL
|
|
972
966
|
);
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
};
|
|
1001
|
-
} catch (e) {
|
|
1002
|
-
throw new APIError2("INTERNAL_SERVER_ERROR");
|
|
1003
|
-
}
|
|
967
|
+
await c.setSignedCookie(
|
|
968
|
+
cookie.state.name,
|
|
969
|
+
state.code,
|
|
970
|
+
c.context.secret,
|
|
971
|
+
cookie.state.options
|
|
972
|
+
);
|
|
973
|
+
const codeVerifier = generateCodeVerifier();
|
|
974
|
+
await c.setSignedCookie(
|
|
975
|
+
cookie.pkCodeVerifier.name,
|
|
976
|
+
codeVerifier,
|
|
977
|
+
c.context.secret,
|
|
978
|
+
cookie.pkCodeVerifier.options
|
|
979
|
+
);
|
|
980
|
+
const url = provider.createAuthorizationURL({
|
|
981
|
+
state: state.state,
|
|
982
|
+
codeVerifier
|
|
983
|
+
});
|
|
984
|
+
url.searchParams.set(
|
|
985
|
+
"redirect_uri",
|
|
986
|
+
`${c.context.baseURL}/callback/${c.body.provider}`
|
|
987
|
+
);
|
|
988
|
+
return c.json({
|
|
989
|
+
url: url.toString(),
|
|
990
|
+
state: state.state,
|
|
991
|
+
codeVerifier,
|
|
992
|
+
redirect: true
|
|
993
|
+
});
|
|
1004
994
|
}
|
|
1005
995
|
);
|
|
1006
996
|
var signInEmail = createAuthEndpoint(
|
|
@@ -1294,14 +1284,14 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1294
1284
|
);
|
|
1295
1285
|
}
|
|
1296
1286
|
const {
|
|
1297
|
-
data: { callbackURL, currentURL,
|
|
1287
|
+
data: { callbackURL, currentURL, code: stateCode }
|
|
1298
1288
|
} = parsedState;
|
|
1299
|
-
const
|
|
1289
|
+
const storedState = await c.getSignedCookie(
|
|
1300
1290
|
c.context.authCookies.state.name,
|
|
1301
1291
|
c.context.secret
|
|
1302
1292
|
);
|
|
1303
|
-
if (
|
|
1304
|
-
logger.error("
|
|
1293
|
+
if (storedState !== stateCode) {
|
|
1294
|
+
logger.error("OAuth state mismatch", storedState, stateCode);
|
|
1305
1295
|
throw c.redirect(
|
|
1306
1296
|
`${c.context.baseURL}/error?error=please_restart_the_process`
|
|
1307
1297
|
);
|
|
@@ -1407,8 +1397,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1407
1397
|
try {
|
|
1408
1398
|
const session = await c.context.internalAdapter.createSession(
|
|
1409
1399
|
userId || id,
|
|
1410
|
-
c.request
|
|
1411
|
-
dontRememberMe
|
|
1400
|
+
c.request
|
|
1412
1401
|
);
|
|
1413
1402
|
if (!session) {
|
|
1414
1403
|
const url = new URL(currentURL || callbackURL);
|
|
@@ -1416,7 +1405,7 @@ var callbackOAuth = createAuthEndpoint(
|
|
|
1416
1405
|
throw c.redirect(url.toString());
|
|
1417
1406
|
}
|
|
1418
1407
|
try {
|
|
1419
|
-
await setSessionCookie(c, session.id
|
|
1408
|
+
await setSessionCookie(c, session.id);
|
|
1420
1409
|
} catch (e) {
|
|
1421
1410
|
c.context.logger.error("Unable to set session cookie", e);
|
|
1422
1411
|
const url = new URL(currentURL || callbackURL);
|
package/dist/react.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { useStore } from '@nanostores/react';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-C6jmDLjB.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-Bs23H3QM.js';
|
|
9
9
|
import 'arctic';
|
package/dist/react.js
CHANGED
|
@@ -85,11 +85,6 @@ var csrfPlugin = {
|
|
|
85
85
|
id: "csrf",
|
|
86
86
|
name: "CSRF Check",
|
|
87
87
|
async init(url, options) {
|
|
88
|
-
if (!options?.baseURL) {
|
|
89
|
-
throw new BetterAuthError(
|
|
90
|
-
"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`"
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
88
|
if (options?.method !== "GET") {
|
|
94
89
|
options = options || {};
|
|
95
90
|
const { data, error } = await betterFetch("/csrf", {
|
package/dist/social.js
CHANGED
|
@@ -93,7 +93,7 @@ function generateCodeChallenge(codeVerifier) {
|
|
|
93
93
|
includePadding: false
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes) {
|
|
96
|
+
function createAuthorizationURL(id, options, authorizationEndpoint, state, codeVerifier, scopes, disablePkce) {
|
|
97
97
|
const url = new URL(authorizationEndpoint);
|
|
98
98
|
url.searchParams.set("response_type", "code");
|
|
99
99
|
url.searchParams.set("client_id", options.clientId);
|
|
@@ -103,9 +103,11 @@ function createAuthorizationURL(id, options, authorizationEndpoint, state, codeV
|
|
|
103
103
|
"redirect_uri",
|
|
104
104
|
options.redirectURI || getRedirectURI(id)
|
|
105
105
|
);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
if (!disablePkce) {
|
|
107
|
+
const codeChallenge = generateCodeChallenge(codeVerifier);
|
|
108
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
109
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
110
|
+
}
|
|
109
111
|
return url;
|
|
110
112
|
}
|
|
111
113
|
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { Accessor } from 'solid-js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-C6jmDLjB.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-Bs23H3QM.js';
|
|
9
9
|
import 'arctic';
|
package/dist/solid.js
CHANGED
|
@@ -85,11 +85,6 @@ var csrfPlugin = {
|
|
|
85
85
|
id: "csrf",
|
|
86
86
|
name: "CSRF Check",
|
|
87
87
|
async init(url, options) {
|
|
88
|
-
if (!options?.baseURL) {
|
|
89
|
-
throw new BetterAuthError(
|
|
90
|
-
"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`"
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
88
|
if (options?.method !== "GET") {
|
|
94
89
|
options = options || {};
|
|
95
90
|
const { data, error } = await betterFetch("/csrf", {
|
package/dist/svelte-kit.d.ts
CHANGED
package/dist/svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as nanostores from 'nanostores';
|
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-C6jmDLjB.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-Bs23H3QM.js';
|
|
9
9
|
import 'arctic';
|
package/dist/svelte.js
CHANGED
|
@@ -82,11 +82,6 @@ var csrfPlugin = {
|
|
|
82
82
|
id: "csrf",
|
|
83
83
|
name: "CSRF Check",
|
|
84
84
|
async init(url, options) {
|
|
85
|
-
if (!options?.baseURL) {
|
|
86
|
-
throw new BetterAuthError(
|
|
87
|
-
"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`"
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
85
|
if (options?.method !== "GET") {
|
|
91
86
|
options = options || {};
|
|
92
87
|
const { data, error } = await betterFetch("/csrf", {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-
|
|
2
|
-
export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-
|
|
1
|
+
import { b as BetterAuthPlugin, a as Auth, I as InferFieldsInputClient, h as InferFieldsOutput } from './index-C6jmDLjB.js';
|
|
2
|
+
export { A as Adapter, k as AdditionalSessionFieldsInput, l as AdditionalSessionFieldsOutput, i as AdditionalUserFieldsInput, j as AdditionalUserFieldsOutput, g as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, p as InferPluginTypes, n as InferSession, m as InferUser, P as PluginSchema, R as RateLimit, S as SecondaryStorage, W as Where, q as init } from './index-C6jmDLjB.js';
|
|
3
3
|
import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
|
|
4
4
|
export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { S as Session, U as User } from './types-Bs23H3QM.js';
|
package/dist/vue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import { Ref, DeepReadonly } from 'vue';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-C6jmDLjB.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './types-Bs23H3QM.js';
|
|
9
9
|
import 'arctic';
|
package/dist/vue.js
CHANGED
|
@@ -85,11 +85,6 @@ var csrfPlugin = {
|
|
|
85
85
|
id: "csrf",
|
|
86
86
|
name: "CSRF Check",
|
|
87
87
|
async init(url, options) {
|
|
88
|
-
if (!options?.baseURL) {
|
|
89
|
-
throw new BetterAuthError(
|
|
90
|
-
"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`"
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
88
|
if (options?.method !== "GET") {
|
|
94
89
|
options = options || {};
|
|
95
90
|
const { data, error } = await betterFetch("/csrf", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "The most comprehensive authentication library for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"mongodb": "^6.9.0",
|
|
56
56
|
"mysql2": "^3.11.0",
|
|
57
57
|
"next": "^14.2.8",
|
|
58
|
+
"oauth2-mock-server": "^7.1.2",
|
|
58
59
|
"pg": "^8.12.0",
|
|
59
60
|
"prisma": "^5.19.1",
|
|
60
61
|
"react": "^18.3.1",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"@simplewebauthn/browser": "^10.0.0",
|
|
82
83
|
"@simplewebauthn/server": "^10.0.1",
|
|
83
84
|
"arctic": "2.0.0-next.9",
|
|
84
|
-
"better-call": "0.2.
|
|
85
|
+
"better-call": "0.2.6",
|
|
85
86
|
"c12": "^1.11.2",
|
|
86
87
|
"chalk": "^5.3.0",
|
|
87
88
|
"commander": "^12.1.0",
|