@supatype/client 0.1.0-alpha.6
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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +7 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/dist/auth.d.ts +243 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +560 -0
- package/dist/auth.js.map +1 -0
- package/dist/error-codes-doc.d.ts +31 -0
- package/dist/error-codes-doc.d.ts.map +1 -0
- package/dist/error-codes-doc.js +294 -0
- package/dist/error-codes-doc.js.map +1 -0
- package/dist/errors.d.ts +197 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +162 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetch-with-retry.d.ts +49 -0
- package/dist/fetch-with-retry.d.ts.map +1 -0
- package/dist/fetch-with-retry.js +150 -0
- package/dist/fetch-with-retry.js.map +1 -0
- package/dist/index.d.ts +137 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +225 -0
- package/dist/index.js.map +1 -0
- package/dist/query.d.ts +53 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +216 -0
- package/dist/query.js.map +1 -0
- package/dist/realtime.d.ts +69 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +279 -0
- package/dist/realtime.js.map +1 -0
- package/dist/retry.d.ts +24 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +25 -0
- package/dist/retry.js.map +1 -0
- package/dist/serverless-docs.d.ts +38 -0
- package/dist/serverless-docs.d.ts.map +1 -0
- package/dist/serverless-docs.js +83 -0
- package/dist/serverless-docs.js.map +1 -0
- package/dist/storage.d.ts +79 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +130 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +26 -0
- package/src/auth.ts +713 -0
- package/src/error-codes-doc.ts +315 -0
- package/src/errors.ts +201 -0
- package/src/fetch-with-retry.ts +200 -0
- package/src/index.ts +418 -0
- package/src/query.ts +280 -0
- package/src/realtime.ts +418 -0
- package/src/retry.ts +35 -0
- package/src/serverless-docs.ts +107 -0
- package/src/storage.ts +182 -0
- package/src/types.ts +184 -0
- package/tests/auth.test.ts +282 -0
- package/tests/mfa-totp-integration.test.ts +359 -0
- package/tests/query.test.ts +286 -0
- package/tests/rate-limit-integration.test.ts +185 -0
- package/tests/realtime-multi-tenant-integration.test.ts +372 -0
- package/tests/retry-integration.test.ts +212 -0
- package/tests/serverless.test.ts +115 -0
- package/tests/storage-quota-integration.test.ts +189 -0
- package/tests/storage-upload-limit-integration.test.ts +185 -0
- package/tests/types.test.ts +123 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/auth.js
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
export class AuthClient {
|
|
2
|
+
url;
|
|
3
|
+
baseHeaders;
|
|
4
|
+
currentSession = null;
|
|
5
|
+
listeners = new Map();
|
|
6
|
+
listenerIdCounter = 0;
|
|
7
|
+
constructor(url, baseHeaders) {
|
|
8
|
+
this.url = url;
|
|
9
|
+
this.baseHeaders = baseHeaders;
|
|
10
|
+
}
|
|
11
|
+
async signUp(credentials) {
|
|
12
|
+
const body = {
|
|
13
|
+
email: credentials.email,
|
|
14
|
+
password: credentials.password,
|
|
15
|
+
};
|
|
16
|
+
if (credentials.options?.data !== undefined) {
|
|
17
|
+
body["data"] = credentials.options.data;
|
|
18
|
+
}
|
|
19
|
+
const res = await fetch(`${this.url}/signup`, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: this.baseHeaders,
|
|
22
|
+
body: JSON.stringify(body),
|
|
23
|
+
});
|
|
24
|
+
return this._parseAuthResponse(res);
|
|
25
|
+
}
|
|
26
|
+
async signInWithPassword(credentials) {
|
|
27
|
+
const res = await fetch(`${this.url}/token?grant_type=password`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: this.baseHeaders,
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
email: credentials.email,
|
|
32
|
+
password: credentials.password,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return this._parseAuthResponse(res);
|
|
36
|
+
}
|
|
37
|
+
async signInWithOAuth(opts) {
|
|
38
|
+
const url = new URL(`${this.url}/authorize`);
|
|
39
|
+
url.searchParams.set("provider", opts.provider);
|
|
40
|
+
if (opts.options?.redirectTo !== undefined) {
|
|
41
|
+
url.searchParams.set("redirect_to", opts.options.redirectTo);
|
|
42
|
+
}
|
|
43
|
+
return { data: { url: url.toString(), provider: opts.provider }, error: null };
|
|
44
|
+
}
|
|
45
|
+
async signInWithOtp(opts) {
|
|
46
|
+
const body = {
|
|
47
|
+
create_user: opts.options?.createUser ?? true,
|
|
48
|
+
};
|
|
49
|
+
if (opts.email !== undefined) {
|
|
50
|
+
body["email"] = opts.email;
|
|
51
|
+
}
|
|
52
|
+
if (opts.phone !== undefined) {
|
|
53
|
+
body["phone"] = opts.phone;
|
|
54
|
+
if (opts.options?.channel !== undefined) {
|
|
55
|
+
body["channel"] = opts.options.channel;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const res = await fetch(`${this.url}/otp`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: this.baseHeaders,
|
|
61
|
+
body: JSON.stringify(body),
|
|
62
|
+
});
|
|
63
|
+
if (res.ok) {
|
|
64
|
+
const json = await res.json().catch(() => ({}));
|
|
65
|
+
return {
|
|
66
|
+
data: {
|
|
67
|
+
...(json["message_id"] !== undefined && { messageId: String(json["message_id"]) }),
|
|
68
|
+
},
|
|
69
|
+
error: null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const err = await res.json().catch(() => ({}));
|
|
73
|
+
return {
|
|
74
|
+
data: {},
|
|
75
|
+
error: {
|
|
76
|
+
message: String(err["error_description"] ?? err["msg"] ?? "Error"),
|
|
77
|
+
status: res.status,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async signOut() {
|
|
82
|
+
if (this.currentSession !== null) {
|
|
83
|
+
await fetch(`${this.url}/logout`, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
...this.baseHeaders,
|
|
87
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
88
|
+
},
|
|
89
|
+
}).catch(() => undefined);
|
|
90
|
+
}
|
|
91
|
+
this._setSession(null);
|
|
92
|
+
return { error: null };
|
|
93
|
+
}
|
|
94
|
+
async getSession() {
|
|
95
|
+
return { data: { session: this.currentSession }, error: null };
|
|
96
|
+
}
|
|
97
|
+
async getUser() {
|
|
98
|
+
if (this.currentSession === null) {
|
|
99
|
+
return { data: { user: null }, error: null };
|
|
100
|
+
}
|
|
101
|
+
const res = await fetch(`${this.url}/user`, {
|
|
102
|
+
headers: {
|
|
103
|
+
...this.baseHeaders,
|
|
104
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
if (!res.ok) {
|
|
108
|
+
return {
|
|
109
|
+
data: { user: null },
|
|
110
|
+
error: { message: "Could not get user", status: res.status },
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const raw = await res.json();
|
|
114
|
+
return { data: { user: this._parseUser(raw) }, error: null };
|
|
115
|
+
}
|
|
116
|
+
async refreshSession() {
|
|
117
|
+
if (this.currentSession === null) {
|
|
118
|
+
return { data: { session: null }, error: { message: "No active session" } };
|
|
119
|
+
}
|
|
120
|
+
const res = await fetch(`${this.url}/token?grant_type=refresh_token`, {
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: this.baseHeaders,
|
|
123
|
+
body: JSON.stringify({ refresh_token: this.currentSession.refreshToken }),
|
|
124
|
+
});
|
|
125
|
+
const result = await this._parseAuthResponse(res);
|
|
126
|
+
return { data: { session: result.data.session }, error: result.error };
|
|
127
|
+
}
|
|
128
|
+
async resetPasswordForEmail(email, options) {
|
|
129
|
+
const body = { email };
|
|
130
|
+
if (options?.redirectTo !== undefined) {
|
|
131
|
+
body["redirect_to"] = options.redirectTo;
|
|
132
|
+
}
|
|
133
|
+
const res = await fetch(`${this.url}/recover`, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: this.baseHeaders,
|
|
136
|
+
body: JSON.stringify(body),
|
|
137
|
+
});
|
|
138
|
+
if (res.ok)
|
|
139
|
+
return { data: {}, error: null };
|
|
140
|
+
const err = await res.json().catch(() => ({}));
|
|
141
|
+
return {
|
|
142
|
+
data: {},
|
|
143
|
+
error: {
|
|
144
|
+
message: String(err["error_description"] ?? err["msg"] ?? "Error"),
|
|
145
|
+
status: res.status,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async updateUser(updates) {
|
|
150
|
+
if (this.currentSession === null) {
|
|
151
|
+
return { data: { user: null }, error: { message: "Not authenticated" } };
|
|
152
|
+
}
|
|
153
|
+
const res = await fetch(`${this.url}/user`, {
|
|
154
|
+
method: "PUT",
|
|
155
|
+
headers: {
|
|
156
|
+
...this.baseHeaders,
|
|
157
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
158
|
+
},
|
|
159
|
+
body: JSON.stringify(updates),
|
|
160
|
+
});
|
|
161
|
+
if (!res.ok) {
|
|
162
|
+
const err = await res.json().catch(() => ({}));
|
|
163
|
+
return {
|
|
164
|
+
data: { user: null },
|
|
165
|
+
error: {
|
|
166
|
+
message: String(err["error_description"] ?? err["msg"] ?? "Error"),
|
|
167
|
+
status: res.status,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const raw = await res.json();
|
|
172
|
+
return { data: { user: this._parseUser(raw) }, error: null };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Verify an OTP token received via email or phone.
|
|
176
|
+
* Completes email confirmation, magic link, recovery, or phone OTP flows.
|
|
177
|
+
*/
|
|
178
|
+
async verifyOtp(params) {
|
|
179
|
+
const body = {
|
|
180
|
+
type: params.type,
|
|
181
|
+
};
|
|
182
|
+
if (params.tokenHash !== undefined) {
|
|
183
|
+
body["token_hash"] = params.tokenHash;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
body["token"] = params.token;
|
|
187
|
+
if (params.email !== undefined)
|
|
188
|
+
body["email"] = params.email;
|
|
189
|
+
if (params.phone !== undefined)
|
|
190
|
+
body["phone"] = params.phone;
|
|
191
|
+
}
|
|
192
|
+
const res = await fetch(`${this.url}/verify`, {
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: this.baseHeaders,
|
|
195
|
+
body: JSON.stringify(body),
|
|
196
|
+
});
|
|
197
|
+
return this._parseAuthResponse(res);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Sign in with an ID token from an external provider (e.g. Google One Tap).
|
|
201
|
+
* Uses the token grant with id_token grant type.
|
|
202
|
+
*/
|
|
203
|
+
async signInWithIdToken(credentials) {
|
|
204
|
+
const body = {
|
|
205
|
+
provider: credentials.provider,
|
|
206
|
+
id_token: credentials.token,
|
|
207
|
+
};
|
|
208
|
+
if (credentials.nonce !== undefined) {
|
|
209
|
+
body["nonce"] = credentials.nonce;
|
|
210
|
+
}
|
|
211
|
+
const res = await fetch(`${this.url}/token?grant_type=id_token`, {
|
|
212
|
+
method: "POST",
|
|
213
|
+
headers: this.baseHeaders,
|
|
214
|
+
body: JSON.stringify(body),
|
|
215
|
+
});
|
|
216
|
+
return this._parseAuthResponse(res);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Resend an OTP or confirmation email/SMS.
|
|
220
|
+
*/
|
|
221
|
+
async resend(params) {
|
|
222
|
+
const body = { type: params.type };
|
|
223
|
+
if (params.email !== undefined)
|
|
224
|
+
body["email"] = params.email;
|
|
225
|
+
if (params.phone !== undefined)
|
|
226
|
+
body["phone"] = params.phone;
|
|
227
|
+
const res = await fetch(`${this.url}/resend`, {
|
|
228
|
+
method: "POST",
|
|
229
|
+
headers: this.baseHeaders,
|
|
230
|
+
body: JSON.stringify(body),
|
|
231
|
+
});
|
|
232
|
+
if (res.ok) {
|
|
233
|
+
const json = await res.json().catch(() => ({}));
|
|
234
|
+
return {
|
|
235
|
+
data: {
|
|
236
|
+
...(json["message_id"] !== undefined && { messageId: String(json["message_id"]) }),
|
|
237
|
+
},
|
|
238
|
+
error: null,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const err = await res.json().catch(() => ({}));
|
|
242
|
+
return {
|
|
243
|
+
data: {},
|
|
244
|
+
error: {
|
|
245
|
+
message: String(err["error_description"] ?? err["msg"] ?? "Error"),
|
|
246
|
+
status: res.status,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
// ─── MFA ──────────────────────────────────────────────────────────────────────
|
|
251
|
+
/**
|
|
252
|
+
* Multi-Factor Authentication namespace.
|
|
253
|
+
* Provides methods for enrolling, challenging, and verifying MFA factors.
|
|
254
|
+
*/
|
|
255
|
+
get mfa() {
|
|
256
|
+
return {
|
|
257
|
+
/**
|
|
258
|
+
* Enroll a new MFA factor (TOTP or Phone).
|
|
259
|
+
* Returns the factor ID and, for TOTP, the QR code and secret.
|
|
260
|
+
*/
|
|
261
|
+
enroll: async (params) => {
|
|
262
|
+
if (this.currentSession === null) {
|
|
263
|
+
return { data: null, error: { message: "Not authenticated" } };
|
|
264
|
+
}
|
|
265
|
+
const body = {
|
|
266
|
+
factor_type: params.factorType,
|
|
267
|
+
};
|
|
268
|
+
if (params.friendlyName !== undefined)
|
|
269
|
+
body["friendly_name"] = params.friendlyName;
|
|
270
|
+
if (params.issuer !== undefined)
|
|
271
|
+
body["issuer"] = params.issuer;
|
|
272
|
+
if (params.phone !== undefined)
|
|
273
|
+
body["phone"] = params.phone;
|
|
274
|
+
const res = await fetch(`${this.url}/factors`, {
|
|
275
|
+
method: "POST",
|
|
276
|
+
headers: {
|
|
277
|
+
...this.baseHeaders,
|
|
278
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
279
|
+
},
|
|
280
|
+
body: JSON.stringify(body),
|
|
281
|
+
});
|
|
282
|
+
if (!res.ok) {
|
|
283
|
+
return { data: null, error: await this._parseError(res) };
|
|
284
|
+
}
|
|
285
|
+
const json = await res.json();
|
|
286
|
+
const data = {
|
|
287
|
+
id: String(json["id"] ?? ""),
|
|
288
|
+
type: String(json["type"] ?? ""),
|
|
289
|
+
friendlyName: String(json["friendly_name"] ?? ""),
|
|
290
|
+
...(json["totp"] !== undefined && {
|
|
291
|
+
totp: {
|
|
292
|
+
qrCode: String(json["totp"]["qr_code"] ?? ""),
|
|
293
|
+
secret: String(json["totp"]["secret"] ?? ""),
|
|
294
|
+
uri: String(json["totp"]["uri"] ?? ""),
|
|
295
|
+
},
|
|
296
|
+
}),
|
|
297
|
+
...(json["phone"] !== undefined && { phone: String(json["phone"]) }),
|
|
298
|
+
};
|
|
299
|
+
return { data, error: null };
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* Create a challenge for an enrolled MFA factor.
|
|
303
|
+
* For TOTP, this simply creates a challenge ID. For Phone, it sends an SMS.
|
|
304
|
+
*/
|
|
305
|
+
challenge: async (params) => {
|
|
306
|
+
if (this.currentSession === null) {
|
|
307
|
+
return { data: null, error: { message: "Not authenticated" } };
|
|
308
|
+
}
|
|
309
|
+
const body = {};
|
|
310
|
+
if (params.channel !== undefined)
|
|
311
|
+
body["channel"] = params.channel;
|
|
312
|
+
const res = await fetch(`${this.url}/factors/${params.factorId}/challenge`, {
|
|
313
|
+
method: "POST",
|
|
314
|
+
headers: {
|
|
315
|
+
...this.baseHeaders,
|
|
316
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
317
|
+
},
|
|
318
|
+
body: JSON.stringify(body),
|
|
319
|
+
});
|
|
320
|
+
if (!res.ok) {
|
|
321
|
+
return { data: null, error: await this._parseError(res) };
|
|
322
|
+
}
|
|
323
|
+
const json = await res.json();
|
|
324
|
+
return {
|
|
325
|
+
data: {
|
|
326
|
+
id: String(json["id"] ?? ""),
|
|
327
|
+
type: String(json["type"] ?? ""),
|
|
328
|
+
expiresAt: Number(json["expires_at"] ?? 0),
|
|
329
|
+
},
|
|
330
|
+
error: null,
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
/**
|
|
334
|
+
* Verify an MFA challenge with a TOTP code or phone OTP.
|
|
335
|
+
* On success, elevates the session to AAL2 and returns new tokens.
|
|
336
|
+
*/
|
|
337
|
+
verify: async (params) => {
|
|
338
|
+
if (this.currentSession === null) {
|
|
339
|
+
return {
|
|
340
|
+
data: { session: null, user: null },
|
|
341
|
+
error: { message: "Not authenticated" },
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const res = await fetch(`${this.url}/factors/${params.factorId}/verify`, {
|
|
345
|
+
method: "POST",
|
|
346
|
+
headers: {
|
|
347
|
+
...this.baseHeaders,
|
|
348
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
349
|
+
},
|
|
350
|
+
body: JSON.stringify({
|
|
351
|
+
challenge_id: params.challengeId,
|
|
352
|
+
code: params.code,
|
|
353
|
+
}),
|
|
354
|
+
});
|
|
355
|
+
const result = await this._parseAuthResponse(res);
|
|
356
|
+
if (result.data.session !== null) {
|
|
357
|
+
this._emitEvent("MFA_CHALLENGE_VERIFIED", result.data.session);
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
},
|
|
361
|
+
/**
|
|
362
|
+
* Convenience method: create a challenge and immediately verify it.
|
|
363
|
+
*/
|
|
364
|
+
challengeAndVerify: async (params) => {
|
|
365
|
+
const challengeResult = await this.mfa.challenge({
|
|
366
|
+
factorId: params.factorId,
|
|
367
|
+
});
|
|
368
|
+
if (challengeResult.error !== null || challengeResult.data === null) {
|
|
369
|
+
return {
|
|
370
|
+
data: { session: null, user: null },
|
|
371
|
+
error: challengeResult.error,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return this.mfa.verify({
|
|
375
|
+
factorId: params.factorId,
|
|
376
|
+
challengeId: challengeResult.data.id,
|
|
377
|
+
code: params.code,
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
/**
|
|
381
|
+
* Unenroll (remove) an MFA factor. Requires AAL2 for verified factors.
|
|
382
|
+
*/
|
|
383
|
+
unenroll: async (params) => {
|
|
384
|
+
if (this.currentSession === null) {
|
|
385
|
+
return { data: null, error: { message: "Not authenticated" } };
|
|
386
|
+
}
|
|
387
|
+
const res = await fetch(`${this.url}/factors/${params.factorId}`, {
|
|
388
|
+
method: "DELETE",
|
|
389
|
+
headers: {
|
|
390
|
+
...this.baseHeaders,
|
|
391
|
+
Authorization: `Bearer ${this.currentSession.accessToken}`,
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
if (!res.ok) {
|
|
395
|
+
return { data: null, error: await this._parseError(res) };
|
|
396
|
+
}
|
|
397
|
+
const json = await res.json();
|
|
398
|
+
return { data: { id: String(json["id"] ?? "") }, error: null };
|
|
399
|
+
},
|
|
400
|
+
/**
|
|
401
|
+
* List the user's enrolled MFA factors, categorized by type.
|
|
402
|
+
*/
|
|
403
|
+
listFactors: async () => {
|
|
404
|
+
const userResult = await this.getUser();
|
|
405
|
+
if (userResult.error !== null || userResult.data.user === null) {
|
|
406
|
+
return { data: null, error: userResult.error ?? { message: "Could not get user" } };
|
|
407
|
+
}
|
|
408
|
+
const allFactors = userResult.data.user.factors ?? [];
|
|
409
|
+
const verifiedFactors = allFactors.filter((f) => f.status === "verified");
|
|
410
|
+
return {
|
|
411
|
+
data: {
|
|
412
|
+
all: allFactors,
|
|
413
|
+
totp: verifiedFactors.filter((f) => f.factorType === "totp"),
|
|
414
|
+
phone: verifiedFactors.filter((f) => f.factorType === "phone"),
|
|
415
|
+
},
|
|
416
|
+
error: null,
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
/**
|
|
420
|
+
* Returns the current Authenticator Assurance Level (AAL) for the session.
|
|
421
|
+
* aal1 = password/otp only; aal2 = MFA verified.
|
|
422
|
+
*/
|
|
423
|
+
getAuthenticatorAssuranceLevel: async () => {
|
|
424
|
+
if (this.currentSession === null) {
|
|
425
|
+
return { data: null, error: { message: "Not authenticated" } };
|
|
426
|
+
}
|
|
427
|
+
// Decode the JWT payload to read the aal and amr claims
|
|
428
|
+
const parts = this.currentSession.accessToken.split(".");
|
|
429
|
+
if (parts.length !== 3) {
|
|
430
|
+
return { data: null, error: { message: "Invalid access token format" } };
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const payload = JSON.parse(atob(parts[1]));
|
|
434
|
+
const currentLevel = payload["aal"] ?? null;
|
|
435
|
+
const amr = payload["amr"] ?? [];
|
|
436
|
+
const methods = amr.map((entry) => entry.method);
|
|
437
|
+
// Determine next level: if user has verified factors, next could be aal2
|
|
438
|
+
const userResult = await this.getUser();
|
|
439
|
+
const factors = userResult.data?.user?.factors ?? [];
|
|
440
|
+
const hasVerifiedFactors = factors.some((f) => f.status === "verified");
|
|
441
|
+
const nextLevel = hasVerifiedFactors ? "aal2" : "aal1";
|
|
442
|
+
return {
|
|
443
|
+
data: {
|
|
444
|
+
currentLevel,
|
|
445
|
+
nextLevel: nextLevel,
|
|
446
|
+
currentAuthenticationMethods: methods,
|
|
447
|
+
},
|
|
448
|
+
error: null,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return { data: null, error: { message: "Failed to decode access token" } };
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
onAuthStateChange(callback) {
|
|
458
|
+
const id = String(++this.listenerIdCounter);
|
|
459
|
+
this.listeners.set(id, callback);
|
|
460
|
+
// Emit current state immediately
|
|
461
|
+
const event = this.currentSession !== null ? "SIGNED_IN" : "SIGNED_OUT";
|
|
462
|
+
callback(event, this.currentSession);
|
|
463
|
+
return {
|
|
464
|
+
data: {
|
|
465
|
+
subscription: {
|
|
466
|
+
unsubscribe: () => {
|
|
467
|
+
this.listeners.delete(id);
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
// ─── Internal ────────────────────────────────────────────────────────────────
|
|
474
|
+
_setSession(session) {
|
|
475
|
+
const prev = this.currentSession;
|
|
476
|
+
this.currentSession = session;
|
|
477
|
+
const event = session !== null
|
|
478
|
+
? prev !== null
|
|
479
|
+
? "TOKEN_REFRESHED"
|
|
480
|
+
: "SIGNED_IN"
|
|
481
|
+
: "SIGNED_OUT";
|
|
482
|
+
for (const cb of this.listeners.values()) {
|
|
483
|
+
cb(event, session);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
_emitEvent(event, session) {
|
|
487
|
+
for (const cb of this.listeners.values()) {
|
|
488
|
+
cb(event, session);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
async _parseError(res) {
|
|
492
|
+
const err = await res.json().catch(() => ({}));
|
|
493
|
+
return {
|
|
494
|
+
message: String(err["error_description"] ?? err["msg"] ?? err["message"] ?? "Error"),
|
|
495
|
+
status: res.status,
|
|
496
|
+
...(err["error_code"] !== undefined && { code: String(err["error_code"]) }),
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
async _parseAuthResponse(res) {
|
|
500
|
+
if (!res.ok) {
|
|
501
|
+
const err = await res.json().catch(() => ({ msg: "Unknown error" }));
|
|
502
|
+
return {
|
|
503
|
+
data: { session: null, user: null },
|
|
504
|
+
error: {
|
|
505
|
+
message: String(err["error_description"] ?? err["msg"] ?? "Error"),
|
|
506
|
+
status: res.status,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const json = await res.json();
|
|
511
|
+
const user = this._parseUser((json["user"] ?? {}));
|
|
512
|
+
const session = {
|
|
513
|
+
accessToken: String(json["access_token"] ?? ""),
|
|
514
|
+
tokenType: String(json["token_type"] ?? "bearer"),
|
|
515
|
+
expiresIn: Number(json["expires_in"] ?? 3600),
|
|
516
|
+
...(json["expires_at"] !== undefined && { expiresAt: Number(json["expires_at"]) }),
|
|
517
|
+
refreshToken: String(json["refresh_token"] ?? ""),
|
|
518
|
+
user,
|
|
519
|
+
};
|
|
520
|
+
this._setSession(session);
|
|
521
|
+
return { data: { session, user }, error: null };
|
|
522
|
+
}
|
|
523
|
+
_parseUser(raw) {
|
|
524
|
+
const user = {
|
|
525
|
+
id: String(raw["id"] ?? ""),
|
|
526
|
+
...(raw["email"] !== undefined && { email: String(raw["email"]) }),
|
|
527
|
+
...(raw["phone"] !== undefined && { phone: String(raw["phone"]) }),
|
|
528
|
+
...(raw["role"] !== undefined && { role: String(raw["role"]) }),
|
|
529
|
+
appMetadata: (raw["app_metadata"] ?? {}),
|
|
530
|
+
userMetadata: (raw["user_metadata"] ?? {}),
|
|
531
|
+
createdAt: String(raw["created_at"] ?? ""),
|
|
532
|
+
updatedAt: String(raw["updated_at"] ?? ""),
|
|
533
|
+
};
|
|
534
|
+
if (Array.isArray(raw["identities"])) {
|
|
535
|
+
user.identities = raw["identities"].map((i) => ({
|
|
536
|
+
id: String(i["id"] ?? ""),
|
|
537
|
+
userId: String(i["user_id"] ?? ""),
|
|
538
|
+
identityData: (i["identity_data"] ?? {}),
|
|
539
|
+
identityId: String(i["identity_id"] ?? ""),
|
|
540
|
+
provider: String(i["provider"] ?? ""),
|
|
541
|
+
createdAt: String(i["created_at"] ?? ""),
|
|
542
|
+
updatedAt: String(i["updated_at"] ?? ""),
|
|
543
|
+
...(i["last_sign_in_at"] !== undefined && { lastSignInAt: String(i["last_sign_in_at"]) }),
|
|
544
|
+
}));
|
|
545
|
+
}
|
|
546
|
+
if (Array.isArray(raw["factors"])) {
|
|
547
|
+
user.factors = raw["factors"].map((f) => ({
|
|
548
|
+
id: String(f["id"] ?? ""),
|
|
549
|
+
factorType: String(f["factor_type"] ?? "totp"),
|
|
550
|
+
status: String(f["status"] ?? "unverified"),
|
|
551
|
+
createdAt: String(f["created_at"] ?? ""),
|
|
552
|
+
updatedAt: String(f["updated_at"] ?? ""),
|
|
553
|
+
...(f["friendly_name"] !== undefined && { friendlyName: String(f["friendly_name"]) }),
|
|
554
|
+
...(f["phone"] !== undefined && { phone: String(f["phone"]) }),
|
|
555
|
+
}));
|
|
556
|
+
}
|
|
557
|
+
return user;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,UAAU;IACJ,GAAG,CAAQ;IACX,WAAW,CAAwB;IAC5C,cAAc,GAAmB,IAAI,CAAA;IAC5B,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAA;IACpD,iBAAiB,GAAG,CAAC,CAAA;IAE7B,YAAY,GAAW,EAAE,WAAmC;QAC1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAIZ;QAIC,MAAM,IAAI,GAA4B;YACpC,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,QAAQ,EAAE,WAAW,CAAC,QAAQ;SAC/B,CAAA;QACD,IAAI,WAAW,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAA;QACzC,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,EAAE;YAC5C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,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AAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,OAAO,GAAI,GAAG,CAAC,SAAS,CAA+B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,MAAM,CAAkC;gBAC/E,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,YAAY,CAA8B;gBACxE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;gBACxC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;gBACxC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;gBACrF,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;aAC/D,CAAC,CAAC,CAAA;QACL,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes documentation — Gap Appendices task 35
|
|
3
|
+
*
|
|
4
|
+
* Published list of all Supatype error codes with descriptions and suggested
|
|
5
|
+
* fixes. Accessible at docs.supatype.io/errors.
|
|
6
|
+
*
|
|
7
|
+
* Each SDK error includes a `helpUrl` field linking to the relevant section
|
|
8
|
+
* on the documentation page.
|
|
9
|
+
*/
|
|
10
|
+
export interface ErrorCodeEntry {
|
|
11
|
+
/** Machine-readable error code (e.g. "AUTH_INVALID_CREDENTIALS"). */
|
|
12
|
+
code: string;
|
|
13
|
+
/** Human-readable short description. */
|
|
14
|
+
description: string;
|
|
15
|
+
/** Suggested fix or resolution. */
|
|
16
|
+
suggestion: string;
|
|
17
|
+
/** HTTP status code typically associated with this error. */
|
|
18
|
+
httpStatus?: number | undefined;
|
|
19
|
+
/** Category grouping. */
|
|
20
|
+
category: "auth" | "postgrest" | "storage" | "realtime" | "network";
|
|
21
|
+
}
|
|
22
|
+
export declare const ERROR_CODES_DOCUMENTATION: readonly ErrorCodeEntry[];
|
|
23
|
+
/**
|
|
24
|
+
* Look up documentation for a specific error code.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getErrorDocumentation(code: string): ErrorCodeEntry | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get all error codes for a specific category.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getErrorCodesByCategory(category: ErrorCodeEntry["category"]): readonly ErrorCodeEntry[];
|
|
31
|
+
//# sourceMappingURL=error-codes-doc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes-doc.d.ts","sourceRoot":"","sources":["../src/error-codes-doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,yBAAyB;IACzB,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;CACpE;AAED,eAAO,MAAM,yBAAyB,EAAE,SAAS,cAAc,EAmRrD,CAAA;AAEV;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,GACnC,SAAS,cAAc,EAAE,CAE3B"}
|