@coinlist-co/react 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{chunk-OETRTIQ4.js → chunk-74NFAQYP.js} +202 -7
  2. package/dist/chunk-74NFAQYP.js.map +1 -0
  3. package/dist/chunk-EPWEY23P.js +118 -0
  4. package/dist/chunk-EPWEY23P.js.map +1 -0
  5. package/dist/{chunk-NLJMUHOG.js → chunk-GRVV7NLV.js} +35 -6
  6. package/dist/chunk-GRVV7NLV.js.map +1 -0
  7. package/dist/chunk-Y5AHTOZO.js +76 -0
  8. package/dist/chunk-Y5AHTOZO.js.map +1 -0
  9. package/dist/client/components/index.cjs +188 -2
  10. package/dist/client/components/index.cjs.map +1 -1
  11. package/dist/client/components/index.d.cts +41 -1
  12. package/dist/client/components/index.d.ts +41 -1
  13. package/dist/client/components/index.js +149 -4
  14. package/dist/client/components/index.js.map +1 -1
  15. package/dist/client/core/index.cjs +229 -6
  16. package/dist/client/core/index.cjs.map +1 -1
  17. package/dist/client/core/index.d.cts +4 -3
  18. package/dist/client/core/index.d.ts +4 -3
  19. package/dist/client/core/index.js +2 -2
  20. package/dist/client/hooks/index.cjs +136 -2
  21. package/dist/client/hooks/index.cjs.map +1 -1
  22. package/dist/client/hooks/index.d.cts +52 -11
  23. package/dist/client/hooks/index.d.ts +52 -11
  24. package/dist/client/hooks/index.js +13 -5
  25. package/dist/client/index.cjs +287 -8
  26. package/dist/client/index.cjs.map +1 -1
  27. package/dist/client/index.d.cts +6 -4
  28. package/dist/client/index.d.ts +6 -4
  29. package/dist/client/index.js +7 -5
  30. package/dist/client/styles.css +1 -1
  31. package/dist/coinlist-client-BJx6w3Xb.d.cts +271 -0
  32. package/dist/coinlist-client-CN48gVhi.d.ts +271 -0
  33. package/dist/newtype-yKTvFdg_.d.cts +6 -0
  34. package/dist/newtype-yKTvFdg_.d.ts +6 -0
  35. package/dist/{oauth-session-g0OPJNKn.d.ts → oauth-session-DgItaMKN.d.cts} +2 -5
  36. package/dist/{oauth-session-g0OPJNKn.d.cts → oauth-session-DnKDI5ou.d.ts} +2 -5
  37. package/dist/offer-CkZxbS45.d.ts +30 -0
  38. package/dist/offer-Ds1HdaFD.d.cts +30 -0
  39. package/dist/server/index.cjs +32 -3
  40. package/dist/server/index.cjs.map +1 -1
  41. package/dist/server/index.d.cts +3 -2
  42. package/dist/server/index.d.ts +3 -2
  43. package/dist/server/index.js +3 -3
  44. package/dist/server/index.js.map +1 -1
  45. package/dist/useCompleteCoinListOAuth-B2Pl0vQo.d.cts +55 -0
  46. package/dist/useCompleteCoinListOAuth-wkCa45w3.d.ts +55 -0
  47. package/package.json +1 -1
  48. package/dist/chunk-F56RBKNS.js +0 -63
  49. package/dist/chunk-F56RBKNS.js.map +0 -1
  50. package/dist/chunk-NLJMUHOG.js.map +0 -1
  51. package/dist/chunk-OETRTIQ4.js.map +0 -1
  52. package/dist/coinlist-client-BH_Cn_7u.d.cts +0 -71
  53. package/dist/coinlist-client-fkB3J-2a.d.ts +0 -71
@@ -1,71 +0,0 @@
1
- import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-g0OPJNKn.cjs';
2
-
3
- type AuthState = 'unknown' | 'logged-in' | 'logged-out';
4
- /** Discriminated error reasons from {@link CoinListClient.completeOauth}. */
5
- type OauthClientErrorReason = 'missing_state' | 'invalid_state' | 'missing_code' | 'missing_code_verifier';
6
- type OauthClientResult = {
7
- type: 'ok';
8
- code: AuthorizationCode;
9
- codeVerifier: CodeVerifier;
10
- } | {
11
- type: 'error';
12
- reason: OauthClientErrorReason;
13
- };
14
-
15
- interface ClientConfig extends Config {
16
- /**
17
- * The SDK user must provide this function. It is responsible for fetching a
18
- * valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
19
- * backend is in TypeScript, it is recommended to use
20
- * {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
21
- */
22
- getAccessToken: () => Promise<OAuthAccessToken | null>;
23
- }
24
- interface CoinListClient {
25
- /**
26
- * Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
27
- * the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
28
- * you typically do not need to call it yourself unless you are using the client
29
- * outside of the provider.
30
- */
31
- init(): Promise<AuthState>;
32
- /**
33
- * Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
34
- * Returns **unknown** until {@link CoinListClient.init} has completed. It is
35
- * recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
36
- * the SDK has initialized, or to manually await {@link CoinListClient.init}
37
- * before relying on this value.
38
- */
39
- getAuthState(): AuthState;
40
- /**
41
- * Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
42
- * stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
43
- * on redirect), then redirects the user to the CoinList authorization page. After
44
- * the user authorizes, they are sent back to your application's redirect URI; call
45
- * {@link CoinListClient.completeOAuth} on that page to finish the flow.
46
- */
47
- startOAuth(): Promise<void>;
48
- /**
49
- * Completes the OAuth flow on the FE with PKCE and state validation. Parses the
50
- * redirect URL (state, code) and validates them against sessionStorage
51
- * (state, code_verifier). The state check protects against CSRF (cross-site
52
- * request forgery). Call this on the frontend page the user is redirected
53
- * to after authorizing.
54
- *
55
- * On `ok`: Call your backend to exchange the short-lived `authorizationCode`
56
- * (and the returned `codeVerifier`) for a long-lived session. If your backend
57
- * is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
58
- * `@/server/coinlist.server` (CoinListServer) to perform that exchange.
59
- *
60
- * On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.
61
- */
62
- completeOAuth(): OauthClientResult;
63
- /**
64
- * Clears the in-memory access token. Note: you need to manually
65
- * also logout on the backend via CoinListServer#logout to clear the session cookie.
66
- */
67
- logout(): void;
68
- }
69
- declare function createCoinListClient(config: ClientConfig): CoinListClient;
70
-
71
- export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };
@@ -1,71 +0,0 @@
1
- import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-g0OPJNKn.js';
2
-
3
- type AuthState = 'unknown' | 'logged-in' | 'logged-out';
4
- /** Discriminated error reasons from {@link CoinListClient.completeOauth}. */
5
- type OauthClientErrorReason = 'missing_state' | 'invalid_state' | 'missing_code' | 'missing_code_verifier';
6
- type OauthClientResult = {
7
- type: 'ok';
8
- code: AuthorizationCode;
9
- codeVerifier: CodeVerifier;
10
- } | {
11
- type: 'error';
12
- reason: OauthClientErrorReason;
13
- };
14
-
15
- interface ClientConfig extends Config {
16
- /**
17
- * The SDK user must provide this function. It is responsible for fetching a
18
- * valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
19
- * backend is in TypeScript, it is recommended to use
20
- * {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
21
- */
22
- getAccessToken: () => Promise<OAuthAccessToken | null>;
23
- }
24
- interface CoinListClient {
25
- /**
26
- * Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
27
- * the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
28
- * you typically do not need to call it yourself unless you are using the client
29
- * outside of the provider.
30
- */
31
- init(): Promise<AuthState>;
32
- /**
33
- * Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
34
- * Returns **unknown** until {@link CoinListClient.init} has completed. It is
35
- * recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
36
- * the SDK has initialized, or to manually await {@link CoinListClient.init}
37
- * before relying on this value.
38
- */
39
- getAuthState(): AuthState;
40
- /**
41
- * Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
42
- * stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
43
- * on redirect), then redirects the user to the CoinList authorization page. After
44
- * the user authorizes, they are sent back to your application's redirect URI; call
45
- * {@link CoinListClient.completeOAuth} on that page to finish the flow.
46
- */
47
- startOAuth(): Promise<void>;
48
- /**
49
- * Completes the OAuth flow on the FE with PKCE and state validation. Parses the
50
- * redirect URL (state, code) and validates them against sessionStorage
51
- * (state, code_verifier). The state check protects against CSRF (cross-site
52
- * request forgery). Call this on the frontend page the user is redirected
53
- * to after authorizing.
54
- *
55
- * On `ok`: Call your backend to exchange the short-lived `authorizationCode`
56
- * (and the returned `codeVerifier`) for a long-lived session. If your backend
57
- * is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
58
- * `@/server/coinlist.server` (CoinListServer) to perform that exchange.
59
- *
60
- * On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.
61
- */
62
- completeOAuth(): OauthClientResult;
63
- /**
64
- * Clears the in-memory access token. Note: you need to manually
65
- * also logout on the backend via CoinListServer#logout to clear the session cookie.
66
- */
67
- logout(): void;
68
- }
69
- declare function createCoinListClient(config: ClientConfig): CoinListClient;
70
-
71
- export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };