@reactor-team/js-sdk 2.0.0 → 2.0.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/README.md +2 -16
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,24 +11,10 @@ There are two main ways to use the frontend SDK:
|
|
|
11
11
|
|
|
12
12
|
## Building the SDK
|
|
13
13
|
|
|
14
|
-
Set up the environment variables:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
cp .env.example .env
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Then add your NPM_TOKEN to the .env file.
|
|
21
|
-
|
|
22
|
-
Build the SDK:
|
|
23
|
-
|
|
24
14
|
```bash
|
|
25
15
|
pnpm build
|
|
26
16
|
```
|
|
27
17
|
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
To publish the SDK:
|
|
18
|
+
## Documentation
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
./publish_package.sh
|
|
34
|
-
```
|
|
20
|
+
- [Getting Started](https://docs.reactor.inc)
|
package/dist/index.d.mts
CHANGED
|
@@ -171,4 +171,17 @@ declare function useReactor<T>(selector: (state: ReactorStore) => T): T;
|
|
|
171
171
|
*/
|
|
172
172
|
declare function useReactorMessage(handler: (message: any) => void): void;
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
/**
|
|
175
|
+
* ⚠️ INSECURE: Fetches a JWT token directly from the client.
|
|
176
|
+
*
|
|
177
|
+
* WARNING: This function exposes your API key in client-side code.
|
|
178
|
+
* Only use this for local development or testing purposes.
|
|
179
|
+
* In production, call /tokens from your server and pass the JWT to your frontend.
|
|
180
|
+
*
|
|
181
|
+
* @param apiKey - Your Reactor API key (will be exposed in client code!)
|
|
182
|
+
* @param coordinatorUrl - Optional coordinator URL, defaults to production
|
|
183
|
+
* @returns string containing the JWT token
|
|
184
|
+
*/
|
|
185
|
+
declare function fetchInsecureJwtToken(apiKey: string, coordinatorUrl?: string): Promise<string>;
|
|
186
|
+
|
|
187
|
+
export { type Options, PROD_COORDINATOR_URL, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, fetchInsecureJwtToken, useReactor, useReactorMessage, useReactorStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -171,4 +171,17 @@ declare function useReactor<T>(selector: (state: ReactorStore) => T): T;
|
|
|
171
171
|
*/
|
|
172
172
|
declare function useReactorMessage(handler: (message: any) => void): void;
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
/**
|
|
175
|
+
* ⚠️ INSECURE: Fetches a JWT token directly from the client.
|
|
176
|
+
*
|
|
177
|
+
* WARNING: This function exposes your API key in client-side code.
|
|
178
|
+
* Only use this for local development or testing purposes.
|
|
179
|
+
* In production, call /tokens from your server and pass the JWT to your frontend.
|
|
180
|
+
*
|
|
181
|
+
* @param apiKey - Your Reactor API key (will be exposed in client code!)
|
|
182
|
+
* @param coordinatorUrl - Optional coordinator URL, defaults to production
|
|
183
|
+
* @returns string containing the JWT token
|
|
184
|
+
*/
|
|
185
|
+
declare function fetchInsecureJwtToken(apiKey: string, coordinatorUrl?: string): Promise<string>;
|
|
186
|
+
|
|
187
|
+
export { type Options, PROD_COORDINATOR_URL, Reactor, ReactorController, type ReactorControllerProps, type ReactorError, type ReactorEvent, ReactorProvider, type ReactorState$1 as ReactorState, type ReactorStatus, ReactorView, type ReactorViewProps, WebcamStream, fetchInsecureJwtToken, useReactor, useReactorMessage, useReactorStore };
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,7 @@ __export(index_exports, {
|
|
|
85
85
|
ReactorProvider: () => ReactorProvider,
|
|
86
86
|
ReactorView: () => ReactorView,
|
|
87
87
|
WebcamStream: () => WebcamStream,
|
|
88
|
+
fetchInsecureJwtToken: () => fetchInsecureJwtToken,
|
|
88
89
|
useReactor: () => useReactor,
|
|
89
90
|
useReactorMessage: () => useReactorMessage,
|
|
90
91
|
useReactorStore: () => useReactorStore
|
|
@@ -2128,6 +2129,27 @@ function WebcamStream({
|
|
|
2128
2129
|
}
|
|
2129
2130
|
);
|
|
2130
2131
|
}
|
|
2132
|
+
|
|
2133
|
+
// src/utils/tokens.ts
|
|
2134
|
+
function fetchInsecureJwtToken(_0) {
|
|
2135
|
+
return __async(this, arguments, function* (apiKey, coordinatorUrl = PROD_COORDINATOR_URL) {
|
|
2136
|
+
console.warn(
|
|
2137
|
+
"[Reactor] \u26A0\uFE0F SECURITY WARNING: fetchInsecureJwtToken() exposes your API key in client-side code. This should ONLY be used for local development or testing. In production, fetch tokens from your server instead."
|
|
2138
|
+
);
|
|
2139
|
+
const response = yield fetch(`${coordinatorUrl}/tokens`, {
|
|
2140
|
+
method: "GET",
|
|
2141
|
+
headers: {
|
|
2142
|
+
"X-API-Key": apiKey
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
if (!response.ok) {
|
|
2146
|
+
const error = yield response.text();
|
|
2147
|
+
throw new Error(`Failed to create token: ${response.status} ${error}`);
|
|
2148
|
+
}
|
|
2149
|
+
const { jwt } = yield response.json();
|
|
2150
|
+
return jwt;
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2131
2153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2132
2154
|
0 && (module.exports = {
|
|
2133
2155
|
PROD_COORDINATOR_URL,
|
|
@@ -2136,6 +2158,7 @@ function WebcamStream({
|
|
|
2136
2158
|
ReactorProvider,
|
|
2137
2159
|
ReactorView,
|
|
2138
2160
|
WebcamStream,
|
|
2161
|
+
fetchInsecureJwtToken,
|
|
2139
2162
|
useReactor,
|
|
2140
2163
|
useReactorMessage,
|
|
2141
2164
|
useReactorStore
|