@supatype/client 0.9.2 → 0.10.1
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 +1 -1
- package/.turbo/turbo-test.log +98 -75
- package/.turbo/turbo-typecheck.log +2 -2
- package/CHANGELOG.md +123 -20
- package/README.md +18 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +38 -13
- package/dist/auth.js.map +1 -1
- package/dist/bindings.d.ts +3 -0
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js +1 -0
- package/dist/bindings.js.map +1 -1
- package/dist/channel-watch.d.ts +42 -0
- package/dist/channel-watch.d.ts.map +1 -0
- package/dist/channel-watch.js +59 -0
- package/dist/channel-watch.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +31 -0
- package/dist/errors.js.map +1 -1
- package/dist/exact-values.d.ts +18 -5
- package/dist/exact-values.d.ts.map +1 -1
- package/dist/exact-values.js +76 -12
- package/dist/exact-values.js.map +1 -1
- package/dist/field-kinds-registry.d.ts +1 -1
- package/dist/field-kinds-registry.d.ts.map +1 -1
- package/dist/field-kinds-registry.js +20 -2
- package/dist/field-kinds-registry.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/public-env.d.ts +13 -0
- package/dist/public-env.d.ts.map +1 -0
- package/dist/public-env.js +23 -0
- package/dist/public-env.js.map +1 -0
- package/dist/query-cache.d.ts +2 -1
- package/dist/query-cache.d.ts.map +1 -1
- package/dist/query-cache.js.map +1 -1
- package/dist/query.js +1 -1
- package/dist/query.js.map +1 -1
- package/dist/realtime-refusals.d.ts +35 -0
- package/dist/realtime-refusals.d.ts.map +1 -0
- package/dist/realtime-refusals.js +73 -0
- package/dist/realtime-refusals.js.map +1 -0
- package/dist/realtime.d.ts +70 -2
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +198 -18
- package/dist/realtime.js.map +1 -1
- package/dist/runtime-env.d.ts +2 -0
- package/dist/runtime-env.d.ts.map +1 -1
- package/dist/runtime-env.js +5 -0
- package/dist/runtime-env.js.map +1 -1
- package/dist/table-subscription.d.ts +23 -9
- package/dist/table-subscription.d.ts.map +1 -1
- package/dist/table-subscription.js +155 -23
- package/dist/table-subscription.js.map +1 -1
- package/dist/types.d.ts +29 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/auth.ts +40 -12
- package/src/bindings.ts +3 -0
- package/src/channel-watch.ts +86 -0
- package/src/errors.ts +54 -0
- package/src/exact-values.ts +101 -13
- package/src/field-kinds-registry.ts +2 -3
- package/src/index.ts +13 -1
- package/src/public-env.ts +22 -0
- package/src/query-cache.ts +2 -1
- package/src/query.ts +1 -1
- package/src/realtime-refusals.ts +100 -0
- package/src/realtime.ts +256 -20
- package/src/runtime-env.ts +6 -0
- package/src/table-subscription.ts +186 -30
- package/src/types.ts +35 -1
- package/tests/auth-restore-user.test.ts +84 -0
- package/tests/auth.test.ts +11 -0
- package/tests/channel-watch-private.test.ts +105 -0
- package/tests/channel-watch.test.ts +97 -0
- package/tests/exact-response.test.ts +101 -0
- package/tests/exact-values.test.ts +57 -0
- package/tests/field-kinds-registry.test.ts +12 -0
- package/tests/helpers/close-event.ts +12 -0
- package/tests/helpers/fake-client.ts +38 -0
- package/tests/public-env.test.ts +43 -0
- package/tests/query-cache.test.ts +1 -1
- package/tests/realtime-connection.test.ts +228 -0
- package/tests/realtime-exact-values.test.ts +42 -0
- package/tests/realtime-private-channels.test.ts +377 -0
- package/tests/realtime-refusal-error.test.ts +2 -1
- package/tests/realtime-typed-channels.test.ts +49 -0
- package/tests/runtime-env.test.ts +14 -0
- package/tests/table-subscription-rows.test.ts +136 -0
- package/tests/table-subscription.test.ts +4 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/type-tests/declared-channels.ts +30 -0
- package/type-tests/tsconfig.json +4 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,87 +1,110 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
2
|
+
> @supatype/client@0.10.1 test /home/runner/work/supatype/supatype/packages/client
|
|
3
3
|
> vitest run --maxWorkers=50%
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/home/runner/work/supatype/supatype/packages/client[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m tests/auth.test.ts [2m([22m[
|
|
9
|
-
[32m✓[39m tests/
|
|
10
|
-
[32m✓[39m tests/
|
|
11
|
-
[32m✓[39m tests/types.test.ts [2m([22m[2m30 tests[22m[2m)[22m[33m
|
|
12
|
-
[33m[2m✓[22m[39m .single() resolves to QueryResult<Row> [33m
|
|
13
|
-
[32m✓[39m tests/
|
|
14
|
-
[32m✓[39m tests/
|
|
15
|
-
[32m✓[39m tests/
|
|
16
|
-
[32m✓[39m tests/runtime-env.test.ts [2m([22m[
|
|
17
|
-
[32m✓[39m tests/
|
|
18
|
-
[32m✓[39m tests/
|
|
19
|
-
[32m✓[39m tests/
|
|
20
|
-
[32m✓[39m tests/
|
|
21
|
-
[32m✓[39m tests/realtime-rows-after-broadcast.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m
|
|
22
|
-
[32m✓[39m tests/
|
|
23
|
-
[32m✓[39m tests/
|
|
24
|
-
[32m✓[39m tests/
|
|
25
|
-
[32m✓[39m tests/
|
|
26
|
-
[32m✓[39m tests/
|
|
27
|
-
[32m✓[39m tests/
|
|
28
|
-
[32m✓[39m tests/
|
|
29
|
-
[32m✓[39m tests/
|
|
30
|
-
[32m✓[39m tests/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[32m✓[39m tests/retry-
|
|
34
|
-
[32m✓[39m tests/
|
|
8
|
+
[32m✓[39m tests/auth.test.ts [2m([22m[2m47 tests[22m[2m)[22m[33m 611[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/realtime-private-channels.test.ts [2m([22m[2m37 tests[22m[2m)[22m[33m 816[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/query.test.ts [2m([22m[2m39 tests[22m[2m)[22m[33m 799[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/types.test.ts [2m([22m[2m30 tests[22m[2m)[22m[33m 569[2mms[22m[39m
|
|
12
|
+
[33m[2m✓[22m[39m .single() resolves to QueryResult<Row> [33m 369[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/mfa-totp-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 526[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/draft-profile.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 386[2mms[22m[39m
|
|
15
|
+
[32m✓[39m tests/table-subscribe.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 498[2mms[22m[39m
|
|
16
|
+
[32m✓[39m tests/runtime-env.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 201[2mms[22m[39m
|
|
17
|
+
[32m✓[39m tests/auth-sso.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 230[2mms[22m[39m
|
|
18
|
+
[32m✓[39m tests/realtime-multi-tenant-integration.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 283[2mms[22m[39m
|
|
19
|
+
[32m✓[39m tests/draft-insert.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 280[2mms[22m[39m
|
|
20
|
+
[32m✓[39m tests/graphql-json.test.ts [2m([22m[2m12 tests[22m[2m)[22m[32m 254[2mms[22m[39m
|
|
21
|
+
[32m✓[39m tests/realtime-rows-after-broadcast.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 221[2mms[22m[39m
|
|
22
|
+
[32m✓[39m tests/exact-values.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 88[2mms[22m[39m
|
|
23
|
+
[32m✓[39m tests/realtime-shared-channel.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 351[2mms[22m[39m
|
|
24
|
+
[32m✓[39m tests/draft-update.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 320[2mms[22m[39m
|
|
25
|
+
[32m✓[39m tests/exact-response.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 62[2mms[22m[39m
|
|
26
|
+
[32m✓[39m tests/server-bodies.test.ts [2m([22m[2m20 tests[22m[2m)[22m[33m 534[2mms[22m[39m
|
|
27
|
+
[32m✓[39m tests/auth-url-session.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 195[2mms[22m[39m
|
|
28
|
+
[32m✓[39m tests/subscribe-frame.test.ts [2m([22m[2m10 tests[22m[2m)[22m[33m 393[2mms[22m[39m
|
|
29
|
+
[32m✓[39m tests/realtime-exact-values.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 596[2mms[22m[39m
|
|
30
|
+
[32m✓[39m tests/realtime-connection.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 2586[2mms[22m[39m
|
|
31
|
+
[33m[2m✓[22m[39m reports a drop as connecting, and connected again once the socket is back [33m 1055[2mms[22m[39m
|
|
32
|
+
[33m[2m✓[22m[39m drops the socket on the error and reconnects [33m 1075[2mms[22m[39m
|
|
33
|
+
[32m✓[39m tests/retry-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 453[2mms[22m[39m
|
|
34
|
+
[32m✓[39m tests/storage-quota-integration.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 72[2mms[22m[39m
|
|
35
|
+
[32m✓[39m tests/runtime-env-page-script.test.ts [2m([22m[2m16 tests[22m[2m)[22m[32m 133[2mms[22m[39m
|
|
36
|
+
[32m✓[39m tests/storage-upload-limit-integration.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 47[2mms[22m[39m
|
|
37
|
+
[32m✓[39m tests/rate-limit-integration.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 192[2mms[22m[39m
|
|
38
|
+
[32m✓[39m tests/realtime-session-auth.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 240[2mms[22m[39m
|
|
39
|
+
[32m✓[39m tests/retry-policy.test.ts [2m([22m[2m17 tests[22m[2m)[22m[33m 1760[2mms[22m[39m
|
|
35
40
|
[2m[90m↓[39m[22m tests/draft-update.integration.test.ts [2m([22m[2m3 tests[22m[2m | [22m[33m3 skipped[39m[2m)[22m
|
|
36
|
-
[32m✓[39m tests/minimal-writes.test.ts [2m([22m[2m8 tests[22m[2m)[22m[
|
|
41
|
+
[32m✓[39m tests/minimal-writes.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 348[2mms[22m[39m
|
|
37
42
|
[2m[90m↓[39m[22m tests/draft-insert.integration.test.ts [2m([22m[2m4 tests[22m[2m | [22m[33m4 skipped[39m[2m)[22m
|
|
38
|
-
[32m✓[39m tests/
|
|
39
|
-
|
|
40
|
-
[33m[2m✓[22m[39m runs supatype generate where the CLI is installed, its bin
|
|
41
|
-
[33m[2m✓[22m[39m finds a CLI hoisted into a parent directory [33m
|
|
42
|
-
[33m[2m✓[22m[39m
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[32m✓[39m tests/
|
|
46
|
-
[32m✓[39m tests/
|
|
47
|
-
[32m✓[39m tests/
|
|
48
|
-
|
|
49
|
-
[32m✓[39m tests/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[32m✓[39m tests/
|
|
57
|
-
[32m✓[39m tests/
|
|
58
|
-
[32m✓[39m tests/
|
|
59
|
-
[32m✓[39m tests/
|
|
60
|
-
[32m✓[39m tests/
|
|
61
|
-
[32m✓[39m tests/
|
|
62
|
-
[32m✓[39m tests/
|
|
43
|
+
[32m✓[39m tests/filters.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 352[2mms[22m[39m
|
|
44
|
+
[32m✓[39m tests/supatype-prepare.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 4075[2mms[22m[39m
|
|
45
|
+
[33m[2m✓[22m[39m runs supatype generate where the CLI is installed, its bin given as a string [33m 436[2mms[22m[39m
|
|
46
|
+
[33m[2m✓[22m[39m finds a CLI hoisted into a parent directory [33m 714[2mms[22m[39m
|
|
47
|
+
[33m[2m✓[22m[39m runs the nearest CLI [33m 398[2mms[22m[39m
|
|
48
|
+
[33m[2m✓[22m[39m fails the install when the CLI folder is a CLI naming no supatype command [33m 303[2mms[22m[39m
|
|
49
|
+
[33m[2m✓[22m[39m fails the install when generate fails [33m 509[2mms[22m[39m
|
|
50
|
+
[32m✓[39m tests/realtime-ack-ref.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 253[2mms[22m[39m
|
|
51
|
+
[32m✓[39m tests/unauthorized-resend.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 268[2mms[22m[39m
|
|
52
|
+
[32m✓[39m tests/table-subscription-rows.test.ts [2m([22m[2m9 tests[22m[2m)[22m[33m 1506[2mms[22m[39m
|
|
53
|
+
[33m[2m✓[22m[39m reads the table again once the join is back, so a change made while down shows up [33m 1241[2mms[22m[39m
|
|
54
|
+
[32m✓[39m tests/storage-object-shape.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 114[2mms[22m[39m
|
|
55
|
+
[32m✓[39m tests/result-error-class.test.ts [2m([22m[2m12 tests[22m[2m)[22m[32m 81[2mms[22m[39m
|
|
56
|
+
[32m✓[39m tests/postgrest-error-codes.test.ts [2m([22m[2m28 tests[22m[2m)[22m[32m 135[2mms[22m[39m
|
|
57
|
+
[32m✓[39m tests/examples-runtime-env.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 7782[2mms[22m[39m
|
|
58
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 4123[2mms[22m[39m
|
|
59
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 2025[2mms[22m[39m
|
|
60
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 1617[2mms[22m[39m
|
|
61
|
+
[32m✓[39m tests/channel-watch-private.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 136[2mms[22m[39m
|
|
62
|
+
[32m✓[39m tests/auth-events.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 125[2mms[22m[39m
|
|
63
|
+
[32m✓[39m tests/data-plane-auth.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 96[2mms[22m[39m
|
|
64
|
+
[32m✓[39m tests/serverless.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
65
|
+
[32m✓[39m tests/runtime-env-bundle.test.ts [2m([22m[2m3 tests[22m[2m)[22m[33m 2368[2mms[22m[39m
|
|
66
|
+
[32m✓[39m tests/query-cache.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 54[2mms[22m[39m
|
|
67
|
+
[32m✓[39m tests/auth-errors.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 112[2mms[22m[39m
|
|
68
|
+
[32m✓[39m tests/identity-change.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
69
|
+
[32m✓[39m tests/table-subscription.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 77[2mms[22m[39m
|
|
70
|
+
[32m✓[39m tests/field-kinds-registry.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
71
|
+
[32m✓[39m tests/channel-watch.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 129[2mms[22m[39m
|
|
72
|
+
[32m✓[39m tests/table-transport.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 476[2mms[22m[39m
|
|
73
|
+
[32m✓[39m tests/signed-url-absolute.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 61[2mms[22m[39m
|
|
74
|
+
(node:10580) TimeoutOverflowWarning: 2306666685677 does not fit into a 32-bit signed integer.
|
|
75
|
+
Timeout duration was set to 1.
|
|
76
|
+
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
77
|
+
(node:10580) TimeoutOverflowWarning: 2306666685676 does not fit into a 32-bit signed integer.
|
|
78
|
+
Timeout duration was set to 1.
|
|
79
|
+
(node:10580) TimeoutOverflowWarning: 2306666685675 does not fit into a 32-bit signed integer.
|
|
80
|
+
Timeout duration was set to 1.
|
|
81
|
+
(node:10580) TimeoutOverflowWarning: 2306666685675 does not fit into a 32-bit signed integer.
|
|
82
|
+
Timeout duration was set to 1.
|
|
83
|
+
(node:10580) TimeoutOverflowWarning: 2306666685673 does not fit into a 32-bit signed integer.
|
|
84
|
+
Timeout duration was set to 1.
|
|
85
|
+
[32m✓[39m tests/auth-restore-user.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 38[2mms[22m[39m
|
|
63
86
|
[32m✓[39m tests/error-family.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
64
|
-
[32m✓[39m tests/
|
|
65
|
-
[32m✓[39m tests/storage-upload-browser.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
66
|
-
[32m✓[39m tests/realtime-
|
|
67
|
-
[32m✓[39m tests/
|
|
68
|
-
[32m✓[39m tests/
|
|
69
|
-
[32m✓[39m tests/
|
|
70
|
-
[32m✓[39m tests/
|
|
71
|
-
[32m✓[39m tests/auth-error-codes.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
72
|
-
[32m✓[39m tests/runtime-env-expo.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
87
|
+
[32m✓[39m tests/realtime-refusal-error.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 89[2mms[22m[39m
|
|
88
|
+
[32m✓[39m tests/storage-upload-browser.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 49[2mms[22m[39m
|
|
89
|
+
[32m✓[39m tests/realtime-presence.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 96[2mms[22m[39m
|
|
90
|
+
[32m✓[39m tests/thrown-error.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
91
|
+
[32m✓[39m tests/storage-reference-url.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
92
|
+
[32m✓[39m tests/runtime-env-expo.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
93
|
+
[32m✓[39m tests/auth-error-codes.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 41[2mms[22m[39m
|
|
73
94
|
[32m✓[39m tests/realtime-swap-status.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 116[2mms[22m[39m
|
|
74
|
-
[32m✓[39m tests/
|
|
75
|
-
[32m✓[39m tests/
|
|
76
|
-
[32m✓[39m tests/
|
|
77
|
-
[32m✓[39m tests/
|
|
78
|
-
[32m✓[39m tests/
|
|
79
|
-
[32m✓[39m tests/
|
|
80
|
-
[32m✓[39m tests/dynamic-headers.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
81
|
-
[32m✓[39m tests/
|
|
95
|
+
[32m✓[39m tests/masked-fields.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
96
|
+
[32m✓[39m tests/rpc-resend.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 79[2mms[22m[39m
|
|
97
|
+
[32m✓[39m tests/storage-url-encoding.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 81[2mms[22m[39m
|
|
98
|
+
[32m✓[39m tests/count.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 30[2mms[22m[39m
|
|
99
|
+
[32m✓[39m tests/realtime-typed-channels.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
100
|
+
[32m✓[39m tests/entry-points.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
101
|
+
[32m✓[39m tests/dynamic-headers.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 37[2mms[22m[39m
|
|
102
|
+
[32m✓[39m tests/public-env.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
103
|
+
[32m✓[39m tests/pkce.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
104
|
+
[32m✓[39m tests/sha256-hex.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
82
105
|
|
|
83
|
-
[2m Test Files [22m [1m[
|
|
84
|
-
[2m Tests [22m [1m[
|
|
85
|
-
[2m Start at [22m
|
|
86
|
-
[2m Duration [22m
|
|
106
|
+
[2m Test Files [22m [1m[32m72 passed[39m[22m[2m | [22m[33m2 skipped[39m[90m (74)[39m
|
|
107
|
+
[2m Tests [22m [1m[32m813 passed[39m[22m[2m | [22m[33m7 skipped[39m[90m (820)[39m
|
|
108
|
+
[2m Start at [22m 11:13:25
|
|
109
|
+
[2m Duration [22m 52.41s[2m (transform 7.96s, setup 0ms, import 26.17s, tests 33.04s, environment 29ms)[22m
|
|
87
110
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
3
|
-
> tsc --project tests/tsconfig.json --noEmit
|
|
2
|
+
> @supatype/client@0.10.1 typecheck /home/runner/work/supatype/supatype/packages/client
|
|
3
|
+
> tsc --project tests/tsconfig.json --noEmit && tsc --project type-tests/tsconfig.json --noEmit
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.9.3
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
* **bindings:** `watchTable` (on `@supatype/client/bindings`) takes the client as its first argument, not
|
|
8
|
+
`client.realtime`, because it now reads the table to seed its rows. The Vue, Solid and Svelte
|
|
9
|
+
bindings are updated; anyone calling it directly must pass the client, as `watchTable(client, table,
|
|
10
|
+
options, handlers)`.
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **client:** `client.anonKey`, beside `client.url`: the anon key as given, else as the page set it,
|
|
15
|
+
read each time and an empty string while neither has one.
|
|
16
|
+
* **realtime:** `client.realtime.isConnected`, `client.realtime.connectionState` and
|
|
17
|
+
`client.realtime.onConnectionChange(listener)`, which returns an unsubscribe function. The state is
|
|
18
|
+
`"connected"`, `"connecting"` (first connect, a reconnect after a drop or a sign-in swap, or a wait
|
|
19
|
+
before retrying) or `"disconnected"`. Channel statuses are unchanged. Exports
|
|
20
|
+
`RealtimeConnectionState`, `RealtimeConnectionListener` and the `ChannelSubscription` type.
|
|
21
|
+
* **bindings:** `watchChannel`, `watchConnection` and `channelSlot` on `@supatype/client/bindings`, which the
|
|
22
|
+
Vue, Solid and Svelte `useChannel` / `createChannel` share. `watchTable` takes the client, not its realtime
|
|
23
|
+
client, so it can read the table: its rows are seeded by a read after each join and re-join and kept by
|
|
24
|
+
upsert on a key (the `key` option, default `id`), so the Vue, Solid and Svelte `useSubscription` /
|
|
25
|
+
`createSubscription` hold rows that existed before subscribing and recover from a drop.
|
|
26
|
+
* **realtime:** `channel(name, { private: true })` asserts that a channel is guarded by a schema
|
|
27
|
+
`Channel` declaration. The join carries `private: true`. The server enforces declarations whether
|
|
28
|
+
or not it is set; the option makes a name no declaration matches a refused join (a typo fails at
|
|
29
|
+
once) and makes the client refuse to join at all when the server does not announce
|
|
30
|
+
`private_channels` on its first frame, since an older server would ignore the flag and admit an
|
|
31
|
+
open channel. A private join waits for that first frame before it is sent.
|
|
32
|
+
* **realtime:** `RealtimeChannelError` (a `RealtimeError`) is what a channel's status callback gets
|
|
33
|
+
with `CHANNEL_ERROR` for any channel-scoped refusal. `reason` is `unsupported_server`,
|
|
34
|
+
`join_denied`, `not_declared`, `does_not_fit`, `unavailable`, `shared_instance`, `withdrawn` or
|
|
35
|
+
`refused`; `channel` names it and `retryable` is true for `unavailable`. It was a plain `Error`
|
|
36
|
+
with the server's message, which `message` still carries. `isRealtimeChannelError(value)` tells one from any other error, across copies of the package.
|
|
37
|
+
* **realtime:** access the server takes away from a channel you hold (token change, periodic
|
|
38
|
+
re-check, declaration removed) reaches every handle as `CHANNEL_ERROR` with reason `withdrawn`.
|
|
39
|
+
It was swallowed for a handle with no row listener. The client does not rejoin by itself;
|
|
40
|
+
subscribing again does.
|
|
41
|
+
* **realtime:** a refusal is read from the `code` the server sends, not from its sentence, so a reworded
|
|
42
|
+
message cannot change what the client does. A server that sends no code is still read by its
|
|
43
|
+
sentence, and a code the client does not know is `refused`.
|
|
44
|
+
* **realtime:** a broadcast, presence track or payload the server refuses on a channel that is
|
|
45
|
+
joined no longer moves the channel to `CHANNEL_ERROR`. `onRefused((refusal) => ...)` on a channel
|
|
46
|
+
handle receives `{ channel, code, message }` with `code` one of `send_denied`, `track_denied` or
|
|
47
|
+
`payload_refused`; the status stays `SUBSCRIBED`. `ChannelActionRefusal` and
|
|
48
|
+
`ChannelActionRefusalCode` are exported.
|
|
49
|
+
* **realtime:** `ChannelOptions` is exported. A broadcast sent from the database with
|
|
50
|
+
`_supatype.realtime_send` reaches `onBroadcast` listeners like any other; the README says so.
|
|
51
|
+
* **realtime:** `channel()` takes a `ChannelName`: a topic the schema declares (`lot:${string}` for
|
|
52
|
+
`Channel<"lot:{id}", ...>`, `lobby:${string}` for a trailing `*`, `${number}` for an Integer
|
|
53
|
+
parameter), which autocompletes, or any other string, which an `open` server still admits. The
|
|
54
|
+
declared topics come from the new `SupatypeChannels` interface that `supatype generate` fills in;
|
|
55
|
+
`DeclaredTopic` and `DeclaredTopics<T>` are exported. Before generating, the name is a plain string.
|
|
56
|
+
* **bindings:** `watchChannel` and `channelSlot` take a `ChannelName`, as `channel()` does, so the Vue, Solid
|
|
57
|
+
and Svelte channel bindings accept a declared topic or any other string.
|
|
58
|
+
* **bindings:** `watchChannel` and `channelSlot` take `ChannelOptions` as a last argument, and a binding's
|
|
59
|
+
`error` for a refused or withdrawn channel is the `RealtimeChannelError` itself, not a copy of its message.
|
|
60
|
+
* **bindings:** `watchChannel` and `channelSlot` take an `onRefused` callback, which the Vue, Solid and
|
|
61
|
+
Svelte channel bindings expose as `refusal`.
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
* **realtime:** a socket that fails before it opens is dropped and retried. Node's built-in
|
|
66
|
+
WebSocket, refused with a 502 while realtime restarted, fired error and never close, so the client
|
|
67
|
+
counted it as live and stopped reconnecting for good.
|
|
68
|
+
* **realtime:** a socket still connecting after 10 seconds is given up and replaced. One opened while
|
|
69
|
+
realtime restarted behind the gateway could stay connecting with no error and no close.
|
|
70
|
+
* **auth:** a restored session kept the user without `isAnonymous`, so a guest looked registered after
|
|
71
|
+
every reload. The persisted user's camelCase keys, including those of `identities` and `factors`
|
|
72
|
+
(`userId`, `identityData`, `factorType`, ...), are read back, and a user stored without the flag takes
|
|
73
|
+
it from the token's `is_anonymous` claim.
|
|
74
|
+
* **realtime:** reconnect backoff is capped at 30 seconds. It doubled from one second for 10 attempts,
|
|
75
|
+
reaching 512 seconds.
|
|
76
|
+
|
|
77
|
+
## 0.9.1 (2026-11-09)
|
|
4
78
|
|
|
5
79
|
### Breaking Changes
|
|
6
80
|
|
|
@@ -15,20 +89,6 @@
|
|
|
15
89
|
`details` and `hint` are absent rather than `null` when the server gave none, and an rpc refusal
|
|
16
90
|
is the `PostgrestError` itself. `AuthRedirectError` is a class too, with `provider` as one more
|
|
17
91
|
own field. `SupatypeErrorFields` is the fields' type, as the constructor takes them.
|
|
18
|
-
* **query:** `insert`, `update`, `upsert` and `delete` ask for no rows back and resolve to
|
|
19
|
-
`data: null`, as postgrest-js does. Chain `.select()` (or `.select(columns)`) to get the written
|
|
20
|
-
rows. Returning a row needs the right to read it, so a table whose rules let a caller create but
|
|
21
|
-
not read (an anon order form, say) refused every insert with 401 `42501`. A plain `delete()`
|
|
22
|
-
resolves to `null` rather than `[]`. On a model that keeps drafts, the drafts are read back only
|
|
23
|
-
after `.select()`.
|
|
24
|
-
* **query:** `.single()` and `.maybeSingle()` on a write are a type error until `.select()` is
|
|
25
|
-
chained. Called without it from untyped code, they answer an error and send nothing.
|
|
26
|
-
* **query:** `fetchWithOptional401Retry`'s `onUnauthorized` (and `GraphqlTransport.onUnauthorized`)
|
|
27
|
-
is an `UnauthorizedHandler`: `(refusedToken: string) => Promise<boolean>`, answering whether the
|
|
28
|
-
session now holds a different token. It was `() => Promise<void>`.
|
|
29
|
-
* **bindings:** `runMutation(client, table, operation, data, request)` takes one `MutationRequest`
|
|
30
|
-
(`filter`, `publish`, `select`) in place of the positional `filter` and update options, and returns
|
|
31
|
-
rows only when `request.select` asks for them (`true`, or the columns as `.select()` takes them).
|
|
32
92
|
|
|
33
93
|
### Features
|
|
34
94
|
|
|
@@ -59,6 +119,25 @@
|
|
|
59
119
|
|
|
60
120
|
### Bug Fixes
|
|
61
121
|
|
|
122
|
+
* **realtime:** a change frame that names an exact-column kind this client does not know is no
|
|
123
|
+
longer dropped. The unknown kind is ignored and that column's value passes through as sent, while
|
|
124
|
+
the kinds it does know are still converted, so a kind added by a newer service never costs a
|
|
125
|
+
change. The REST field-kinds document already behaved this way and is now pinned by the same
|
|
126
|
+
shared check.
|
|
127
|
+
* **client:** a response is refused, with the same error as a single lossy number, when a number
|
|
128
|
+
inside an array in a column the generated types do not describe would lose digits in
|
|
129
|
+
`JSON.parse`. The error names the column. Elements are checked at any nesting depth by the
|
|
130
|
+
rules that already applied to a single value: a literal is lossy when its value changes, so
|
|
131
|
+
`19.0000` and `1e2` pass. Columns registered as `bigint[]` or `numeric[]` are still kept exact,
|
|
132
|
+
not refused. A json column holding an array of numbers too large for a double was read with
|
|
133
|
+
rounded elements before; it is now refused.
|
|
134
|
+
* **client:** an array of exact values no longer loses digits. A stored `bigint[]` of
|
|
135
|
+
9007199254740993 came back as 9007199254740992 and a `numeric[]` of 1.10 as 1.1, because only a
|
|
136
|
+
number that was the direct value of a column was protected from `JSON.parse`. Every element of
|
|
137
|
+
a `bigint[]` or `numeric[]` column, at any nesting depth, is now kept as written: `bigint[]`
|
|
138
|
+
elements are native bigints and `numeric[]` elements are exact strings, as the single values
|
|
139
|
+
are. Nulls inside an array stay null. A generated `client.ts` from before this change still
|
|
140
|
+
works, and registers no array kinds until `supatype push` regenerates it.
|
|
62
141
|
* **client:** `MissingClientValuesError` gives the script tag as
|
|
63
142
|
`<script src="/supatype-env.js" vite-ignore></script>`, the form `vite build` leaves alone. The
|
|
64
143
|
tag it gave made every `vite build` warn that it could not bundle the script.
|
|
@@ -85,11 +164,6 @@
|
|
|
85
164
|
from a server too old to serve it) and to open it in the browser. A page with no element is told
|
|
86
165
|
to add it, as before.
|
|
87
166
|
|
|
88
|
-
* **auth:** a request refused with 401 is sent again only when the server said the token was
|
|
89
|
-
expired or invalid (`PGRST301`, `PGRST303`, or "JWT expired"), a session was there to refresh, and
|
|
90
|
-
the refresh produced a different token. Every 401 used to be sent twice, an anon write a row rule
|
|
91
|
-
refused among them. The refresh now runs even when the local clock still calls the token valid,
|
|
92
|
-
since the server has said otherwise.
|
|
93
167
|
* **bindings:** `reportThrown(where, thrown)` turns a request that threw instead of answering
|
|
94
168
|
`{ data, error }` into the binding's `error`, and logs it once with `console.error`. A thrown
|
|
95
169
|
`Error` is kept as it is, so `instanceof` still names it; the SDK's own error classes get the shape
|
|
@@ -108,3 +182,32 @@
|
|
|
108
182
|
from one. Server refusals, client-side refusals (`Not authenticated`) and `reportThrown` follow
|
|
109
183
|
suit: `reportThrown` keeps an SDK error as it is and holds any other thrown value as the `cause`
|
|
110
184
|
of a `SupatypeError`.
|
|
185
|
+
|
|
186
|
+
## 0.9.0 (2026-11-04)
|
|
187
|
+
|
|
188
|
+
### Breaking Changes
|
|
189
|
+
|
|
190
|
+
* **query:** `insert`, `update`, `upsert` and `delete` ask for no rows back and resolve to
|
|
191
|
+
`data: null`, as postgrest-js does. Chain `.select()` (or `.select(columns)`) to get the written
|
|
192
|
+
rows. Returning a row needs the right to read it, so a table whose rules let a caller create but
|
|
193
|
+
not read (an anon order form, say) refused every insert with 401 `42501`. A plain `delete()`
|
|
194
|
+
resolves to `null` rather than `[]`. On a model that keeps drafts, the drafts are read back only
|
|
195
|
+
after `.select()`.
|
|
196
|
+
* **query:** `.single()` and `.maybeSingle()` on a write are a type error until `.select()` is
|
|
197
|
+
chained. Called without it from untyped code, they answer an error and send nothing.
|
|
198
|
+
* **query:** `fetchWithOptional401Retry`'s `onUnauthorized` (and `GraphqlTransport.onUnauthorized`)
|
|
199
|
+
is an `UnauthorizedHandler`: `(refusedToken: string) => Promise<boolean>`, answering whether the
|
|
200
|
+
session now holds a different token. It was `() => Promise<void>`.
|
|
201
|
+
* **bindings:** `runMutation(client, table, operation, data, request)` takes one `MutationRequest`
|
|
202
|
+
(`filter`, `publish`, `select`) in place of the positional `filter` and update options, and returns
|
|
203
|
+
rows only when `request.select` asks for them (`true`, or the columns as `.select()` takes them).
|
|
204
|
+
|
|
205
|
+
### Bug Fixes
|
|
206
|
+
|
|
207
|
+
* **auth:** a request refused with 401 is sent again only when the server said the token was
|
|
208
|
+
expired or invalid (`PGRST301`, `PGRST303`, or "JWT expired"), a session was there to refresh, and
|
|
209
|
+
the refresh produced a different token. Every 401 used to be sent twice, an anon write a row rule
|
|
210
|
+
refused among them. The refresh now runs even when the local clock still calls the token valid,
|
|
211
|
+
since the server has said otherwise.
|
|
212
|
+
|
|
213
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @supatype/client
|
|
2
|
+
|
|
3
|
+
The typed Supatype client: REST, auth, storage and realtime. The full guide, including private
|
|
4
|
+
channels, is on the docs site: https://www.supatype.com/docs/realtime.html
|
|
5
|
+
|
|
6
|
+
## Private channels
|
|
7
|
+
|
|
8
|
+
A channel is private when your schema declares it. The server enforces every declaration for every
|
|
9
|
+
client; `private: true` asserts it, so a name no declaration matches is refused and a server that
|
|
10
|
+
cannot enforce it is never asked.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
client.realtime.channel(`lot:${id}`, { private: true }).onBroadcast("bid", show).subscribe()
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
A refusal arrives as `CHANNEL_ERROR` with a `RealtimeChannelError` (`reason`, `channel`). A function in
|
|
17
|
+
the database can broadcast to the channel with `_supatype.realtime_send`; the client receives it like
|
|
18
|
+
any other broadcast. See the docs page for the reasons and the rules.
|
package/dist/auth.d.ts
CHANGED
|
@@ -131,6 +131,10 @@ export declare class AuthClient {
|
|
|
131
131
|
signInWithPassword(credentials: {
|
|
132
132
|
email: string;
|
|
133
133
|
password: string;
|
|
134
|
+
/** `captchaToken` is the provider widget's answer, which a project with captcha on requires. */
|
|
135
|
+
options?: {
|
|
136
|
+
captchaToken?: string | undefined;
|
|
137
|
+
} | undefined;
|
|
134
138
|
}): Promise<{
|
|
135
139
|
data: {
|
|
136
140
|
session: Session | null;
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,WAAW,EAEX,OAAO,EACP,OAAO,EACP,wBAAwB,EAExB,mBAAmB,EACnB,IAAI,EAEL,MAAM,YAAY,CAAA;AAMnB,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAqBzE,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE9D,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK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BACpC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;gBACjC,4BAA4B,EAAE,MAAM,EAAE,CAAA;aACvC,GAAG,IAAI,CAAA;YACR,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;SAC5B,CAAC;MA0BL;IAED,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG;QACzC,IAAI,EAAE;YAAE,YAAY,EAAE;gBAAE,WAAW,IAAI,IAAI,CAAA;aAAE,CAAA;SAAE,CAAA;KAChD;IAmBD,2EAA2E;IAC3E,IAAI,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAEtC;IAED,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;YACW,aAAa;YASb,YAAY;YAUZ,cAAc;IAS5B,4EAA4E;YAC9D,YAAY;IAM1B;;;OAGG;YACW,SAAS;YAOT,gBAAgB;YAMhB,iBAAiB;IAK/B,8DAA8D;IAC9D,OAAO,CAAC,YAAY;YAON,eAAe;YAKf,yBAAyB;IASvC,OAAO,CAAC,oBAAoB;IAmC5B,OAAO,CAAC,qBAAqB;IAQ7B,oGAAoG;IACpG,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,oBAAoB;YAKd,qBAAqB;IA+CnC,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,WAAW;IAgBnB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI;IAqB1C,OAAO,CAAC,UAAU;IAMlB,4FAA4F;YAC9E,WAAW;IAIzB,yFAAyF;YAC3E,SAAS;YAIT,kBAAkB;IA4BhC,OAAO,CAAC,UAAU;CAkBnB"}
|
package/dist/auth.js
CHANGED
|
@@ -72,18 +72,41 @@ function eitherKey(body, first, second, guard) {
|
|
|
72
72
|
const b = body[second];
|
|
73
73
|
return guard(b) ? b : undefined;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
]
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
/** `appMetadata` as `app_metadata`: the key `_parseUser` and its helpers read. */
|
|
76
|
+
function snakeCaseKey(key) {
|
|
77
|
+
return key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
78
|
+
}
|
|
79
|
+
/** A stored object with each camelCase key also under its snake_case name, unless that is set. Shallow. */
|
|
80
|
+
function withSnakeKeys(stored) {
|
|
81
|
+
const normalized = { ...stored };
|
|
82
|
+
for (const [key, value] of Object.entries(stored)) {
|
|
83
|
+
const snake = snakeCaseKey(key);
|
|
84
|
+
if (snake !== key && stored[snake] === undefined)
|
|
85
|
+
normalized[snake] = value;
|
|
86
|
+
}
|
|
87
|
+
return normalized;
|
|
88
|
+
}
|
|
89
|
+
/** The `is_anonymous` claim of an access token, or undefined when it has none. */
|
|
90
|
+
function anonymousClaim(accessToken) {
|
|
91
|
+
const claim = decodeJwtPayload(accessToken.split(".")[1] ?? "")?.["is_anonymous"];
|
|
92
|
+
return typeof claim === "boolean" ? claim : undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A stored user with its camelCase keys copied to the snake_case ones `_parseUser` reads, so a user
|
|
96
|
+
* this client wrote (`isAnonymous`, `identities[].userId`, ...) survives a restore. A user stored
|
|
97
|
+
* without the anonymous flag takes it from the token's claim.
|
|
98
|
+
*/
|
|
99
|
+
function snakeCaseUser(user, accessToken) {
|
|
100
|
+
const normalized = withSnakeKeys(user);
|
|
101
|
+
for (const list of ["identities", "factors"]) {
|
|
102
|
+
const items = user[list];
|
|
103
|
+
if (Array.isArray(items))
|
|
104
|
+
normalized[list] = items.map((i) => (isJsonObject(i) ? withSnakeKeys(i) : i));
|
|
105
|
+
}
|
|
106
|
+
if (normalized["is_anonymous"] === undefined) {
|
|
107
|
+
const claim = anonymousClaim(accessToken);
|
|
108
|
+
if (claim !== undefined)
|
|
109
|
+
normalized["is_anonymous"] = claim;
|
|
87
110
|
}
|
|
88
111
|
return normalized;
|
|
89
112
|
}
|
|
@@ -358,12 +381,14 @@ export class AuthClient {
|
|
|
358
381
|
return this._parseAuthResponse(res);
|
|
359
382
|
}
|
|
360
383
|
async signInWithPassword(credentials) {
|
|
384
|
+
const captchaToken = credentials.options?.captchaToken;
|
|
361
385
|
const res = await this.send(`${this.url}/token?grant_type=password`, {
|
|
362
386
|
method: "POST",
|
|
363
387
|
headers: this.baseHeaders,
|
|
364
388
|
body: JSON.stringify({
|
|
365
389
|
email: credentials.email,
|
|
366
390
|
password: credentials.password,
|
|
391
|
+
...(captchaToken !== undefined && { supatype_meta_security: { captcha_token: captchaToken } }),
|
|
367
392
|
}),
|
|
368
393
|
});
|
|
369
394
|
return this._parseAuthResponse(res);
|
|
@@ -1172,7 +1197,7 @@ export class AuthClient {
|
|
|
1172
1197
|
refreshToken: eitherKey(raw, "refreshToken", "refresh_token", isString) ?? "",
|
|
1173
1198
|
tokenType: eitherKey(raw, "tokenType", "token_type", isString) ?? "bearer",
|
|
1174
1199
|
expiresIn: eitherKey(raw, "expiresIn", "expires_in", isNumber) ?? 3600,
|
|
1175
|
-
user: this._parseUser(snakeCaseUser(user)),
|
|
1200
|
+
user: this._parseUser(snakeCaseUser(user, accessToken)),
|
|
1176
1201
|
...(expiresAt !== undefined && { expiresAt }),
|
|
1177
1202
|
};
|
|
1178
1203
|
}
|