@echoxyz/sonar-react 0.5.0 → 0.6.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/CHANGELOG.md +18 -0
- package/README.md +1 -3
- package/dist/index.cjs +2 -4
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @echoxyz/sonar-react
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d52cd7b]
|
|
8
|
+
- @echoxyz/sonar-core@0.4.1
|
|
9
|
+
|
|
10
|
+
## 0.6.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 1ccce38: Remove redundant saleUUID from constructor/Provider
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [1ccce38]
|
|
19
|
+
- @echoxyz/sonar-core@0.4.0
|
|
20
|
+
|
|
3
21
|
## 0.5.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ React provider and hooks for Echo’s Sonar APIs, built on `@echoxyz/sonar-core`
|
|
|
4
4
|
|
|
5
5
|
- Framework/router agnostic (works with React Router, Next.js, etc.).
|
|
6
6
|
- Handles PKCE OAuth redirect flow and token storage for the browser.
|
|
7
|
-
- Exposes a ready-to-use API client bound to a single
|
|
7
|
+
- Exposes a ready-to-use API client bound to a single Sonar oauth client.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -25,7 +25,6 @@ export function AppRoot({ children }: { children: React.ReactNode }) {
|
|
|
25
25
|
return (
|
|
26
26
|
<SonarProvider
|
|
27
27
|
config={{
|
|
28
|
-
saleUUID: "<your-sale-uuid>",
|
|
29
28
|
clientUUID: "<your-oauth-client-id>",
|
|
30
29
|
redirectURI: window.location.origin + "/oauth/callback",
|
|
31
30
|
// Optional:
|
|
@@ -195,7 +194,6 @@ function PurchaseButton({
|
|
|
195
194
|
|
|
196
195
|
- `SonarProvider`
|
|
197
196
|
- Props `config`:
|
|
198
|
-
- `saleUUID: string` (required) – Sale to scope API calls against.
|
|
199
197
|
- `clientUUID: string` (required) – Echo OAuth Client ID.
|
|
200
198
|
- `redirectURI: string` (required) – Your OAuth callback URI.
|
|
201
199
|
- `apiURL?: string` (default: `https://api.echo.xyz`) – API base URL.
|
package/dist/index.cjs
CHANGED
|
@@ -38,14 +38,13 @@ function SonarProvider({ children, config }) {
|
|
|
38
38
|
const [authState, setAuthState] = (0, import_react.useState)({ token: void 0, ready: false });
|
|
39
39
|
const client = (0, import_react.useMemo)(() => {
|
|
40
40
|
return (0, import_sonar_core.createClient)({
|
|
41
|
-
saleUUID: config.saleUUID,
|
|
42
41
|
apiURL: config.apiURL,
|
|
43
42
|
tokenKey: config.tokenStorageKey,
|
|
44
43
|
onTokenChange: (nextToken) => {
|
|
45
44
|
setAuthState({ token: nextToken ?? void 0, ready: true });
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
|
-
}, [config.apiURL, config.
|
|
47
|
+
}, [config.apiURL, config.tokenStorageKey]);
|
|
49
48
|
(0, import_react.useEffect)(() => {
|
|
50
49
|
setAuthState({ token: client.getToken() ?? void 0, ready: true });
|
|
51
50
|
}, [client]);
|
|
@@ -57,7 +56,6 @@ function SonarProvider({ children, config }) {
|
|
|
57
56
|
window.sessionStorage.setItem("sonar:oauth:state", state);
|
|
58
57
|
window.sessionStorage.setItem("sonar:oauth:verifier", codeVerifier);
|
|
59
58
|
const url = (0, import_sonar_core.buildAuthorizationUrl)({
|
|
60
|
-
saleUUID: config.saleUUID,
|
|
61
59
|
clientUUID: config.clientUUID,
|
|
62
60
|
redirectURI: config.redirectURI,
|
|
63
61
|
state,
|
|
@@ -65,7 +63,7 @@ function SonarProvider({ children, config }) {
|
|
|
65
63
|
frontendURL: config.frontendURL
|
|
66
64
|
});
|
|
67
65
|
window.location.href = url.toString();
|
|
68
|
-
}, [config.
|
|
66
|
+
}, [config.clientUUID, config.redirectURI, config.frontendURL]);
|
|
69
67
|
const completeOAuth = (0, import_react.useCallback)(
|
|
70
68
|
async ({ code, state }) => {
|
|
71
69
|
if (typeof window === "undefined") {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,14 +8,13 @@ function SonarProvider({ children, config }) {
|
|
|
8
8
|
const [authState, setAuthState] = useState({ token: void 0, ready: false });
|
|
9
9
|
const client = useMemo(() => {
|
|
10
10
|
return createClient({
|
|
11
|
-
saleUUID: config.saleUUID,
|
|
12
11
|
apiURL: config.apiURL,
|
|
13
12
|
tokenKey: config.tokenStorageKey,
|
|
14
13
|
onTokenChange: (nextToken) => {
|
|
15
14
|
setAuthState({ token: nextToken ?? void 0, ready: true });
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
|
-
}, [config.apiURL, config.
|
|
17
|
+
}, [config.apiURL, config.tokenStorageKey]);
|
|
19
18
|
useEffect(() => {
|
|
20
19
|
setAuthState({ token: client.getToken() ?? void 0, ready: true });
|
|
21
20
|
}, [client]);
|
|
@@ -27,7 +26,6 @@ function SonarProvider({ children, config }) {
|
|
|
27
26
|
window.sessionStorage.setItem("sonar:oauth:state", state);
|
|
28
27
|
window.sessionStorage.setItem("sonar:oauth:verifier", codeVerifier);
|
|
29
28
|
const url = buildAuthorizationUrl({
|
|
30
|
-
saleUUID: config.saleUUID,
|
|
31
29
|
clientUUID: config.clientUUID,
|
|
32
30
|
redirectURI: config.redirectURI,
|
|
33
31
|
state,
|
|
@@ -35,7 +33,7 @@ function SonarProvider({ children, config }) {
|
|
|
35
33
|
frontendURL: config.frontendURL
|
|
36
34
|
});
|
|
37
35
|
window.location.href = url.toString();
|
|
38
|
-
}, [config.
|
|
36
|
+
}, [config.clientUUID, config.redirectURI, config.frontendURL]);
|
|
39
37
|
const completeOAuth = useCallback(
|
|
40
38
|
async ({ code, state }) => {
|
|
41
39
|
if (typeof window === "undefined") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echoxyz/sonar-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"react": ">=18"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@echoxyz/sonar-core": "0.
|
|
19
|
+
"@echoxyz/sonar-core": "0.4.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@testing-library/react": "^16.0.0",
|