@decartai/sdk 0.0.49 → 0.0.50
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/dist/index.d.ts +2 -2
- package/dist/tokens/client.d.ts +11 -2
- package/dist/tokens/client.js +10 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { RealTimeSubscribeClient, SubscribeEvents, SubscribeOptions } from "./re
|
|
|
12
12
|
import { WebRTCStats } from "./realtime/webrtc-stats.js";
|
|
13
13
|
import { Events, RealTimeClient, RealTimeClientConnectOptions, RealTimeClientInitialState } from "./realtime/client.js";
|
|
14
14
|
import { ModelState } from "./shared/types.js";
|
|
15
|
-
import { CreateTokenResponse, TokensClient } from "./tokens/client.js";
|
|
15
|
+
import { CreateTokenOptions, CreateTokenResponse, TokensClient } from "./tokens/client.js";
|
|
16
16
|
|
|
17
17
|
//#region src/index.d.ts
|
|
18
18
|
type DecartClientOptions = {
|
|
@@ -128,4 +128,4 @@ declare const createDecartClient: (options?: DecartClientOptions) => {
|
|
|
128
128
|
tokens: TokensClient;
|
|
129
129
|
};
|
|
130
130
|
//#endregion
|
|
131
|
-
export { type ConnectionPhase, type ConnectionState, type CreateTokenResponse, DecartClientOptions, type DecartSDKError, type DiagnosticEvent, type DiagnosticEventName, type DiagnosticEvents, ERROR_CODES, type FileInput, type IceCandidateEvent, type IceStateEvent, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type LogLevel, type Logger, type Model, type ModelDefinition, type ModelState, type PeerConnectionStateEvent, type PhaseTimingEvent, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type Events as RealTimeEvents, type RealTimeModels, type RealTimeSubscribeClient, type ReconnectEvent, type SelectedCandidatePairEvent, type SetInput, type SignalingStateEvent, type SubscribeEvents, type SubscribeOptions, type TokensClient, type VideoModelDefinition, type VideoModels, type VideoStallEvent, type WebRTCStats, createConsoleLogger, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models, noopLogger };
|
|
131
|
+
export { type ConnectionPhase, type ConnectionState, type CreateTokenOptions, type CreateTokenResponse, DecartClientOptions, type DecartSDKError, type DiagnosticEvent, type DiagnosticEventName, type DiagnosticEvents, ERROR_CODES, type FileInput, type IceCandidateEvent, type IceStateEvent, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type LogLevel, type Logger, type Model, type ModelDefinition, type ModelState, type PeerConnectionStateEvent, type PhaseTimingEvent, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type Events as RealTimeEvents, type RealTimeModels, type RealTimeSubscribeClient, type ReconnectEvent, type SelectedCandidatePairEvent, type SetInput, type SignalingStateEvent, type SubscribeEvents, type SubscribeOptions, type TokensClient, type VideoModelDefinition, type VideoModels, type VideoStallEvent, type WebRTCStats, createConsoleLogger, createDecartClient, isImageModel, isRealtimeModel, isVideoModel, models, noopLogger };
|
package/dist/tokens/client.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
//#region src/tokens/client.d.ts
|
|
2
2
|
|
|
3
|
+
type CreateTokenOptions = {
|
|
4
|
+
/** Custom key-value pairs to attach to the client token. */
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
};
|
|
3
7
|
type CreateTokenResponse = {
|
|
4
8
|
apiKey: string;
|
|
5
9
|
expiresAt: string;
|
|
@@ -7,15 +11,20 @@ type CreateTokenResponse = {
|
|
|
7
11
|
type TokensClient = {
|
|
8
12
|
/**
|
|
9
13
|
* Create a client token.
|
|
14
|
+
* @param options - Optional configuration for the token.
|
|
15
|
+
* @param options.metadata - Custom key-value pairs to attach to the token.
|
|
10
16
|
* @returns A short-lived API key safe for client-side use.
|
|
11
17
|
* @example
|
|
12
18
|
* ```ts
|
|
13
19
|
* const client = createDecartClient({ apiKey: process.env.DECART_API_KEY });
|
|
14
20
|
* const token = await client.tokens.create();
|
|
15
21
|
* // Returns: { apiKey: "ek_...", expiresAt: "2024-12-15T12:10:00Z" }
|
|
22
|
+
*
|
|
23
|
+
* // With metadata:
|
|
24
|
+
* const token = await client.tokens.create({ metadata: { role: "viewer" } });
|
|
16
25
|
* ```
|
|
17
26
|
*/
|
|
18
|
-
create: () => Promise<CreateTokenResponse>;
|
|
27
|
+
create: (options?: CreateTokenOptions) => Promise<CreateTokenResponse>;
|
|
19
28
|
};
|
|
20
29
|
//#endregion
|
|
21
|
-
export { CreateTokenResponse, TokensClient };
|
|
30
|
+
export { CreateTokenOptions, CreateTokenResponse, TokensClient };
|
package/dist/tokens/client.js
CHANGED
|
@@ -4,14 +4,18 @@ import { buildAuthHeaders } from "../shared/request.js";
|
|
|
4
4
|
//#region src/tokens/client.ts
|
|
5
5
|
const createTokensClient = (opts) => {
|
|
6
6
|
const { baseUrl, apiKey, integration } = opts;
|
|
7
|
-
const create = async () => {
|
|
8
|
-
const headers =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const create = async (options) => {
|
|
8
|
+
const headers = {
|
|
9
|
+
...buildAuthHeaders({
|
|
10
|
+
apiKey,
|
|
11
|
+
integration
|
|
12
|
+
}),
|
|
13
|
+
"content-type": "application/json"
|
|
14
|
+
};
|
|
12
15
|
const response = await fetch(`${baseUrl}/v1/client/tokens`, {
|
|
13
16
|
method: "POST",
|
|
14
|
-
headers
|
|
17
|
+
headers,
|
|
18
|
+
body: JSON.stringify(options?.metadata ? { metadata: options.metadata } : {})
|
|
15
19
|
});
|
|
16
20
|
if (!response.ok) {
|
|
17
21
|
const errorText = await response.text().catch(() => "Unknown error");
|