@choiceform/shared-auth 0.1.18 → 0.1.19
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/README.md +370 -139
- package/dist/core.d.ts +109 -66
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/init.d.ts +109 -66
- package/dist/init.d.ts.map +1 -1
- package/dist/lib/auth-client.d.ts +108 -66
- package/dist/lib/auth-client.d.ts.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -0
- package/dist/services/referral-service.d.ts +54 -0
- package/dist/services/referral-service.d.ts.map +1 -0
- package/dist/services/referral-service.js +54 -0
- package/dist/store/utils.d.ts +1 -1
- package/dist/store/utils.d.ts.map +1 -1
- package/dist/types/user.d.ts +4 -0
- package/dist/types/user.d.ts.map +1 -1
- package/dist/utils/user-mapper.d.ts.map +1 -1
- package/dist/utils/user-mapper.js +2 -0
- package/package.json +11 -12
- package/dist/components/auth-sync.d.ts +0 -27
- package/dist/components/auth-sync.d.ts.map +0 -1
- package/dist/components/auth-sync.js +0 -117
- package/dist/components/protected-route.d.ts +0 -18
- package/dist/components/protected-route.d.ts.map +0 -1
- package/dist/components/protected-route.js +0 -34
- package/dist/components/sign-in-page.d.ts +0 -21
- package/dist/components/sign-in-page.d.ts.map +0 -1
- package/dist/components/sign-in-page.js +0 -31
|
@@ -30,7 +30,7 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
30
30
|
requestSignUp?: boolean | undefined;
|
|
31
31
|
loginHint?: string | undefined;
|
|
32
32
|
additionalData?: Record<string, any> | undefined;
|
|
33
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
33
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
34
34
|
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
35
35
|
callbackURL?: string | undefined;
|
|
36
36
|
newUserCallbackURL?: string | undefined;
|
|
@@ -49,7 +49,7 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
49
49
|
additionalData?: Record<string, any> | undefined;
|
|
50
50
|
} & {
|
|
51
51
|
fetchOptions?: FetchOptions | undefined;
|
|
52
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
52
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<{
|
|
53
53
|
redirect: boolean;
|
|
54
54
|
url: string;
|
|
55
55
|
} | {
|
|
@@ -71,10 +71,10 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
71
71
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
72
72
|
};
|
|
73
73
|
} & {
|
|
74
|
-
signOut: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
74
|
+
signOut: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
75
75
|
query?: Record<string, any> | undefined;
|
|
76
76
|
fetchOptions?: FetchOptions | undefined;
|
|
77
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
77
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
78
78
|
success: boolean;
|
|
79
79
|
}, {
|
|
80
80
|
code?: string | undefined;
|
|
@@ -89,14 +89,14 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
89
89
|
image?: string | undefined;
|
|
90
90
|
callbackURL?: string | undefined;
|
|
91
91
|
rememberMe?: boolean | undefined;
|
|
92
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
92
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
93
93
|
email: string;
|
|
94
94
|
name: string;
|
|
95
95
|
password: string;
|
|
96
96
|
image?: string | undefined;
|
|
97
97
|
callbackURL?: string | undefined;
|
|
98
98
|
fetchOptions?: FetchOptions | undefined;
|
|
99
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
99
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<{
|
|
100
100
|
token: null;
|
|
101
101
|
user: {
|
|
102
102
|
id: string;
|
|
@@ -130,14 +130,14 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
130
130
|
password: string;
|
|
131
131
|
callbackURL?: string | undefined;
|
|
132
132
|
rememberMe?: boolean | undefined;
|
|
133
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
133
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
134
134
|
email: string;
|
|
135
135
|
password: string;
|
|
136
136
|
callbackURL?: string | undefined;
|
|
137
137
|
rememberMe?: boolean | undefined;
|
|
138
138
|
} & {
|
|
139
139
|
fetchOptions?: FetchOptions | undefined;
|
|
140
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
140
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
141
141
|
redirect: boolean;
|
|
142
142
|
token: string;
|
|
143
143
|
url?: string | undefined;
|
|
@@ -161,12 +161,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
161
161
|
token?: string | undefined;
|
|
162
162
|
}> & Record<string, any>, Partial<{
|
|
163
163
|
token?: string | undefined;
|
|
164
|
-
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
164
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
165
165
|
newPassword: string;
|
|
166
166
|
token?: string | undefined;
|
|
167
167
|
} & {
|
|
168
168
|
fetchOptions?: FetchOptions | undefined;
|
|
169
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
169
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
170
170
|
status: boolean;
|
|
171
171
|
}, {
|
|
172
172
|
code?: string | undefined;
|
|
@@ -176,13 +176,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
176
176
|
verifyEmail: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
177
177
|
token: string;
|
|
178
178
|
callbackURL?: string | undefined;
|
|
179
|
-
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
179
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
180
180
|
query: {
|
|
181
181
|
token: string;
|
|
182
182
|
callbackURL?: string | undefined;
|
|
183
183
|
};
|
|
184
184
|
fetchOptions?: FetchOptions | undefined;
|
|
185
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
185
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<void | {
|
|
186
186
|
status: boolean;
|
|
187
187
|
}>, {
|
|
188
188
|
code?: string | undefined;
|
|
@@ -192,12 +192,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
192
192
|
sendVerificationEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
193
193
|
email: string;
|
|
194
194
|
callbackURL?: string | undefined;
|
|
195
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
195
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
196
196
|
email: string;
|
|
197
197
|
callbackURL?: string | undefined;
|
|
198
198
|
} & {
|
|
199
199
|
fetchOptions?: FetchOptions | undefined;
|
|
200
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
200
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
201
201
|
status: boolean;
|
|
202
202
|
}, {
|
|
203
203
|
code?: string | undefined;
|
|
@@ -207,12 +207,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
207
207
|
changeEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
208
208
|
newEmail: string;
|
|
209
209
|
callbackURL?: string | undefined;
|
|
210
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
210
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
211
211
|
newEmail: string;
|
|
212
212
|
callbackURL?: string | undefined;
|
|
213
213
|
} & {
|
|
214
214
|
fetchOptions?: FetchOptions | undefined;
|
|
215
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
215
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
216
216
|
status: boolean;
|
|
217
217
|
}, {
|
|
218
218
|
code?: string | undefined;
|
|
@@ -223,13 +223,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
223
223
|
newPassword: string;
|
|
224
224
|
currentPassword: string;
|
|
225
225
|
revokeOtherSessions?: boolean | undefined;
|
|
226
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
226
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
227
227
|
newPassword: string;
|
|
228
228
|
currentPassword: string;
|
|
229
229
|
revokeOtherSessions?: boolean | undefined;
|
|
230
230
|
} & {
|
|
231
231
|
fetchOptions?: FetchOptions | undefined;
|
|
232
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
232
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
233
233
|
token: string | null;
|
|
234
234
|
user: {
|
|
235
235
|
id: string;
|
|
@@ -247,12 +247,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
247
247
|
} & {
|
|
248
248
|
updateUser: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<Partial<{}> & {
|
|
249
249
|
name?: string | undefined;
|
|
250
|
-
image?: string | undefined;
|
|
251
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
250
|
+
image?: string | undefined | null;
|
|
251
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
252
252
|
image?: (string | null) | undefined;
|
|
253
253
|
name?: string | undefined;
|
|
254
254
|
fetchOptions?: FetchOptions | undefined;
|
|
255
|
-
} & Partial<{}>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
255
|
+
} & Partial<{}>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
256
256
|
status: boolean;
|
|
257
257
|
}, {
|
|
258
258
|
code?: string | undefined;
|
|
@@ -263,13 +263,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
263
263
|
callbackURL?: string | undefined;
|
|
264
264
|
password?: string | undefined;
|
|
265
265
|
token?: string | undefined;
|
|
266
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
266
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
267
267
|
callbackURL?: string | undefined;
|
|
268
268
|
password?: string | undefined;
|
|
269
269
|
token?: string | undefined;
|
|
270
270
|
} & {
|
|
271
271
|
fetchOptions?: FetchOptions | undefined;
|
|
272
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
272
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
273
273
|
success: boolean;
|
|
274
274
|
message: string;
|
|
275
275
|
}, {
|
|
@@ -280,12 +280,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
280
280
|
requestPasswordReset: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
281
281
|
email: string;
|
|
282
282
|
redirectTo?: string | undefined;
|
|
283
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
283
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
284
284
|
email: string;
|
|
285
285
|
redirectTo?: string | undefined;
|
|
286
286
|
} & {
|
|
287
287
|
fetchOptions?: FetchOptions | undefined;
|
|
288
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
288
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
289
289
|
status: boolean;
|
|
290
290
|
message: string;
|
|
291
291
|
}, {
|
|
@@ -298,21 +298,21 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
298
298
|
callbackURL: string;
|
|
299
299
|
}> & Record<string, any>, {
|
|
300
300
|
token: string;
|
|
301
|
-
}>>(data_0: import("better-auth
|
|
301
|
+
}>>(data_0: import("better-auth").Prettify<{
|
|
302
302
|
query: {
|
|
303
303
|
callbackURL: string;
|
|
304
304
|
};
|
|
305
305
|
fetchOptions?: FetchOptions | undefined;
|
|
306
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
306
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<never, {
|
|
307
307
|
code?: string | undefined;
|
|
308
308
|
message?: string | undefined;
|
|
309
309
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
310
310
|
};
|
|
311
311
|
} & {
|
|
312
|
-
listSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
312
|
+
listSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
313
313
|
query?: Record<string, any> | undefined;
|
|
314
314
|
fetchOptions?: FetchOptions | undefined;
|
|
315
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
315
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<import("better-auth").Prettify<{
|
|
316
316
|
id: string;
|
|
317
317
|
createdAt: Date;
|
|
318
318
|
updatedAt: Date;
|
|
@@ -328,31 +328,31 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
328
328
|
} & {
|
|
329
329
|
revokeSession: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
330
330
|
token: string;
|
|
331
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
331
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
332
332
|
token: string;
|
|
333
333
|
} & {
|
|
334
334
|
fetchOptions?: FetchOptions | undefined;
|
|
335
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
335
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
336
336
|
status: boolean;
|
|
337
337
|
}, {
|
|
338
338
|
code?: string | undefined;
|
|
339
339
|
message?: string | undefined;
|
|
340
340
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
341
341
|
} & {
|
|
342
|
-
revokeSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
342
|
+
revokeSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
343
343
|
query?: Record<string, any> | undefined;
|
|
344
344
|
fetchOptions?: FetchOptions | undefined;
|
|
345
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
345
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
346
346
|
status: boolean;
|
|
347
347
|
}, {
|
|
348
348
|
code?: string | undefined;
|
|
349
349
|
message?: string | undefined;
|
|
350
350
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
351
351
|
} & {
|
|
352
|
-
revokeOtherSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
352
|
+
revokeOtherSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
353
353
|
query?: Record<string, any> | undefined;
|
|
354
354
|
fetchOptions?: FetchOptions | undefined;
|
|
355
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
355
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
356
356
|
status: boolean;
|
|
357
357
|
}, {
|
|
358
358
|
code?: string | undefined;
|
|
@@ -374,7 +374,7 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
374
374
|
errorCallbackURL?: string | undefined;
|
|
375
375
|
disableRedirect?: boolean | undefined;
|
|
376
376
|
additionalData?: Record<string, any> | undefined;
|
|
377
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
377
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
378
378
|
provider: unknown;
|
|
379
379
|
callbackURL?: string | undefined;
|
|
380
380
|
idToken?: {
|
|
@@ -391,7 +391,7 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
391
391
|
additionalData?: Record<string, any> | undefined;
|
|
392
392
|
} & {
|
|
393
393
|
fetchOptions?: FetchOptions | undefined;
|
|
394
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
394
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
395
395
|
url: string;
|
|
396
396
|
redirect: boolean;
|
|
397
397
|
}, {
|
|
@@ -399,10 +399,10 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
399
399
|
message?: string | undefined;
|
|
400
400
|
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
401
401
|
} & {
|
|
402
|
-
listAccounts: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
402
|
+
listAccounts: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
403
403
|
query?: Record<string, any> | undefined;
|
|
404
404
|
fetchOptions?: FetchOptions | undefined;
|
|
405
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
405
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
406
406
|
id: string;
|
|
407
407
|
providerId: string;
|
|
408
408
|
createdAt: Date;
|
|
@@ -419,13 +419,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
419
419
|
callback: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
420
420
|
token: string;
|
|
421
421
|
callbackURL?: string | undefined;
|
|
422
|
-
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
422
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
423
423
|
query: {
|
|
424
424
|
token: string;
|
|
425
425
|
callbackURL?: string | undefined;
|
|
426
426
|
};
|
|
427
427
|
fetchOptions?: FetchOptions | undefined;
|
|
428
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
428
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
429
429
|
success: boolean;
|
|
430
430
|
message: string;
|
|
431
431
|
}, {
|
|
@@ -437,12 +437,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
437
437
|
unlinkAccount: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
438
438
|
providerId: string;
|
|
439
439
|
accountId?: string | undefined;
|
|
440
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
440
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
441
441
|
providerId: string;
|
|
442
442
|
accountId?: string | undefined;
|
|
443
443
|
} & {
|
|
444
444
|
fetchOptions?: FetchOptions | undefined;
|
|
445
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
445
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
446
446
|
status: boolean;
|
|
447
447
|
}, {
|
|
448
448
|
code?: string | undefined;
|
|
@@ -453,13 +453,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
453
453
|
providerId: string;
|
|
454
454
|
accountId?: string | undefined;
|
|
455
455
|
userId?: string | undefined;
|
|
456
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
456
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
457
457
|
providerId: string;
|
|
458
458
|
accountId?: string | undefined;
|
|
459
459
|
userId?: string | undefined;
|
|
460
460
|
} & {
|
|
461
461
|
fetchOptions?: FetchOptions | undefined;
|
|
462
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
462
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
463
463
|
accessToken: string | undefined;
|
|
464
464
|
refreshToken: string | undefined;
|
|
465
465
|
accessTokenExpiresAt: Date | undefined;
|
|
@@ -477,13 +477,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
477
477
|
providerId: string;
|
|
478
478
|
accountId?: string | undefined;
|
|
479
479
|
userId?: string | undefined;
|
|
480
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth
|
|
480
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
481
481
|
providerId: string;
|
|
482
482
|
accountId?: string | undefined;
|
|
483
483
|
userId?: string | undefined;
|
|
484
484
|
} & {
|
|
485
485
|
fetchOptions?: FetchOptions | undefined;
|
|
486
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("
|
|
486
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
487
487
|
accessToken: string;
|
|
488
488
|
accessTokenExpiresAt: Date | undefined;
|
|
489
489
|
scopes: string[];
|
|
@@ -495,12 +495,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
495
495
|
} & {
|
|
496
496
|
accountInfo: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
497
497
|
accountId?: string | undefined;
|
|
498
|
-
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
498
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
499
499
|
query?: {
|
|
500
500
|
accountId?: string | undefined;
|
|
501
501
|
} | undefined;
|
|
502
502
|
fetchOptions?: FetchOptions | undefined;
|
|
503
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
503
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
504
504
|
user: import("better-auth").OAuth2UserInfo;
|
|
505
505
|
data: Record<string, any>;
|
|
506
506
|
}, {
|
|
@@ -511,13 +511,13 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
511
511
|
getSession: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
512
512
|
disableCookieCache?: unknown;
|
|
513
513
|
disableRefresh?: unknown;
|
|
514
|
-
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth
|
|
514
|
+
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
515
515
|
query?: {
|
|
516
516
|
disableCookieCache?: unknown;
|
|
517
517
|
disableRefresh?: unknown;
|
|
518
518
|
} | undefined;
|
|
519
519
|
fetchOptions?: FetchOptions | undefined;
|
|
520
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("
|
|
520
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
521
521
|
user: {
|
|
522
522
|
id: string;
|
|
523
523
|
createdAt: Date;
|
|
@@ -566,7 +566,7 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
566
566
|
} | null;
|
|
567
567
|
isPending: boolean;
|
|
568
568
|
isRefetching: boolean;
|
|
569
|
-
error: import("
|
|
569
|
+
error: import("better-auth/client").BetterFetchError | null;
|
|
570
570
|
refetch: (queryParams?: {
|
|
571
571
|
query?: import("better-auth").SessionQueryParams;
|
|
572
572
|
} | undefined) => Promise<void>;
|
|
@@ -594,21 +594,21 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
594
594
|
};
|
|
595
595
|
};
|
|
596
596
|
};
|
|
597
|
-
$fetch: import("
|
|
598
|
-
plugins: (import("
|
|
597
|
+
$fetch: import("better-auth/client").BetterFetch<{
|
|
598
|
+
plugins: (import("better-auth/client").BetterFetchPlugin<Record<string, any>> | {
|
|
599
599
|
id: string;
|
|
600
600
|
name: string;
|
|
601
601
|
hooks: {
|
|
602
|
-
onSuccess(context: import("
|
|
602
|
+
onSuccess(context: import("better-auth/client").SuccessContext<any>): void;
|
|
603
603
|
};
|
|
604
604
|
} | {
|
|
605
605
|
id: string;
|
|
606
606
|
name: string;
|
|
607
607
|
hooks: {
|
|
608
|
-
onSuccess: ((context: import("
|
|
609
|
-
onError: ((context: import("
|
|
610
|
-
onRequest: (<T extends Record<string, any>>(context: import("
|
|
611
|
-
onResponse: ((context: import("
|
|
608
|
+
onSuccess: ((context: import("better-auth/client").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
609
|
+
onError: ((context: import("better-auth/client").ErrorContext) => Promise<void> | void) | undefined;
|
|
610
|
+
onRequest: (<T extends Record<string, any>>(context: import("better-auth/client").RequestContext<T>) => Promise<import("better-auth/client").RequestContext | void> | import("better-auth/client").RequestContext | void) | undefined;
|
|
611
|
+
onResponse: ((context: import("better-auth/client").ResponseContext) => Promise<Response | void | import("better-auth/client").ResponseContext> | Response | import("better-auth/client").ResponseContext | void) | undefined;
|
|
612
612
|
};
|
|
613
613
|
})[];
|
|
614
614
|
cache?: RequestCache | undefined;
|
|
@@ -628,12 +628,12 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
628
628
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
629
629
|
signal?: (AbortSignal | null) | undefined;
|
|
630
630
|
window?: null | undefined;
|
|
631
|
-
onRetry?: ((response: import("
|
|
631
|
+
onRetry?: ((response: import("better-auth/client").ResponseContext) => Promise<void> | void) | undefined;
|
|
632
632
|
hookOptions?: {
|
|
633
633
|
cloneResponse?: boolean;
|
|
634
634
|
} | undefined;
|
|
635
635
|
timeout?: number | undefined;
|
|
636
|
-
customFetchImpl: import("
|
|
636
|
+
customFetchImpl: import("better-auth/client").FetchEsque;
|
|
637
637
|
baseURL: string;
|
|
638
638
|
throw?: boolean | undefined;
|
|
639
639
|
auth?: ({
|
|
@@ -653,20 +653,62 @@ export declare function createAuthClientFromConfig(config: AuthConfig): {
|
|
|
653
653
|
params?: any;
|
|
654
654
|
duplex?: "full" | "half" | undefined;
|
|
655
655
|
jsonParser: (text: string) => Promise<any> | any;
|
|
656
|
-
retry?: import("
|
|
656
|
+
retry?: import("better-auth/client").RetryOptions | undefined;
|
|
657
657
|
retryAttempt?: number | undefined;
|
|
658
|
-
output?: (import("
|
|
659
|
-
errorSchema?: import("
|
|
658
|
+
output?: (import("better-auth/client").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
659
|
+
errorSchema?: import("better-auth/client").StandardSchemaV1 | undefined;
|
|
660
660
|
disableValidation?: boolean | undefined;
|
|
661
661
|
disableSignal?: boolean | undefined;
|
|
662
662
|
}, unknown, unknown, {}>;
|
|
663
663
|
$store: {
|
|
664
664
|
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
665
665
|
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
666
|
-
atoms: Record<string, import("
|
|
666
|
+
atoms: Record<string, import("better-auth/client").WritableAtom<any>>;
|
|
667
667
|
};
|
|
668
668
|
$ERROR_CODES: {
|
|
669
|
-
|
|
669
|
+
readonly USER_NOT_FOUND: "User not found";
|
|
670
|
+
readonly FAILED_TO_CREATE_USER: "Failed to create user";
|
|
671
|
+
readonly FAILED_TO_CREATE_SESSION: "Failed to create session";
|
|
672
|
+
readonly FAILED_TO_UPDATE_USER: "Failed to update user";
|
|
673
|
+
readonly FAILED_TO_GET_SESSION: "Failed to get session";
|
|
674
|
+
readonly INVALID_PASSWORD: "Invalid password";
|
|
675
|
+
readonly INVALID_EMAIL: "Invalid email";
|
|
676
|
+
readonly INVALID_EMAIL_OR_PASSWORD: "Invalid email or password";
|
|
677
|
+
readonly SOCIAL_ACCOUNT_ALREADY_LINKED: "Social account already linked";
|
|
678
|
+
readonly PROVIDER_NOT_FOUND: "Provider not found";
|
|
679
|
+
readonly INVALID_TOKEN: "Invalid token";
|
|
680
|
+
readonly ID_TOKEN_NOT_SUPPORTED: "id_token not supported";
|
|
681
|
+
readonly FAILED_TO_GET_USER_INFO: "Failed to get user info";
|
|
682
|
+
readonly USER_EMAIL_NOT_FOUND: "User email not found";
|
|
683
|
+
readonly EMAIL_NOT_VERIFIED: "Email not verified";
|
|
684
|
+
readonly PASSWORD_TOO_SHORT: "Password too short";
|
|
685
|
+
readonly PASSWORD_TOO_LONG: "Password too long";
|
|
686
|
+
readonly USER_ALREADY_EXISTS: "User already exists.";
|
|
687
|
+
readonly USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "User already exists. Use another email.";
|
|
688
|
+
readonly EMAIL_CAN_NOT_BE_UPDATED: "Email can not be updated";
|
|
689
|
+
readonly CREDENTIAL_ACCOUNT_NOT_FOUND: "Credential account not found";
|
|
690
|
+
readonly SESSION_EXPIRED: "Session expired. Re-authenticate to perform this action.";
|
|
691
|
+
readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
|
|
692
|
+
readonly ACCOUNT_NOT_FOUND: "Account not found";
|
|
693
|
+
readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
|
|
694
|
+
readonly CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.";
|
|
695
|
+
readonly VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled";
|
|
696
|
+
readonly EMAIL_ALREADY_VERIFIED: "Email is already verified";
|
|
697
|
+
readonly EMAIL_MISMATCH: "Email mismatch";
|
|
698
|
+
readonly SESSION_NOT_FRESH: "Session is not fresh";
|
|
699
|
+
readonly LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists";
|
|
700
|
+
readonly INVALID_ORIGIN: "Invalid origin";
|
|
701
|
+
readonly INVALID_CALLBACK_URL: "Invalid callbackURL";
|
|
702
|
+
readonly INVALID_REDIRECT_URL: "Invalid redirectURL";
|
|
703
|
+
readonly INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL";
|
|
704
|
+
readonly INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL";
|
|
705
|
+
readonly MISSING_OR_NULL_ORIGIN: "Missing or null Origin";
|
|
706
|
+
readonly CALLBACK_URL_REQUIRED: "callbackURL is required";
|
|
707
|
+
readonly FAILED_TO_CREATE_VERIFICATION: "Unable to create verification";
|
|
708
|
+
readonly FIELD_NOT_ALLOWED: "Field not allowed to be set";
|
|
709
|
+
readonly ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported";
|
|
710
|
+
readonly VALIDATION_ERROR: "Validation Error";
|
|
711
|
+
readonly MISSING_FIELD: "Field is required";
|
|
670
712
|
};
|
|
671
713
|
};
|
|
672
714
|
//# sourceMappingURL=auth-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../src/lib/auth-client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../src/lib/auth-client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAmD9C,CAAC;iBACA,CAAV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAyCsb,CAAC;;eAA2D,CAAC;;;;;gBAA8U,CAAC;mBAA8C,CAAC;iBAAmC,CAAC;iBAAmC,CAAC;YAA+B,CAAC;gBAAuC,CAAC;gBAA2C,CAAC;sBAAwC,CAAC;cAAwC,CAAC;cAA8C,CAAC;eAA+B,CAAC;mBAA0G,CAAC;yBAAuB,CAAC;;eAAyC,CAAC;;;aAA2G,CAAC;YAA+B,CAAC;;;;;;;;;;;;YAA+e,CAAC;aAAgB,CAAC;cAAiB,CAAC;cAAiB,CAAC;;aAA8F,CAAC;oBAAkE,CAAC;cAAgC,CAAC;mBAAmG,CAAC;yBAA2E,CAAC;qBAAwC,CAAC;;;uBAAkF,CAAC;+GAAuL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADxtF"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
export { setupCompanionTeam } from "./companion-team";
|
|
5
5
|
export { createAuthService, type AuthService, type AuthServiceConfig, type BetterAuthClientMethods, } from "./auth-service";
|
|
6
6
|
export { createCallbackService, type CallbackService, } from "./callback-service";
|
|
7
|
+
export { createReferralService, needsReferral, getReferralFields, type ReferralService, type ReferralResponse, type ReferralErrorType, type ReferralResult, type NeedsReferralOptions, } from "./referral-service";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAA"}
|
package/dist/services/index.js
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 邀请码服务
|
|
3
|
+
*
|
|
4
|
+
* 提供邀请码相关的业务逻辑:
|
|
5
|
+
* - 提交邀请码
|
|
6
|
+
* - 检查用户是否需要填写邀请码
|
|
7
|
+
* - 提取用户邀请码字段
|
|
8
|
+
*/
|
|
9
|
+
import type { ApiClient } from "../api";
|
|
10
|
+
import type { SessionUser } from "../types";
|
|
11
|
+
/** POST /referral 响应 */
|
|
12
|
+
export interface ReferralResponse {
|
|
13
|
+
referral: {
|
|
14
|
+
createdAt: string;
|
|
15
|
+
id: string;
|
|
16
|
+
referreeId: string;
|
|
17
|
+
referrerId: string;
|
|
18
|
+
status: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** 邀请码 API 错误类型 */
|
|
22
|
+
export type ReferralErrorType = "already_referred" | "not_found" | "unknown";
|
|
23
|
+
/** 提交邀请码的结果 */
|
|
24
|
+
export interface ReferralResult {
|
|
25
|
+
error: ReferralErrorType | undefined;
|
|
26
|
+
success: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** 邀请码检查选项 */
|
|
29
|
+
export interface NeedsReferralOptions {
|
|
30
|
+
/** 跳过检查的角色列表,默认 ["admin"] */
|
|
31
|
+
skipRoles?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface ReferralService {
|
|
34
|
+
/** 提交邀请码 */
|
|
35
|
+
submitReferralCode: (referralCode: string) => Promise<ReferralResult>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 创建邀请码服务
|
|
39
|
+
*/
|
|
40
|
+
export declare function createReferralService(apiClient: ApiClient): ReferralService;
|
|
41
|
+
/**
|
|
42
|
+
* 检查用户是否需要完成邀请码步骤
|
|
43
|
+
*
|
|
44
|
+
* 仅检查用户状态,不包含 feature flag 判断(由应用层控制)
|
|
45
|
+
*/
|
|
46
|
+
export declare function needsReferral(user: SessionUser | null, options?: NeedsReferralOptions): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 提取用户的邀请码相关字段
|
|
49
|
+
*/
|
|
50
|
+
export declare function getReferralFields(user: SessionUser | null): {
|
|
51
|
+
referralCode: string | undefined;
|
|
52
|
+
referredBy: string | undefined;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=referral-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referral-service.d.ts","sourceRoot":"","sources":["../../src/services/referral-service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,QAAQ,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI3C,wBAAwB;AACxB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAA;QACjB,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,mBAAmB;AACnB,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAAA;AAE5E,eAAe;AACf,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,cAAc;AACd,MAAM,WAAW,oBAAoB;IACnC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAID,MAAM,WAAW,eAAe;IAC9B,YAAY;IACZ,kBAAkB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;CACtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe,CAsB3E;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAST;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;;;EAKzD"}
|