@supabase/gotrue-js 2.9.0 → 2.10.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 +44 -21
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +131 -75
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +10 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +40 -1
- package/dist/main/lib/helpers.js.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 +44 -21
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +133 -77
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +10 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +37 -0
- package/dist/module/lib/helpers.js.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 +144 -73
- package/src/lib/helpers.ts +42 -0
- package/src/lib/version.ts +1 -1
package/src/lib/helpers.ts
CHANGED
|
@@ -149,3 +149,45 @@ export function decodeJWTPayload(token: string) {
|
|
|
149
149
|
const base64Url = parts[1]
|
|
150
150
|
return JSON.parse(decodeBase64URL(base64Url))
|
|
151
151
|
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Creates a promise that resolves to null after some time.
|
|
155
|
+
*/
|
|
156
|
+
export function sleep(time: number): Promise<null> {
|
|
157
|
+
return new Promise((accept) => {
|
|
158
|
+
setTimeout(() => accept(null), time)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Converts the provided async function into a retryable function. Each result
|
|
164
|
+
* or thrown error is sent to the isRetryable function which should return true
|
|
165
|
+
* if the function should run again.
|
|
166
|
+
*/
|
|
167
|
+
export function retryable<T>(
|
|
168
|
+
fn: (attempt: number) => Promise<T>,
|
|
169
|
+
isRetryable: (attempt: number, error: any | null, result?: T) => boolean
|
|
170
|
+
): Promise<T> {
|
|
171
|
+
const promise = new Promise<T>((accept, reject) => {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-extra-semi
|
|
173
|
+
;(async () => {
|
|
174
|
+
for (let attempt = 0; attempt < Infinity; attempt++) {
|
|
175
|
+
try {
|
|
176
|
+
const result = await fn(attempt)
|
|
177
|
+
|
|
178
|
+
if (!isRetryable(attempt, null, result)) {
|
|
179
|
+
accept(result)
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
} catch (e: any) {
|
|
183
|
+
if (!isRetryable(attempt, e)) {
|
|
184
|
+
reject(e)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
})()
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
return promise
|
|
193
|
+
}
|
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.10.0'
|