@supabase/gotrue-js 1.17.0 → 1.20.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.
Files changed (75) hide show
  1. package/README.md +16 -4
  2. package/dist/main/GoTrueApi.d.ts +39 -22
  3. package/dist/main/GoTrueApi.d.ts.map +1 -1
  4. package/dist/main/GoTrueApi.js +84 -75
  5. package/dist/main/GoTrueApi.js.map +1 -1
  6. package/dist/main/GoTrueClient.d.ts +26 -13
  7. package/dist/main/GoTrueClient.d.ts.map +1 -1
  8. package/dist/main/GoTrueClient.js +57 -59
  9. package/dist/main/GoTrueClient.js.map +1 -1
  10. package/dist/main/lib/constants.d.ts +3 -1
  11. package/dist/main/lib/constants.d.ts.map +1 -1
  12. package/dist/main/lib/constants.js +2 -1
  13. package/dist/main/lib/constants.js.map +1 -1
  14. package/dist/main/lib/cookies.d.ts.map +1 -1
  15. package/dist/main/lib/cookies.js +1 -0
  16. package/dist/main/lib/cookies.js.map +1 -1
  17. package/dist/main/lib/fetch.d.ts +5 -4
  18. package/dist/main/lib/fetch.d.ts.map +1 -1
  19. package/dist/main/lib/fetch.js +10 -10
  20. package/dist/main/lib/fetch.js.map +1 -1
  21. package/dist/main/lib/helpers.d.ts +0 -11
  22. package/dist/main/lib/helpers.d.ts.map +1 -1
  23. package/dist/main/lib/helpers.js +6 -25
  24. package/dist/main/lib/helpers.js.map +1 -1
  25. package/dist/main/lib/polyfills.d.ts.map +1 -1
  26. package/dist/main/lib/polyfills.js +3 -1
  27. package/dist/main/lib/polyfills.js.map +1 -1
  28. package/dist/main/lib/types.d.ts +1 -1
  29. package/dist/main/lib/types.d.ts.map +1 -1
  30. package/dist/main/lib/version.d.ts +2 -0
  31. package/dist/main/lib/version.d.ts.map +1 -0
  32. package/dist/main/lib/version.js +6 -0
  33. package/dist/main/lib/version.js.map +1 -0
  34. package/dist/module/GoTrueApi.d.ts +39 -22
  35. package/dist/module/GoTrueApi.d.ts.map +1 -1
  36. package/dist/module/GoTrueApi.js +77 -68
  37. package/dist/module/GoTrueApi.js.map +1 -1
  38. package/dist/module/GoTrueClient.d.ts +26 -13
  39. package/dist/module/GoTrueClient.d.ts.map +1 -1
  40. package/dist/module/GoTrueClient.js +43 -45
  41. package/dist/module/GoTrueClient.js.map +1 -1
  42. package/dist/module/lib/constants.d.ts +3 -1
  43. package/dist/module/lib/constants.d.ts.map +1 -1
  44. package/dist/module/lib/constants.js +2 -1
  45. package/dist/module/lib/constants.js.map +1 -1
  46. package/dist/module/lib/cookies.d.ts.map +1 -1
  47. package/dist/module/lib/cookies.js +1 -0
  48. package/dist/module/lib/cookies.js.map +1 -1
  49. package/dist/module/lib/fetch.d.ts +5 -4
  50. package/dist/module/lib/fetch.d.ts.map +1 -1
  51. package/dist/module/lib/fetch.js +11 -11
  52. package/dist/module/lib/fetch.js.map +1 -1
  53. package/dist/module/lib/helpers.d.ts +0 -11
  54. package/dist/module/lib/helpers.d.ts.map +1 -1
  55. package/dist/module/lib/helpers.js +3 -22
  56. package/dist/module/lib/helpers.js.map +1 -1
  57. package/dist/module/lib/polyfills.d.ts.map +1 -1
  58. package/dist/module/lib/polyfills.js +3 -1
  59. package/dist/module/lib/polyfills.js.map +1 -1
  60. package/dist/module/lib/types.d.ts +1 -1
  61. package/dist/module/lib/types.d.ts.map +1 -1
  62. package/dist/module/lib/version.d.ts +2 -0
  63. package/dist/module/lib/version.d.ts.map +1 -0
  64. package/dist/module/lib/version.js +3 -0
  65. package/dist/module/lib/version.js.map +1 -0
  66. package/package.json +18 -7
  67. package/src/GoTrueApi.ts +142 -80
  68. package/src/GoTrueClient.ts +74 -59
  69. package/src/lib/constants.ts +2 -1
  70. package/src/lib/cookies.ts +1 -0
  71. package/src/lib/fetch.ts +32 -10
  72. package/src/lib/helpers.ts +3 -26
  73. package/src/lib/polyfills.ts +3 -2
  74. package/src/lib/types.ts +2 -0
  75. package/src/lib/version.ts +2 -0
@@ -1,5 +1,5 @@
1
- import GoTrueApi from './GoTrueApi'
2
- import { isBrowser, getParameterByName, uuid, LocalStorage } from './lib/helpers'
1
+ import GoTrueApi, { ApiError } from './GoTrueApi'
2
+ import { isBrowser, getParameterByName, uuid } from './lib/helpers'
3
3
  import { GOTRUE_URL, DEFAULT_HEADERS, STORAGE_KEY } from './lib/constants'
4
4
  import {
5
5
  Session,
@@ -13,6 +13,7 @@ import {
13
13
  VerifyOTPParams,
14
14
  } from './lib/types'
15
15
  import { polyfillGlobalThis } from './lib/polyfills'
16
+ import { Fetch } from './lib/fetch'
16
17
 
17
18
  polyfillGlobalThis() // Make "globalThis" available
18
19
 
@@ -20,10 +21,21 @@ const DEFAULT_OPTIONS = {
20
21
  url: GOTRUE_URL,
21
22
  autoRefreshToken: true,
22
23
  persistSession: true,
23
- localStorage: globalThis.localStorage,
24
24
  detectSessionInUrl: true,
25
25
  headers: DEFAULT_HEADERS,
26
26
  }
27
+
28
+ type AnyFunction = (...args: any[]) => any
29
+ type MaybePromisify<T> = T | Promise<T>
30
+
31
+ type PromisifyMethods<T> = {
32
+ [K in keyof T]: T[K] extends AnyFunction
33
+ ? (...args: Parameters<T[K]>) => MaybePromisify<ReturnType<T[K]>>
34
+ : T[K]
35
+ }
36
+
37
+ type SupportedStorage = PromisifyMethods<Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>>
38
+
27
39
  export default class GoTrueClient {
28
40
  /**
29
41
  * Namespace for the GoTrue API methods.
@@ -41,7 +53,7 @@ export default class GoTrueClient {
41
53
 
42
54
  protected autoRefreshToken: boolean
43
55
  protected persistSession: boolean
44
- protected localStorage: Storage
56
+ protected localStorage: SupportedStorage
45
57
  protected stateChangeEmitters: Map<string, Subscription> = new Map()
46
58
  protected refreshTokenTimer?: ReturnType<typeof setTimeout>
47
59
 
@@ -53,6 +65,8 @@ export default class GoTrueClient {
53
65
  * @param options.autoRefreshToken Set to "true" if you want to automatically refresh the token before expiring.
54
66
  * @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
55
67
  * @param options.localStorage
68
+ * @param options.cookieOptions
69
+ * @param options.fetch A custom fetch implementation.
56
70
  */
57
71
  constructor(options: {
58
72
  url?: string
@@ -60,30 +74,32 @@ export default class GoTrueClient {
60
74
  detectSessionInUrl?: boolean
61
75
  autoRefreshToken?: boolean
62
76
  persistSession?: boolean
63
- localStorage?: Storage
77
+ localStorage?: SupportedStorage
64
78
  cookieOptions?: CookieOptions
79
+ fetch?: Fetch
65
80
  }) {
66
81
  const settings = { ...DEFAULT_OPTIONS, ...options }
67
82
  this.currentUser = null
68
83
  this.currentSession = null
69
84
  this.autoRefreshToken = settings.autoRefreshToken
70
85
  this.persistSession = settings.persistSession
71
- this.localStorage = new LocalStorage(settings.localStorage)
86
+ this.localStorage = settings.localStorage || globalThis.localStorage
72
87
  this.api = new GoTrueApi({
73
88
  url: settings.url,
74
89
  headers: settings.headers,
75
90
  cookieOptions: settings.cookieOptions,
91
+ fetch: settings.fetch,
76
92
  })
77
93
  this._recoverSession()
78
94
  this._recoverAndRefresh()
79
95
 
80
96
  // Handle the OAuth redirect
81
- try {
82
- if (settings.detectSessionInUrl && isBrowser() && !!getParameterByName('access_token')) {
83
- this.getSessionFromUrl({ storeSession: true })
84
- }
85
- } catch (error) {
86
- console.log('Error getting session from URL.')
97
+ if (settings.detectSessionInUrl && isBrowser() && !!getParameterByName('access_token')) {
98
+ this.getSessionFromUrl({ storeSession: true }).then(({ error }) => {
99
+ if (error) {
100
+ console.error('Error getting session from URL.', error)
101
+ }
102
+ })
87
103
  }
88
104
  }
89
105
 
@@ -94,16 +110,18 @@ export default class GoTrueClient {
94
110
  * @param password The user's password.
95
111
  * @param phone The user's phone number.
96
112
  * @param redirectTo A URL or mobile address to send the user to after they are confirmed.
113
+ * @param data Optional user metadata.
97
114
  */
98
115
  async signUp(
99
116
  { email, password, phone }: UserCredentials,
100
117
  options: {
101
118
  redirectTo?: string
119
+ data?: object
102
120
  } = {}
103
121
  ): Promise<{
104
122
  user: User | null
105
123
  session: Session | null
106
- error: Error | null
124
+ error: ApiError | null
107
125
  data: Session | User | null // Deprecated
108
126
  }> {
109
127
  try {
@@ -111,9 +129,12 @@ export default class GoTrueClient {
111
129
 
112
130
  const { data, error } =
113
131
  phone && password
114
- ? await this.api.signUpWithPhone(phone!, password!)
132
+ ? await this.api.signUpWithPhone(phone!, password!, {
133
+ data: options.data,
134
+ })
115
135
  : await this.api.signUpWithEmail(email!, password!, {
116
136
  redirectTo: options.redirectTo,
137
+ data: options.data,
117
138
  })
118
139
 
119
140
  if (error) {
@@ -139,8 +160,8 @@ export default class GoTrueClient {
139
160
  }
140
161
 
141
162
  return { data, user, session, error: null }
142
- } catch (error) {
143
- return { data: null, user: null, session: null, error }
163
+ } catch (e) {
164
+ return { data: null, user: null, session: null, error: e as ApiError }
144
165
  }
145
166
  }
146
167
 
@@ -165,7 +186,7 @@ export default class GoTrueClient {
165
186
  user: User | null
166
187
  provider?: Provider
167
188
  url?: string | null
168
- error: Error | null
189
+ error: ApiError | null
169
190
  data: Session | null // Deprecated
170
191
  }> {
171
192
  try {
@@ -208,8 +229,8 @@ export default class GoTrueClient {
208
229
  })
209
230
  }
210
231
  throw new Error(`You must provide either an email, phone number or a third-party provider.`)
211
- } catch (error) {
212
- return { data: null, user: null, session: null, error }
232
+ } catch (e) {
233
+ return { data: null, user: null, session: null, error: e as ApiError }
213
234
  }
214
235
  }
215
236
 
@@ -227,7 +248,7 @@ export default class GoTrueClient {
227
248
  ): Promise<{
228
249
  user: User | null
229
250
  session: Session | null
230
- error: Error | null
251
+ error: ApiError | null
231
252
  data: Session | User | null // Deprecated
232
253
  }> {
233
254
  try {
@@ -258,8 +279,8 @@ export default class GoTrueClient {
258
279
  }
259
280
 
260
281
  return { data, user, session, error: null }
261
- } catch (error) {
262
- return { data: null, user: null, session: null, error }
282
+ } catch (e) {
283
+ return { data: null, user: null, session: null, error: e as ApiError }
263
284
  }
264
285
  }
265
286
 
@@ -285,7 +306,7 @@ export default class GoTrueClient {
285
306
  async refreshSession(): Promise<{
286
307
  data: Session | null
287
308
  user: User | null
288
- error: Error | null
309
+ error: ApiError | null
289
310
  }> {
290
311
  try {
291
312
  if (!this.currentSession?.access_token) throw new Error('Not logged in.')
@@ -295,8 +316,8 @@ export default class GoTrueClient {
295
316
  if (error) throw error
296
317
 
297
318
  return { data: this.currentSession, user: this.currentUser, error: null }
298
- } catch (error) {
299
- return { data: null, user: null, error }
319
+ } catch (e) {
320
+ return { data: null, user: null, error: e as ApiError }
300
321
  }
301
322
  }
302
323
 
@@ -305,7 +326,7 @@ export default class GoTrueClient {
305
326
  */
306
327
  async update(
307
328
  attributes: UserAttributes
308
- ): Promise<{ data: User | null; user: User | null; error: Error | null }> {
329
+ ): Promise<{ data: User | null; user: User | null; error: ApiError | null }> {
309
330
  try {
310
331
  if (!this.currentSession?.access_token) throw new Error('Not logged in.')
311
332
 
@@ -321,8 +342,8 @@ export default class GoTrueClient {
321
342
  this._notifyAllSubscribers('USER_UPDATED')
322
343
 
323
344
  return { data: user, user, error: null }
324
- } catch (error) {
325
- return { data: null, user: null, error }
345
+ } catch (e) {
346
+ return { data: null, user: null, error: e as ApiError }
326
347
  }
327
348
  }
328
349
 
@@ -332,7 +353,7 @@ export default class GoTrueClient {
332
353
  */
333
354
  async setSession(
334
355
  refresh_token: string
335
- ): Promise<{ session: Session | null; error: Error | null }> {
356
+ ): Promise<{ session: Session | null; error: ApiError | null }> {
336
357
  try {
337
358
  if (!refresh_token) {
338
359
  throw new Error('No current session.')
@@ -341,18 +362,12 @@ export default class GoTrueClient {
341
362
  if (error) {
342
363
  return { session: null, error: error }
343
364
  }
344
- if (!data) {
345
- return {
346
- session: null,
347
- error: { name: 'Invalid refresh_token', message: 'JWT token provided is Invalid' },
348
- }
349
- }
350
365
 
351
- this._saveSession(data)
366
+ this._saveSession(data!)
352
367
  this._notifyAllSubscribers('SIGNED_IN')
353
368
  return { session: data, error: null }
354
- } catch (error) {
355
- return { error, session: null }
369
+ } catch (e) {
370
+ return { error: e as ApiError, session: null }
356
371
  }
357
372
  }
358
373
 
@@ -377,7 +392,7 @@ export default class GoTrueClient {
377
392
  */
378
393
  async getSessionFromUrl(options?: {
379
394
  storeSession?: boolean
380
- }): Promise<{ data: Session | null; error: Error | null }> {
395
+ }): Promise<{ data: Session | null; error: ApiError | null }> {
381
396
  try {
382
397
  if (!isBrowser()) throw new Error('No browser detected.')
383
398
 
@@ -420,18 +435,18 @@ export default class GoTrueClient {
420
435
  window.location.hash = ''
421
436
 
422
437
  return { data: session, error: null }
423
- } catch (error) {
424
- return { data: null, error }
438
+ } catch (e) {
439
+ return { data: null, error: e as ApiError }
425
440
  }
426
441
  }
427
442
 
428
443
  /**
429
- * Inside a browser context, `signOut()` will remove extract the logged in user from the browser session
444
+ * Inside a browser context, `signOut()` will remove the logged in user from the browser session
430
445
  * and log them out - removing all items from localstorage and then trigger a "SIGNED_OUT" event.
431
446
  *
432
447
  * For server-side management, you can disable sessions by passing a JWT through to `auth.api.signOut(JWT: string)`
433
448
  */
434
- async signOut(): Promise<{ error: Error | null }> {
449
+ async signOut(): Promise<{ error: ApiError | null }> {
435
450
  const accessToken = this.currentSession?.access_token
436
451
  this._removeSession()
437
452
  this._notifyAllSubscribers('SIGNED_OUT')
@@ -446,23 +461,23 @@ export default class GoTrueClient {
446
461
  * Receive a notification every time an auth event happens.
447
462
  * @returns {Subscription} A subscription object which can be used to unsubscribe itself.
448
463
  */
449
- onAuthStateChange(
450
- callback: (event: AuthChangeEvent, session: Session | null) => void
451
- ): { data: Subscription | null; error: Error | null } {
464
+ onAuthStateChange(callback: (event: AuthChangeEvent, session: Session | null) => void): {
465
+ data: Subscription | null
466
+ error: ApiError | null
467
+ } {
452
468
  try {
453
469
  const id: string = uuid()
454
- const self = this
455
470
  const subscription: Subscription = {
456
471
  id,
457
472
  callback,
458
473
  unsubscribe: () => {
459
- self.stateChangeEmitters.delete(id)
474
+ this.stateChangeEmitters.delete(id)
460
475
  },
461
476
  }
462
477
  this.stateChangeEmitters.set(id, subscription)
463
478
  return { data: subscription, error: null }
464
- } catch (error) {
465
- return { data: null, error }
479
+ } catch (e) {
480
+ return { data: null, error: e as ApiError }
466
481
  }
467
482
  }
468
483
 
@@ -485,8 +500,8 @@ export default class GoTrueClient {
485
500
  }
486
501
 
487
502
  return { data, user: data.user, session: data, error: null }
488
- } catch (error) {
489
- return { data: null, user: null, session: null, error }
503
+ } catch (e) {
504
+ return { data: null, user: null, session: null, error: e as ApiError }
490
505
  }
491
506
  }
492
507
 
@@ -501,8 +516,8 @@ export default class GoTrueClient {
501
516
  }
502
517
 
503
518
  return { data, user: data.user, session: data, error: null }
504
- } catch (error) {
505
- return { data: null, user: null, session: null, error }
519
+ } catch (e) {
520
+ return { data: null, user: null, session: null, error: e as ApiError }
506
521
  }
507
522
  }
508
523
 
@@ -524,10 +539,10 @@ export default class GoTrueClient {
524
539
  window.location.href = url
525
540
  }
526
541
  return { provider, url, data: null, session: null, user: null, error: null }
527
- } catch (error) {
542
+ } catch (e) {
528
543
  // fallback to returning the URL
529
- if (!!url) return { provider, url, data: null, session: null, user: null, error: null }
530
- return { data: null, user: null, session: null, error }
544
+ if (url) return { provider, url, data: null, session: null, user: null, error: null }
545
+ return { data: null, user: null, session: null, error: e as ApiError }
531
546
  }
532
547
  }
533
548
 
@@ -608,8 +623,8 @@ export default class GoTrueClient {
608
623
  this._notifyAllSubscribers('SIGNED_IN')
609
624
 
610
625
  return { data, error: null }
611
- } catch (error) {
612
- return { data: null, error }
626
+ } catch (e) {
627
+ return { data: null, error: e as ApiError }
613
628
  }
614
629
  }
615
630
 
@@ -1,6 +1,7 @@
1
+ import { version } from './version'
1
2
  export const GOTRUE_URL = 'http://localhost:9999'
2
3
  export const AUDIENCE = ''
3
- export const DEFAULT_HEADERS = {}
4
+ export const DEFAULT_HEADERS = { 'X-Client-Info': `gotrue-js/${version}` }
4
5
  export const EXPIRY_MARGIN = 60 * 1000
5
6
  export const STORAGE_KEY = 'supabase.auth.token'
6
7
  export const COOKIE_OPTIONS = {
@@ -25,6 +25,7 @@ function serialize(
25
25
  ) {
26
26
  const opt = options || {}
27
27
  const enc = encodeURIComponent
28
+ /* eslint-disable-next-line no-control-regex */
28
29
  const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/
29
30
 
30
31
  if (typeof enc !== 'function') {
package/src/lib/fetch.ts CHANGED
@@ -1,4 +1,6 @@
1
- import fetch from 'cross-fetch'
1
+ import crossFetch from 'cross-fetch'
2
+
3
+ export type Fetch = typeof fetch
2
4
 
3
5
  export interface FetchOptions {
4
6
  headers?: {
@@ -38,13 +40,14 @@ const _getRequestParams = (method: RequestMethodType, options?: FetchOptions, bo
38
40
  }
39
41
 
40
42
  async function _handleRequest(
43
+ fetcher: Fetch = crossFetch,
41
44
  method: RequestMethodType,
42
45
  url: string,
43
46
  options?: FetchOptions,
44
47
  body?: object
45
48
  ): Promise<any> {
46
49
  return new Promise((resolve, reject) => {
47
- fetch(url, _getRequestParams(method, options, body))
50
+ fetcher(url, _getRequestParams(method, options, body))
48
51
  .then((result) => {
49
52
  if (!result.ok) throw result
50
53
  if (options?.noResolveJson) return resolve
@@ -55,18 +58,37 @@ async function _handleRequest(
55
58
  })
56
59
  }
57
60
 
58
- export async function get(url: string, options?: FetchOptions): Promise<any> {
59
- return _handleRequest('GET', url, options)
61
+ export async function get(
62
+ fetcher: Fetch | undefined,
63
+ url: string,
64
+ options?: FetchOptions
65
+ ): Promise<any> {
66
+ return _handleRequest(fetcher, 'GET', url, options)
60
67
  }
61
68
 
62
- export async function post(url: string, body: object, options?: FetchOptions): Promise<any> {
63
- return _handleRequest('POST', url, options, body)
69
+ export async function post(
70
+ fetcher: Fetch | undefined,
71
+ url: string,
72
+ body: object,
73
+ options?: FetchOptions
74
+ ): Promise<any> {
75
+ return _handleRequest(fetcher, 'POST', url, options, body)
64
76
  }
65
77
 
66
- export async function put(url: string, body: object, options?: FetchOptions): Promise<any> {
67
- return _handleRequest('PUT', url, options, body)
78
+ export async function put(
79
+ fetcher: Fetch | undefined,
80
+ url: string,
81
+ body: object,
82
+ options?: FetchOptions
83
+ ): Promise<any> {
84
+ return _handleRequest(fetcher, 'PUT', url, options, body)
68
85
  }
69
86
 
70
- export async function remove(url: string, body: object, options?: FetchOptions): Promise<any> {
71
- return _handleRequest('DELETE', url, options, body)
87
+ export async function remove(
88
+ fetcher: Fetch | undefined,
89
+ url: string,
90
+ body: object,
91
+ options?: FetchOptions
92
+ ): Promise<any> {
93
+ return _handleRequest(fetcher, 'DELETE', url, options, body)
72
94
  }
@@ -5,7 +5,7 @@ export function expiresAt(expiresIn: number) {
5
5
 
6
6
  export function uuid() {
7
7
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
8
- var r = (Math.random() * 16) | 0,
8
+ const r = (Math.random() * 16) | 0,
9
9
  v = c == 'x' ? r : (r & 0x3) | 0x8
10
10
  return v.toString(16)
11
11
  })
@@ -15,34 +15,11 @@ export const isBrowser = () => typeof window !== 'undefined'
15
15
 
16
16
  export function getParameterByName(name: string, url?: string) {
17
17
  if (!url) url = window.location.href
18
+ /* eslint-disable-next-line no-useless-escape */
18
19
  name = name.replace(/[\[\]]/g, '\\$&')
19
- var regex = new RegExp('[?&#]' + name + '(=([^&#]*)|&|#|$)'),
20
+ const regex = new RegExp('[?&#]' + name + '(=([^&#]*)|&|#|$)'),
20
21
  results = regex.exec(url)
21
22
  if (!results) return null
22
23
  if (!results[2]) return ''
23
24
  return decodeURIComponent(results[2].replace(/\+/g, ' '))
24
25
  }
25
-
26
- export class LocalStorage implements Storage {
27
- localStorage: Storage;
28
- [name: string]: any
29
- length!: number
30
- constructor(localStorage: Storage) {
31
- this.localStorage = localStorage || globalThis.localStorage
32
- }
33
- clear(): void {
34
- return this.localStorage.clear()
35
- }
36
- key(index: number): string | null {
37
- return this.localStorage.key(index)
38
- }
39
- setItem(key: string, value: any): void {
40
- return this.localStorage.setItem(key, value)
41
- }
42
- getItem(key: string): string | null {
43
- return this.localStorage.getItem(key)
44
- }
45
- removeItem(key: string): void {
46
- return this.localStorage.removeItem(key)
47
- }
48
- }
@@ -1,5 +1,3 @@
1
- // @ts-nocheck
2
-
3
1
  /**
4
2
  * https://mathiasbynens.be/notes/globalthis
5
3
  */
@@ -12,10 +10,13 @@ export function polyfillGlobalThis() {
12
10
  },
13
11
  configurable: true,
14
12
  })
13
+ // @ts-expect-error 'Allow access to magic'
15
14
  __magic__.globalThis = __magic__
15
+ // @ts-expect-error 'Allow access to magic'
16
16
  delete Object.prototype.__magic__
17
17
  } catch (e) {
18
18
  if (typeof self !== 'undefined') {
19
+ // @ts-expect-error 'Allow access to globals'
19
20
  self.globalThis = self
20
21
  }
21
22
  }
package/src/lib/types.ts CHANGED
@@ -9,6 +9,8 @@ export type Provider =
9
9
  | 'apple'
10
10
  | 'discord'
11
11
  | 'twitch'
12
+ | 'spotify'
13
+ | 'slack'
12
14
 
13
15
  export type AuthChangeEvent =
14
16
  | 'SIGNED_IN'
@@ -0,0 +1,2 @@
1
+ // generated by genversion
2
+ export const version = '1.20.0'