@supatype/client 0.3.6 → 0.8.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 +69 -30
- package/.turbo/turbo-typecheck.log +2 -2
- package/LICENSE +1 -1
- package/dist/auth-redirect.d.ts +48 -0
- package/dist/auth-redirect.d.ts.map +1 -0
- package/dist/auth-redirect.js +70 -0
- package/dist/auth-redirect.js.map +1 -0
- package/dist/auth.d.ts +86 -4
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +383 -275
- package/dist/auth.js.map +1 -1
- package/dist/bindings.d.ts +16 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +13 -0
- package/dist/bindings.js.map +1 -0
- package/dist/caller-types.d.ts +18 -0
- package/dist/caller-types.d.ts.map +1 -0
- package/dist/caller-types.js +22 -0
- package/dist/caller-types.js.map +1 -0
- package/dist/draft-create.d.ts +12 -0
- package/dist/draft-create.d.ts.map +1 -0
- package/dist/draft-create.js +47 -0
- package/dist/draft-create.js.map +1 -0
- package/dist/draft-models-registry.d.ts +27 -0
- package/dist/draft-models-registry.d.ts.map +1 -0
- package/dist/draft-models-registry.js +61 -0
- package/dist/draft-models-registry.js.map +1 -0
- package/dist/error-codes-doc.d.ts +1 -1
- package/dist/error-codes-doc.d.ts.map +1 -1
- package/dist/error-codes-doc.js +42 -34
- package/dist/error-codes-doc.js.map +1 -1
- package/dist/errors.d.ts +102 -60
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +69 -28
- package/dist/errors.js.map +1 -1
- package/dist/exact-response.d.ts.map +1 -1
- package/dist/exact-response.js +2 -1
- package/dist/exact-response.js.map +1 -1
- package/dist/exact-values.d.ts +2 -0
- package/dist/exact-values.d.ts.map +1 -1
- package/dist/exact-values.js +12 -10
- package/dist/exact-values.js.map +1 -1
- package/dist/fetch-with-retry.d.ts +21 -6
- package/dist/fetch-with-retry.d.ts.map +1 -1
- package/dist/fetch-with-retry.js +67 -53
- package/dist/fetch-with-retry.js.map +1 -1
- package/dist/field-kinds-registry.d.ts +11 -3
- package/dist/field-kinds-registry.d.ts.map +1 -1
- package/dist/field-kinds-registry.js +10 -6
- package/dist/field-kinds-registry.js.map +1 -1
- package/dist/filters.d.ts +51 -0
- package/dist/filters.d.ts.map +1 -0
- package/dist/filters.js +117 -0
- package/dist/filters.js.map +1 -0
- package/dist/generated-client.d.ts +7 -0
- package/dist/generated-client.d.ts.map +1 -0
- package/dist/generated-client.js +7 -0
- package/dist/generated-client.js.map +1 -0
- package/dist/graphql-document.d.ts +39 -0
- package/dist/graphql-document.d.ts.map +1 -0
- package/dist/graphql-document.js +228 -0
- package/dist/graphql-document.js.map +1 -0
- package/dist/graphql-json.d.ts +56 -0
- package/dist/graphql-json.d.ts.map +1 -0
- package/dist/graphql-json.js +220 -0
- package/dist/graphql-json.js.map +1 -0
- package/dist/graphql-transport.d.ts +28 -0
- package/dist/graphql-transport.d.ts.map +1 -0
- package/dist/graphql-transport.js +77 -0
- package/dist/graphql-transport.js.map +1 -0
- package/dist/index.d.ts +103 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +170 -165
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +61 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +83 -0
- package/dist/json.js.map +1 -0
- package/dist/jwt.d.ts +16 -0
- package/dist/jwt.d.ts.map +1 -0
- package/dist/jwt.js +37 -0
- package/dist/jwt.js.map +1 -0
- package/dist/live-preview.d.ts +23 -0
- package/dist/live-preview.d.ts.map +1 -0
- package/dist/live-preview.js +28 -0
- package/dist/live-preview.js.map +1 -0
- package/dist/mutation-request.d.ts +17 -0
- package/dist/mutation-request.d.ts.map +1 -0
- package/dist/mutation-request.js +41 -0
- package/dist/mutation-request.js.map +1 -0
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +8 -6
- package/dist/preview.js.map +1 -1
- package/dist/query-cache.d.ts.map +1 -1
- package/dist/query-cache.js +19 -13
- package/dist/query-cache.js.map +1 -1
- package/dist/query.d.ts +108 -29
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +294 -224
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.ts +57 -2
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +300 -88
- package/dist/realtime.js.map +1 -1
- package/dist/select-types.d.ts +99 -0
- package/dist/select-types.d.ts.map +1 -0
- package/dist/select-types.js +2 -0
- package/dist/select-types.js.map +1 -0
- package/dist/storage.d.ts +81 -11
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +137 -38
- package/dist/storage.js.map +1 -1
- package/dist/table-subscription.d.ts +69 -0
- package/dist/table-subscription.d.ts.map +1 -0
- package/dist/table-subscription.js +93 -0
- package/dist/table-subscription.js.map +1 -0
- package/dist/types.d.ts +98 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -2
- package/src/auth-redirect.ts +90 -0
- package/src/auth.ts +434 -281
- package/src/bindings.ts +22 -0
- package/src/caller-types.ts +27 -0
- package/src/draft-create.ts +51 -0
- package/src/draft-models-registry.ts +81 -0
- package/src/error-codes-doc.ts +44 -35
- package/src/errors.ts +72 -28
- package/src/exact-response.ts +2 -1
- package/src/exact-values.ts +16 -9
- package/src/fetch-with-retry.ts +80 -70
- package/src/field-kinds-registry.ts +22 -9
- package/src/filters.ts +133 -0
- package/src/generated-client.ts +6 -0
- package/src/graphql-document.ts +234 -0
- package/src/graphql-json.ts +243 -0
- package/src/graphql-transport.ts +97 -0
- package/src/index.ts +289 -208
- package/src/json.ts +117 -0
- package/src/jwt.ts +37 -0
- package/src/live-preview.ts +37 -0
- package/src/mutation-request.ts +66 -0
- package/src/preview.ts +9 -11
- package/src/query-cache.ts +19 -16
- package/src/query.ts +389 -270
- package/src/realtime.ts +333 -90
- package/src/select-types.ts +184 -0
- package/src/storage.ts +223 -44
- package/src/table-subscription.ts +160 -0
- package/src/types.ts +104 -5
- package/tests/auth-error-codes.test.ts +53 -0
- package/tests/auth-errors.test.ts +84 -0
- package/tests/auth-events.test.ts +136 -0
- package/tests/auth-url-session.test.ts +204 -0
- package/tests/auth.test.ts +187 -26
- package/tests/count.test.ts +60 -0
- package/tests/data-plane-auth.test.ts +21 -46
- package/tests/draft-insert.integration.test.ts +118 -0
- package/tests/draft-insert.test.ts +225 -0
- package/tests/draft-profile.test.ts +55 -84
- package/tests/draft-update.integration.test.ts +122 -0
- package/tests/draft-update.test.ts +174 -0
- package/tests/dynamic-headers.test.ts +45 -0
- package/tests/entry-points.test.ts +42 -0
- package/tests/exact-response.test.ts +4 -4
- package/tests/exact-values.test.ts +14 -25
- package/tests/field-kinds-registry.test.ts +3 -3
- package/tests/filters.test.ts +146 -0
- package/tests/graphql-json.test.ts +199 -0
- package/tests/helpers/mock-websocket.ts +44 -11
- package/tests/helpers/oauth-binding.ts +92 -0
- package/tests/helpers/signup-binding.ts +73 -0
- package/tests/helpers/socket-swap.ts +142 -0
- package/tests/mfa-totp-integration.test.ts +13 -20
- package/tests/postgrest-error-codes.test.ts +85 -0
- package/tests/query-cache.test.ts +116 -117
- package/tests/query.test.ts +29 -31
- package/tests/rate-limit-integration.test.ts +4 -12
- package/tests/realtime-ack-ref.test.ts +112 -0
- package/tests/realtime-exact-values.test.ts +2 -4
- package/tests/realtime-presence.test.ts +75 -0
- package/tests/realtime-session-auth.test.ts +2 -4
- package/tests/realtime-shared-channel.test.ts +209 -0
- package/tests/realtime-swap-status.test.ts +62 -0
- package/tests/retry-integration.test.ts +3 -8
- package/tests/retry-policy.test.ts +166 -0
- package/tests/rpc-resend.test.ts +24 -0
- package/tests/server-bodies.test.ts +187 -0
- package/tests/serverless.test.ts +2 -2
- package/tests/signed-url-absolute.test.ts +2 -5
- package/tests/storage-object-shape.test.ts +101 -0
- package/tests/storage-quota-integration.test.ts +7 -9
- package/tests/storage-reference-url.test.ts +51 -0
- package/tests/storage-upload-browser.test.ts +71 -0
- package/tests/storage-upload-limit-integration.test.ts +17 -31
- package/tests/storage-url-encoding.test.ts +52 -0
- package/tests/subscribe-frame.test.ts +5 -11
- package/tests/support/blob.ts +10 -0
- package/tests/support/fetch-mock.ts +64 -0
- package/tests/support/storage-object.ts +37 -0
- package/tests/table-subscribe.test.ts +41 -14
- package/tests/table-subscription.test.ts +105 -0
- package/tests/table-transport.test.ts +94 -0
- package/tests/tsconfig.json +1 -1
- package/tests/types.test.ts +153 -1
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,39 +1,78 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
2
|
+
> @supatype/client@0.8.0 test /home/runner/work/supatype/supatype/packages/client
|
|
3
3
|
> vitest run
|
|
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
|
-
|
|
10
|
-
[32m✓[39m tests/
|
|
11
|
-
|
|
12
|
-
[32m✓[39m tests/
|
|
13
|
-
|
|
14
|
-
[32m✓[39m tests/
|
|
15
|
-
|
|
16
|
-
[32m✓[39m tests/
|
|
17
|
-
|
|
18
|
-
[32m✓[39m tests/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[32m✓[39m tests/
|
|
22
|
-
|
|
23
|
-
[32m✓[39m tests/
|
|
24
|
-
|
|
25
|
-
[32m✓[39m tests/
|
|
26
|
-
[32m✓[39m tests/
|
|
27
|
-
|
|
28
|
-
[32m✓[39m tests/
|
|
29
|
-
|
|
30
|
-
[32m✓[39m tests/
|
|
8
|
+
[32m✓[39m tests/auth.test.ts [2m([22m[2m46 tests[22m[2m)[22m[33m 1095[2mms[22m[39m
|
|
9
|
+
[33m[2m✓[22m[39m sends POST to /signup [33m 400[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/query.test.ts [2m([22m[2m36 tests[22m[2m)[22m[33m 770[2mms[22m[39m
|
|
11
|
+
[33m[2m✓[22m[39m sends request to base + path with no params [33m 422[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/types.test.ts [2m([22m[2m30 tests[22m[2m)[22m[33m 494[2mms[22m[39m
|
|
13
|
+
[33m[2m✓[22m[39m .single() resolves to QueryResult<Row> [33m 364[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/mfa-totp-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 715[2mms[22m[39m
|
|
15
|
+
[33m[2m✓[22m[39m calls POST /factors with factor_type=totp [33m 558[2mms[22m[39m
|
|
16
|
+
[32m✓[39m tests/draft-profile.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 619[2mms[22m[39m
|
|
17
|
+
[33m[2m✓[22m[39m is sent as Accept-Profile when the query asks for it [33m 326[2mms[22m[39m
|
|
18
|
+
[32m✓[39m tests/table-subscribe.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 584[2mms[22m[39m
|
|
19
|
+
[32m✓[39m tests/realtime-multi-tenant-integration.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 574[2mms[22m[39m
|
|
20
|
+
[33m[2m✓[22m[39m receives INSERT events on the subscribed channel [33m 391[2mms[22m[39m
|
|
21
|
+
[32m✓[39m tests/graphql-json.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 663[2mms[22m[39m
|
|
22
|
+
[33m[2m✓[22m[39m decodes a rich text field [33m 315[2mms[22m[39m
|
|
23
|
+
[32m✓[39m tests/draft-insert.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 1090[2mms[22m[39m
|
|
24
|
+
[33m[2m✓[22m[39m creates the record through supatype.create_record [33m 445[2mms[22m[39m
|
|
25
|
+
[32m✓[39m tests/realtime-shared-channel.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 275[2mms[22m[39m
|
|
26
|
+
[32m✓[39m tests/draft-update.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 552[2mms[22m[39m
|
|
27
|
+
[33m[2m✓[22m[39m reads the keys of the records its filters match, as the caller reads the table [33m 318[2mms[22m[39m
|
|
28
|
+
[32m✓[39m tests/auth-url-session.test.ts [2m([22m[2m10 tests[22m[2m)[22m[33m 483[2mms[22m[39m
|
|
29
|
+
[33m[2m✓[22m[39m signs in from implicit-grant tokens in the fragment and cleans the URL [33m 321[2mms[22m[39m
|
|
30
|
+
[32m✓[39m tests/server-bodies.test.ts [2m([22m[2m20 tests[22m[2m)[22m[33m 305[2mms[22m[39m
|
|
31
|
+
[32m✓[39m tests/exact-values.test.ts [2m([22m[2m24 tests[22m[2m)[22m[32m 155[2mms[22m[39m
|
|
32
|
+
[32m✓[39m tests/retry-integration.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 745[2mms[22m[39m
|
|
33
|
+
[33m[2m✓[22m[39m succeeds immediately on 200 with no retries [33m 451[2mms[22m[39m
|
|
34
|
+
[32m✓[39m tests/storage-quota-integration.test.ts [2m([22m[2m10 tests[22m[2m)[22m[33m 499[2mms[22m[39m
|
|
35
|
+
[33m[2m✓[22m[39m returns 507 Insufficient Storage with clear message [33m 340[2mms[22m[39m
|
|
36
|
+
[32m✓[39m tests/rate-limit-integration.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 695[2mms[22m[39m
|
|
37
|
+
[33m[2m✓[22m[39m waits Retry-After seconds then retries on 429 [33m 427[2mms[22m[39m
|
|
38
|
+
[32m✓[39m tests/storage-upload-limit-integration.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 339[2mms[22m[39m
|
|
39
|
+
[32m✓[39m tests/realtime-session-auth.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 237[2mms[22m[39m
|
|
40
|
+
[32m✓[39m tests/retry-policy.test.ts [2m([22m[2m17 tests[22m[2m)[22m[33m 1825[2mms[22m[39m
|
|
41
|
+
[32m✓[39m tests/realtime-exact-values.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 512[2mms[22m[39m
|
|
42
|
+
[2m[90m↓[39m[22m tests/draft-update.integration.test.ts [2m([22m[2m3 tests[22m[2m | [22m[33m3 skipped[39m[2m)[22m
|
|
43
|
+
[32m✓[39m tests/subscribe-frame.test.ts [2m([22m[2m6 tests[22m[2m)[22m[33m 360[2mms[22m[39m
|
|
44
|
+
[2m[90m↓[39m[22m tests/draft-insert.integration.test.ts [2m([22m[2m4 tests[22m[2m | [22m[33m4 skipped[39m[2m)[22m
|
|
45
|
+
[32m✓[39m tests/filters.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 399[2mms[22m[39m
|
|
46
|
+
[32m✓[39m tests/storage-object-shape.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 270[2mms[22m[39m
|
|
47
|
+
[32m✓[39m tests/realtime-ack-ref.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m 302[2mms[22m[39m
|
|
48
|
+
[32m✓[39m tests/postgrest-error-codes.test.ts [2m([22m[2m28 tests[22m[2m)[22m[32m 58[2mms[22m[39m
|
|
49
|
+
[32m✓[39m tests/auth-events.test.ts [2m([22m[2m6 tests[22m[2m)[22m[33m 323[2mms[22m[39m
|
|
50
|
+
[32m✓[39m tests/data-plane-auth.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 220[2mms[22m[39m
|
|
51
|
+
[32m✓[39m tests/serverless.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 71[2mms[22m[39m
|
|
52
|
+
[32m✓[39m tests/exact-response.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 43[2mms[22m[39m
|
|
53
|
+
[32m✓[39m tests/query-cache.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 228[2mms[22m[39m
|
|
54
|
+
[32m✓[39m tests/auth-errors.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 275[2mms[22m[39m
|
|
55
|
+
[32m✓[39m tests/identity-change.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 30[2mms[22m[39m
|
|
56
|
+
[32m✓[39m tests/table-subscription.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 231[2mms[22m[39m
|
|
57
|
+
[32m✓[39m tests/table-transport.test.ts [2m([22m[2m8 tests[22m[2m)[22m[33m 511[2mms[22m[39m
|
|
58
|
+
[32m✓[39m tests/storage-upload-browser.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 123[2mms[22m[39m
|
|
59
|
+
[32m✓[39m tests/signed-url-absolute.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 177[2mms[22m[39m
|
|
60
|
+
[32m✓[39m tests/field-kinds-registry.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 21[2mms[22m[39m
|
|
61
|
+
[32m✓[39m tests/realtime-presence.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 177[2mms[22m[39m
|
|
62
|
+
[32m✓[39m tests/storage-reference-url.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 19[2mms[22m[39m
|
|
63
|
+
[32m✓[39m tests/auth-error-codes.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 48[2mms[22m[39m
|
|
31
64
|
[32m✓[39m tests/masked-fields.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
32
|
-
[32m✓[39m tests/
|
|
33
|
-
[32m✓[39m tests/
|
|
65
|
+
[32m✓[39m tests/realtime-swap-status.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 168[2mms[22m[39m
|
|
66
|
+
[32m✓[39m tests/count.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 36[2mms[22m[39m
|
|
67
|
+
[32m✓[39m tests/storage-url-encoding.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 97[2mms[22m[39m
|
|
68
|
+
[32m✓[39m tests/dynamic-headers.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 136[2mms[22m[39m
|
|
69
|
+
[32m✓[39m tests/entry-points.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
70
|
+
[32m✓[39m tests/pkce.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 15[2mms[22m[39m
|
|
71
|
+
[32m✓[39m tests/sha256-hex.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
72
|
+
[32m✓[39m tests/rpc-resend.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 47[2mms[22m[39m
|
|
34
73
|
|
|
35
|
-
[2m Test Files [22m [1m[
|
|
36
|
-
[2m Tests [22m [1m[
|
|
37
|
-
[2m Start at [22m
|
|
38
|
-
[2m Duration [22m
|
|
74
|
+
[2m Test Files [22m [1m[32m50 passed[39m[22m[2m | [22m[33m2 skipped[39m[90m (52)[39m
|
|
75
|
+
[2m Tests [22m [1m[32m548 passed[39m[22m[2m | [22m[33m7 skipped[39m[90m (555)[39m
|
|
76
|
+
[2m Start at [22m 21:33:34
|
|
77
|
+
[2m Duration [22m 34.85s[2m (transform 10.82s, setup 0ms, import 28.16s, tests 17.65s, environment 45ms)[22m
|
|
39
78
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/client@0.
|
|
3
|
-
> tsc --project
|
|
2
|
+
> @supatype/client@0.8.0 typecheck /home/runner/work/supatype/supatype/packages/client
|
|
3
|
+
> tsc --project tests/tsconfig.json --noEmit
|
|
4
4
|
|
package/LICENSE
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the auth server's redirect back to the app.
|
|
3
|
+
*
|
|
4
|
+
* The server returns a browser with the outcome in the URL: implicit-grant tokens in the fragment
|
|
5
|
+
* (`#access_token=...&refresh_token=...`), a PKCE `code` in the query, or a refusal as `error`,
|
|
6
|
+
* `error_code` and `error_description` in both. These helpers follow supabase-js: a URL is an auth
|
|
7
|
+
* redirect when it carries `access_token` or `error_description`, or a `code` this client is
|
|
8
|
+
* waiting for, and once read it loses those parameters so a reload or a shared link does not replay
|
|
9
|
+
* them.
|
|
10
|
+
*/
|
|
11
|
+
import type { SupatypeError } from "./types.js";
|
|
12
|
+
export interface RedirectParams {
|
|
13
|
+
query: URLSearchParams;
|
|
14
|
+
fragment: URLSearchParams;
|
|
15
|
+
}
|
|
16
|
+
/** The redirect's query and fragment parameters, or null when `href` is not a URL. */
|
|
17
|
+
export declare function redirectParams(href: string): RedirectParams | null;
|
|
18
|
+
/** A parameter from the fragment or the query, as the server may put it in either. */
|
|
19
|
+
export declare function redirectParam(params: RedirectParams, key: string): string | null;
|
|
20
|
+
/** True when the URL carries implicit-grant tokens or the server's refusal. */
|
|
21
|
+
export declare function carriesImplicitResult(params: RedirectParams): boolean;
|
|
22
|
+
/** `href` without the parameters the server added, ready for `history.replaceState`. */
|
|
23
|
+
export declare function withoutAuthParams(href: string): string;
|
|
24
|
+
/** The page's URL when running in a browser, else null (a server, a worker, React Native). */
|
|
25
|
+
export declare function browserHref(): string | null;
|
|
26
|
+
/** Take the auth parameters out of the address bar without a navigation. */
|
|
27
|
+
export declare function cleanBrowserUrl(href: string): void;
|
|
28
|
+
/** The part of `AuthClient` a binding starts an OAuth sign-in through. */
|
|
29
|
+
interface OAuthStarter {
|
|
30
|
+
signInWithOAuth(opts: {
|
|
31
|
+
provider: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
data: {
|
|
34
|
+
url: string;
|
|
35
|
+
};
|
|
36
|
+
error: SupatypeError | null;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Start an OAuth sign-in for a framework binding: ask the client for the provider's URL and send
|
|
41
|
+
* the browser there, as supabase-js's `signInWithOAuth` does. A refusal (a provider the project has
|
|
42
|
+
* not enabled) is returned and the page stays put.
|
|
43
|
+
*/
|
|
44
|
+
export declare function startOAuthRedirect(auth: OAuthStarter, provider: string): Promise<{
|
|
45
|
+
error: SupatypeError | null;
|
|
46
|
+
}>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=auth-redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-redirect.d.ts","sourceRoot":"","sources":["../src/auth-redirect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAQ/C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,eAAe,CAAA;IACtB,QAAQ,EAAE,eAAe,CAAA;CAC1B;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CASlE;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhF;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAErE;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAI3C;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGlD;AAED,0EAA0E;AAC1E,UAAU,YAAY;IACpB,eAAe,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QACnD,IAAI,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;QACrB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAC5B,CAAC,CAAA;CACH;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC,CAI1C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the auth server's redirect back to the app.
|
|
3
|
+
*
|
|
4
|
+
* The server returns a browser with the outcome in the URL: implicit-grant tokens in the fragment
|
|
5
|
+
* (`#access_token=...&refresh_token=...`), a PKCE `code` in the query, or a refusal as `error`,
|
|
6
|
+
* `error_code` and `error_description` in both. These helpers follow supabase-js: a URL is an auth
|
|
7
|
+
* redirect when it carries `access_token` or `error_description`, or a `code` this client is
|
|
8
|
+
* waiting for, and once read it loses those parameters so a reload or a shared link does not replay
|
|
9
|
+
* them.
|
|
10
|
+
*/
|
|
11
|
+
/** Query parameters the server adds to the redirect; anything else is the app's own and is kept. */
|
|
12
|
+
const QUERY_KEYS = ["code", "error", "error_code", "error_description", "sb"];
|
|
13
|
+
/** Fragment parameters that mark the fragment as the server's rather than the app's (a hash route). */
|
|
14
|
+
const FRAGMENT_KEYS = ["access_token", "refresh_token", "error", "error_description", "sb"];
|
|
15
|
+
/** The redirect's query and fragment parameters, or null when `href` is not a URL. */
|
|
16
|
+
export function redirectParams(href) {
|
|
17
|
+
let url;
|
|
18
|
+
try {
|
|
19
|
+
url = new URL(href);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const hash = url.hash.startsWith("#") ? url.hash.slice(1) : url.hash;
|
|
25
|
+
return { query: url.searchParams, fragment: new URLSearchParams(hash) };
|
|
26
|
+
}
|
|
27
|
+
/** A parameter from the fragment or the query, as the server may put it in either. */
|
|
28
|
+
export function redirectParam(params, key) {
|
|
29
|
+
const value = params.fragment.get(key) ?? params.query.get(key);
|
|
30
|
+
return value === null || value === "" ? null : value;
|
|
31
|
+
}
|
|
32
|
+
/** True when the URL carries implicit-grant tokens or the server's refusal. */
|
|
33
|
+
export function carriesImplicitResult(params) {
|
|
34
|
+
return redirectParam(params, "access_token") !== null || redirectParam(params, "error_description") !== null;
|
|
35
|
+
}
|
|
36
|
+
/** `href` without the parameters the server added, ready for `history.replaceState`. */
|
|
37
|
+
export function withoutAuthParams(href) {
|
|
38
|
+
const url = new URL(href);
|
|
39
|
+
for (const key of QUERY_KEYS)
|
|
40
|
+
url.searchParams.delete(key);
|
|
41
|
+
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
42
|
+
if (FRAGMENT_KEYS.some((key) => fragment.has(key)))
|
|
43
|
+
url.hash = "";
|
|
44
|
+
return url.toString();
|
|
45
|
+
}
|
|
46
|
+
/** The page's URL when running in a browser, else null (a server, a worker, React Native). */
|
|
47
|
+
export function browserHref() {
|
|
48
|
+
if (typeof window === "undefined")
|
|
49
|
+
return null;
|
|
50
|
+
const href = window.location?.href;
|
|
51
|
+
return typeof href === "string" ? href : null;
|
|
52
|
+
}
|
|
53
|
+
/** Take the auth parameters out of the address bar without a navigation. */
|
|
54
|
+
export function cleanBrowserUrl(href) {
|
|
55
|
+
if (typeof window === "undefined" || typeof window.history?.replaceState !== "function")
|
|
56
|
+
return;
|
|
57
|
+
window.history.replaceState(window.history.state, "", withoutAuthParams(href));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Start an OAuth sign-in for a framework binding: ask the client for the provider's URL and send
|
|
61
|
+
* the browser there, as supabase-js's `signInWithOAuth` does. A refusal (a provider the project has
|
|
62
|
+
* not enabled) is returned and the page stays put.
|
|
63
|
+
*/
|
|
64
|
+
export async function startOAuthRedirect(auth, provider) {
|
|
65
|
+
const { data, error } = await auth.signInWithOAuth({ provider });
|
|
66
|
+
if (error === null && data.url !== "" && typeof window !== "undefined")
|
|
67
|
+
window.location.assign(data.url);
|
|
68
|
+
return { error };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=auth-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-redirect.js","sourceRoot":"","sources":["../src/auth-redirect.ts"],"names":[],"mappings":"AA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AAK,EAAE,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAChE,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxG,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import type { AuthChangeEvent, AuthFlowType, AuthMFAChallengeResponse, AuthMFAEnrollResponse, AuthMFAListFactorsResponse, AuthStorage, OtpType, Session, SupatypeError, User } from "./types.js";
|
|
1
|
+
import type { AuthChangeEvent, AuthFlowType, AuthRedirectError, AuthMFAChallengeResponse, AuthMFAEnrollResponse, AuthMFAListFactorsResponse, AuthStorage, OtpType, Session, SupatypeError, User } from "./types.js";
|
|
2
|
+
import { type RequestTransport } from "./fetch-with-retry.js";
|
|
2
3
|
export type AuthListener = (event: AuthChangeEvent, session: Session | null) => void;
|
|
3
4
|
interface AuthClientOptions {
|
|
4
5
|
initialSession?: Session | undefined;
|
|
5
6
|
persistSession?: boolean | undefined;
|
|
7
|
+
/** Refresh on a timer before the token expires, and at once when it starts expired. Default: true. */
|
|
8
|
+
autoRefreshToken?: boolean | undefined;
|
|
9
|
+
/** Refresh an expired access token when a request or `getSession` finds it. Default: true. */
|
|
10
|
+
refreshExpiredToken?: boolean | undefined;
|
|
6
11
|
storageKey?: string | undefined;
|
|
7
12
|
cookiePrefix?: string | undefined;
|
|
8
13
|
/** Custom session store (replaces browser localStorage/cookies when set). */
|
|
9
14
|
storage?: AuthStorage | undefined;
|
|
15
|
+
/** How requests are sent. `createClient` passes its fetch, so `timeout` and `retry` apply here too. */
|
|
16
|
+
transport?: RequestTransport | undefined;
|
|
17
|
+
/** Finish a sign-in carried by the page's URL on start (browser only). Default: true. */
|
|
18
|
+
detectSessionInUrl?: boolean | undefined;
|
|
10
19
|
}
|
|
11
20
|
export declare class AuthClient {
|
|
12
21
|
private readonly url;
|
|
@@ -15,13 +24,21 @@ export declare class AuthClient {
|
|
|
15
24
|
private readonly listeners;
|
|
16
25
|
private listenerIdCounter;
|
|
17
26
|
private readonly persistSession;
|
|
27
|
+
/** False leaves every refresh to `ensureValidSession`, which each request calls first. */
|
|
28
|
+
private readonly autoRefreshToken;
|
|
29
|
+
/** False makes `ensureValidSession` leave an expired session as it is, for the server to refuse. */
|
|
30
|
+
private readonly refreshExpiredToken;
|
|
18
31
|
private readonly storageKey;
|
|
19
32
|
private readonly cookieName;
|
|
20
33
|
private readonly storage;
|
|
34
|
+
/** The client's fetch, with its timeout; only reads are retried. */
|
|
35
|
+
private readonly send;
|
|
21
36
|
/** When true, session is also mirrored to document.cookie (browser default path only). */
|
|
22
37
|
private readonly useCookies;
|
|
23
|
-
/** Resolves when async storage hydration
|
|
38
|
+
/** Resolves when async storage hydration and any sign-in carried by the page's URL complete. */
|
|
24
39
|
private readonly ready;
|
|
40
|
+
/** What `ready` settles with: the refusal the page's URL reported, if any. */
|
|
41
|
+
private readonly initialized;
|
|
25
42
|
/** Pending auto-refresh timer; refreshes the access token shortly before it expires. */
|
|
26
43
|
private refreshTimer;
|
|
27
44
|
/** Dedupes concurrent refresh attempts (getSession + auto-refresh). */
|
|
@@ -29,8 +46,28 @@ export declare class AuthClient {
|
|
|
29
46
|
/** In-memory PKCE code_verifier for the in-flight OAuth / OTP redirect. */
|
|
30
47
|
private codeVerifier;
|
|
31
48
|
constructor(url: string, baseHeaders: Record<string, string>, opts?: AuthClientOptions);
|
|
32
|
-
/**
|
|
49
|
+
/** The session the client starts with: the one passed in, else the persisted one. */
|
|
50
|
+
private loadInitialSession;
|
|
51
|
+
/** Resolves when the client has its starting session (storage hydrated, any URL sign-in done). */
|
|
33
52
|
whenReady(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Wait for the client's start, and learn whether a sign-in in the page's URL was refused.
|
|
55
|
+
*
|
|
56
|
+
* The same shape as supabase-js's `initialize()`. A refused OAuth sign-in comes back as
|
|
57
|
+
* `?error=...&error_description=...`; this is where an app (or `useAuth`) reads it.
|
|
58
|
+
*/
|
|
59
|
+
initialize(): Promise<{
|
|
60
|
+
error: AuthRedirectError | null;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Finish the sign-in the page's URL carries, as supabase-js's `detectSessionInUrl` does.
|
|
64
|
+
*
|
|
65
|
+
* Whatever session was stored is set aside first, so a new sign-in is announced as `SIGNED_IN`
|
|
66
|
+
* and a refused one leaves the browser signed out, as supabase-js does after a failed attempt.
|
|
67
|
+
*/
|
|
68
|
+
private completeRedirect;
|
|
69
|
+
/** A URL with tokens or a refusal, or with a `code` for a PKCE flow this client started. */
|
|
70
|
+
private isAuthRedirect;
|
|
34
71
|
private hydrateFromStorage;
|
|
35
72
|
/** Milliseconds since epoch when the access token expires (with optional skew). */
|
|
36
73
|
private sessionExpiresAtMs;
|
|
@@ -80,6 +117,12 @@ export declare class AuthClient {
|
|
|
80
117
|
};
|
|
81
118
|
error: SupatypeError | null;
|
|
82
119
|
}>;
|
|
120
|
+
/**
|
|
121
|
+
* An auth endpoint, carrying the caller's redirect as `redirect_to` in the query string. The
|
|
122
|
+
* server reads it from there (or a header) and never from a JSON body, so a redirect sent in the
|
|
123
|
+
* body is dropped in silence and the email links to SITE_URL instead.
|
|
124
|
+
*/
|
|
125
|
+
private endpoint;
|
|
83
126
|
signInWithOAuth(opts: {
|
|
84
127
|
provider: string;
|
|
85
128
|
options?: {
|
|
@@ -87,6 +130,11 @@ export declare class AuthClient {
|
|
|
87
130
|
/** Default: `implicit` (web-compatible). Pass `pkce` for mobile / RN. */
|
|
88
131
|
flowType?: AuthFlowType | undefined;
|
|
89
132
|
scopes?: string | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Extra `/authorize` query parameters, sent as given. The flow's own (`provider`,
|
|
135
|
+
* `redirect_to`, `scopes`, the PKCE challenge) are set after these and cannot be replaced.
|
|
136
|
+
*/
|
|
137
|
+
queryParams?: Record<string, string> | undefined;
|
|
90
138
|
} | undefined;
|
|
91
139
|
}): Promise<{
|
|
92
140
|
data: {
|
|
@@ -95,6 +143,12 @@ export declare class AuthClient {
|
|
|
95
143
|
};
|
|
96
144
|
error: SupatypeError | null;
|
|
97
145
|
}>;
|
|
146
|
+
/**
|
|
147
|
+
* True only when the server's `/settings` list the provider as off. A provider they do not list
|
|
148
|
+
* (a `custom:` one) or settings that cannot be read leave the decision to `/authorize`. Looked up
|
|
149
|
+
* in lower case, as `/authorize` resolves it, so `GitHub` is refused exactly when `github` is.
|
|
150
|
+
*/
|
|
151
|
+
private providerDisabled;
|
|
98
152
|
/**
|
|
99
153
|
* Apply tokens from an OAuth / deep-link redirect (implicit grant) or restore a session.
|
|
100
154
|
* Fetches `/user` to hydrate the user object, then persists via the configured storage.
|
|
@@ -132,6 +186,15 @@ export declare class AuthClient {
|
|
|
132
186
|
};
|
|
133
187
|
error: SupatypeError | null;
|
|
134
188
|
}>;
|
|
189
|
+
/** The session a redirect carries: a PKCE code to exchange, or implicit-grant tokens. */
|
|
190
|
+
private sessionFromRedirect;
|
|
191
|
+
/**
|
|
192
|
+
* Emit `PASSWORD_RECOVERY` once a recovery link or code has produced a session.
|
|
193
|
+
*
|
|
194
|
+
* After the `SIGNED_IN` that establishing the session already emitted, as `MFA_CHALLENGE_VERIFIED`
|
|
195
|
+
* follows it, so a listener keyed on sign-in still sees one and a reset page can key on this.
|
|
196
|
+
*/
|
|
197
|
+
private announceRecovery;
|
|
135
198
|
signInWithOtp(opts: {
|
|
136
199
|
email?: string | undefined;
|
|
137
200
|
phone?: string | undefined;
|
|
@@ -183,6 +246,13 @@ export declare class AuthClient {
|
|
|
183
246
|
};
|
|
184
247
|
error: SupatypeError | null;
|
|
185
248
|
}>;
|
|
249
|
+
/**
|
|
250
|
+
* Put the server's updated user on the session, persist it, and tell listeners.
|
|
251
|
+
*
|
|
252
|
+
* The tokens are unchanged, so this neither reschedules the refresh nor emits `TOKEN_REFRESHED`;
|
|
253
|
+
* without it the session kept the old email and metadata until the next refresh.
|
|
254
|
+
*/
|
|
255
|
+
private applyUpdatedUser;
|
|
186
256
|
/**
|
|
187
257
|
* Verify an OTP token received via email or phone.
|
|
188
258
|
* Completes email confirmation, magic link, recovery, or phone OTP flows.
|
|
@@ -326,7 +396,15 @@ export declare class AuthClient {
|
|
|
326
396
|
/** Returns the current session's access token, or null when signed out. */
|
|
327
397
|
get currentAccessToken(): string | null;
|
|
328
398
|
private getBrowserStorage;
|
|
329
|
-
|
|
399
|
+
/**
|
|
400
|
+
* Keep a value for the OAuth redirect to find on the way back (a new page load, so not memory).
|
|
401
|
+
* A write that fails is ignored: same-process flows still have the in-memory copy.
|
|
402
|
+
*/
|
|
403
|
+
private writeFlowItem;
|
|
404
|
+
private readFlowItem;
|
|
405
|
+
private removeFlowItem;
|
|
406
|
+
/** Read a flow value once: the redirect it was kept for has now arrived. */
|
|
407
|
+
private takeFlowItem;
|
|
330
408
|
private beginPkce;
|
|
331
409
|
private readCodeVerifier;
|
|
332
410
|
private clearCodeVerifier;
|
|
@@ -336,6 +414,7 @@ export declare class AuthClient {
|
|
|
336
414
|
private loadPersistedSessionAsync;
|
|
337
415
|
private loadPersistedSession;
|
|
338
416
|
private parsePersistedSession;
|
|
417
|
+
/** A stored session, written by this client (camelCase) or by a server-side helper (snake_case). */
|
|
339
418
|
private normalizePersistedSession;
|
|
340
419
|
private syncPersistedSession;
|
|
341
420
|
private writePersistedSession;
|
|
@@ -344,7 +423,10 @@ export declare class AuthClient {
|
|
|
344
423
|
private writeCookie;
|
|
345
424
|
_setSession(session: Session | null): void;
|
|
346
425
|
private _emitEvent;
|
|
426
|
+
/** Every refusal from the auth server goes through here, so none of them drops the code. */
|
|
347
427
|
private _parseError;
|
|
428
|
+
/** The user a `/user` response describes. Throws on a body that is not a JSON object. */
|
|
429
|
+
private _readUser;
|
|
348
430
|
private _parseAuthResponse;
|
|
349
431
|
private _parseUser;
|
|
350
432
|
}
|
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,aAAa,EACb,IAAI,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,WAAW,EAEX,OAAO,EACP,OAAO,EACP,aAAa,EACb,IAAI,EAEL,MAAM,YAAY,CAAA;AAMnB,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAqBzE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;AAEpF,UAAU,iBAAiB;IACzB,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACpC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACpC,sGAAsG;IACtG,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,8FAA8F;IAC9F,mBAAmB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IACjC,uGAAuG;IACvG,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAA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