@depup/supabase__auth-js 2.99.2-depup.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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/changes.json +5 -0
  4. package/dist/main/AuthAdminApi.d.ts +4 -0
  5. package/dist/main/AuthAdminApi.d.ts.map +1 -0
  6. package/dist/main/AuthAdminApi.js +7 -0
  7. package/dist/main/AuthAdminApi.js.map +1 -0
  8. package/dist/main/AuthClient.d.ts +4 -0
  9. package/dist/main/AuthClient.d.ts.map +1 -0
  10. package/dist/main/AuthClient.js +7 -0
  11. package/dist/main/AuthClient.js.map +1 -0
  12. package/dist/main/GoTrueAdminApi.d.ts +227 -0
  13. package/dist/main/GoTrueAdminApi.d.ts.map +1 -0
  14. package/dist/main/GoTrueAdminApi.js +596 -0
  15. package/dist/main/GoTrueAdminApi.js.map +1 -0
  16. package/dist/main/GoTrueClient.d.ts +783 -0
  17. package/dist/main/GoTrueClient.d.ts.map +1 -0
  18. package/dist/main/GoTrueClient.js +3029 -0
  19. package/dist/main/GoTrueClient.js.map +1 -0
  20. package/dist/main/index.d.ts +9 -0
  21. package/dist/main/index.d.ts.map +1 -0
  22. package/dist/main/index.js +20 -0
  23. package/dist/main/index.js.map +1 -0
  24. package/dist/main/lib/base64url.d.ts +76 -0
  25. package/dist/main/lib/base64url.d.ts.map +1 -0
  26. package/dist/main/lib/base64url.js +269 -0
  27. package/dist/main/lib/base64url.js.map +1 -0
  28. package/dist/main/lib/constants.d.ts +26 -0
  29. package/dist/main/lib/constants.d.ts.map +1 -0
  30. package/dist/main/lib/constants.js +31 -0
  31. package/dist/main/lib/constants.js.map +1 -0
  32. package/dist/main/lib/error-codes.d.ts +7 -0
  33. package/dist/main/lib/error-codes.d.ts.map +1 -0
  34. package/dist/main/lib/error-codes.js +3 -0
  35. package/dist/main/lib/error-codes.js.map +1 -0
  36. package/dist/main/lib/errors.d.ts +243 -0
  37. package/dist/main/lib/errors.d.ts.map +1 -0
  38. package/dist/main/lib/errors.js +289 -0
  39. package/dist/main/lib/errors.js.map +1 -0
  40. package/dist/main/lib/fetch.d.ts +34 -0
  41. package/dist/main/lib/fetch.d.ts.map +1 -0
  42. package/dist/main/lib/fetch.js +184 -0
  43. package/dist/main/lib/fetch.js.map +1 -0
  44. package/dist/main/lib/helpers.d.ts +91 -0
  45. package/dist/main/lib/helpers.d.ts.map +1 -0
  46. package/dist/main/lib/helpers.js +395 -0
  47. package/dist/main/lib/helpers.js.map +1 -0
  48. package/dist/main/lib/local-storage.d.ts +9 -0
  49. package/dist/main/lib/local-storage.d.ts.map +1 -0
  50. package/dist/main/lib/local-storage.js +21 -0
  51. package/dist/main/lib/local-storage.js.map +1 -0
  52. package/dist/main/lib/locks.d.ts +107 -0
  53. package/dist/main/lib/locks.d.ts.map +1 -0
  54. package/dist/main/lib/locks.js +314 -0
  55. package/dist/main/lib/locks.js.map +1 -0
  56. package/dist/main/lib/polyfills.d.ts +5 -0
  57. package/dist/main/lib/polyfills.d.ts.map +1 -0
  58. package/dist/main/lib/polyfills.js +29 -0
  59. package/dist/main/lib/polyfills.js.map +1 -0
  60. package/dist/main/lib/types.d.ts +1861 -0
  61. package/dist/main/lib/types.d.ts.map +1 -0
  62. package/dist/main/lib/types.js +23 -0
  63. package/dist/main/lib/types.js.map +1 -0
  64. package/dist/main/lib/version.d.ts +2 -0
  65. package/dist/main/lib/version.d.ts.map +1 -0
  66. package/dist/main/lib/version.js +11 -0
  67. package/dist/main/lib/version.js.map +1 -0
  68. package/dist/main/lib/web3/ethereum.d.ts +96 -0
  69. package/dist/main/lib/web3/ethereum.d.ts.map +1 -0
  70. package/dist/main/lib/web3/ethereum.js +66 -0
  71. package/dist/main/lib/web3/ethereum.js.map +1 -0
  72. package/dist/main/lib/web3/solana.d.ts +160 -0
  73. package/dist/main/lib/web3/solana.d.ts.map +1 -0
  74. package/dist/main/lib/web3/solana.js +4 -0
  75. package/dist/main/lib/web3/solana.js.map +1 -0
  76. package/dist/main/lib/webauthn.d.ts +276 -0
  77. package/dist/main/lib/webauthn.d.ts.map +1 -0
  78. package/dist/main/lib/webauthn.dom.d.ts +583 -0
  79. package/dist/main/lib/webauthn.dom.d.ts.map +1 -0
  80. package/dist/main/lib/webauthn.dom.js +4 -0
  81. package/dist/main/lib/webauthn.dom.js.map +1 -0
  82. package/dist/main/lib/webauthn.errors.d.ts +80 -0
  83. package/dist/main/lib/webauthn.errors.d.ts.map +1 -0
  84. package/dist/main/lib/webauthn.errors.js +265 -0
  85. package/dist/main/lib/webauthn.errors.js.map +1 -0
  86. package/dist/main/lib/webauthn.js +706 -0
  87. package/dist/main/lib/webauthn.js.map +1 -0
  88. package/dist/module/AuthAdminApi.d.ts +4 -0
  89. package/dist/module/AuthAdminApi.d.ts.map +1 -0
  90. package/dist/module/AuthAdminApi.js +4 -0
  91. package/dist/module/AuthAdminApi.js.map +1 -0
  92. package/dist/module/AuthClient.d.ts +4 -0
  93. package/dist/module/AuthClient.d.ts.map +1 -0
  94. package/dist/module/AuthClient.js +4 -0
  95. package/dist/module/AuthClient.js.map +1 -0
  96. package/dist/module/GoTrueAdminApi.d.ts +227 -0
  97. package/dist/module/GoTrueAdminApi.d.ts.map +1 -0
  98. package/dist/module/GoTrueAdminApi.js +593 -0
  99. package/dist/module/GoTrueAdminApi.js.map +1 -0
  100. package/dist/module/GoTrueClient.d.ts +783 -0
  101. package/dist/module/GoTrueClient.d.ts.map +1 -0
  102. package/dist/module/GoTrueClient.js +3026 -0
  103. package/dist/module/GoTrueClient.js.map +1 -0
  104. package/dist/module/index.d.ts +9 -0
  105. package/dist/module/index.d.ts.map +1 -0
  106. package/dist/module/index.js +9 -0
  107. package/dist/module/index.js.map +1 -0
  108. package/dist/module/lib/base64url.d.ts +76 -0
  109. package/dist/module/lib/base64url.d.ts.map +1 -0
  110. package/dist/module/lib/base64url.js +257 -0
  111. package/dist/module/lib/base64url.js.map +1 -0
  112. package/dist/module/lib/constants.d.ts +26 -0
  113. package/dist/module/lib/constants.d.ts.map +1 -0
  114. package/dist/module/lib/constants.js +28 -0
  115. package/dist/module/lib/constants.js.map +1 -0
  116. package/dist/module/lib/error-codes.d.ts +7 -0
  117. package/dist/module/lib/error-codes.d.ts.map +1 -0
  118. package/dist/module/lib/error-codes.js +2 -0
  119. package/dist/module/lib/error-codes.js.map +1 -0
  120. package/dist/module/lib/errors.d.ts +243 -0
  121. package/dist/module/lib/errors.d.ts.map +1 -0
  122. package/dist/module/lib/errors.js +266 -0
  123. package/dist/module/lib/errors.js.map +1 -0
  124. package/dist/module/lib/fetch.d.ts +34 -0
  125. package/dist/module/lib/fetch.d.ts.map +1 -0
  126. package/dist/module/lib/fetch.js +174 -0
  127. package/dist/module/lib/fetch.js.map +1 -0
  128. package/dist/module/lib/helpers.d.ts +91 -0
  129. package/dist/module/lib/helpers.d.ts.map +1 -0
  130. package/dist/module/lib/helpers.js +368 -0
  131. package/dist/module/lib/helpers.js.map +1 -0
  132. package/dist/module/lib/local-storage.d.ts +9 -0
  133. package/dist/module/lib/local-storage.d.ts.map +1 -0
  134. package/dist/module/lib/local-storage.js +18 -0
  135. package/dist/module/lib/local-storage.js.map +1 -0
  136. package/dist/module/lib/locks.d.ts +107 -0
  137. package/dist/module/lib/locks.d.ts.map +1 -0
  138. package/dist/module/lib/locks.js +306 -0
  139. package/dist/module/lib/locks.js.map +1 -0
  140. package/dist/module/lib/polyfills.d.ts +5 -0
  141. package/dist/module/lib/polyfills.d.ts.map +1 -0
  142. package/dist/module/lib/polyfills.js +26 -0
  143. package/dist/module/lib/polyfills.js.map +1 -0
  144. package/dist/module/lib/types.d.ts +1861 -0
  145. package/dist/module/lib/types.d.ts.map +1 -0
  146. package/dist/module/lib/types.js +20 -0
  147. package/dist/module/lib/types.js.map +1 -0
  148. package/dist/module/lib/version.d.ts +2 -0
  149. package/dist/module/lib/version.d.ts.map +1 -0
  150. package/dist/module/lib/version.js +8 -0
  151. package/dist/module/lib/version.js.map +1 -0
  152. package/dist/module/lib/web3/ethereum.d.ts +96 -0
  153. package/dist/module/lib/web3/ethereum.d.ts.map +1 -0
  154. package/dist/module/lib/web3/ethereum.js +60 -0
  155. package/dist/module/lib/web3/ethereum.js.map +1 -0
  156. package/dist/module/lib/web3/solana.d.ts +160 -0
  157. package/dist/module/lib/web3/solana.d.ts.map +1 -0
  158. package/dist/module/lib/web3/solana.js +3 -0
  159. package/dist/module/lib/web3/solana.js.map +1 -0
  160. package/dist/module/lib/webauthn.d.ts +276 -0
  161. package/dist/module/lib/webauthn.d.ts.map +1 -0
  162. package/dist/module/lib/webauthn.dom.d.ts +583 -0
  163. package/dist/module/lib/webauthn.dom.d.ts.map +1 -0
  164. package/dist/module/lib/webauthn.dom.js +3 -0
  165. package/dist/module/lib/webauthn.dom.js.map +1 -0
  166. package/dist/module/lib/webauthn.errors.d.ts +80 -0
  167. package/dist/module/lib/webauthn.errors.d.ts.map +1 -0
  168. package/dist/module/lib/webauthn.errors.js +257 -0
  169. package/dist/module/lib/webauthn.errors.js.map +1 -0
  170. package/dist/module/lib/webauthn.js +689 -0
  171. package/dist/module/lib/webauthn.js.map +1 -0
  172. package/dist/tsconfig.module.tsbuildinfo +1 -0
  173. package/dist/tsconfig.tsbuildinfo +1 -0
  174. package/package.json +56 -0
  175. package/src/AuthAdminApi.ts +5 -0
  176. package/src/AuthClient.ts +5 -0
  177. package/src/GoTrueAdminApi.ts +723 -0
  178. package/src/GoTrueClient.ts +4078 -0
  179. package/src/index.ts +13 -0
  180. package/src/lib/base64url.ts +308 -0
  181. package/src/lib/constants.ts +34 -0
  182. package/src/lib/error-codes.ts +90 -0
  183. package/src/lib/errors.ts +324 -0
  184. package/src/lib/fetch.ts +283 -0
  185. package/src/lib/helpers.ts +463 -0
  186. package/src/lib/local-storage.ts +21 -0
  187. package/src/lib/locks.ts +375 -0
  188. package/src/lib/polyfills.ts +23 -0
  189. package/src/lib/types.ts +2229 -0
  190. package/src/lib/version.ts +7 -0
  191. package/src/lib/web3/ethereum.ts +184 -0
  192. package/src/lib/web3/solana.ts +186 -0
  193. package/src/lib/webauthn.dom.ts +636 -0
  194. package/src/lib/webauthn.errors.ts +317 -0
  195. package/src/lib/webauthn.ts +946 -0
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import GoTrueAdminApi from './GoTrueAdminApi'
2
+ import GoTrueClient from './GoTrueClient'
3
+ import AuthAdminApi from './AuthAdminApi'
4
+ import AuthClient from './AuthClient'
5
+ export { GoTrueAdminApi, GoTrueClient, AuthAdminApi, AuthClient }
6
+ export * from './lib/types'
7
+ export * from './lib/errors'
8
+ export {
9
+ navigatorLock,
10
+ NavigatorLockAcquireTimeoutError,
11
+ internals as lockInternals,
12
+ processLock,
13
+ } from './lib/locks'
@@ -0,0 +1,308 @@
1
+ /**
2
+ * Avoid modifying this file. It's part of
3
+ * https://github.com/supabase-community/base64url-js. Submit all fixes on
4
+ * that repo!
5
+ */
6
+
7
+ import { Uint8Array_ } from './webauthn.dom'
8
+
9
+ /**
10
+ * An array of characters that encode 6 bits into a Base64-URL alphabet
11
+ * character.
12
+ */
13
+ const TO_BASE64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'.split('')
14
+
15
+ /**
16
+ * An array of characters that can appear in a Base64-URL encoded string but
17
+ * should be ignored.
18
+ */
19
+ const IGNORE_BASE64URL = ' \t\n\r='.split('')
20
+
21
+ /**
22
+ * An array of 128 numbers that map a Base64-URL character to 6 bits, or if -2
23
+ * used to skip the character, or if -1 used to error out.
24
+ */
25
+ const FROM_BASE64URL = (() => {
26
+ const charMap: number[] = new Array(128)
27
+
28
+ for (let i = 0; i < charMap.length; i += 1) {
29
+ charMap[i] = -1
30
+ }
31
+
32
+ for (let i = 0; i < IGNORE_BASE64URL.length; i += 1) {
33
+ charMap[IGNORE_BASE64URL[i].charCodeAt(0)] = -2
34
+ }
35
+
36
+ for (let i = 0; i < TO_BASE64URL.length; i += 1) {
37
+ charMap[TO_BASE64URL[i].charCodeAt(0)] = i
38
+ }
39
+
40
+ return charMap
41
+ })()
42
+
43
+ /**
44
+ * Converts a byte to a Base64-URL string.
45
+ *
46
+ * @param byte The byte to convert, or null to flush at the end of the byte sequence.
47
+ * @param state The Base64 conversion state. Pass an initial value of `{ queue: 0, queuedBits: 0 }`.
48
+ * @param emit A function called with the next Base64 character when ready.
49
+ */
50
+ export function byteToBase64URL(
51
+ byte: number | null,
52
+ state: { queue: number; queuedBits: number },
53
+ emit: (char: string) => void
54
+ ) {
55
+ if (byte !== null) {
56
+ state.queue = (state.queue << 8) | byte
57
+ state.queuedBits += 8
58
+
59
+ while (state.queuedBits >= 6) {
60
+ const pos = (state.queue >> (state.queuedBits - 6)) & 63
61
+ emit(TO_BASE64URL[pos])
62
+ state.queuedBits -= 6
63
+ }
64
+ } else if (state.queuedBits > 0) {
65
+ state.queue = state.queue << (6 - state.queuedBits)
66
+ state.queuedBits = 6
67
+
68
+ while (state.queuedBits >= 6) {
69
+ const pos = (state.queue >> (state.queuedBits - 6)) & 63
70
+ emit(TO_BASE64URL[pos])
71
+ state.queuedBits -= 6
72
+ }
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Converts a String char code (extracted using `string.charCodeAt(position)`) to a sequence of Base64-URL characters.
78
+ *
79
+ * @param charCode The char code of the JavaScript string.
80
+ * @param state The Base64 state. Pass an initial value of `{ queue: 0, queuedBits: 0 }`.
81
+ * @param emit A function called with the next byte.
82
+ */
83
+ export function byteFromBase64URL(
84
+ charCode: number,
85
+ state: { queue: number; queuedBits: number },
86
+ emit: (byte: number) => void
87
+ ) {
88
+ const bits = FROM_BASE64URL[charCode]
89
+
90
+ if (bits > -1) {
91
+ // valid Base64-URL character
92
+ state.queue = (state.queue << 6) | bits
93
+ state.queuedBits += 6
94
+
95
+ while (state.queuedBits >= 8) {
96
+ emit((state.queue >> (state.queuedBits - 8)) & 0xff)
97
+ state.queuedBits -= 8
98
+ }
99
+ } else if (bits === -2) {
100
+ // ignore spaces, tabs, newlines, =
101
+ return
102
+ } else {
103
+ throw new Error(`Invalid Base64-URL character "${String.fromCharCode(charCode)}"`)
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Converts a JavaScript string (which may include any valid character) into a
109
+ * Base64-URL encoded string. The string is first encoded in UTF-8 which is
110
+ * then encoded as Base64-URL.
111
+ *
112
+ * @param str The string to convert.
113
+ */
114
+ export function stringToBase64URL(str: string) {
115
+ const base64: string[] = []
116
+
117
+ const emitter = (char: string) => {
118
+ base64.push(char)
119
+ }
120
+
121
+ const state = { queue: 0, queuedBits: 0 }
122
+
123
+ stringToUTF8(str, (byte: number) => {
124
+ byteToBase64URL(byte, state, emitter)
125
+ })
126
+
127
+ byteToBase64URL(null, state, emitter)
128
+
129
+ return base64.join('')
130
+ }
131
+
132
+ /**
133
+ * Converts a Base64-URL encoded string into a JavaScript string. It is assumed
134
+ * that the underlying string has been encoded as UTF-8.
135
+ *
136
+ * @param str The Base64-URL encoded string.
137
+ */
138
+ export function stringFromBase64URL(str: string) {
139
+ const conv: string[] = []
140
+
141
+ const utf8Emit = (codepoint: number) => {
142
+ conv.push(String.fromCodePoint(codepoint))
143
+ }
144
+
145
+ const utf8State = {
146
+ utf8seq: 0,
147
+ codepoint: 0,
148
+ }
149
+
150
+ const b64State = { queue: 0, queuedBits: 0 }
151
+
152
+ const byteEmit = (byte: number) => {
153
+ stringFromUTF8(byte, utf8State, utf8Emit)
154
+ }
155
+
156
+ for (let i = 0; i < str.length; i += 1) {
157
+ byteFromBase64URL(str.charCodeAt(i), b64State, byteEmit)
158
+ }
159
+
160
+ return conv.join('')
161
+ }
162
+
163
+ /**
164
+ * Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
165
+ *
166
+ * @param codepoint The Unicode codepoint.
167
+ * @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
168
+ */
169
+ export function codepointToUTF8(codepoint: number, emit: (byte: number) => void) {
170
+ if (codepoint <= 0x7f) {
171
+ emit(codepoint)
172
+ return
173
+ } else if (codepoint <= 0x7ff) {
174
+ emit(0xc0 | (codepoint >> 6))
175
+ emit(0x80 | (codepoint & 0x3f))
176
+ return
177
+ } else if (codepoint <= 0xffff) {
178
+ emit(0xe0 | (codepoint >> 12))
179
+ emit(0x80 | ((codepoint >> 6) & 0x3f))
180
+ emit(0x80 | (codepoint & 0x3f))
181
+ return
182
+ } else if (codepoint <= 0x10ffff) {
183
+ emit(0xf0 | (codepoint >> 18))
184
+ emit(0x80 | ((codepoint >> 12) & 0x3f))
185
+ emit(0x80 | ((codepoint >> 6) & 0x3f))
186
+ emit(0x80 | (codepoint & 0x3f))
187
+ return
188
+ }
189
+
190
+ throw new Error(`Unrecognized Unicode codepoint: ${codepoint.toString(16)}`)
191
+ }
192
+
193
+ /**
194
+ * Converts a JavaScript string to a sequence of UTF-8 bytes.
195
+ *
196
+ * @param str The string to convert to UTF-8.
197
+ * @param emit Function which will be called for each UTF-8 byte of the string.
198
+ */
199
+ export function stringToUTF8(str: string, emit: (byte: number) => void) {
200
+ for (let i = 0; i < str.length; i += 1) {
201
+ let codepoint = str.charCodeAt(i)
202
+
203
+ if (codepoint > 0xd7ff && codepoint <= 0xdbff) {
204
+ // most UTF-16 codepoints are Unicode codepoints, except values in this
205
+ // range where the next UTF-16 codepoint needs to be combined with the
206
+ // current one to get the Unicode codepoint
207
+ const highSurrogate = ((codepoint - 0xd800) * 0x400) & 0xffff
208
+ const lowSurrogate = (str.charCodeAt(i + 1) - 0xdc00) & 0xffff
209
+ codepoint = (lowSurrogate | highSurrogate) + 0x10000
210
+ i += 1
211
+ }
212
+
213
+ codepointToUTF8(codepoint, emit)
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Converts a UTF-8 byte to a Unicode codepoint.
219
+ *
220
+ * @param byte The UTF-8 byte next in the sequence.
221
+ * @param state The shared state between consecutive UTF-8 bytes in the
222
+ * sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
223
+ * @param emit Function which will be called for each codepoint.
224
+ */
225
+ export function stringFromUTF8(
226
+ byte: number,
227
+ state: { utf8seq: number; codepoint: number },
228
+ emit: (codepoint: number) => void
229
+ ) {
230
+ if (state.utf8seq === 0) {
231
+ if (byte <= 0x7f) {
232
+ emit(byte)
233
+ return
234
+ }
235
+
236
+ // count the number of 1 leading bits until you reach 0
237
+ for (let leadingBit = 1; leadingBit < 6; leadingBit += 1) {
238
+ if (((byte >> (7 - leadingBit)) & 1) === 0) {
239
+ state.utf8seq = leadingBit
240
+ break
241
+ }
242
+ }
243
+
244
+ if (state.utf8seq === 2) {
245
+ state.codepoint = byte & 31
246
+ } else if (state.utf8seq === 3) {
247
+ state.codepoint = byte & 15
248
+ } else if (state.utf8seq === 4) {
249
+ state.codepoint = byte & 7
250
+ } else {
251
+ throw new Error('Invalid UTF-8 sequence')
252
+ }
253
+
254
+ state.utf8seq -= 1
255
+ } else if (state.utf8seq > 0) {
256
+ if (byte <= 0x7f) {
257
+ throw new Error('Invalid UTF-8 sequence')
258
+ }
259
+
260
+ state.codepoint = (state.codepoint << 6) | (byte & 63)
261
+ state.utf8seq -= 1
262
+
263
+ if (state.utf8seq === 0) {
264
+ emit(state.codepoint)
265
+ }
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Helper functions to convert different types of strings to Uint8Array
271
+ */
272
+
273
+ export function base64UrlToUint8Array(str: string): Uint8Array_ {
274
+ const result: number[] = []
275
+ const state = { queue: 0, queuedBits: 0 }
276
+
277
+ const onByte = (byte: number) => {
278
+ result.push(byte)
279
+ }
280
+
281
+ for (let i = 0; i < str.length; i += 1) {
282
+ byteFromBase64URL(str.charCodeAt(i), state, onByte)
283
+ }
284
+
285
+ return new Uint8Array(result)
286
+ }
287
+
288
+ export function stringToUint8Array(str: string): Uint8Array_ {
289
+ const result: number[] = []
290
+ stringToUTF8(str, (byte: number) => result.push(byte))
291
+ return new Uint8Array(result)
292
+ }
293
+
294
+ export function bytesToBase64URL(bytes: Uint8Array) {
295
+ const result: string[] = []
296
+ const state = { queue: 0, queuedBits: 0 }
297
+
298
+ const onChar = (char: string) => {
299
+ result.push(char)
300
+ }
301
+
302
+ bytes.forEach((byte) => byteToBase64URL(byte, state, onChar))
303
+
304
+ // always call with `null` after processing all bytes
305
+ byteToBase64URL(null, state, onChar)
306
+
307
+ return result.join('')
308
+ }
@@ -0,0 +1,34 @@
1
+ import { version } from './version'
2
+
3
+ /** Current session will be checked for refresh at this interval. */
4
+ export const AUTO_REFRESH_TICK_DURATION_MS = 30 * 1000
5
+
6
+ /**
7
+ * A token refresh will be attempted this many ticks before the current session expires. */
8
+ export const AUTO_REFRESH_TICK_THRESHOLD = 3
9
+
10
+ /*
11
+ * Earliest time before an access token expires that the session should be refreshed.
12
+ */
13
+ export const EXPIRY_MARGIN_MS = AUTO_REFRESH_TICK_THRESHOLD * AUTO_REFRESH_TICK_DURATION_MS
14
+
15
+ export const GOTRUE_URL = 'http://localhost:9999'
16
+ export const STORAGE_KEY = 'supabase.auth.token'
17
+ export const AUDIENCE = ''
18
+ export const DEFAULT_HEADERS = { 'X-Client-Info': `gotrue-js/${version}` }
19
+ export const NETWORK_FAILURE = {
20
+ MAX_RETRIES: 10,
21
+ RETRY_INTERVAL: 2, // in deciseconds
22
+ }
23
+
24
+ export const API_VERSION_HEADER_NAME = 'X-Supabase-Api-Version'
25
+ export const API_VERSIONS = {
26
+ '2024-01-01': {
27
+ timestamp: Date.parse('2024-01-01T00:00:00.0Z'),
28
+ name: '2024-01-01',
29
+ },
30
+ }
31
+
32
+ export const BASE64URL_REGEX = /^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i
33
+
34
+ export const JWKS_TTL = 10 * 60 * 1000 // 10 minutes
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Known error codes. Note that the server may also return other error codes
3
+ * not included in this list (if the SDK is older than the version
4
+ * on the server).
5
+ */
6
+ export type ErrorCode =
7
+ | 'unexpected_failure'
8
+ | 'validation_failed'
9
+ | 'bad_json'
10
+ | 'email_exists'
11
+ | 'phone_exists'
12
+ | 'bad_jwt'
13
+ | 'not_admin'
14
+ | 'no_authorization'
15
+ | 'user_not_found'
16
+ | 'session_not_found'
17
+ | 'session_expired'
18
+ | 'refresh_token_not_found'
19
+ | 'refresh_token_already_used'
20
+ | 'flow_state_not_found'
21
+ | 'flow_state_expired'
22
+ | 'signup_disabled'
23
+ | 'user_banned'
24
+ | 'provider_email_needs_verification'
25
+ | 'invite_not_found'
26
+ | 'bad_oauth_state'
27
+ | 'bad_oauth_callback'
28
+ | 'oauth_provider_not_supported'
29
+ | 'unexpected_audience'
30
+ | 'single_identity_not_deletable'
31
+ | 'email_conflict_identity_not_deletable'
32
+ | 'identity_already_exists'
33
+ | 'email_provider_disabled'
34
+ | 'phone_provider_disabled'
35
+ | 'too_many_enrolled_mfa_factors'
36
+ | 'mfa_factor_name_conflict'
37
+ | 'mfa_factor_not_found'
38
+ | 'mfa_ip_address_mismatch'
39
+ | 'mfa_challenge_expired'
40
+ | 'mfa_verification_failed'
41
+ | 'mfa_verification_rejected'
42
+ | 'insufficient_aal'
43
+ | 'captcha_failed'
44
+ | 'saml_provider_disabled'
45
+ | 'manual_linking_disabled'
46
+ | 'sms_send_failed'
47
+ | 'email_not_confirmed'
48
+ | 'phone_not_confirmed'
49
+ | 'reauth_nonce_missing'
50
+ | 'saml_relay_state_not_found'
51
+ | 'saml_relay_state_expired'
52
+ | 'saml_idp_not_found'
53
+ | 'saml_assertion_no_user_id'
54
+ | 'saml_assertion_no_email'
55
+ | 'user_already_exists'
56
+ | 'sso_provider_not_found'
57
+ | 'saml_metadata_fetch_failed'
58
+ | 'saml_idp_already_exists'
59
+ | 'sso_domain_already_exists'
60
+ | 'saml_entity_id_mismatch'
61
+ | 'conflict'
62
+ | 'provider_disabled'
63
+ | 'user_sso_managed'
64
+ | 'reauthentication_needed'
65
+ | 'same_password'
66
+ | 'reauthentication_not_valid'
67
+ | 'otp_expired'
68
+ | 'otp_disabled'
69
+ | 'identity_not_found'
70
+ | 'weak_password'
71
+ | 'over_request_rate_limit'
72
+ | 'over_email_send_rate_limit'
73
+ | 'over_sms_send_rate_limit'
74
+ | 'bad_code_verifier'
75
+ | 'anonymous_provider_disabled'
76
+ | 'hook_timeout'
77
+ | 'hook_timeout_after_retry'
78
+ | 'hook_payload_over_size_limit'
79
+ | 'hook_payload_invalid_content_type'
80
+ | 'request_timeout'
81
+ | 'mfa_phone_enroll_not_enabled'
82
+ | 'mfa_phone_verify_not_enabled'
83
+ | 'mfa_totp_enroll_not_enabled'
84
+ | 'mfa_totp_verify_not_enabled'
85
+ | 'mfa_webauthn_enroll_not_enabled'
86
+ | 'mfa_webauthn_verify_not_enabled'
87
+ | 'mfa_verified_factor_exists'
88
+ | 'invalid_credentials'
89
+ | 'email_address_not_authorized'
90
+ | 'email_address_invalid'