@better-auth/expo 1.2.0-beta.8 → 1.2.0

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.
@@ -1,43 +1,28 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
2
+
3
+ const Browser = require('expo-web-browser');
4
+ const Linking = require('expo-linking');
5
+ const reactNative = require('react-native');
6
+ const Constants = require('expo-constants');
7
+
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
+
10
+ function _interopNamespaceCompat(e) {
11
+ if (e && typeof e === 'object' && 'default' in e) return e;
12
+ const n = Object.create(null);
13
+ if (e) {
14
+ for (const k in e) {
15
+ n[k] = e[k];
16
+ }
17
+ }
18
+ n.default = e;
19
+ return n;
20
+ }
21
+
22
+ const Browser__namespace = /*#__PURE__*/_interopNamespaceCompat(Browser);
23
+ const Linking__namespace = /*#__PURE__*/_interopNamespaceCompat(Linking);
24
+ const Constants__default = /*#__PURE__*/_interopDefaultCompat(Constants);
29
25
 
30
- // src/client.ts
31
- var client_exports = {};
32
- __export(client_exports, {
33
- expoClient: () => expoClient,
34
- getCookie: () => getCookie
35
- });
36
- module.exports = __toCommonJS(client_exports);
37
- var Browser = __toESM(require("expo-web-browser"));
38
- var Linking = __toESM(require("expo-linking"));
39
- var import_react_native = require("react-native");
40
- var import_expo_constants = __toESM(require("expo-constants"));
41
26
  function parseSetCookieHeader(header) {
42
27
  const cookieMap = /* @__PURE__ */ new Map();
43
28
  const cookies = header.split(", ");
@@ -92,16 +77,16 @@ function getCookie(cookie) {
92
77
  return toSend;
93
78
  }
94
79
  function getOrigin(scheme) {
95
- const schemeURI = Linking.createURL("", { scheme });
80
+ const schemeURI = Linking__namespace.createURL("", { scheme });
96
81
  return schemeURI;
97
82
  }
98
- var expoClient = (opts) => {
83
+ const expoClient = (opts) => {
99
84
  let store = null;
100
85
  const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
101
86
  const localCacheName = `${opts?.storagePrefix || "better-auth"}_session_data`;
102
87
  const storage = opts?.storage;
103
- const isWeb = import_react_native.Platform.OS === "web";
104
- const rawScheme = opts?.scheme || import_expo_constants.default.expoConfig?.scheme || import_expo_constants.default.platform?.scheme;
88
+ const isWeb = reactNative.Platform.OS === "web";
89
+ const rawScheme = opts?.scheme || Constants__default.expoConfig?.scheme || Constants__default.platform?.scheme;
105
90
  const scheme = Array.isArray(rawScheme) ? rawScheme[0] : rawScheme;
106
91
  if (!scheme && !isWeb) {
107
92
  throw new Error(
@@ -159,7 +144,7 @@ var expoClient = (opts) => {
159
144
  const callbackURL = JSON.parse(context.request.body)?.callbackURL;
160
145
  const to = callbackURL;
161
146
  const signInURL = context.data?.url;
162
- const result = await Browser.openAuthSessionAsync(signInURL, to);
147
+ const result = await Browser__namespace.openAuthSessionAsync(signInURL, to);
163
148
  if (result.type !== "success") return;
164
149
  const url = new URL(result.url);
165
150
  const cookie = String(url.searchParams.get("cookie"));
@@ -173,9 +158,7 @@ var expoClient = (opts) => {
173
158
  if (isWeb) {
174
159
  return {
175
160
  url,
176
- options: {
177
- ...options
178
- }
161
+ options
179
162
  };
180
163
  }
181
164
  options = options || {};
@@ -189,7 +172,7 @@ var expoClient = (opts) => {
189
172
  };
190
173
  if (options.body?.callbackURL) {
191
174
  if (options.body.callbackURL.startsWith("/")) {
192
- const url2 = Linking.createURL(options.body.callbackURL, {
175
+ const url2 = Linking__namespace.createURL(options.body.callbackURL, {
193
176
  scheme
194
177
  });
195
178
  options.body.callbackURL = url2;
@@ -197,7 +180,7 @@ var expoClient = (opts) => {
197
180
  }
198
181
  if (options.body?.newUserCallbackURL) {
199
182
  if (options.body.newUserCallbackURL.startsWith("/")) {
200
- const url2 = Linking.createURL(options.body.newUserCallbackURL, {
183
+ const url2 = Linking__namespace.createURL(options.body.newUserCallbackURL, {
201
184
  scheme
202
185
  });
203
186
  options.body.newUserCallbackURL = url2;
@@ -205,7 +188,7 @@ var expoClient = (opts) => {
205
188
  }
206
189
  if (options.body?.errorCallbackURL) {
207
190
  if (options.body.errorCallbackURL.startsWith("/")) {
208
- const url2 = Linking.createURL(options.body.errorCallbackURL, {
191
+ const url2 = Linking__namespace.createURL(options.body.errorCallbackURL, {
209
192
  scheme
210
193
  });
211
194
  options.body.errorCallbackURL = url2;
@@ -232,8 +215,6 @@ var expoClient = (opts) => {
232
215
  ]
233
216
  };
234
217
  };
235
- // Annotate the CommonJS export names for ESM import in node:
236
- 0 && (module.exports = {
237
- expoClient,
238
- getCookie
239
- });
218
+
219
+ exports.expoClient = expoClient;
220
+ exports.getCookie = getCookie;
@@ -0,0 +1,153 @@
1
+ import * as _better_fetch_fetch from '@better-fetch/fetch';
2
+ import { Store } from 'better-auth';
3
+
4
+ interface ExpoClientOptions {
5
+ scheme?: string;
6
+ storage: {
7
+ setItem: (key: string, value: string) => any;
8
+ getItem: (key: string) => string | null;
9
+ };
10
+ storagePrefix?: string;
11
+ disableCache?: boolean;
12
+ }
13
+ declare function getCookie(cookie: string): string;
14
+ declare const expoClient: (opts: ExpoClientOptions) => {
15
+ id: "expo";
16
+ getActions(_: _better_fetch_fetch.BetterFetch, $store: Store): {
17
+ /**
18
+ * Get the stored cookie.
19
+ *
20
+ * You can use this to get the cookie stored in the device and use it in your fetch
21
+ * requests.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const cookie = client.getCookie();
26
+ * fetch("https://api.example.com", {
27
+ * headers: {
28
+ * cookie,
29
+ * },
30
+ * });
31
+ */
32
+ getCookie: () => string;
33
+ };
34
+ fetchPlugins: {
35
+ id: string;
36
+ name: string;
37
+ hooks: {
38
+ onSuccess(context: _better_fetch_fetch.SuccessContext<any>): Promise<void>;
39
+ };
40
+ init(url: string, options: {
41
+ cache?: RequestCache | undefined;
42
+ credentials?: RequestCredentials | undefined;
43
+ headers?: (HeadersInit & (HeadersInit | {
44
+ accept: "application/json" | "text/plain" | "application/octet-stream";
45
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
46
+ authorization: "Bearer" | "Basic";
47
+ })) | undefined;
48
+ integrity?: string | undefined;
49
+ keepalive?: boolean | undefined;
50
+ method?: string | undefined;
51
+ mode?: RequestMode | undefined;
52
+ priority?: RequestPriority | undefined;
53
+ redirect?: RequestRedirect | undefined;
54
+ referrer?: string | undefined;
55
+ referrerPolicy?: ReferrerPolicy | undefined;
56
+ signal?: (AbortSignal | null) | undefined;
57
+ window?: null | undefined;
58
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
59
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
60
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
61
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
62
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
63
+ hookOptions?: {
64
+ cloneResponse?: boolean;
65
+ } | undefined;
66
+ timeout?: number | undefined;
67
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
68
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
69
+ baseURL?: string | undefined;
70
+ throw?: boolean | undefined;
71
+ auth?: ({
72
+ type: "Bearer";
73
+ token: string | (() => string | undefined) | undefined;
74
+ } | {
75
+ type: "Basic";
76
+ username: string | (() => string | undefined) | undefined;
77
+ password: string | (() => string | undefined) | undefined;
78
+ } | {
79
+ type: "Custom";
80
+ prefix: string | (() => string | undefined) | undefined;
81
+ value: string | (() => string | undefined) | undefined;
82
+ }) | undefined;
83
+ body?: any;
84
+ query?: any;
85
+ params?: any;
86
+ duplex?: "full" | "half" | undefined;
87
+ jsonParser?: ((text: string) => Promise<any> | any) | undefined;
88
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
89
+ retryAttempt?: number | undefined;
90
+ output?: (_better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
91
+ errorSchema?: _better_fetch_fetch.StandardSchemaV1 | undefined;
92
+ disableValidation?: boolean | undefined;
93
+ } | undefined): Promise<{
94
+ url: string;
95
+ options: {
96
+ cache?: RequestCache | undefined;
97
+ credentials?: RequestCredentials | undefined;
98
+ headers?: (HeadersInit & (HeadersInit | {
99
+ accept: "application/json" | "text/plain" | "application/octet-stream";
100
+ "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
101
+ authorization: "Bearer" | "Basic";
102
+ })) | undefined;
103
+ integrity?: string | undefined;
104
+ keepalive?: boolean | undefined;
105
+ method?: string | undefined;
106
+ mode?: RequestMode | undefined;
107
+ priority?: RequestPriority | undefined;
108
+ redirect?: RequestRedirect | undefined;
109
+ referrer?: string | undefined;
110
+ referrerPolicy?: ReferrerPolicy | undefined;
111
+ signal?: (AbortSignal | null) | undefined;
112
+ window?: null | undefined;
113
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
114
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
115
+ onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
116
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
117
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
118
+ hookOptions?: {
119
+ cloneResponse?: boolean;
120
+ } | undefined;
121
+ timeout?: number | undefined;
122
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
123
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
124
+ baseURL?: string | undefined;
125
+ throw?: boolean | undefined;
126
+ auth?: ({
127
+ type: "Bearer";
128
+ token: string | (() => string | undefined) | undefined;
129
+ } | {
130
+ type: "Basic";
131
+ username: string | (() => string | undefined) | undefined;
132
+ password: string | (() => string | undefined) | undefined;
133
+ } | {
134
+ type: "Custom";
135
+ prefix: string | (() => string | undefined) | undefined;
136
+ value: string | (() => string | undefined) | undefined;
137
+ }) | undefined;
138
+ body?: any;
139
+ query?: any;
140
+ params?: any;
141
+ duplex?: "full" | "half" | undefined;
142
+ jsonParser?: ((text: string) => Promise<any> | any) | undefined;
143
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
144
+ retryAttempt?: number | undefined;
145
+ output?: (_better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
146
+ errorSchema?: _better_fetch_fetch.StandardSchemaV1 | undefined;
147
+ disableValidation?: boolean | undefined;
148
+ } | undefined;
149
+ }>;
150
+ }[];
151
+ };
152
+
153
+ export { expoClient, getCookie };
package/dist/client.d.mts CHANGED
@@ -83,7 +83,7 @@ declare const expoClient: (opts: ExpoClientOptions) => {
83
83
  body?: any;
84
84
  query?: any;
85
85
  params?: any;
86
- duplex?: ("full" | "half") | undefined;
86
+ duplex?: "full" | "half" | undefined;
87
87
  jsonParser?: ((text: string) => Promise<any> | any) | undefined;
88
88
  retry?: _better_fetch_fetch.RetryOptions | undefined;
89
89
  retryAttempt?: number | undefined;
@@ -93,37 +93,37 @@ declare const expoClient: (opts: ExpoClientOptions) => {
93
93
  } | undefined): Promise<{
94
94
  url: string;
95
95
  options: {
96
- cache?: RequestCache;
97
- credentials?: RequestCredentials;
96
+ cache?: RequestCache | undefined;
97
+ credentials?: RequestCredentials | undefined;
98
98
  headers?: (HeadersInit & (HeadersInit | {
99
99
  accept: "application/json" | "text/plain" | "application/octet-stream";
100
100
  "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
101
101
  authorization: "Bearer" | "Basic";
102
102
  })) | undefined;
103
- integrity?: string;
104
- keepalive?: boolean;
105
- method?: string;
106
- mode?: RequestMode;
107
- priority?: RequestPriority;
108
- redirect?: RequestRedirect;
109
- referrer?: string;
110
- referrerPolicy?: ReferrerPolicy;
111
- signal?: AbortSignal | null;
112
- window?: null;
113
- onRequest?: <T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void;
114
- onResponse?: (context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void;
103
+ integrity?: string | undefined;
104
+ keepalive?: boolean | undefined;
105
+ method?: string | undefined;
106
+ mode?: RequestMode | undefined;
107
+ priority?: RequestPriority | undefined;
108
+ redirect?: RequestRedirect | undefined;
109
+ referrer?: string | undefined;
110
+ referrerPolicy?: ReferrerPolicy | undefined;
111
+ signal?: (AbortSignal | null) | undefined;
112
+ window?: null | undefined;
113
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
114
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
115
115
  onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
116
- onError?: (context: _better_fetch_fetch.ErrorContext) => Promise<void> | void;
117
- onRetry?: (response: _better_fetch_fetch.ResponseContext) => Promise<void> | void;
116
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
117
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
118
118
  hookOptions?: {
119
119
  cloneResponse?: boolean;
120
- };
121
- timeout?: number;
122
- customFetchImpl?: _better_fetch_fetch.FetchEsque;
123
- plugins?: _better_fetch_fetch.BetterFetchPlugin[];
124
- baseURL?: string;
125
- throw?: boolean;
126
- auth?: {
120
+ } | undefined;
121
+ timeout?: number | undefined;
122
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
123
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
124
+ baseURL?: string | undefined;
125
+ throw?: boolean | undefined;
126
+ auth?: ({
127
127
  type: "Bearer";
128
128
  token: string | (() => string | undefined) | undefined;
129
129
  } | {
@@ -134,18 +134,18 @@ declare const expoClient: (opts: ExpoClientOptions) => {
134
134
  type: "Custom";
135
135
  prefix: string | (() => string | undefined) | undefined;
136
136
  value: string | (() => string | undefined) | undefined;
137
- };
137
+ }) | undefined;
138
138
  body?: any;
139
139
  query?: any;
140
140
  params?: any;
141
- duplex?: "full" | "half";
142
- jsonParser?: (text: string) => Promise<any> | any;
143
- retry?: _better_fetch_fetch.RetryOptions;
144
- retryAttempt?: number;
145
- output?: _better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File;
146
- errorSchema?: _better_fetch_fetch.StandardSchemaV1;
147
- disableValidation?: boolean;
148
- };
141
+ duplex?: "full" | "half" | undefined;
142
+ jsonParser?: ((text: string) => Promise<any> | any) | undefined;
143
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
144
+ retryAttempt?: number | undefined;
145
+ output?: (_better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
146
+ errorSchema?: _better_fetch_fetch.StandardSchemaV1 | undefined;
147
+ disableValidation?: boolean | undefined;
148
+ } | undefined;
149
149
  }>;
150
150
  }[];
151
151
  };
package/dist/client.d.ts CHANGED
@@ -83,7 +83,7 @@ declare const expoClient: (opts: ExpoClientOptions) => {
83
83
  body?: any;
84
84
  query?: any;
85
85
  params?: any;
86
- duplex?: ("full" | "half") | undefined;
86
+ duplex?: "full" | "half" | undefined;
87
87
  jsonParser?: ((text: string) => Promise<any> | any) | undefined;
88
88
  retry?: _better_fetch_fetch.RetryOptions | undefined;
89
89
  retryAttempt?: number | undefined;
@@ -93,37 +93,37 @@ declare const expoClient: (opts: ExpoClientOptions) => {
93
93
  } | undefined): Promise<{
94
94
  url: string;
95
95
  options: {
96
- cache?: RequestCache;
97
- credentials?: RequestCredentials;
96
+ cache?: RequestCache | undefined;
97
+ credentials?: RequestCredentials | undefined;
98
98
  headers?: (HeadersInit & (HeadersInit | {
99
99
  accept: "application/json" | "text/plain" | "application/octet-stream";
100
100
  "content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
101
101
  authorization: "Bearer" | "Basic";
102
102
  })) | undefined;
103
- integrity?: string;
104
- keepalive?: boolean;
105
- method?: string;
106
- mode?: RequestMode;
107
- priority?: RequestPriority;
108
- redirect?: RequestRedirect;
109
- referrer?: string;
110
- referrerPolicy?: ReferrerPolicy;
111
- signal?: AbortSignal | null;
112
- window?: null;
113
- onRequest?: <T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void;
114
- onResponse?: (context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void;
103
+ integrity?: string | undefined;
104
+ keepalive?: boolean | undefined;
105
+ method?: string | undefined;
106
+ mode?: RequestMode | undefined;
107
+ priority?: RequestPriority | undefined;
108
+ redirect?: RequestRedirect | undefined;
109
+ referrer?: string | undefined;
110
+ referrerPolicy?: ReferrerPolicy | undefined;
111
+ signal?: (AbortSignal | null) | undefined;
112
+ window?: null | undefined;
113
+ onRequest?: (<T extends Record<string, any>>(context: _better_fetch_fetch.RequestContext<T>) => Promise<_better_fetch_fetch.RequestContext | void> | _better_fetch_fetch.RequestContext | void) | undefined;
114
+ onResponse?: ((context: _better_fetch_fetch.ResponseContext) => Promise<Response | void | _better_fetch_fetch.ResponseContext> | Response | _better_fetch_fetch.ResponseContext | void) | undefined;
115
115
  onSuccess?: ((context: _better_fetch_fetch.SuccessContext<any>) => Promise<void> | void) | undefined;
116
- onError?: (context: _better_fetch_fetch.ErrorContext) => Promise<void> | void;
117
- onRetry?: (response: _better_fetch_fetch.ResponseContext) => Promise<void> | void;
116
+ onError?: ((context: _better_fetch_fetch.ErrorContext) => Promise<void> | void) | undefined;
117
+ onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
118
118
  hookOptions?: {
119
119
  cloneResponse?: boolean;
120
- };
121
- timeout?: number;
122
- customFetchImpl?: _better_fetch_fetch.FetchEsque;
123
- plugins?: _better_fetch_fetch.BetterFetchPlugin[];
124
- baseURL?: string;
125
- throw?: boolean;
126
- auth?: {
120
+ } | undefined;
121
+ timeout?: number | undefined;
122
+ customFetchImpl?: _better_fetch_fetch.FetchEsque | undefined;
123
+ plugins?: _better_fetch_fetch.BetterFetchPlugin[] | undefined;
124
+ baseURL?: string | undefined;
125
+ throw?: boolean | undefined;
126
+ auth?: ({
127
127
  type: "Bearer";
128
128
  token: string | (() => string | undefined) | undefined;
129
129
  } | {
@@ -134,18 +134,18 @@ declare const expoClient: (opts: ExpoClientOptions) => {
134
134
  type: "Custom";
135
135
  prefix: string | (() => string | undefined) | undefined;
136
136
  value: string | (() => string | undefined) | undefined;
137
- };
137
+ }) | undefined;
138
138
  body?: any;
139
139
  query?: any;
140
140
  params?: any;
141
- duplex?: "full" | "half";
142
- jsonParser?: (text: string) => Promise<any> | any;
143
- retry?: _better_fetch_fetch.RetryOptions;
144
- retryAttempt?: number;
145
- output?: _better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File;
146
- errorSchema?: _better_fetch_fetch.StandardSchemaV1;
147
- disableValidation?: boolean;
148
- };
141
+ duplex?: "full" | "half" | undefined;
142
+ jsonParser?: ((text: string) => Promise<any> | any) | undefined;
143
+ retry?: _better_fetch_fetch.RetryOptions | undefined;
144
+ retryAttempt?: number | undefined;
145
+ output?: (_better_fetch_fetch.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
146
+ errorSchema?: _better_fetch_fetch.StandardSchemaV1 | undefined;
147
+ disableValidation?: boolean | undefined;
148
+ } | undefined;
149
149
  }>;
150
150
  }[];
151
151
  };
package/dist/client.mjs CHANGED
@@ -1,8 +1,8 @@
1
- // src/client.ts
2
- import * as Browser from "expo-web-browser";
3
- import * as Linking from "expo-linking";
4
- import { Platform } from "react-native";
5
- import Constants from "expo-constants";
1
+ import * as Browser from 'expo-web-browser';
2
+ import * as Linking from 'expo-linking';
3
+ import { Platform } from 'react-native';
4
+ import Constants from 'expo-constants';
5
+
6
6
  function parseSetCookieHeader(header) {
7
7
  const cookieMap = /* @__PURE__ */ new Map();
8
8
  const cookies = header.split(", ");
@@ -60,7 +60,7 @@ function getOrigin(scheme) {
60
60
  const schemeURI = Linking.createURL("", { scheme });
61
61
  return schemeURI;
62
62
  }
63
- var expoClient = (opts) => {
63
+ const expoClient = (opts) => {
64
64
  let store = null;
65
65
  const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
66
66
  const localCacheName = `${opts?.storagePrefix || "better-auth"}_session_data`;
@@ -138,9 +138,7 @@ var expoClient = (opts) => {
138
138
  if (isWeb) {
139
139
  return {
140
140
  url,
141
- options: {
142
- ...options
143
- }
141
+ options
144
142
  };
145
143
  }
146
144
  options = options || {};
@@ -197,7 +195,5 @@ var expoClient = (opts) => {
197
195
  ]
198
196
  };
199
197
  };
200
- export {
201
- expoClient,
202
- getCookie
203
- };
198
+
199
+ export { expoClient, getCookie };
@@ -1,30 +1,8 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- expo: () => expo
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
- var import_api = require("better-auth/api");
27
- var expo = (options) => {
3
+ const api = require('better-auth/api');
4
+
5
+ const expo = (options) => {
28
6
  return {
29
7
  id: "expo",
30
8
  init: (ctx) => {
@@ -55,7 +33,7 @@ var expo = (options) => {
55
33
  matcher(context) {
56
34
  return context.path?.startsWith("/callback") || context.path?.startsWith("/oauth2/callback");
57
35
  },
58
- handler: (0, import_api.createAuthMiddleware)(async (ctx) => {
36
+ handler: api.createAuthMiddleware(async (ctx) => {
59
37
  const headers = ctx.context.responseHeader;
60
38
  const location = headers.get("location");
61
39
  if (!location) {
@@ -83,7 +61,5 @@ var expo = (options) => {
83
61
  }
84
62
  };
85
63
  };
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- expo
89
- });
64
+
65
+ exports.expo = expo;
@@ -0,0 +1,36 @@
1
+ import * as better_call from 'better-call';
2
+ import * as better_auth from 'better-auth';
3
+
4
+ interface ExpoOptions {
5
+ /**
6
+ * Override origin header for expo api routes
7
+ */
8
+ overrideOrigin?: boolean;
9
+ }
10
+ declare const expo: (options?: ExpoOptions) => {
11
+ id: "expo";
12
+ init: (ctx: better_auth.AuthContext) => {
13
+ options: {
14
+ trustedOrigins: string[];
15
+ };
16
+ };
17
+ onRequest(request: Request, ctx: better_auth.AuthContext): Promise<{
18
+ request: Request;
19
+ } | undefined>;
20
+ hooks: {
21
+ after: {
22
+ matcher(context: better_auth.HookEndpointContext): boolean;
23
+ handler: (inputContext: {
24
+ body?: any;
25
+ query?: Record<string, any> | undefined;
26
+ request?: Request | undefined;
27
+ headers?: Headers | undefined;
28
+ asResponse?: boolean | undefined;
29
+ returnHeaders?: boolean | undefined;
30
+ use?: better_call.Middleware[] | undefined;
31
+ }) => Promise<void>;
32
+ }[];
33
+ };
34
+ };
35
+
36
+ export { type ExpoOptions, expo };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as better_call from 'better-call';
1
2
  import * as better_auth from 'better-auth';
2
3
 
3
4
  interface ExpoOptions {
@@ -26,7 +27,7 @@ declare const expo: (options?: ExpoOptions) => {
26
27
  headers?: Headers | undefined;
27
28
  asResponse?: boolean | undefined;
28
29
  returnHeaders?: boolean | undefined;
29
- use?: better_auth.Middleware[] | undefined;
30
+ use?: better_call.Middleware[] | undefined;
30
31
  }) => Promise<void>;
31
32
  }[];
32
33
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as better_call from 'better-call';
1
2
  import * as better_auth from 'better-auth';
2
3
 
3
4
  interface ExpoOptions {
@@ -26,7 +27,7 @@ declare const expo: (options?: ExpoOptions) => {
26
27
  headers?: Headers | undefined;
27
28
  asResponse?: boolean | undefined;
28
29
  returnHeaders?: boolean | undefined;
29
- use?: better_auth.Middleware[] | undefined;
30
+ use?: better_call.Middleware[] | undefined;
30
31
  }) => Promise<void>;
31
32
  }[];
32
33
  };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- // src/index.ts
2
- import { createAuthMiddleware } from "better-auth/api";
3
- var expo = (options) => {
1
+ import { createAuthMiddleware } from 'better-auth/api';
2
+
3
+ const expo = (options) => {
4
4
  return {
5
5
  id: "expo",
6
6
  init: (ctx) => {
@@ -59,6 +59,5 @@ var expo = (options) => {
59
59
  }
60
60
  };
61
61
  };
62
- export {
63
- expo
64
- };
62
+
63
+ export { expo };
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@better-auth/expo",
3
- "version": "1.2.0-beta.8",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
- "main": "dist/index.js",
5
+ "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
10
10
  "import": "./dist/index.mjs",
11
- "require": "./dist/index.js"
11
+ "require": "./dist/index.cjs"
12
12
  },
13
13
  "./client": {
14
14
  "types": "./dist/client.d.ts",
15
15
  "import": "./dist/client.mjs",
16
- "require": "./dist/client.js"
16
+ "require": "./dist/client.cjs"
17
17
  }
18
18
  },
19
19
  "typesVersions": {
@@ -30,21 +30,22 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "devDependencies": {
33
- "@better-fetch/fetch": "1.1.14-beta.2",
33
+ "@better-fetch/fetch": "^1.1.15",
34
34
  "better-sqlite3": "^11.6.0",
35
35
  "expo-constants": "~16.0.2",
36
36
  "expo-crypto": "^13.0.2",
37
37
  "expo-linking": "~6.3.1",
38
38
  "expo-secure-store": "~13.0.2",
39
39
  "expo-web-browser": "~13.0.3",
40
+ "unbuild": "^3.5.0",
40
41
  "vitest": "^1.6.0",
41
- "better-auth": "1.2.0-beta.8"
42
+ "better-auth": "1.2.0"
42
43
  },
43
44
  "peerDependencies": {
44
- "better-auth": "1.2.0-beta.8"
45
+ "better-auth": "1.2.0"
45
46
  },
46
47
  "dependencies": {
47
- "better-call": "1.0.0-beta.4",
48
+ "better-call": "^1.0.3",
48
49
  "zod": "^3.23.8"
49
50
  },
50
51
  "files": [
@@ -52,7 +53,8 @@
52
53
  ],
53
54
  "scripts": {
54
55
  "test": "vitest",
55
- "build": "tsup --dts --clean",
56
- "dev": "tsup --watch --sourcemap --dts"
56
+ "build": "unbuild --clean",
57
+ "dev": "unbuild --watch",
58
+ "stub": "unbuild --stub"
57
59
  }
58
60
  }