@supatype/client 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +112 -72
- package/.turbo/turbo-typecheck.log +2 -2
- package/CHANGELOG.md +123 -20
- package/README.md +18 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +53 -13
- package/dist/auth.js.map +1 -1
- package/dist/bindings.d.ts +4 -1
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js +2 -1
- 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 +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/latest-rows.d.ts +15 -0
- package/dist/latest-rows.d.ts.map +1 -1
- package/dist/latest-rows.js +14 -7
- package/dist/latest-rows.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.d.ts +7 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +12 -4
- 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 +87 -8
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +304 -51
- 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 +45 -5
- package/dist/runtime-env.js.map +1 -1
- package/dist/table-subscription.d.ts +27 -11
- package/dist/table-subscription.d.ts.map +1 -1
- package/dist/table-subscription.js +159 -25
- package/dist/table-subscription.js.map +1 -1
- package/dist/types.d.ts +34 -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 +55 -12
- package/src/bindings.ts +4 -1
- 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 +14 -2
- package/src/latest-rows.ts +24 -7
- package/src/public-env.ts +22 -0
- package/src/query-cache.ts +2 -1
- package/src/query.ts +12 -4
- package/src/realtime-refusals.ts +100 -0
- package/src/realtime.ts +385 -56
- package/src/runtime-env.ts +53 -5
- package/src/table-subscription.ts +190 -32
- package/src/types.ts +40 -1
- package/tests/auth-restore-user.test.ts +84 -0
- package/tests/auth-sso.test.ts +32 -1
- 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/examples-runtime-env.test.ts +135 -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/helpers/mock-websocket.ts +22 -0
- package/tests/helpers/reactive-options-binding.ts +99 -0
- package/tests/public-env.test.ts +43 -0
- package/tests/query-cache.test.ts +1 -1
- package/tests/query.test.ts +39 -2
- package/tests/realtime-connection.test.ts +228 -0
- package/tests/realtime-exact-values.test.ts +42 -0
- package/tests/realtime-multi-tenant-integration.test.ts +0 -1
- package/tests/realtime-private-channels.test.ts +377 -0
- package/tests/realtime-refusal-error.test.ts +80 -0
- package/tests/realtime-rows-after-broadcast.test.ts +205 -0
- package/tests/realtime-session-auth.test.ts +0 -1
- package/tests/realtime-shared-channel.test.ts +9 -27
- package/tests/realtime-typed-channels.test.ts +49 -0
- package/tests/runtime-env-expo.test.ts +58 -0
- package/tests/runtime-env.test.ts +49 -0
- package/tests/subscribe-frame.test.ts +48 -0
- package/tests/table-subscription-rows.test.ts +136 -0
- package/tests/table-subscription.test.ts +4 -3
- package/tsconfig.json +2 -1
- 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,82 +1,122 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
2
|
+
> @supatype/client@0.10.0 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/
|
|
9
|
-
[32m✓[39m tests/
|
|
10
|
-
[32m✓[39m tests/
|
|
11
|
-
[32m✓[39m tests/types.test.ts [2m([22m[2m30 tests[22m[2m)[22m[33m
|
|
12
|
-
|
|
13
|
-
[32m✓[39m tests/
|
|
14
|
-
|
|
15
|
-
[32m✓[39m tests/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[32m✓[39m tests/
|
|
20
|
-
[32m✓[39m tests/
|
|
21
|
-
[32m✓[39m tests/
|
|
22
|
-
|
|
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
|
-
[32m✓[39m tests/
|
|
33
|
-
[32m✓[39m tests/realtime-
|
|
8
|
+
[32m✓[39m tests/auth.test.ts [2m([22m[2m47 tests[22m[2m)[22m[33m 436[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/realtime-private-channels.test.ts [2m([22m[2m37 tests[22m[2m)[22m[33m 838[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/query.test.ts [2m([22m[2m39 tests[22m[2m)[22m[33m 593[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/types.test.ts [2m([22m[2m30 tests[22m[2m)[22m[33m 904[2mms[22m[39m
|
|
12
|
+
[33m[2m✓[22m[39m .single() resolves to QueryResult<Row> [33m 712[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/mfa-totp-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 809[2mms[22m[39m
|
|
14
|
+
[33m[2m✓[22m[39m calls POST /factors with factor_type=totp [33m 420[2mms[22m[39m
|
|
15
|
+
[32m✓[39m tests/draft-profile.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 710[2mms[22m[39m
|
|
16
|
+
[33m[2m✓[22m[39m is sent as Accept-Profile when the query asks for it [33m 313[2mms[22m[39m
|
|
17
|
+
[32m✓[39m tests/table-subscribe.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 843[2mms[22m[39m
|
|
18
|
+
[33m[2m✓[22m[39m opens a socket, sends the subscribe frame, and delivers a change [33m 480[2mms[22m[39m
|
|
19
|
+
[32m✓[39m tests/runtime-env.test.ts [2m([22m[2m33 tests[22m[2m)[22m[33m 358[2mms[22m[39m
|
|
20
|
+
[32m✓[39m tests/auth-sso.test.ts [2m([22m[2m20 tests[22m[2m)[22m[33m 531[2mms[22m[39m
|
|
21
|
+
[32m✓[39m tests/realtime-multi-tenant-integration.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 367[2mms[22m[39m
|
|
22
|
+
[32m✓[39m tests/draft-insert.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 429[2mms[22m[39m
|
|
23
|
+
[32m✓[39m tests/graphql-json.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 306[2mms[22m[39m
|
|
24
|
+
[32m✓[39m tests/realtime-rows-after-broadcast.test.ts [2m([22m[2m9 tests[22m[2m)[22m[33m 404[2mms[22m[39m
|
|
25
|
+
[32m✓[39m tests/exact-values.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 135[2mms[22m[39m
|
|
26
|
+
[32m✓[39m tests/realtime-shared-channel.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 289[2mms[22m[39m
|
|
27
|
+
[32m✓[39m tests/draft-update.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 482[2mms[22m[39m
|
|
28
|
+
[32m✓[39m tests/exact-response.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 96[2mms[22m[39m
|
|
29
|
+
[32m✓[39m tests/server-bodies.test.ts [2m([22m[2m20 tests[22m[2m)[22m[33m 707[2mms[22m[39m
|
|
30
|
+
[32m✓[39m tests/auth-url-session.test.ts [2m([22m[2m10 tests[22m[2m)[22m[33m 558[2mms[22m[39m
|
|
31
|
+
[33m[2m✓[22m[39m signs in from implicit-grant tokens in the fragment and cleans the URL [33m 361[2mms[22m[39m
|
|
32
|
+
[32m✓[39m tests/subscribe-frame.test.ts [2m([22m[2m10 tests[22m[2m)[22m[33m 449[2mms[22m[39m
|
|
33
|
+
[32m✓[39m tests/realtime-exact-values.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 728[2mms[22m[39m
|
|
34
|
+
[33m[2m✓[22m[39m gives a bigint column a native bigint [33m 381[2mms[22m[39m
|
|
35
|
+
[32m✓[39m tests/realtime-connection.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 2469[2mms[22m[39m
|
|
36
|
+
[33m[2m✓[22m[39m reports a drop as connecting, and connected again once the socket is back [33m 1058[2mms[22m[39m
|
|
37
|
+
[33m[2m✓[22m[39m drops the socket on the error and reconnects [33m 1027[2mms[22m[39m
|
|
38
|
+
[32m✓[39m tests/retry-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 549[2mms[22m[39m
|
|
39
|
+
[32m✓[39m tests/storage-quota-integration.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 196[2mms[22m[39m
|
|
40
|
+
[32m✓[39m tests/runtime-env-page-script.test.ts [2m([22m[2m16 tests[22m[2m)[22m[32m 261[2mms[22m[39m
|
|
41
|
+
[32m✓[39m tests/storage-upload-limit-integration.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 404[2mms[22m[39m
|
|
42
|
+
[32m✓[39m tests/rate-limit-integration.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 771[2mms[22m[39m
|
|
43
|
+
[33m[2m✓[22m[39m waits Retry-After seconds then retries on 429 [33m 474[2mms[22m[39m
|
|
44
|
+
[32m✓[39m tests/realtime-session-auth.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 240[2mms[22m[39m
|
|
45
|
+
[32m✓[39m tests/retry-policy.test.ts [2m([22m[2m17 tests[22m[2m)[22m[33m 1933[2mms[22m[39m
|
|
34
46
|
[2m[90m↓[39m[22m tests/draft-update.integration.test.ts [2m([22m[2m3 tests[22m[2m | [22m[33m3 skipped[39m[2m)[22m
|
|
35
|
-
[32m✓[39m tests/
|
|
36
|
-
|
|
47
|
+
[32m✓[39m tests/minimal-writes.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 437[2mms[22m[39m
|
|
48
|
+
[33m[2m✓[22m[39m insert asks for no representation and resolves to no rows [33m 302[2mms[22m[39m
|
|
37
49
|
[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/supatype-prepare.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m
|
|
39
|
-
[33m[2m✓[22m[39m
|
|
40
|
-
[33m[2m✓[22m[39m runs supatype generate where the CLI is installed, its bin
|
|
41
|
-
[33m[2m✓[22m[39m
|
|
42
|
-
[33m[2m✓[22m[39m
|
|
43
|
-
[33m[2m✓[22m[39m
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[32m✓[39m tests/
|
|
49
|
-
|
|
50
|
-
[32m✓[39m tests/
|
|
51
|
-
[32m✓[39m tests/
|
|
52
|
-
[32m✓[39m tests/
|
|
53
|
-
|
|
54
|
-
[32m✓[39m tests/
|
|
55
|
-
[32m✓[39m tests/
|
|
56
|
-
[32m✓[39m tests/
|
|
57
|
-
[32m✓[39m tests/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
[32m✓[39m tests/
|
|
62
|
-
[32m✓[39m tests/
|
|
63
|
-
[32m✓[39m tests/
|
|
64
|
-
[32m✓[39m tests/
|
|
65
|
-
[32m✓[39m tests/
|
|
66
|
-
[32m✓[39m tests/
|
|
67
|
-
[32m✓[39m tests/auth-
|
|
68
|
-
[32m✓[39m tests/
|
|
69
|
-
[32m✓[39m tests/
|
|
70
|
-
[32m✓[39m tests/
|
|
71
|
-
[32m✓[39m tests/
|
|
72
|
-
[32m✓[39m tests/
|
|
73
|
-
[32m✓[39m tests/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
[32m✓[39m tests/supatype-prepare.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 5116[2mms[22m[39m
|
|
51
|
+
[33m[2m✓[22m[39m ignores a CLI in the home folder's .node_modules [33m 428[2mms[22m[39m
|
|
52
|
+
[33m[2m✓[22m[39m runs supatype generate where the CLI is installed, its bin named [33m 401[2mms[22m[39m
|
|
53
|
+
[33m[2m✓[22m[39m runs supatype generate where the CLI is installed, its bin given as a string [33m 542[2mms[22m[39m
|
|
54
|
+
[33m[2m✓[22m[39m finds a CLI hoisted into a parent directory [33m 656[2mms[22m[39m
|
|
55
|
+
[33m[2m✓[22m[39m runs the nearest CLI [33m 659[2mms[22m[39m
|
|
56
|
+
[33m[2m✓[22m[39m passes over a node_modules it cannot look inside [33m 336[2mms[22m[39m
|
|
57
|
+
[33m[2m✓[22m[39m fails the install when the CLI folder is a link to nothing [33m 391[2mms[22m[39m
|
|
58
|
+
[33m[2m✓[22m[39m fails the install when the CLI folder is an empty folder [33m 355[2mms[22m[39m
|
|
59
|
+
[33m[2m✓[22m[39m fails the install when generate fails [33m 452[2mms[22m[39m
|
|
60
|
+
[32m✓[39m tests/filters.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 448[2mms[22m[39m
|
|
61
|
+
[33m[2m✓[22m[39m an array becomes a Postgres array literal, not JSON [33m 306[2mms[22m[39m
|
|
62
|
+
[32m✓[39m tests/realtime-ack-ref.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 173[2mms[22m[39m
|
|
63
|
+
[32m✓[39m tests/unauthorized-resend.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 287[2mms[22m[39m
|
|
64
|
+
[32m✓[39m tests/table-subscription-rows.test.ts [2m([22m[2m9 tests[22m[2m)[22m[33m 1473[2mms[22m[39m
|
|
65
|
+
[33m[2m✓[22m[39m reads the table again once the join is back, so a change made while down shows up [33m 1234[2mms[22m[39m
|
|
66
|
+
[32m✓[39m tests/storage-object-shape.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 208[2mms[22m[39m
|
|
67
|
+
[32m✓[39m tests/result-error-class.test.ts [2m([22m[2m12 tests[22m[2m)[22m[32m 278[2mms[22m[39m
|
|
68
|
+
[32m✓[39m tests/postgrest-error-codes.test.ts [2m([22m[2m28 tests[22m[2m)[22m[32m 268[2mms[22m[39m
|
|
69
|
+
[32m✓[39m tests/examples-runtime-env.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 9782[2mms[22m[39m
|
|
70
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 4921[2mms[22m[39m
|
|
71
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 2839[2mms[22m[39m
|
|
72
|
+
[33m[2m✓[22m[39m loads, and sends the key the server's /supatype-env.js set [33m 1992[2mms[22m[39m
|
|
73
|
+
[32m✓[39m tests/channel-watch-private.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 206[2mms[22m[39m
|
|
74
|
+
[32m✓[39m tests/auth-events.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 53[2mms[22m[39m
|
|
75
|
+
[32m✓[39m tests/runtime-env-bundle.test.ts [2m([22m[2m3 tests[22m[2m)[22m[33m 2008[2mms[22m[39m
|
|
76
|
+
[32m✓[39m tests/data-plane-auth.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 67[2mms[22m[39m
|
|
77
|
+
[32m✓[39m tests/serverless.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 20[2mms[22m[39m
|
|
78
|
+
[32m✓[39m tests/query-cache.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 65[2mms[22m[39m
|
|
79
|
+
[32m✓[39m tests/auth-errors.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 63[2mms[22m[39m
|
|
80
|
+
[32m✓[39m tests/table-subscription.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 63[2mms[22m[39m
|
|
81
|
+
[32m✓[39m tests/identity-change.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
82
|
+
[32m✓[39m tests/field-kinds-registry.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 22[2mms[22m[39m
|
|
83
|
+
[32m✓[39m tests/channel-watch.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 132[2mms[22m[39m
|
|
84
|
+
[32m✓[39m tests/table-transport.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 475[2mms[22m[39m
|
|
85
|
+
[32m✓[39m tests/signed-url-absolute.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 108[2mms[22m[39m
|
|
86
|
+
(node:11496) TimeoutOverflowWarning: 2306736714334 does not fit into a 32-bit signed integer.
|
|
87
|
+
Timeout duration was set to 1.
|
|
88
|
+
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
89
|
+
(node:11496) TimeoutOverflowWarning: 2306736714332 does not fit into a 32-bit signed integer.
|
|
90
|
+
Timeout duration was set to 1.
|
|
91
|
+
(node:11496) TimeoutOverflowWarning: 2306736714330 does not fit into a 32-bit signed integer.
|
|
92
|
+
Timeout duration was set to 1.
|
|
93
|
+
(node:11496) TimeoutOverflowWarning: 2306736714330 does not fit into a 32-bit signed integer.
|
|
94
|
+
Timeout duration was set to 1.
|
|
95
|
+
(node:11496) TimeoutOverflowWarning: 2306736714328 does not fit into a 32-bit signed integer.
|
|
96
|
+
Timeout duration was set to 1.
|
|
97
|
+
[32m✓[39m tests/auth-restore-user.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 100[2mms[22m[39m
|
|
98
|
+
[32m✓[39m tests/error-family.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 24[2mms[22m[39m
|
|
99
|
+
[32m✓[39m tests/realtime-refusal-error.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 83[2mms[22m[39m
|
|
100
|
+
[32m✓[39m tests/storage-upload-browser.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 159[2mms[22m[39m
|
|
101
|
+
[32m✓[39m tests/realtime-presence.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 116[2mms[22m[39m
|
|
102
|
+
[32m✓[39m tests/thrown-error.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 24[2mms[22m[39m
|
|
103
|
+
[32m✓[39m tests/storage-reference-url.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
104
|
+
[32m✓[39m tests/runtime-env-expo.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 25[2mms[22m[39m
|
|
105
|
+
[32m✓[39m tests/realtime-swap-status.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 167[2mms[22m[39m
|
|
106
|
+
[32m✓[39m tests/auth-error-codes.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 31[2mms[22m[39m
|
|
107
|
+
[32m✓[39m tests/masked-fields.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
108
|
+
[32m✓[39m tests/rpc-resend.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 60[2mms[22m[39m
|
|
109
|
+
[32m✓[39m tests/count.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
110
|
+
[32m✓[39m tests/storage-url-encoding.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 58[2mms[22m[39m
|
|
111
|
+
[32m✓[39m tests/realtime-typed-channels.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
112
|
+
[32m✓[39m tests/entry-points.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
113
|
+
[32m✓[39m tests/public-env.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
114
|
+
[32m✓[39m tests/dynamic-headers.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 45[2mms[22m[39m
|
|
115
|
+
[32m✓[39m tests/pkce.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
116
|
+
[32m✓[39m tests/sha256-hex.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
77
117
|
|
|
78
|
-
[2m Test Files [22m [1m[
|
|
79
|
-
[2m Tests [22m [1m[
|
|
80
|
-
[2m Start at [22m
|
|
81
|
-
[2m Duration [22m
|
|
118
|
+
[2m Test Files [22m [1m[32m72 passed[39m[22m[2m | [22m[33m2 skipped[39m[90m (74)[39m
|
|
119
|
+
[2m Tests [22m [1m[32m813 passed[39m[22m[2m | [22m[33m7 skipped[39m[90m (820)[39m
|
|
120
|
+
[2m Start at [22m 15:46:01
|
|
121
|
+
[2m Duration [22m 68.62s[2m (transform 9.66s, setup 0ms, import 32.75s, tests 40.55s, environment 61ms)[22m
|
|
82
122
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
3
|
-
> tsc --project tests/tsconfig.json --noEmit
|
|
2
|
+
> @supatype/client@0.10.0 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
|
@@ -24,6 +24,15 @@ interface AuthClientOptions {
|
|
|
24
24
|
* sent back in the URL for a sign-in `signInWithSSO` started.
|
|
25
25
|
*/
|
|
26
26
|
export declare const SSO_PROVIDER = "sso";
|
|
27
|
+
/**
|
|
28
|
+
* The domain `signInWithSSO` looks a provider up by, from what a person typed: the part after the
|
|
29
|
+
* last `@` of a work email, or the whole of a bare domain, trimmed and lower-cased. Null when there
|
|
30
|
+
* is nothing to look up, so a form can refuse it before asking the server.
|
|
31
|
+
*
|
|
32
|
+
* One implementation for `<SSOForm>` and Studio's sign-in, which each had their own and disagreed:
|
|
33
|
+
* Studio found no domain in a bare one, and the form sent a domain typed after `@ ` with its space.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ssoDomain(input: string): string | null;
|
|
27
36
|
export declare class AuthClient {
|
|
28
37
|
private readonly urlSource;
|
|
29
38
|
private readonly baseHeadersSource;
|
|
@@ -122,6 +131,10 @@ export declare class AuthClient {
|
|
|
122
131
|
signInWithPassword(credentials: {
|
|
123
132
|
email: string;
|
|
124
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;
|
|
125
138
|
}): Promise<{
|
|
126
139
|
data: {
|
|
127
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,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SO_PROVIDER = "sso";
|
|
19
|
+
/**
|
|
20
|
+
* The domain `signInWithSSO` looks a provider up by, from what a person typed: the part after the
|
|
21
|
+
* last `@` of a work email, or the whole of a bare domain, trimmed and lower-cased. Null when there
|
|
22
|
+
* is nothing to look up, so a form can refuse it before asking the server.
|
|
23
|
+
*
|
|
24
|
+
* One implementation for `<SSOForm>` and Studio's sign-in, which each had their own and disagreed:
|
|
25
|
+
* Studio found no domain in a bare one, and the form sent a domain typed after `@ ` with its space.
|
|
26
|
+
*/
|
|
27
|
+
export function ssoDomain(input) {
|
|
28
|
+
const value = input.trim().toLowerCase();
|
|
29
|
+
const domain = value.slice(value.lastIndexOf("@") + 1).trim();
|
|
30
|
+
return domain === "" ? null : domain;
|
|
31
|
+
}
|
|
19
32
|
const DEBUG_AUTH = typeof process !== "undefined" && process.env["NEXT_PUBLIC_SUPATYPE_DEBUG_AUTH"] === "1";
|
|
20
33
|
/**
|
|
21
34
|
* The auth server's refusal as a `SupatypeError`, with its machine-readable code kept.
|
|
@@ -59,18 +72,41 @@ function eitherKey(body, first, second, guard) {
|
|
|
59
72
|
const b = body[second];
|
|
60
73
|
return guard(b) ? b : undefined;
|
|
61
74
|
}
|
|
62
|
-
/**
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
110
|
}
|
|
75
111
|
return normalized;
|
|
76
112
|
}
|
|
@@ -345,12 +381,14 @@ export class AuthClient {
|
|
|
345
381
|
return this._parseAuthResponse(res);
|
|
346
382
|
}
|
|
347
383
|
async signInWithPassword(credentials) {
|
|
384
|
+
const captchaToken = credentials.options?.captchaToken;
|
|
348
385
|
const res = await this.send(`${this.url}/token?grant_type=password`, {
|
|
349
386
|
method: "POST",
|
|
350
387
|
headers: this.baseHeaders,
|
|
351
388
|
body: JSON.stringify({
|
|
352
389
|
email: credentials.email,
|
|
353
390
|
password: credentials.password,
|
|
391
|
+
...(captchaToken !== undefined && { supatype_meta_security: { captcha_token: captchaToken } }),
|
|
354
392
|
}),
|
|
355
393
|
});
|
|
356
394
|
return this._parseAuthResponse(res);
|
|
@@ -446,6 +484,8 @@ export class AuthClient {
|
|
|
446
484
|
body["redirect_to"] = opts.redirectTo;
|
|
447
485
|
if (opts.captchaToken !== undefined)
|
|
448
486
|
body["supatype_meta_security"] = { captcha_token: opts.captchaToken };
|
|
487
|
+
if (opts.studio === true)
|
|
488
|
+
body["studio"] = true;
|
|
449
489
|
const flowType = opts.flowType ?? "pkce";
|
|
450
490
|
return flowType === "pkce" ? { ...body, ...(await this.beginPkce()) } : body;
|
|
451
491
|
}
|
|
@@ -1157,7 +1197,7 @@ export class AuthClient {
|
|
|
1157
1197
|
refreshToken: eitherKey(raw, "refreshToken", "refresh_token", isString) ?? "",
|
|
1158
1198
|
tokenType: eitherKey(raw, "tokenType", "token_type", isString) ?? "bearer",
|
|
1159
1199
|
expiresIn: eitherKey(raw, "expiresIn", "expires_in", isNumber) ?? 3600,
|
|
1160
|
-
user: this._parseUser(snakeCaseUser(user)),
|
|
1200
|
+
user: this._parseUser(snakeCaseUser(user, accessToken)),
|
|
1161
1201
|
...(expiresAt !== undefined && { expiresAt }),
|
|
1162
1202
|
};
|
|
1163
1203
|
}
|