@better-auth/expo 0.6.3-beta.4

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.
Files changed (45) hide show
  1. package/.turbo/turbo-build.log +25 -0
  2. package/dist/client.d.mts +136 -0
  3. package/dist/client.d.ts +136 -0
  4. package/dist/client.js +1 -0
  5. package/dist/client.mjs +1 -0
  6. package/dist/index.d.mts +22 -0
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.js +1 -0
  9. package/dist/index.mjs +1 -0
  10. package/examples/tanstack-example/node_modules/better-sqlite3/LICENSE +21 -0
  11. package/examples/tanstack-example/node_modules/better-sqlite3/README.md +92 -0
  12. package/examples/tanstack-example/node_modules/better-sqlite3/binding.gyp +38 -0
  13. package/examples/tanstack-example/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
  14. package/examples/tanstack-example/node_modules/better-sqlite3/deps/common.gypi +68 -0
  15. package/examples/tanstack-example/node_modules/better-sqlite3/deps/copy.js +31 -0
  16. package/examples/tanstack-example/node_modules/better-sqlite3/deps/defines.gypi +41 -0
  17. package/examples/tanstack-example/node_modules/better-sqlite3/deps/download.sh +122 -0
  18. package/examples/tanstack-example/node_modules/better-sqlite3/deps/patches/1208.patch +15 -0
  19. package/examples/tanstack-example/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c +260455 -0
  20. package/examples/tanstack-example/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h +13574 -0
  21. package/examples/tanstack-example/node_modules/better-sqlite3/deps/sqlite3/sqlite3ext.h +719 -0
  22. package/examples/tanstack-example/node_modules/better-sqlite3/deps/sqlite3.gyp +80 -0
  23. package/examples/tanstack-example/node_modules/better-sqlite3/deps/test_extension.c +21 -0
  24. package/examples/tanstack-example/node_modules/better-sqlite3/lib/database.js +90 -0
  25. package/examples/tanstack-example/node_modules/better-sqlite3/lib/index.js +3 -0
  26. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
  27. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
  28. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/function.js +31 -0
  29. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
  30. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
  31. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
  32. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/table.js +189 -0
  33. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/transaction.js +75 -0
  34. package/examples/tanstack-example/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
  35. package/examples/tanstack-example/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
  36. package/examples/tanstack-example/node_modules/better-sqlite3/lib/util.js +12 -0
  37. package/examples/tanstack-example/node_modules/better-sqlite3/package.json +54 -0
  38. package/examples/tanstack-example/node_modules/better-sqlite3/src/better_sqlite3.cpp +2165 -0
  39. package/examples/tanstack-example/node_modules/better-sqlite3/src/better_sqlite3.hpp +1036 -0
  40. package/package.json +42 -0
  41. package/src/client.ts +198 -0
  42. package/src/expo.test.ts +133 -0
  43. package/src/index.ts +55 -0
  44. package/tsconfig.json +20 -0
  45. package/tsup.config.ts +13 -0
@@ -0,0 +1,25 @@
1
+
2
+ 
3
+ > @better-auth/expo@0.6.3-beta.3 build /Users/beka/Desktop/Development/better-auth-1/packages/expo
4
+ > tsup --dts --minify --clean
5
+
6
+ CLI Building entry: {"index":"src/index.ts","client":"src/client.ts"}
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.3.0
9
+ CLI Using tsup config: /Users/beka/Desktop/Development/better-auth-1/packages/expo/tsup.config.ts
10
+ CLI Target: es2022
11
+ CLI Cleaning output folder
12
+ ESM Build start
13
+ CJS Build start
14
+ ESM dist/index.mjs 603.00 B
15
+ ESM dist/client.mjs 2.23 KB
16
+ ESM ⚡️ Build success in 56ms
17
+ CJS dist/client.js 2.86 KB
18
+ CJS dist/index.js 1.06 KB
19
+ CJS ⚡️ Build success in 56ms
20
+ DTS Build start
21
+ DTS ⚡️ Build success in 3788ms
22
+ DTS dist/index.d.mts 558.00 B
23
+ DTS dist/client.d.mts 7.18 KB
24
+ DTS dist/index.d.ts 558.00 B
25
+ DTS dist/client.d.ts 7.18 KB
@@ -0,0 +1,136 @@
1
+ import * as zod from 'zod';
2
+ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
+ import { Store } from 'better-auth';
4
+
5
+ interface ExpoClientOptions {
6
+ scheme?: string;
7
+ storage?: {
8
+ setItem: (key: string, value: string) => any;
9
+ getItem: (key: string) => string | null;
10
+ };
11
+ storagePrefix?: string;
12
+ disableCache?: boolean;
13
+ }
14
+ declare const expoClient: (opts: ExpoClientOptions) => {
15
+ id: "expo";
16
+ getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
17
+ fetchPlugins: {
18
+ id: string;
19
+ name: string;
20
+ hooks: {
21
+ onSuccess(context: _better_fetch_fetch.SuccessContext<any>): Promise<void>;
22
+ };
23
+ init(url: string, options: {
24
+ cache?: RequestCache | undefined;
25
+ credentials?: RequestCredentials | undefined;
26
+ headers?: (HeadersInit & (HeadersInit | {
27
+ accept: "application/json" | "text/plain" | "application/octet-stream";
28
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
29
+ authorization: "Bearer" | "Basic";
30
+ })) | undefined;
31
+ integrity?: string | undefined;
32
+ keepalive?: boolean | undefined;
33
+ method?: string | undefined;
34
+ mode?: RequestMode | undefined;
35
+ priority?: RequestPriority | undefined;
36
+ redirect?: RequestRedirect | undefined;
37
+ referrer?: string | undefined;
38
+ referrerPolicy?: ReferrerPolicy | undefined;
39
+ signal?: (AbortSignal | null) | undefined;
40
+ window?: null | undefined;
41
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
42
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
43
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
44
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
45
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
46
+ hookOptions?: {
47
+ cloneResponse?: boolean;
48
+ } | undefined;
49
+ timeout?: number | undefined;
50
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
51
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
52
+ baseURL?: string | undefined;
53
+ throw?: boolean | undefined;
54
+ auth?: ({
55
+ type: "Bearer";
56
+ token: string | (() => string | undefined) | undefined;
57
+ } | {
58
+ type: "Basic";
59
+ username: string | (() => string | undefined) | undefined;
60
+ password: string | (() => string | undefined) | undefined;
61
+ } | {
62
+ type: "Custom";
63
+ prefix: string | (() => string | undefined) | undefined;
64
+ value: string | (() => string | undefined) | undefined;
65
+ }) | undefined;
66
+ body?: any;
67
+ query?: any;
68
+ params?: any;
69
+ duplex?: ("full" | "half") | undefined;
70
+ jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
71
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
72
+ retryAttempt?: number | undefined;
73
+ output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
74
+ errorSchema?: zod.ZodType | undefined;
75
+ disableValidation?: boolean | undefined;
76
+ } | undefined): Promise<{
77
+ url: string;
78
+ options: {
79
+ cache?: RequestCache | undefined;
80
+ credentials?: RequestCredentials | undefined;
81
+ headers?: (HeadersInit & (HeadersInit | {
82
+ accept: "application/json" | "text/plain" | "application/octet-stream";
83
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
84
+ authorization: "Bearer" | "Basic";
85
+ })) | undefined;
86
+ integrity?: string | undefined;
87
+ keepalive?: boolean | undefined;
88
+ method?: string | undefined;
89
+ mode?: RequestMode | undefined;
90
+ priority?: RequestPriority | undefined;
91
+ redirect?: RequestRedirect | undefined;
92
+ referrer?: string | undefined;
93
+ referrerPolicy?: ReferrerPolicy | undefined;
94
+ signal?: (AbortSignal | null) | undefined;
95
+ window?: null | undefined;
96
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
97
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
98
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
99
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
100
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
101
+ hookOptions?: {
102
+ cloneResponse?: boolean;
103
+ } | undefined;
104
+ timeout?: number | undefined;
105
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
106
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
107
+ baseURL?: string | undefined;
108
+ throw?: boolean | undefined;
109
+ auth?: ({
110
+ type: "Bearer";
111
+ token: string | (() => string | undefined) | undefined;
112
+ } | {
113
+ type: "Basic";
114
+ username: string | (() => string | undefined) | undefined;
115
+ password: string | (() => string | undefined) | undefined;
116
+ } | {
117
+ type: "Custom";
118
+ prefix: string | (() => string | undefined) | undefined;
119
+ value: string | (() => string | undefined) | undefined;
120
+ }) | undefined;
121
+ body?: any;
122
+ query?: any;
123
+ params?: any;
124
+ duplex?: ("full" | "half") | undefined;
125
+ jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
126
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
127
+ retryAttempt?: number | undefined;
128
+ output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
129
+ errorSchema?: zod.ZodType | undefined;
130
+ disableValidation?: boolean | undefined;
131
+ } | undefined;
132
+ }>;
133
+ }[];
134
+ };
135
+
136
+ export { expoClient };
@@ -0,0 +1,136 @@
1
+ import * as zod from 'zod';
2
+ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
+ import { Store } from 'better-auth';
4
+
5
+ interface ExpoClientOptions {
6
+ scheme?: string;
7
+ storage?: {
8
+ setItem: (key: string, value: string) => any;
9
+ getItem: (key: string) => string | null;
10
+ };
11
+ storagePrefix?: string;
12
+ disableCache?: boolean;
13
+ }
14
+ declare const expoClient: (opts: ExpoClientOptions) => {
15
+ id: "expo";
16
+ getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {};
17
+ fetchPlugins: {
18
+ id: string;
19
+ name: string;
20
+ hooks: {
21
+ onSuccess(context: _better_fetch_fetch.SuccessContext<any>): Promise<void>;
22
+ };
23
+ init(url: string, options: {
24
+ cache?: RequestCache | undefined;
25
+ credentials?: RequestCredentials | undefined;
26
+ headers?: (HeadersInit & (HeadersInit | {
27
+ accept: "application/json" | "text/plain" | "application/octet-stream";
28
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
29
+ authorization: "Bearer" | "Basic";
30
+ })) | undefined;
31
+ integrity?: string | undefined;
32
+ keepalive?: boolean | undefined;
33
+ method?: string | undefined;
34
+ mode?: RequestMode | undefined;
35
+ priority?: RequestPriority | undefined;
36
+ redirect?: RequestRedirect | undefined;
37
+ referrer?: string | undefined;
38
+ referrerPolicy?: ReferrerPolicy | undefined;
39
+ signal?: (AbortSignal | null) | undefined;
40
+ window?: null | undefined;
41
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
42
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
43
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
44
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
45
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
46
+ hookOptions?: {
47
+ cloneResponse?: boolean;
48
+ } | undefined;
49
+ timeout?: number | undefined;
50
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
51
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
52
+ baseURL?: string | undefined;
53
+ throw?: boolean | undefined;
54
+ auth?: ({
55
+ type: "Bearer";
56
+ token: string | (() => string | undefined) | undefined;
57
+ } | {
58
+ type: "Basic";
59
+ username: string | (() => string | undefined) | undefined;
60
+ password: string | (() => string | undefined) | undefined;
61
+ } | {
62
+ type: "Custom";
63
+ prefix: string | (() => string | undefined) | undefined;
64
+ value: string | (() => string | undefined) | undefined;
65
+ }) | undefined;
66
+ body?: any;
67
+ query?: any;
68
+ params?: any;
69
+ duplex?: ("full" | "half") | undefined;
70
+ jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
71
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
72
+ retryAttempt?: number | undefined;
73
+ output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
74
+ errorSchema?: zod.ZodType | undefined;
75
+ disableValidation?: boolean | undefined;
76
+ } | undefined): Promise<{
77
+ url: string;
78
+ options: {
79
+ cache?: RequestCache | undefined;
80
+ credentials?: RequestCredentials | undefined;
81
+ headers?: (HeadersInit & (HeadersInit | {
82
+ accept: "application/json" | "text/plain" | "application/octet-stream";
83
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
84
+ authorization: "Bearer" | "Basic";
85
+ })) | undefined;
86
+ integrity?: string | undefined;
87
+ keepalive?: boolean | undefined;
88
+ method?: string | undefined;
89
+ mode?: RequestMode | undefined;
90
+ priority?: RequestPriority | undefined;
91
+ redirect?: RequestRedirect | undefined;
92
+ referrer?: string | undefined;
93
+ referrerPolicy?: ReferrerPolicy | undefined;
94
+ signal?: (AbortSignal | null) | undefined;
95
+ window?: null | undefined;
96
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
97
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
98
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
99
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
100
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
101
+ hookOptions?: {
102
+ cloneResponse?: boolean;
103
+ } | undefined;
104
+ timeout?: number | undefined;
105
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
106
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
107
+ baseURL?: string | undefined;
108
+ throw?: boolean | undefined;
109
+ auth?: ({
110
+ type: "Bearer";
111
+ token: string | (() => string | undefined) | undefined;
112
+ } | {
113
+ type: "Basic";
114
+ username: string | (() => string | undefined) | undefined;
115
+ password: string | (() => string | undefined) | undefined;
116
+ } | {
117
+ type: "Custom";
118
+ prefix: string | (() => string | undefined) | undefined;
119
+ value: string | (() => string | undefined) | undefined;
120
+ }) | undefined;
121
+ body?: any;
122
+ query?: any;
123
+ params?: any;
124
+ duplex?: ("full" | "half") | undefined;
125
+ jsonParser?: (<T>(text: string) => Promise<T | undefined>) | undefined;
126
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
127
+ retryAttempt?: number | undefined;
128
+ output?: (zod.ZodType | typeof Blob | typeof File) | undefined;
129
+ errorSchema?: zod.ZodType | undefined;
130
+ disableValidation?: boolean | undefined;
131
+ } | undefined;
132
+ }>;
133
+ }[];
134
+ };
135
+
136
+ export { expoClient };
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var L=Object.create;var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},h=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!U.call(e,n)&&n!==r&&m(e,n,{get:()=>t[n],enumerable:!(i=R(t,n))||i.enumerable});return e};var d=(e,t,r)=>(r=e!=null?L(O(e)):{},h(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>h(m({},"__esModule",{value:!0}),e);var $={};I($,{expoClient:()=>D});module.exports=A($);var C=d(require("expo-web-browser")),k=d(require("expo-linking")),f=require("react-native"),P=d(require("expo-secure-store")),y=d(require("expo-constants"));function N(e){let t=new Map;return e.split(", ").forEach(i=>{let[n,...a]=i.split("; "),[l,o]=n.split("="),s={value:o};a.forEach(c=>{let[u,g]=c.split("=");s[u.toLowerCase()]=g}),t.set(l,s)}),t}function p(e){let t=N(e),r={};return t.forEach((i,n)=>{let a=i.expires,l=i["max-age"],o=a?new Date(String(a)):l?new Date(Date.now()+Number(l)):null;r[n]={value:i.value,expires:o}}),JSON.stringify(r)}function v(e){let t={};try{t=JSON.parse(e)}catch{}return Object.entries(t).reduce((i,[n,a])=>a.expires&&a.expires<new Date?i:`${i}; ${n}=${a.value}`,"")}function E(e){return k.createURL("",{scheme:e})}var D=e=>{let t=null,r=`${e.storagePrefix||"better-auth"}_cookie`,i=`${e.storagePrefix||"better-auth"}_session_data`,n=e.storage||P,a=e.scheme||y.default.platform?.scheme,l=f.Platform.OS==="web";if(!a&&!l)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(o,s){if(f.Platform.OS==="web")return{};t=s;let c=n.getItem(r);return c&&s.atoms.session.set({data:JSON.parse(c),error:null,isPending:!1}),{}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(o){if(l)return;let s=o.response.headers.get("set-cookie");if(s){let c=p(s||"");await n.setItem(r,c),t?.notify("$sessionSignal")}if(o.request.url.toString().includes("/get-session")&&!e.disableCache){let c=o.data;n.setItem(i,JSON.stringify(c))}if(o.data.redirect&&o.request.url.toString().includes("/sign-in")){let u=JSON.parse(o.request.body)?.callbackURL,g=o.data?.url,S=await C.openAuthSessionAsync(g,u);if(S.type!=="success")return;let w=new URL(S.url),b=String(w.searchParams.get("cookie"));if(!b)return;n.setItem(r,p(b)),t?.notify("$sessionSignal")}}},async init(o,s){if(l)return{url:o,options:s};s=s||{};let c=n.getItem(r),u=v(c||"{}");if(s.credentials="omit",s.headers={...s.headers,cookie:u,origin:E(a)},s.body?.callbackURL&&s.body.callbackURL.startsWith("/")){let g=k.createURL(s.body.callbackURL,{scheme:a});s.body.callbackURL=g}return o.includes("/sign-out")&&(await n.setItem(r,"{}"),t?.atoms.session?.set({data:null,error:null,isPending:!1}),n.setItem(i,"{}")),{url:o,options:s}}}]}};0&&(module.exports={expoClient});
@@ -0,0 +1 @@
1
+ import*as b from"expo-web-browser";import*as m from"expo-linking";import{Platform as k}from"react-native";import*as p from"expo-secure-store";import C from"expo-constants";function y(s){let r=new Map;return s.split(", ").forEach(o=>{let[n,...i]=o.split("; "),[l,t]=n.split("="),e={value:t};i.forEach(a=>{let[u,g]=a.split("=");e[u.toLowerCase()]=g}),r.set(l,e)}),r}function S(s){let r=y(s),c={};return r.forEach((o,n)=>{let i=o.expires,l=o["max-age"],t=i?new Date(String(i)):l?new Date(Date.now()+Number(l)):null;c[n]={value:o.value,expires:t}}),JSON.stringify(c)}function w(s){let r={};try{r=JSON.parse(s)}catch{}return Object.entries(r).reduce((o,[n,i])=>i.expires&&i.expires<new Date?o:`${o}; ${n}=${i.value}`,"")}function L(s){return m.createURL("",{scheme:s})}var O=s=>{let r=null,c=`${s.storagePrefix||"better-auth"}_cookie`,o=`${s.storagePrefix||"better-auth"}_session_data`,n=s.storage||p,i=s.scheme||C.platform?.scheme,l=k.OS==="web";if(!i&&!l)throw new Error("Scheme not found in app.json. Please provide a scheme in the options.");return{id:"expo",getActions(t,e){if(k.OS==="web")return{};r=e;let a=n.getItem(c);return a&&e.atoms.session.set({data:JSON.parse(a),error:null,isPending:!1}),{}},fetchPlugins:[{id:"expo",name:"Expo",hooks:{async onSuccess(t){if(l)return;let e=t.response.headers.get("set-cookie");if(e){let a=S(e||"");await n.setItem(c,a),r?.notify("$sessionSignal")}if(t.request.url.toString().includes("/get-session")&&!s.disableCache){let a=t.data;n.setItem(o,JSON.stringify(a))}if(t.data.redirect&&t.request.url.toString().includes("/sign-in")){let u=JSON.parse(t.request.body)?.callbackURL,g=t.data?.url,d=await b.openAuthSessionAsync(g,u);if(d.type!=="success")return;let h=new URL(d.url),f=String(h.searchParams.get("cookie"));if(!f)return;n.setItem(c,S(f)),r?.notify("$sessionSignal")}}},async init(t,e){if(l)return{url:t,options:e};e=e||{};let a=n.getItem(c),u=w(a||"{}");if(e.credentials="omit",e.headers={...e.headers,cookie:u,origin:L(i)},e.body?.callbackURL&&e.body.callbackURL.startsWith("/")){let g=m.createURL(e.body.callbackURL,{scheme:i});e.body.callbackURL=g}return t.includes("/sign-out")&&(await n.setItem(c,"{}"),r?.atoms.session?.set({data:null,error:null,isPending:!1}),n.setItem(o,"{}")),{url:t,options:e}}}]}};export{O as expoClient};
@@ -0,0 +1,22 @@
1
+ import * as better_auth from 'better-auth';
2
+
3
+ declare const expo: () => {
4
+ id: "expo";
5
+ init: (ctx: better_auth.AuthContext) => {
6
+ options: {
7
+ trustedOrigins: string[] | undefined;
8
+ };
9
+ };
10
+ hooks: {
11
+ after: {
12
+ matcher(context: better_auth.HookEndpointContext<{}>): boolean;
13
+ handler: (ctx: better_auth.HookEndpointContext<{
14
+ returned: unknown;
15
+ }>) => Promise<{
16
+ response: Response;
17
+ } | undefined>;
18
+ }[];
19
+ };
20
+ };
21
+
22
+ export { expo };
@@ -0,0 +1,22 @@
1
+ import * as better_auth from 'better-auth';
2
+
3
+ declare const expo: () => {
4
+ id: "expo";
5
+ init: (ctx: better_auth.AuthContext) => {
6
+ options: {
7
+ trustedOrigins: string[] | undefined;
8
+ };
9
+ };
10
+ hooks: {
11
+ after: {
12
+ matcher(context: better_auth.HookEndpointContext<{}>): boolean;
13
+ handler: (ctx: better_auth.HookEndpointContext<{
14
+ returned: unknown;
15
+ }>) => Promise<{
16
+ response: Response;
17
+ } | undefined>;
18
+ }[];
19
+ };
20
+ };
21
+
22
+ export { expo };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var s in t)o(e,s,{get:t[s],enumerable:!0})},g=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!h.call(e,r)&&r!==s&&o(e,r,{get:()=>t[r],enumerable:!(i=c(t,r))||i.enumerable});return e};var l=e=>g(o({},"__esModule",{value:!0}),e);var f={};p(f,{expo:()=>O});module.exports=l(f);var O=()=>({id:"expo",init:e=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...e.options.trustedOrigins||[],"exp://"]:e.options.trustedOrigins}}),hooks:{after:[{matcher(e){return e.path?.startsWith("/callback")},handler:async e=>{let t=e.context.returned;if(t.status===302){let s=t.headers.get("location");if(!s||!e.context.trustedOrigins.filter(n=>!n.startsWith("http")).some(n=>s?.startsWith(n)))return;let u=t.headers.get("set-cookie");if(!u)return;let a=new URL(s);return a.searchParams.set("cookie",u),t.headers.set("location",a.toString()),{response:t}}}}]}});0&&(module.exports={expo});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var a=()=>({id:"expo",init:t=>({options:{trustedOrigins:process.env.NODE_ENV==="development"?[...t.options.trustedOrigins||[],"exp://"]:t.options.trustedOrigins}}),hooks:{after:[{matcher(t){return t.path?.startsWith("/callback")},handler:async t=>{let e=t.context.returned;if(e.status===302){let s=e.headers.get("location");if(!s||!t.context.trustedOrigins.filter(r=>!r.startsWith("http")).some(r=>s?.startsWith(r)))return;let i=e.headers.get("set-cookie");if(!i)return;let n=new URL(s);return n.searchParams.set("cookie",i),e.headers.set("location",n.toString()),{response:e}}}}]}});export{a as expo};
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Joshua Wise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,92 @@
1
+ # better-sqlite3 [![Build Status](https://github.com/JoshuaWise/better-sqlite3/actions/workflows/build.yml/badge.svg)](https://github.com/JoshuaWise/better-sqlite3/actions/workflows/build.yml?query=branch%3Amaster)
2
+
3
+ The fastest and simplest library for SQLite3 in Node.js.
4
+
5
+ - Full transaction support
6
+ - High performance, efficiency, and safety
7
+ - Easy-to-use synchronous API *(better concurrency than an asynchronous API... yes, you read that correctly)*
8
+ - Support for user-defined functions, aggregates, virtual tables, and extensions
9
+ - 64-bit integers *(invisible until you need them)*
10
+ - Worker thread support *(for large/slow queries)*
11
+
12
+ ## Help this project stay strong! &#128170;
13
+
14
+ `better-sqlite3` is used by thousands of developers and engineers on a daily basis. Long nights and weekends were spent keeping this project strong and dependable, with no ask for compensation or funding, until now. If your company uses `better-sqlite3`, ask your manager to consider supporting the project:
15
+
16
+ - [Become a GitHub sponsor](https://github.com/sponsors/JoshuaWise)
17
+ - [Become a backer on Patreon](https://www.patreon.com/joshuawise)
18
+ - [Make a one-time donation on PayPal](https://www.paypal.me/joshuathomaswise)
19
+
20
+ ## How other libraries compare
21
+
22
+ | |select 1 row &nbsp;`get()`&nbsp;|select 100 rows &nbsp;&nbsp;`all()`&nbsp;&nbsp;|select 100 rows `iterate()` 1-by-1|insert 1 row `run()`|insert 100 rows in a transaction|
23
+ |---|---|---|---|---|---|
24
+ |better-sqlite3|1x|1x|1x|1x|1x|
25
+ |[sqlite](https://www.npmjs.com/package/sqlite) and [sqlite3](https://www.npmjs.com/package/sqlite3)|11.7x slower|2.9x slower|24.4x slower|2.8x slower|15.6x slower|
26
+
27
+ > You can verify these results by [running the benchmark yourself](./docs/benchmark.md).
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install better-sqlite3
33
+ ```
34
+
35
+ > You must be using Node.js v14.21.1 or above. Prebuilt binaries are available for [LTS versions](https://nodejs.org/en/about/releases/). If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).
36
+
37
+ ## Usage
38
+
39
+ ```js
40
+ const db = require('better-sqlite3')('foobar.db', options);
41
+
42
+ const row = db.prepare('SELECT * FROM users WHERE id = ?').get(userId);
43
+ console.log(row.firstName, row.lastName, row.email);
44
+ ```
45
+
46
+ Though not required, [it is generally important to set the WAL pragma for performance reasons](https://github.com/WiseLibs/better-sqlite3/blob/master/docs/performance.md).
47
+
48
+ ```js
49
+ db.pragma('journal_mode = WAL');
50
+ ```
51
+
52
+ ##### In ES6 module notation:
53
+
54
+ ```js
55
+ import Database from 'better-sqlite3';
56
+ const db = new Database('foobar.db', options);
57
+ db.pragma('journal_mode = WAL');
58
+ ```
59
+
60
+ ## Why should I use this instead of [node-sqlite3](https://github.com/mapbox/node-sqlite3)?
61
+
62
+ - `node-sqlite3` uses asynchronous APIs for tasks that are either CPU-bound or serialized. That's not only bad design, but it wastes tons of resources. It also causes [mutex thrashing](https://en.wikipedia.org/wiki/Resource_contention) which has devastating effects on performance.
63
+ - `node-sqlite3` exposes low-level (C language) memory management functions. `better-sqlite3` does it the JavaScript way, allowing the garbage collector to worry about memory management.
64
+ - `better-sqlite3` is simpler to use, and it provides nice utilities for some operations that are very difficult or impossible in `node-sqlite3`.
65
+ - `better-sqlite3` is much faster than `node-sqlite3` in most cases, and just as fast in all other cases.
66
+
67
+ #### When is this library not appropriate?
68
+
69
+ In most cases, if you're attempting something that cannot be reasonably accomplished with `better-sqlite3`, it probably cannot be reasonably accomplished with SQLite3 in general. For example, if you're executing queries that take one second to complete, and you expect to have many concurrent users executing those queries, no amount of asynchronicity will save you from SQLite3's serialized nature. Fortunately, SQLite3 is very *very* fast. With proper indexing, we've been able to achieve upward of 2000 queries per second with 5-way-joins in a 60 GB database, where each query was handling 5–50 kilobytes of real data.
70
+
71
+ If you have a performance problem, the most likely causes are inefficient queries, improper indexing, or a lack of [WAL mode](./docs/performance.md)—not `better-sqlite3` itself. However, there are some cases where `better-sqlite3` could be inappropriate:
72
+
73
+ - If you expect a high volume of concurrent reads each returning many megabytes of data (i.e., videos)
74
+ - If you expect a high volume of concurrent writes (i.e., a social media site)
75
+ - If your database's size is near the terabyte range
76
+
77
+ For these situations, you should probably use a full-fledged RDBMS such as [PostgreSQL](https://www.postgresql.org/).
78
+
79
+ # Documentation
80
+
81
+ - [API documentation](./docs/api.md)
82
+ - [Performance](./docs/performance.md) (also see [benchmark results](./docs/benchmark.md))
83
+ - [64-bit integer support](./docs/integer.md)
84
+ - [Worker thread support](./docs/threads.md)
85
+ - [Unsafe mode (advanced)](./docs/unsafe.md)
86
+ - [SQLite3 compilation (advanced)](./docs/compilation.md)
87
+ - [Contribution rules](./docs/contribution.md)
88
+ - [Code of conduct](./docs/conduct.md)
89
+
90
+ # License
91
+
92
+ [MIT](./LICENSE)
@@ -0,0 +1,38 @@
1
+ # ===
2
+ # This is the main GYP file, which builds better-sqlite3 with SQLite3 itself.
3
+ # ===
4
+
5
+ {
6
+ 'includes': ['deps/common.gypi'],
7
+ 'targets': [
8
+ {
9
+ 'target_name': 'better_sqlite3',
10
+ 'dependencies': ['deps/sqlite3.gyp:sqlite3'],
11
+ 'sources': ['src/better_sqlite3.cpp'],
12
+ 'cflags_cc': ['-std=c++20'],
13
+ 'xcode_settings': {
14
+ 'OTHER_CPLUSPLUSFLAGS': ['-std=c++20', '-stdlib=libc++'],
15
+ },
16
+ 'msvs_settings': {
17
+ 'VCCLCompilerTool': {
18
+ 'AdditionalOptions': [
19
+ '/std:c++20',
20
+ ],
21
+ },
22
+ },
23
+ 'conditions': [
24
+ ['OS=="linux"', {
25
+ 'ldflags': [
26
+ '-Wl,-Bsymbolic',
27
+ '-Wl,--exclude-libs,ALL',
28
+ ],
29
+ }],
30
+ ],
31
+ },
32
+ {
33
+ 'target_name': 'test_extension',
34
+ 'dependencies': ['deps/sqlite3.gyp:sqlite3'],
35
+ 'conditions': [['sqlite3 == ""', { 'sources': ['deps/test_extension.c'] }]],
36
+ },
37
+ ],
38
+ }
@@ -0,0 +1,68 @@
1
+ # ===
2
+ # This configuration defines the differences between Release and Debug builds.
3
+ # Some miscellaneous Windows settings are also defined here.
4
+ # ===
5
+
6
+ {
7
+ 'variables': { 'sqlite3%': '' },
8
+ 'target_defaults': {
9
+ 'default_configuration': 'Release',
10
+ 'msvs_settings': {
11
+ 'VCCLCompilerTool': {
12
+ 'ExceptionHandling': 1,
13
+ },
14
+ },
15
+ 'conditions': [
16
+ ['OS == "win"', {
17
+ 'defines': ['WIN32'],
18
+ }],
19
+ ],
20
+ 'configurations': {
21
+ 'Debug': {
22
+ 'defines!': [
23
+ 'NDEBUG',
24
+ ],
25
+ 'defines': [
26
+ 'DEBUG',
27
+ '_DEBUG',
28
+ 'SQLITE_DEBUG',
29
+ 'SQLITE_MEMDEBUG',
30
+ 'SQLITE_ENABLE_API_ARMOR',
31
+ 'SQLITE_WIN32_MALLOC_VALIDATE',
32
+ ],
33
+ 'cflags': [
34
+ '-O0',
35
+ ],
36
+ 'xcode_settings': {
37
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
38
+ 'GCC_OPTIMIZATION_LEVEL': '0',
39
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
40
+ },
41
+ 'msvs_settings': {
42
+ 'VCLinkerTool': {
43
+ 'GenerateDebugInformation': 'true',
44
+ },
45
+ },
46
+ },
47
+ 'Release': {
48
+ 'defines!': [
49
+ 'DEBUG',
50
+ '_DEBUG',
51
+ ],
52
+ 'defines': [
53
+ 'NDEBUG',
54
+ ],
55
+ 'cflags': [
56
+ '-O3',
57
+ ],
58
+ 'xcode_settings': {
59
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
60
+ 'GCC_OPTIMIZATION_LEVEL': '3',
61
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
62
+ 'DEAD_CODE_STRIPPING': 'YES',
63
+ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
64
+ },
65
+ },
66
+ },
67
+ },
68
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const dest = process.argv[2];
6
+ const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
7
+ const files = [
8
+ { filename: 'sqlite3.c', optional: false },
9
+ { filename: 'sqlite3.h', optional: false },
10
+ ];
11
+
12
+ if (process.argv[3]) {
13
+ // Support "_HAVE_SQLITE_CONFIG_H" in custom builds.
14
+ files.push({ filename: 'config.h', optional: true });
15
+ } else {
16
+ // Required for some tests.
17
+ files.push({ filename: 'sqlite3ext.h', optional: false });
18
+ }
19
+
20
+ for (const { filename, optional } of files) {
21
+ const sourceFilepath = path.join(source, filename);
22
+ const destFilepath = path.join(dest, filename);
23
+
24
+ if (optional && !fs.existsSync(sourceFilepath)) {
25
+ continue;
26
+ }
27
+
28
+ fs.accessSync(sourceFilepath);
29
+ fs.mkdirSync(path.dirname(destFilepath), { recursive: true });
30
+ fs.copyFileSync(sourceFilepath, destFilepath);
31
+ }