@centive/aria-sdk 0.4.7 → 0.4.8

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 CHANGED
@@ -246,12 +246,77 @@ function MyComponent() {
246
246
  startSession,
247
247
  stopSession,
248
248
  triggerSession,
249
+ getSessionIdFromToken, // Extract session ID from tokens
249
250
  } = useAria();
250
251
 
251
252
  // Use the methods and state
252
253
  }
253
254
  ```
254
255
 
256
+ ### 🔑 Token Utilities
257
+
258
+ The SDK provides utilities to extract session IDs from tokens, supporting both JWT and opaque tokens.
259
+
260
+ #### In React Components (via useAria hook)
261
+
262
+ ```tsx
263
+ import { useAria } from '@centive/aria-sdk';
264
+
265
+ function MyComponent() {
266
+ const { getSessionIdFromToken, sessionState } = useAria();
267
+
268
+ // Get session ID from current state
269
+ const currentSessionId = getSessionIdFromToken();
270
+
271
+ // Extract session ID from a stored token (e.g., JWT)
272
+ const storedToken = localStorage.getItem('token');
273
+ const sessionId = getSessionIdFromToken(storedToken);
274
+
275
+ return <div>Session: {currentSessionId}</div>;
276
+ }
277
+ ```
278
+
279
+ #### In External Code (non-React)
280
+
281
+ ```tsx
282
+ import {
283
+ extractSessionIdFromToken,
284
+ isJWT,
285
+ decodeJWT,
286
+ getTokenInfo,
287
+ isTokenExpired
288
+ } from '@centive/aria-sdk';
289
+
290
+ // Check if token is a JWT
291
+ if (isJWT(token)) {
292
+ // Extract session ID
293
+ const sessionId = extractSessionIdFromToken(token);
294
+
295
+ // Get full token information
296
+ const tokenInfo = getTokenInfo(token);
297
+ console.log('Session ID:', tokenInfo.sessionId);
298
+ console.log('Expires:', tokenInfo.exp ? new Date(tokenInfo.exp * 1000) : 'N/A');
299
+
300
+ // Check if expired
301
+ if (isTokenExpired(token)) {
302
+ console.log('Token expired, need to refresh');
303
+ }
304
+
305
+ // Decode full payload
306
+ const payload = decodeJWT(token);
307
+ console.log('Payload:', payload);
308
+ }
309
+ ```
310
+
311
+ **Supported JWT Claims** (checked in order):
312
+ - `session_id`
313
+ - `sessionId`
314
+ - `sid`
315
+ - `jti` (JWT ID)
316
+ - `sub` (Subject)
317
+
318
+ **Note:** JWT decoding is done client-side without signature verification. Only use for extracting public information.
319
+
255
320
  ## ⚙️ Configuration
256
321
 
257
322
  ### AriaSDKConfig
@@ -22,6 +22,7 @@ export interface AriaContextType {
22
22
  triggerMode: TriggerMode;
23
23
  theme: Theme;
24
24
  config: AriaSDKConfig;
25
+ getSessionIdFromToken: (token?: string) => string | null;
25
26
  }
26
27
  export declare const AriaContext: import("react").Context<AriaContextType | null>;
27
28
  //# sourceMappingURL=AriaContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AriaContext.d.ts","sourceRoot":"","sources":["../../src/context/AriaContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhI,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,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O,CAAC,IAAI,CAAC,CAAC;IACjC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1D,eAAe,EAAE,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,qBAAqB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,WAAW,iDAA8C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AriaProvider.d.ts","sourceRoot":"","sources":["../../src/context/AriaProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAoB1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C,UAAU,iBAAiB;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAgGD,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA4oB9C,CAAC"}
1
+ {"version":3,"file":"AriaProvider.d.ts","sourceRoot":"","sources":["../../src/context/AriaProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAoB1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO7C,UAAU,iBAAiB;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAgGD,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAgrB9C,CAAC"}
@@ -1,5 +1,5 @@
1
- import { A as n } from "./index-Cdd4Ol1Y.js";
2
- import { d as i, b as C, a as d, C as l, c as m, D as A, E as c, I as g, M as u, S as E } from "./index-Cdd4Ol1Y.js";
1
+ import { A as n } from "./index-DZgBM4LN.js";
2
+ import { d as i, b as C, a as d, C as l, c as m, D as A, E as c, I as g, M as u, S as E } from "./index-DZgBM4LN.js";
3
3
  const t = (e, a) => new n(e, void 0, a);
4
4
  export {
5
5
  i as AgentAudioInputStream,
@@ -14,4 +14,4 @@ export {
14
14
  E as SignalMessageAction,
15
15
  t as createClient
16
16
  };
17
- //# sourceMappingURL=index-BHMESAEF.js.map
17
+ //# sourceMappingURL=index-DOSWxknt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-BHMESAEF.js","sources":["../node_modules/@anam-ai/js-sdk/dist/module/index.js"],"sourcesContent":["import AnamClient from './AnamClient';\nimport { ClientError, ErrorCode } from './lib/ClientError';\n/**\n * Create a new Anam client.\n * @param sessionToken - A session token can be obtained from the Anam API.\n * @param personaConfig - The persona configuration to use.\n * @param options - Additional options.\n * @returns A new Anam client instance.\n */\nconst createClient = (sessionToken, options) => {\n return new AnamClient(sessionToken, undefined, options);\n};\n/**\n * Create a new Anam client with an API key instead of a session token.\n * This method is unsafe for production environments because it requires exposing your API key to the client side.\n * Only use this method for local testing.\n * @param apiKey - Your Anam API key.\n * @param personaConfig - The persona configuration to use.\n * @param options - Additional options.\n * @returns A new Anam client instance.\n */\nconst unsafe_createClientWithApiKey = (apiKey, personaConfig, options) => {\n return new AnamClient(undefined, personaConfig, Object.assign(Object.assign({}, options), { apiKey }));\n};\nexport { createClient, unsafe_createClientWithApiKey, ClientError, ErrorCode };\nexport * from './types';\n//# sourceMappingURL=index.js.map"],"names":["createClient","sessionToken","options","AnamClient"],"mappings":";;AASK,MAACA,IAAe,CAACC,GAAcC,MACzB,IAAIC,EAAWF,GAAc,QAAWC,CAAO;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index-DOSWxknt.js","sources":["../node_modules/@anam-ai/js-sdk/dist/module/index.js"],"sourcesContent":["import AnamClient from './AnamClient';\nimport { ClientError, ErrorCode } from './lib/ClientError';\n/**\n * Create a new Anam client.\n * @param sessionToken - A session token can be obtained from the Anam API.\n * @param personaConfig - The persona configuration to use.\n * @param options - Additional options.\n * @returns A new Anam client instance.\n */\nconst createClient = (sessionToken, options) => {\n return new AnamClient(sessionToken, undefined, options);\n};\n/**\n * Create a new Anam client with an API key instead of a session token.\n * This method is unsafe for production environments because it requires exposing your API key to the client side.\n * Only use this method for local testing.\n * @param apiKey - Your Anam API key.\n * @param personaConfig - The persona configuration to use.\n * @param options - Additional options.\n * @returns A new Anam client instance.\n */\nconst unsafe_createClientWithApiKey = (apiKey, personaConfig, options) => {\n return new AnamClient(undefined, personaConfig, Object.assign(Object.assign({}, options), { apiKey }));\n};\nexport { createClient, unsafe_createClientWithApiKey, ClientError, ErrorCode };\nexport * from './types';\n//# sourceMappingURL=index.js.map"],"names":["createClient","sessionToken","options","AnamClient"],"mappings":";;AASK,MAACA,IAAe,CAACC,GAAcC,MACzB,IAAIC,EAAWF,GAAc,QAAWC,CAAO;","x_google_ignoreList":[0]}