@supabase/gotrue-js 2.44.0 → 2.45.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.
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +14 -4
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +6 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +28 -5
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +11 -2
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +15 -5
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +6 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +26 -4
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +11 -2
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/GoTrueClient.ts +21 -4
- package/src/lib/helpers.ts +33 -4
- package/src/lib/types.ts +14 -2
- package/src/lib/version.ts +1 -1
package/src/lib/helpers.ts
CHANGED
|
@@ -197,8 +197,8 @@ export function decodeJWTPayload(token: string) {
|
|
|
197
197
|
/**
|
|
198
198
|
* Creates a promise that resolves to null after some time.
|
|
199
199
|
*/
|
|
200
|
-
export function sleep(time: number): Promise<null> {
|
|
201
|
-
return new Promise((accept) => {
|
|
200
|
+
export async function sleep(time: number): Promise<null> {
|
|
201
|
+
return await new Promise((accept) => {
|
|
202
202
|
setTimeout(() => accept(null), time)
|
|
203
203
|
})
|
|
204
204
|
}
|
|
@@ -309,6 +309,8 @@ const STACK_ENTRY_REGEX = /__stack_guard__([a-zA-Z0-9_-]+)__/
|
|
|
309
309
|
let STACK_GUARD_CHECKED = false
|
|
310
310
|
let STACK_GUARD_CHECK_FN: () => Promise<void> // eslint-disable-line prefer-const
|
|
311
311
|
|
|
312
|
+
let STACK_GUARDS_SUPPORTED = false
|
|
313
|
+
|
|
312
314
|
/**
|
|
313
315
|
* Checks if the current caller of the function is in a {@link
|
|
314
316
|
* #stackGuard} of the provided `name`. Works by looking through
|
|
@@ -370,9 +372,30 @@ export async function stackGuard<R>(name: string, fn: () => Promise<R>): Promise
|
|
|
370
372
|
[guardName]: async () => await fn(),
|
|
371
373
|
}
|
|
372
374
|
|
|
375
|
+
// Safari does not log the name of a dynamically named function unless you
|
|
376
|
+
// explicitly set the displayName
|
|
377
|
+
Object.assign(guardFunc[guardName], { displayName: guardName })
|
|
378
|
+
|
|
373
379
|
return await guardFunc[guardName]()
|
|
374
380
|
}
|
|
375
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Returns if the JavaScript engine supports stack guards. If it doesn't
|
|
384
|
+
* certain features that depend on detecting recursive calls should be disabled
|
|
385
|
+
* to prevent deadlocks.
|
|
386
|
+
*/
|
|
387
|
+
export async function stackGuardsSupported(): Promise<boolean> {
|
|
388
|
+
if (STACK_GUARD_CHECKED) {
|
|
389
|
+
return STACK_GUARDS_SUPPORTED
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
await STACK_GUARD_CHECK_FN()
|
|
393
|
+
|
|
394
|
+
return STACK_GUARDS_SUPPORTED
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let STACK_GUARD_WARNING_LOGGED = false
|
|
398
|
+
|
|
376
399
|
// In certain cases, if this file is transpiled using an ES2015 target, or is
|
|
377
400
|
// running in a JS engine that does not support async/await stack traces, this
|
|
378
401
|
// function will log a single warning message.
|
|
@@ -381,11 +404,17 @@ STACK_GUARD_CHECK_FN = async () => {
|
|
|
381
404
|
STACK_GUARD_CHECKED = true
|
|
382
405
|
|
|
383
406
|
await stackGuard('ENV_CHECK', async () => {
|
|
407
|
+
// sleeping for the next tick as Safari loses track of the async/await
|
|
408
|
+
// trace beyond this point
|
|
409
|
+
await sleep(0)
|
|
410
|
+
|
|
384
411
|
const result = isInStackGuard('ENV_CHECK')
|
|
412
|
+
STACK_GUARDS_SUPPORTED = result
|
|
385
413
|
|
|
386
|
-
if (!result) {
|
|
414
|
+
if (!result && !STACK_GUARD_WARNING_LOGGED) {
|
|
415
|
+
STACK_GUARD_WARNING_LOGGED = true
|
|
387
416
|
console.warn(
|
|
388
|
-
'@supabase/gotrue-js: Stack guards not supported in this environment. Generally not an issue but may point to a very conservative transpilation environment (use ES2017 or above) that implements async/await with generators, or this is a JavaScript engine that does not support async/await stack traces.'
|
|
417
|
+
'@supabase/gotrue-js: Stack guards not supported in this environment. Generally not an issue but may point to a very conservative transpilation environment (use ES2017 or above) that implements async/await with generators, or this is a JavaScript engine that does not support async/await stack traces. Safari is known to not support stack guards.'
|
|
389
418
|
)
|
|
390
419
|
}
|
|
391
420
|
|
package/src/lib/types.ts
CHANGED
|
@@ -533,7 +533,7 @@ export type SignInWithIdTokenCredentials = {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
export type VerifyOtpParams = VerifyMobileOtpParams | VerifyEmailOtpParams
|
|
536
|
+
export type VerifyOtpParams = VerifyMobileOtpParams | VerifyEmailOtpParams | VerifyTokenHashParams
|
|
537
537
|
export interface VerifyMobileOtpParams {
|
|
538
538
|
/** The user's phone number. */
|
|
539
539
|
phone: string
|
|
@@ -563,11 +563,23 @@ export interface VerifyEmailOtpParams {
|
|
|
563
563
|
options?: {
|
|
564
564
|
/** A URL to send the user to after they are confirmed. */
|
|
565
565
|
redirectTo?: string
|
|
566
|
-
|
|
566
|
+
|
|
567
|
+
/** Verification token received when the user completes the captcha on the site.
|
|
568
|
+
*
|
|
569
|
+
* @deprecated
|
|
570
|
+
*/
|
|
567
571
|
captchaToken?: string
|
|
568
572
|
}
|
|
569
573
|
}
|
|
570
574
|
|
|
575
|
+
export interface VerifyTokenHashParams {
|
|
576
|
+
/** The token hash used in an email link */
|
|
577
|
+
token_hash: string
|
|
578
|
+
|
|
579
|
+
/** The user's verification type. */
|
|
580
|
+
type: EmailOtpType
|
|
581
|
+
}
|
|
582
|
+
|
|
571
583
|
export type MobileOtpType = 'sms' | 'phone_change'
|
|
572
584
|
export type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email'
|
|
573
585
|
|
package/src/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.45.0'
|