@bigio/better-auth-electron 1.0.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.
@@ -0,0 +1,254 @@
1
+ import { Session, User } from 'better-auth';
2
+ import { BrowserWindow } from 'electron';
3
+
4
+ type ElectronServerPluginOptions = {
5
+ /**
6
+ * The custom protocol scheme used for deep linking authentication.
7
+ * @remarks
8
+ * This should match the protocol registered in your Electron Main Process.
9
+ * Do not include the `://` suffix.
10
+ * @example "bigio" to be like "bigio://better-auth-callback"
11
+ */
12
+ ELECTRON_SCHEME: string;
13
+ PROVIDERS: string[];
14
+ debugMode?: boolean;
15
+ WEB_ERROR_PAGE_URL?: string;
16
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME?: string;
17
+ ELECTRON_TO_BACKEND_HOST_PATH?: string;
18
+ ELECTRON_APP_HOST?: string;
19
+ /**
20
+ * The specific action path or host used to identify the auth callback.
21
+ * This will be combined with the scheme to form the full callback URL.
22
+ * Format: `${scheme}://${hostname}`
23
+ * @example "better-auth-callback"
24
+ * // Resulting URL: "bigio://better-auth-callback"
25
+ */
26
+ ELECTRON_CALLBACK_HOST_PATH?: string;
27
+ /**
28
+ * The IPC event name used to receive deep link URLs from the main process.
29
+ * @example "deep-link-received"
30
+ */
31
+ DEEPLINK_EVENT_NAME?: string;
32
+ /**
33
+ * The IPC event name used to notify the main process that the renderer app is mounted.
34
+ * @example "renderer-app-mounted"
35
+ */
36
+ APP_MOUNTED_EVENT_NAME?: string;
37
+ /**
38
+ * The URL path for the backend exchange endpoint to exchange the JWT ticket.
39
+ * @example "/electron/exchange"
40
+ */
41
+ BACKEND_EXCHANGE_URL?: string;
42
+ BACKEND_FAST_TICKET_URL?: string;
43
+ BACKEND_LOGIN_URL?: string;
44
+ PREACT_LOGIN_PAGE?: (baseURL?: string | undefined, scheme?: string | undefined, provider?: string | undefined) => string;
45
+ customPreactJS?: string;
46
+ TICKET_NAME_IN_URL?: string;
47
+ SCHEME_NAME_IN_URL?: string;
48
+ PROVIDER_NAME_IN_URL?: string;
49
+ CHALLENGE_NAME_IN_URL?: string;
50
+ TICKET_TTL_SEC?: number;
51
+ ELECTRON_SESSION_DURATION?: number;
52
+ };
53
+ type ElectronRendererPluginOptions = {
54
+ /**
55
+ * The custom protocol scheme used for deep linking authentication.
56
+ * @remarks
57
+ * This should match the protocol registered in your Electron Main Process.
58
+ * Do not include the `://` suffix.
59
+ * @example "bigio" to be like "bigio://better-auth-callback"
60
+ */
61
+ ELECTRON_SCHEME: string;
62
+ debug?: boolean;
63
+ refetchSessionOnFocus?: boolean;
64
+ CHALLENGE_NAME_IN_URL?: string;
65
+ ELECTRON_APP_HOST?: string;
66
+ TICKET_NAME_IN_URL?: string;
67
+ onDeepLinkFailedFn?: (error: unknown) => Promise<void>;
68
+ onDeepLinkSuccessFn?: (data: {
69
+ session: Pick<Session, 'createdAt' | 'updatedAt' | 'expiresAt'>;
70
+ user: User;
71
+ }) => Promise<void>;
72
+ lazySignalUIReadyForFn?: boolean;
73
+ /**
74
+ * The specific action path or host used to identify the auth callback.
75
+ * This will be combined with the scheme to form the full callback URL.
76
+ * Format: `${scheme}://${hostname}`
77
+ * @example "better-auth-callback"
78
+ * // Resulting URL: "bigio://better-auth-callback"
79
+ */
80
+ ELECTRON_CALLBACK_HOST_PATH?: string;
81
+ /**
82
+ * The IPC event name used to receive deep link URLs from the main process.
83
+ * @example "deep-link-received"
84
+ */
85
+ DEEPLINK_EVENT_NAME?: string;
86
+ /**
87
+ * The IPC event name used to notify the main process that the renderer app is mounted.
88
+ * @example "renderer-app-mounted"
89
+ */
90
+ APP_MOUNTED_EVENT_NAME?: string;
91
+ /**
92
+ * The URL path for the backend exchange endpoint to exchange the JWT ticket.
93
+ * @example "/electron/exchange"
94
+ */
95
+ BACKEND_EXCHANGE_URL?: string;
96
+ };
97
+ type ElectronMainPluginOptions = {
98
+ isOAuth: boolean;
99
+ /**
100
+ * The custom protocol scheme used for deep linking authentication.
101
+ * @remarks
102
+ * This should match the protocol registered in your Electron Main Process.
103
+ * Do not include the `://` suffix.
104
+ * @example "bigio" to be like "bigio://better-auth-callback"
105
+ */
106
+ ELECTRON_SCHEME: string;
107
+ BETTER_AUTH_BASEURL: string;
108
+ PROVIDERS: string[];
109
+ FRONTEND_URL: string;
110
+ ELECTRON_APP_NAME: string;
111
+ /**
112
+ * The specific action path or host used to identify the auth callback.
113
+ * This will be combined with the scheme to form the full callback URL.
114
+ * Format: `${scheme}://${hostname}`
115
+ * @example "better-auth-callback"
116
+ * // Resulting URL: "bigio://better-auth-callback"
117
+ */
118
+ debugMode?: boolean;
119
+ ELECTRON_VERIFIER_LENGTH?: number;
120
+ CHALLENGE_NAME_IN_URL?: string;
121
+ SCHEME_NAME_IN_URL?: string;
122
+ PROVIDER_NAME_IN_URL?: string;
123
+ CALLBACK_PATHNAME_IN_URL?: string;
124
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME?: string;
125
+ ELECTRON_APP_HOST?: string;
126
+ ELECTRON_RENDERER_PATH?: string;
127
+ OLD_SCHOOL_ONBEFORE_WAY?: boolean;
128
+ GET_COOKIES_EVENT_NAME?: string;
129
+ ELECTRON_VERIFIER_FILE_NAME?: string;
130
+ /**
131
+ * The specific action path or host used to identify the auth callback.
132
+ * This will be combined with the scheme to form the full callback URL.
133
+ * Format: `${scheme}://${hostname}`
134
+ * @example "better-auth-callback"
135
+ * // Resulting URL: "bigio://better-auth-callback"
136
+ */
137
+ ELECTRON_CALLBACK_HOST_PATH?: string;
138
+ /**
139
+ * The IPC event name used to receive deep link URLs from the main process.
140
+ * @example "deep-link-received"
141
+ */
142
+ DEEPLINK_EVENT_NAME?: string;
143
+ /**
144
+ * The IPC event name used to clear cookies from the main process.
145
+ * @example "clear-Cookies"
146
+ */
147
+ CLEAR_COOKIES_EVENT_NAME?: string;
148
+ /**
149
+ * The IPC event name used to notify the main process that the renderer app is mounted.
150
+ * @example "renderer-app-mounted"
151
+ */
152
+ APP_MOUNTED_EVENT_NAME?: string;
153
+ /**
154
+ * The URL path for the backend exchange endpoint to exchange the JWT ticket.
155
+ * @example "/electron/exchange"
156
+ */
157
+ BACKEND_EXCHANGE_URL?: string;
158
+ openHandlerHelper?: (details: Electron.HandlerDetails) => Electron.WindowOpenHandlerResponse;
159
+ beforeSendHelper?: (details: Electron.OnBeforeSendHeadersListenerDetails) => {
160
+ callback: {
161
+ requestHeaders: Record<string, string | string[]>;
162
+ cancel?: boolean;
163
+ };
164
+ };
165
+ customProtocolServingHelper?: {
166
+ scheme?: string;
167
+ privileges?: {
168
+ standard: boolean;
169
+ secure: boolean;
170
+ supportFetchAPI: boolean;
171
+ corsEnabled: boolean;
172
+ bypassCSP: boolean;
173
+ allowServiceWorkers?: boolean;
174
+ codeCache?: boolean;
175
+ stream?: boolean;
176
+ };
177
+ protocolHandleOnCreateWindow?: (mainWindow: BrowserWindow) => Promise<void>;
178
+ protocolHandleOnAppReady?: (request: Request) => Response | Promise<Response>;
179
+ };
180
+ };
181
+ type ElectronButtonOptions = {
182
+ FRONTEND_URL: string;
183
+ PROVIDER_NAME_IN_URL: string;
184
+ };
185
+ type ElectronWebOptions = typeof defatultWebOptions;
186
+ declare const defaultServerPluginOptions: {
187
+ ELECTRON_SCHEME: string;
188
+ ELECTRON_APP_HOST: string;
189
+ PROVIDERS: string[];
190
+ BACKEND_EXCHANGE_URL: string;
191
+ BACKEND_FAST_TICKET_URL: string;
192
+ WEB_ERROR_PAGE_URL: string;
193
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: string;
194
+ ELECTRON_CALLBACK_HOST_PATH: string;
195
+ ELECTRON_TO_BACKEND_HOST_PATH: string;
196
+ BACKEND_LOGIN_URL: string;
197
+ TICKET_NAME_IN_URL: string;
198
+ SCHEME_NAME_IN_URL: string;
199
+ PROVIDER_NAME_IN_URL: string;
200
+ CHALLENGE_NAME_IN_URL: string;
201
+ TICKET_TTL_SEC: number;
202
+ ELECTRON_SESSION_DURATION: number;
203
+ };
204
+ declare const defaultRendererPluginOptions: {
205
+ ELECTRON_SCHEME: string;
206
+ ELECTRON_APP_HOST: string;
207
+ BACKEND_EXCHANGE_URL: string;
208
+ refetchSessionOnFocus: true;
209
+ ELECTRON_CALLBACK_HOST_PATH: string;
210
+ DEEPLINK_EVENT_NAME: string;
211
+ APP_MOUNTED_EVENT_NAME: string;
212
+ CHALLENGE_NAME_IN_URL: string;
213
+ TICKET_NAME_IN_URL: string;
214
+ lazySignalUIReadyForFn: false;
215
+ };
216
+ declare const defaultMainPluginOptions: {
217
+ debugMode: false;
218
+ isOAuth: true;
219
+ BETTER_AUTH_BASEURL: string;
220
+ ELECTRON_APP_NAME: string;
221
+ PROVIDERS: string[];
222
+ ELECTRON_APP_HOST: string;
223
+ ELECTRON_SCHEME: string;
224
+ ELECTRON_RENDERER_PATH: string;
225
+ DEEPLINK_EVENT_NAME: string;
226
+ APP_MOUNTED_EVENT_NAME: string;
227
+ CLEAR_COOKIES_EVENT_NAME: string;
228
+ GET_COOKIES_EVENT_NAME: string;
229
+ ELECTRON_VERIFIER_LENGTH: number;
230
+ FRONTEND_URL: string;
231
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: string;
232
+ SCHEME_NAME_IN_URL: string;
233
+ PROVIDER_NAME_IN_URL: string;
234
+ CHALLENGE_NAME_IN_URL: string;
235
+ CALLBACK_PATHNAME_IN_URL: string;
236
+ OLD_SCHOOL_ONBEFORE_WAY: false;
237
+ ELECTRON_CALLBACK_HOST_PATH: string;
238
+ ELECTRON_VERIFIER_FILE_NAME: string;
239
+ };
240
+ declare const defaultButtonOptions: {
241
+ FRONTEND_URL: string;
242
+ PROVIDER_NAME_IN_URL: string;
243
+ };
244
+ declare const defatultWebOptions: {
245
+ readonly ELECTRON_SCHEME: "bigio";
246
+ readonly SCHEME_NAME_IN_URL: "scheme";
247
+ readonly PROVIDERS: readonly ["github", "google"];
248
+ readonly PROVIDER_NAME_IN_URL: "provider";
249
+ readonly CHALLENGE_NAME_IN_URL: "electron_challenge";
250
+ readonly WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: "electron-handoff";
251
+ readonly BACKEND_FAST_TICKET_URL: "electron/fastTicket";
252
+ };
253
+
254
+ export { type ElectronButtonOptions, type ElectronMainPluginOptions, type ElectronRendererPluginOptions, type ElectronServerPluginOptions, type ElectronWebOptions, defatultWebOptions, defaultButtonOptions, defaultMainPluginOptions, defaultRendererPluginOptions, defaultServerPluginOptions };
@@ -0,0 +1,78 @@
1
+ // src/options/electron-plugin-options.ts
2
+ var defaultServerPluginOptions = {
3
+ ELECTRON_SCHEME: "bigio",
4
+ ELECTRON_APP_HOST: "app-renderer",
5
+ PROVIDERS: ["github", "google"],
6
+ BACKEND_EXCHANGE_URL: "electron/exchange",
7
+ BACKEND_FAST_TICKET_URL: "electron/fastTicket",
8
+ WEB_ERROR_PAGE_URL: "http://localhost:3001/better-auth",
9
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: "electron-handoff",
10
+ ELECTRON_CALLBACK_HOST_PATH: "better-auth-callback",
11
+ ELECTRON_TO_BACKEND_HOST_PATH: "from-electron-to-auth-backend",
12
+ BACKEND_LOGIN_URL: "electron/login",
13
+ // PREACT_LOGIN_PAGE: renderOAuthPage,
14
+ TICKET_NAME_IN_URL: "ticket",
15
+ SCHEME_NAME_IN_URL: "scheme",
16
+ PROVIDER_NAME_IN_URL: "provider",
17
+ CHALLENGE_NAME_IN_URL: "electron_challenge",
18
+ TICKET_TTL_SEC: 60 * 5,
19
+ ELECTRON_SESSION_DURATION: 7 * 24 * 60 * 60 * 1e3
20
+ // customPreactJS: customPreactJS,
21
+ };
22
+ var defaultRendererPluginOptions = {
23
+ ELECTRON_SCHEME: "bigio",
24
+ ELECTRON_APP_HOST: "app-renderer",
25
+ BACKEND_EXCHANGE_URL: "electron/exchange",
26
+ refetchSessionOnFocus: true,
27
+ ELECTRON_CALLBACK_HOST_PATH: "better-auth-callback",
28
+ DEEPLINK_EVENT_NAME: "deep-link-received",
29
+ APP_MOUNTED_EVENT_NAME: "renderer-app-mounted",
30
+ CHALLENGE_NAME_IN_URL: "electron_challenge",
31
+ TICKET_NAME_IN_URL: "ticket",
32
+ lazySignalUIReadyForFn: false
33
+ };
34
+ var defaultMainPluginOptions = {
35
+ debugMode: false,
36
+ isOAuth: true,
37
+ BETTER_AUTH_BASEURL: "http://localhost:3002",
38
+ ELECTRON_APP_NAME: "bigio-electron-demo",
39
+ PROVIDERS: ["github", "google"],
40
+ ELECTRON_APP_HOST: "app-renderer",
41
+ ELECTRON_SCHEME: "bigio",
42
+ ELECTRON_RENDERER_PATH: "out/renderer",
43
+ DEEPLINK_EVENT_NAME: "deep-link-received",
44
+ APP_MOUNTED_EVENT_NAME: "renderer-app-mounted",
45
+ CLEAR_COOKIES_EVENT_NAME: "clear-Cookies",
46
+ GET_COOKIES_EVENT_NAME: "get-Cookies",
47
+ ELECTRON_VERIFIER_LENGTH: 32,
48
+ FRONTEND_URL: "http://localhost:3002/oauth",
49
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: "electron-handoff",
50
+ SCHEME_NAME_IN_URL: "scheme",
51
+ PROVIDER_NAME_IN_URL: "provider",
52
+ CHALLENGE_NAME_IN_URL: "electron_challenge",
53
+ CALLBACK_PATHNAME_IN_URL: "callbackpath",
54
+ OLD_SCHOOL_ONBEFORE_WAY: false,
55
+ ELECTRON_CALLBACK_HOST_PATH: "better-auth-callback",
56
+ ELECTRON_VERIFIER_FILE_NAME: "bigio-auth-state.json"
57
+ };
58
+ var defaultButtonOptions = {
59
+ FRONTEND_URL: "http://localhost:3001/oauth",
60
+ PROVIDER_NAME_IN_URL: "provider"
61
+ };
62
+ var defatultWebOptions = {
63
+ ELECTRON_SCHEME: "bigio",
64
+ SCHEME_NAME_IN_URL: "scheme",
65
+ PROVIDERS: ["github", "google"],
66
+ PROVIDER_NAME_IN_URL: "provider",
67
+ CHALLENGE_NAME_IN_URL: "electron_challenge",
68
+ WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: "electron-handoff",
69
+ BACKEND_FAST_TICKET_URL: "electron/fastTicket"
70
+ };
71
+ export {
72
+ defatultWebOptions,
73
+ defaultButtonOptions,
74
+ defaultMainPluginOptions,
75
+ defaultRendererPluginOptions,
76
+ defaultServerPluginOptions
77
+ };
78
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/options/electron-plugin-options.ts"],"sourcesContent":["// root/src/utils/electron-plugin-options.ts\n\nimport type { BetterAuthClientOptions, Session, User } from 'better-auth'\nimport type { AuthClient } from 'better-auth/client'\nimport type { BrowserWindow } from 'electron'\n// import { renderOAuthPage } from '../preact/electron-login'\nimport type { BigIOError } from '../utils/electron-plugin-env'\n\nexport type ElectronServerPluginOptions = {\n /**\n * The custom protocol scheme used for deep linking authentication.\n * @remarks\n * This should match the protocol registered in your Electron Main Process.\n * Do not include the `://` suffix.\n * @example \"bigio\" to be like \"bigio://better-auth-callback\"\n */\n ELECTRON_SCHEME: string\n PROVIDERS: string[]\n // baseURL?: string\n // cookiePrefix?: string\n // logger?: typeof bigIOLogger | typeof logsgh\n debugMode?: boolean\n WEB_ERROR_PAGE_URL?: string\n WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME?: string\n ELECTRON_TO_BACKEND_HOST_PATH?: string\n ELECTRON_APP_HOST?: string\n\n /**\n * The specific action path or host used to identify the auth callback.\n * This will be combined with the scheme to form the full callback URL.\n * Format: `${scheme}://${hostname}`\n * @example \"better-auth-callback\"\n * // Resulting URL: \"bigio://better-auth-callback\"\n */\n ELECTRON_CALLBACK_HOST_PATH?: string\n /**\n * The IPC event name used to receive deep link URLs from the main process.\n * @example \"deep-link-received\"\n */\n DEEPLINK_EVENT_NAME?: string\n /**\n * The IPC event name used to notify the main process that the renderer app is mounted.\n * @example \"renderer-app-mounted\"\n */\n APP_MOUNTED_EVENT_NAME?: string\n /**\n * The URL path for the backend exchange endpoint to exchange the JWT ticket.\n * @example \"/electron/exchange\"\n */\n BACKEND_EXCHANGE_URL?: string\n BACKEND_FAST_TICKET_URL?: string\n BACKEND_LOGIN_URL?: string\n PREACT_LOGIN_PAGE?: (\n baseURL?: string | undefined,\n scheme?: string | undefined,\n provider?: string | undefined,\n ) => string\n customPreactJS?: string\n TICKET_NAME_IN_URL?: string\n SCHEME_NAME_IN_URL?: string\n PROVIDER_NAME_IN_URL?: string\n CHALLENGE_NAME_IN_URL?: string\n TICKET_TTL_SEC?: number\n ELECTRON_SESSION_DURATION?: number\n}\n\nexport type ElectronRendererPluginOptions = {\n /**\n * The custom protocol scheme used for deep linking authentication.\n * @remarks\n * This should match the protocol registered in your Electron Main Process.\n * Do not include the `://` suffix.\n * @example \"bigio\" to be like \"bigio://better-auth-callback\"\n */\n ELECTRON_SCHEME: string\n // baseURL?: string\n // cookiePrefix?: string\n // logger?: typeof bigIOLogger | typeof log\n // betterAuthClient: AuthClient<BetterAuthClientOptions>\n debug?: boolean\n refetchSessionOnFocus?: boolean\n CHALLENGE_NAME_IN_URL?: string\n ELECTRON_APP_HOST?: string\n TICKET_NAME_IN_URL?: string\n onDeepLinkFailedFn?: (error: unknown) => Promise<void>\n onDeepLinkSuccessFn?: (data: {\n session: Pick<Session, 'createdAt' | 'updatedAt' | 'expiresAt'>\n user: User\n }) => Promise<void>\n lazySignalUIReadyForFn?: boolean\n /**\n * The specific action path or host used to identify the auth callback.\n * This will be combined with the scheme to form the full callback URL.\n * Format: `${scheme}://${hostname}`\n * @example \"better-auth-callback\"\n * // Resulting URL: \"bigio://better-auth-callback\"\n */\n ELECTRON_CALLBACK_HOST_PATH?: string\n /**\n * The IPC event name used to receive deep link URLs from the main process.\n * @example \"deep-link-received\"\n */\n DEEPLINK_EVENT_NAME?: string\n /**\n * The IPC event name used to notify the main process that the renderer app is mounted.\n * @example \"renderer-app-mounted\"\n */\n APP_MOUNTED_EVENT_NAME?: string\n /**\n * The URL path for the backend exchange endpoint to exchange the JWT ticket.\n * @example \"/electron/exchange\"\n */\n BACKEND_EXCHANGE_URL?: string\n}\nexport type ElectronMainPluginOptions = {\n isOAuth: boolean\n /**\n * The custom protocol scheme used for deep linking authentication.\n * @remarks\n * This should match the protocol registered in your Electron Main Process.\n * Do not include the `://` suffix.\n * @example \"bigio\" to be like \"bigio://better-auth-callback\"\n */\n ELECTRON_SCHEME: string\n BETTER_AUTH_BASEURL: string\n PROVIDERS: string[]\n FRONTEND_URL: string\n ELECTRON_APP_NAME: string\n /**\n * The specific action path or host used to identify the auth callback.\n * This will be combined with the scheme to form the full callback URL.\n * Format: `${scheme}://${hostname}`\n * @example \"better-auth-callback\"\n * // Resulting URL: \"bigio://better-auth-callback\"\n */\n // logger?: typeof bigIOLogger | typeof log\n debugMode?: boolean\n ELECTRON_VERIFIER_LENGTH?: number\n CHALLENGE_NAME_IN_URL?: string\n SCHEME_NAME_IN_URL?: string\n PROVIDER_NAME_IN_URL?: string\n CALLBACK_PATHNAME_IN_URL?: string\n WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME?: string\n ELECTRON_APP_HOST?: string\n ELECTRON_RENDERER_PATH?: string\n OLD_SCHOOL_ONBEFORE_WAY?: boolean\n GET_COOKIES_EVENT_NAME?: string\n ELECTRON_VERIFIER_FILE_NAME?: string\n /**\n * The specific action path or host used to identify the auth callback.\n * This will be combined with the scheme to form the full callback URL.\n * Format: `${scheme}://${hostname}`\n * @example \"better-auth-callback\"\n * // Resulting URL: \"bigio://better-auth-callback\"\n */\n ELECTRON_CALLBACK_HOST_PATH?: string\n /**\n * The IPC event name used to receive deep link URLs from the main process.\n * @example \"deep-link-received\"\n */\n DEEPLINK_EVENT_NAME?: string\n /**\n * The IPC event name used to clear cookies from the main process.\n * @example \"clear-Cookies\"\n */\n CLEAR_COOKIES_EVENT_NAME?: string\n /**\n * The IPC event name used to notify the main process that the renderer app is mounted.\n * @example \"renderer-app-mounted\"\n */\n APP_MOUNTED_EVENT_NAME?: string\n /**\n * The URL path for the backend exchange endpoint to exchange the JWT ticket.\n * @example \"/electron/exchange\"\n */\n BACKEND_EXCHANGE_URL?: string\n openHandlerHelper?: (details: Electron.HandlerDetails) => Electron.WindowOpenHandlerResponse\n\n beforeSendHelper?: (details: Electron.OnBeforeSendHeadersListenerDetails) => {\n callback: {\n requestHeaders: Record<string, string | string[]>\n cancel?: boolean\n }\n }\n customProtocolServingHelper?: {\n scheme?: string\n privileges?: {\n standard: boolean\n secure: boolean\n supportFetchAPI: boolean\n corsEnabled: boolean\n bypassCSP: boolean\n allowServiceWorkers?: boolean\n codeCache?: boolean\n stream?: boolean\n }\n protocolHandleOnCreateWindow?: (mainWindow: BrowserWindow) => Promise<void>\n protocolHandleOnAppReady?: (request: Request) => Response | Promise<Response>\n }\n}\nexport type ElectronButtonOptions = {\n FRONTEND_URL: string\n PROVIDER_NAME_IN_URL: string\n}\nexport type ElectronWebOptions = typeof defatultWebOptions\n\nexport const defaultServerPluginOptions = {\n ELECTRON_SCHEME: 'bigio',\n ELECTRON_APP_HOST: 'app-renderer',\n PROVIDERS: ['github', 'google'],\n BACKEND_EXCHANGE_URL: 'electron/exchange',\n BACKEND_FAST_TICKET_URL: 'electron/fastTicket',\n WEB_ERROR_PAGE_URL: 'http://localhost:3001/better-auth',\n WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: 'electron-handoff',\n ELECTRON_CALLBACK_HOST_PATH: 'better-auth-callback',\n ELECTRON_TO_BACKEND_HOST_PATH: 'from-electron-to-auth-backend',\n BACKEND_LOGIN_URL: 'electron/login',\n // PREACT_LOGIN_PAGE: renderOAuthPage,\n TICKET_NAME_IN_URL: 'ticket',\n SCHEME_NAME_IN_URL: 'scheme',\n PROVIDER_NAME_IN_URL: 'provider',\n CHALLENGE_NAME_IN_URL: 'electron_challenge',\n TICKET_TTL_SEC: 60 * 5,\n ELECTRON_SESSION_DURATION: 7 * 24 * 60 * 60 * 1000,\n // customPreactJS: customPreactJS,\n} satisfies Partial<ElectronServerPluginOptions>\n\nexport const defaultRendererPluginOptions = {\n ELECTRON_SCHEME: 'bigio',\n ELECTRON_APP_HOST: 'app-renderer',\n BACKEND_EXCHANGE_URL: 'electron/exchange',\n refetchSessionOnFocus: true,\n ELECTRON_CALLBACK_HOST_PATH: 'better-auth-callback',\n DEEPLINK_EVENT_NAME: 'deep-link-received',\n APP_MOUNTED_EVENT_NAME: 'renderer-app-mounted',\n CHALLENGE_NAME_IN_URL: 'electron_challenge',\n TICKET_NAME_IN_URL: 'ticket',\n lazySignalUIReadyForFn: false,\n} satisfies Partial<ElectronRendererPluginOptions>\n\nexport const defaultMainPluginOptions = {\n debugMode: false,\n isOAuth: true,\n BETTER_AUTH_BASEURL: 'http://localhost:3002',\n ELECTRON_APP_NAME: 'bigio-electron-demo',\n PROVIDERS: ['github', 'google'],\n ELECTRON_APP_HOST: 'app-renderer',\n ELECTRON_SCHEME: 'bigio',\n ELECTRON_RENDERER_PATH: 'out/renderer',\n DEEPLINK_EVENT_NAME: 'deep-link-received',\n APP_MOUNTED_EVENT_NAME: 'renderer-app-mounted',\n CLEAR_COOKIES_EVENT_NAME: 'clear-Cookies',\n GET_COOKIES_EVENT_NAME: 'get-Cookies',\n ELECTRON_VERIFIER_LENGTH: 32,\n FRONTEND_URL: 'http://localhost:3002/oauth',\n WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: 'electron-handoff',\n SCHEME_NAME_IN_URL: 'scheme',\n PROVIDER_NAME_IN_URL: 'provider',\n CHALLENGE_NAME_IN_URL: 'electron_challenge',\n CALLBACK_PATHNAME_IN_URL: 'callbackpath',\n OLD_SCHOOL_ONBEFORE_WAY: false,\n ELECTRON_CALLBACK_HOST_PATH: 'better-auth-callback',\n ELECTRON_VERIFIER_FILE_NAME: 'bigio-auth-state.json',\n} satisfies Partial<ElectronMainPluginOptions>\n\nexport const defaultButtonOptions = {\n FRONTEND_URL: 'http://localhost:3001/oauth',\n PROVIDER_NAME_IN_URL: 'provider',\n} satisfies Partial<ElectronButtonOptions>\n\nexport const defatultWebOptions = {\n ELECTRON_SCHEME: 'bigio',\n SCHEME_NAME_IN_URL: 'scheme',\n PROVIDERS: ['github', 'google'],\n PROVIDER_NAME_IN_URL: 'provider',\n CHALLENGE_NAME_IN_URL: 'electron_challenge',\n WEB_OAUTH_SIGNIN_CALLBACK_PATHNAME: 'electron-handoff',\n BACKEND_FAST_TICKET_URL: 'electron/fastTicket',\n} as const\n"],"mappings":";AA8MO,IAAM,6BAA6B;AAAA,EACtC,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,WAAW,CAAC,UAAU,QAAQ;AAAA,EAC9B,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,oBAAoB;AAAA,EACpB,oCAAoC;AAAA,EACpC,6BAA6B;AAAA,EAC7B,+BAA+B;AAAA,EAC/B,mBAAmB;AAAA;AAAA,EAEnB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,gBAAgB,KAAK;AAAA,EACrB,2BAA2B,IAAI,KAAK,KAAK,KAAK;AAAA;AAElD;AAEO,IAAM,+BAA+B;AAAA,EACxC,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,6BAA6B;AAAA,EAC7B,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,wBAAwB;AAC5B;AAEO,IAAM,2BAA2B;AAAA,EACpC,WAAW;AAAA,EACX,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,WAAW,CAAC,UAAU,QAAQ;AAAA,EAC9B,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,cAAc;AAAA,EACd,oCAAoC;AAAA,EACpC,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,6BAA6B;AAAA,EAC7B,6BAA6B;AACjC;AAEO,IAAM,uBAAuB;AAAA,EAChC,cAAc;AAAA,EACd,sBAAsB;AAC1B;AAEO,IAAM,qBAAqB;AAAA,EAC9B,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,WAAW,CAAC,UAAU,QAAQ;AAAA,EAC9B,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,oCAAoC;AAAA,EACpC,yBAAyB;AAC7B;","names":[]}
@@ -0,0 +1,23 @@
1
+ import * as better_auth from 'better-auth';
2
+ import * as nanostores from 'nanostores';
3
+ import * as better_auth_client from 'better-auth/client';
4
+ import { ElectronRendererPluginOptions } from './options.js';
5
+ import { electronServerPlugin } from './server.js';
6
+ import 'electron';
7
+ import 'zod';
8
+
9
+ declare const electronRendererPlugin: (electronRendererPluginOptions: ElectronRendererPluginOptions) => {
10
+ id: "bigio-electron-renderer-plugin";
11
+ $InferServerPlugin: ReturnType<typeof electronServerPlugin>;
12
+ getAtoms: ($fetch: better_auth_client.BetterFetch) => {
13
+ myAtom: nanostores.PreinitializedWritableAtom<null> & object;
14
+ };
15
+ getActions: ($fetch: better_auth_client.BetterFetch, $store: better_auth.ClientStore, options: better_auth.BetterAuthClientOptions | undefined) => {
16
+ bigio: {
17
+ onDeepLinkSuccess: (fn: ElectronRendererPluginOptions["onDeepLinkSuccessFn"]) => void;
18
+ onDeepLinkFailed: (fn: ElectronRendererPluginOptions["onDeepLinkFailedFn"]) => void;
19
+ };
20
+ };
21
+ };
22
+
23
+ export { electronRendererPlugin };