space-react-client 0.2.4 → 0.3.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/README.md +6 -6
- package/dist/index.d.ts +15850 -14
- package/dist/index.js +83 -30
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -134,15 +134,15 @@ You can then inject a Pricing Token from your backend:
|
|
|
134
134
|
|
|
135
135
|
```tsx
|
|
136
136
|
import { useEffect } from 'react';
|
|
137
|
-
import {
|
|
137
|
+
import { useTokenService } from 'space-react-client';
|
|
138
138
|
|
|
139
139
|
export function InjectTokenFromServer() {
|
|
140
|
-
const tokenService =
|
|
140
|
+
const tokenService = useTokenService();
|
|
141
141
|
|
|
142
142
|
useEffect(() => {
|
|
143
143
|
fetch('/api/my-pricing-token')
|
|
144
144
|
.then(res => res.text()) // token as string
|
|
145
|
-
.then(token => tokenService.
|
|
145
|
+
.then(token => tokenService.update(token))
|
|
146
146
|
.catch(console.error);
|
|
147
147
|
}, [tokenService]);
|
|
148
148
|
|
|
@@ -173,7 +173,7 @@ export function InjectTokenFromServer() {
|
|
|
173
173
|
- **`useSpaceClient(): SpaceClient`**
|
|
174
174
|
Access the connected SPACE client. Throws if not available.
|
|
175
175
|
|
|
176
|
-
- **`
|
|
176
|
+
- **`useTokenService(): TokenService`**
|
|
177
177
|
Manage Pricing Tokens in context. Available even if live connection is disabled.
|
|
178
178
|
|
|
179
179
|
---
|
|
@@ -230,8 +230,8 @@ All events (except `synchronized` and `error`) include the following object:
|
|
|
230
230
|
|
|
231
231
|
**Methods:**
|
|
232
232
|
|
|
233
|
-
- `
|
|
234
|
-
- `
|
|
233
|
+
- `update(token)` — Validates & stores a pricing token.
|
|
234
|
+
- `getPayload()` — Return parsed token payload.
|
|
235
235
|
- `evaluateFeature(featureId)` — Returns `true | false | null`.
|
|
236
236
|
|
|
237
237
|
Token expectations:
|