better-auth 0.5.2-beta.11 → 0.5.2-beta.13
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/api.cjs +4 -4
- package/dist/api.js +3 -3
- package/dist/client/plugins.cjs +1 -1
- package/dist/client/plugins.js +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/cookies.cjs +1 -1
- package/dist/cookies.js +1 -1
- package/dist/db.cjs +3 -3
- package/dist/db.js +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/next-js.cjs +1 -1
- package/dist/next-js.js +1 -1
- package/dist/oauth2.cjs +1 -1
- package/dist/oauth2.js +1 -1
- package/dist/plugins.cjs +5 -5
- package/dist/plugins.js +5 -5
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/social.cjs +2 -2
- package/dist/social.js +2 -2
- package/dist/solid.cjs +1 -1
- package/dist/solid.d.cts +2 -2
- package/dist/solid.d.ts +2 -2
- package/dist/solid.js +1 -1
- package/dist/svelte.cjs +1 -1
- package/dist/svelte.d.cts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +1 -1
- package/dist/types.d.cts +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +1 -1
- package/package.json +3 -2
package/dist/vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useStore as
|
|
1
|
+
import{useStore as O}from"@nanostores/vue";import{createFetch as W}from"@better-fetch/fetch";import{env as g}from"std-env";var p=class extends Error{constructor(t,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=i,this.stack=""}};function $(e){try{return new URL(e).pathname!=="/"}catch{throw new p(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function U(e,t="/api/auth"){return $(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function F(e,t){if(e)return U(e,t);let i=g.BETTER_AUTH_URL||g.NEXT_PUBLIC_BETTER_AUTH_URL||g.PUBLIC_BETTER_AUTH_URL||g.NUXT_PUBLIC_BETTER_AUTH_URL||g.NUXT_PUBLIC_AUTH_URL||(g.BASE_URL!=="/"?g.BASE_URL:void 0);if(i)return U(i,t);if(typeof window<"u")return U(window.location.origin,t)}import"nanostores";import{betterFetch as v}from"@better-fetch/fetch";var S={id:"redirect",name:"Redirect",hooks:{onSuccess(e){e.data?.url&&e.data?.redirect&&typeof window<"u"&&(window.location.href=e.data.url)}}},L={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window<"u"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},B={id:"csrf",name:"CSRF Check",async init(e,t){if(t?.method!=="GET"){t=t||{};let{data:i,error:s}=await v("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(s){if(s.status===404)throw new p("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(s.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new p("Failed to fetch CSRF token: "+s.message)}let r=i?.csrfToken;t.body={...t?.body,csrfToken:r}}return t.credentials="include",{url:e,options:t}}};var C=e=>{let t=W({baseURL:F(e?.fetchOptions?.baseURL||e?.baseURL),credentials:"include",method:"GET",...e?.fetchOptions,plugins:[...e?.disableCSRFTokenCheck?[]:[B],S,L,...e?.fetchOptions?.plugins?.filter(n=>n!==void 0)||[],...e?.plugins?.flatMap(n=>n.fetchPlugins).filter(n=>n!==void 0)||[]]}),i=e?.plugins||[],s={},r={},u={"/sign-out":"POST","/user/revoke-sessions":"POST"},o=[{signal:"_sessionSignal",matcher(n){return n==="/sign-out"||n==="/user/update"||n.startsWith("/sign-in")||n.startsWith("/sign-up")}}];for(let n of i)n.getActions&&Object.assign(s,n.getActions?.(t)),n.getAtoms&&Object.assign(r,n.getAtoms?.(t)),n.pathMethods&&Object.assign(u,n.pathMethods),n.atomListeners&&o.push(...n.atomListeners);return{pluginsActions:s,pluginsAtoms:r,pluginPathMethods:u,atomListeners:o,$fetch:t}};function x(e){return e.charAt(0).toUpperCase()+e.slice(1)}function q(e,t,i){let s=t[e],{fetchOptions:r,query:u,...o}=i||{};return s||(r?.method?r.method:o&&Object.keys(o).length>0?"POST":"GET")}function w(e,t,i,s,r){function u(o=[]){return new Proxy(function(){},{get(n,c){let f=[...o,c],a=e;for(let l of f)if(a&&typeof a=="object"&&l in a)a=a[l];else{a=void 0;break}return typeof a=="function"?a:u(f)},apply:async(n,c,f)=>{let a="/"+o.map(m=>m.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),l=f[0]||{},A=f[1]||{},{query:b,fetchOptions:h,...y}=l,d={...A,...h},R=q(a,i,l);return await t(a,{...d,body:R==="GET"?void 0:{...y,...d?.body||{}},query:b||d?.query,method:R,async onSuccess(m){await d?.onSuccess?.(m);let P=r?.find(_=>_.matcher(a));if(!P)return;let T=s[P.signal];if(!T)return;let I=T.get();setTimeout(()=>{T.set(!I)},10)}})}})}return u()}import{atom as H}from"nanostores";import"@better-fetch/fetch";import{atom as M,onMount as G}from"nanostores";var E=(e,t,i,s)=>{let r=M({data:null,error:null,isPending:!1,isRefetching:!1}),u=()=>{let n=typeof s=="function"?s({data:r.get().data,error:r.get().error,isPending:r.get().isPending}):s;return i(t,{...n,onSuccess:async c=>{r.set({data:c.data,error:null,isPending:!1,isRefetching:!1}),await n?.onSuccess?.(c)},async onError(c){r.set({error:c.error,data:null,isPending:!1,isRefetching:!1}),await n?.onError?.(c)},async onRequest(c){let f=r.get();r.set({isPending:f.data===null,data:f.data,error:null,isRefetching:!0}),await n?.onRequest?.(c)}})};e=Array.isArray(e)?e:[e];let o=!1;for(let n of e)n.subscribe(()=>{o?u():G(r,()=>(u(),o=!0,()=>{r.off(),n.off()}))});return r};function k(e){let t=H(!1);return{$session:E(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function j(e){return`use${x(e)}`}function me(e){let{pluginPathMethods:t,pluginsActions:i,pluginsAtoms:s,$fetch:r,atomListeners:u}=C(e),o={};for(let[h,y]of Object.entries(s))o[j(h)]=()=>O(y);let{$session:n,_sessionSignal:c,$Infer:f}=k(r);function a(){return O(n)}function l(h){if(h){let y=O(c),d=e?.fetchOptions?.baseURL||e?.baseURL,R=d?new URL(d).pathname:"/api/auth";return h(`${R}/session`,{ref:y}).then(m=>({data:m.data,isPending:!1,error:m.error}))}return a()}let A={...i,...o,useSession:l};return w(A,r,t,{...s,_sessionSignal:c},u)}export{me as createAuthClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "0.5.2-beta.
|
|
3
|
+
"version": "0.5.2-beta.13",
|
|
4
4
|
"description": "The most comprehensive authentication library for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -239,11 +239,12 @@
|
|
|
239
239
|
"better-call": "0.2.7",
|
|
240
240
|
"consola": "^3.2.3",
|
|
241
241
|
"defu": "^6.1.4",
|
|
242
|
+
"jose": "^5.9.4",
|
|
242
243
|
"kysely": "^0.27.4",
|
|
243
244
|
"nanoid": "^5.0.7",
|
|
244
245
|
"nanostores": "^0.11.2",
|
|
245
246
|
"oslo": "^1.2.1",
|
|
246
|
-
"
|
|
247
|
+
"std-env": "^3.7.0",
|
|
247
248
|
"zod": "^3.22.5"
|
|
248
249
|
},
|
|
249
250
|
"files": [
|