@corti/sdk 0.6.0 → 0.7.0-rc

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.
Files changed (110) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/errors/InternalServerError.d.ts +2 -1
  4. package/dist/cjs/api/resources/documents/client/Client.js +35 -5
  5. package/dist/cjs/api/resources/facts/client/Client.js +7 -1
  6. package/dist/cjs/api/resources/interactions/client/Client.js +7 -1
  7. package/dist/cjs/api/resources/recordings/client/Client.js +28 -4
  8. package/dist/cjs/api/resources/stream/client/Socket.d.ts +2 -1
  9. package/dist/cjs/api/resources/stream/client/Socket.js +13 -3
  10. package/dist/cjs/api/resources/templates/client/Client.js +21 -3
  11. package/dist/cjs/api/resources/transcribe/client/Socket.d.ts +2 -1
  12. package/dist/cjs/api/resources/transcribe/client/Socket.js +13 -3
  13. package/dist/cjs/api/resources/transcripts/client/Client.js +28 -4
  14. package/dist/cjs/api/types/StreamFlushMessage.d.ts +6 -0
  15. package/dist/cjs/api/types/StreamFlushMessage.js +5 -0
  16. package/dist/cjs/api/types/StreamFlushedMessage.d.ts +6 -0
  17. package/dist/cjs/api/types/StreamFlushedMessage.js +5 -0
  18. package/dist/cjs/api/types/TranscribeFlushMessage.d.ts +6 -0
  19. package/dist/cjs/api/types/TranscribeFlushMessage.js +5 -0
  20. package/dist/cjs/api/types/TranscribeFlushedMessage.d.ts +6 -0
  21. package/dist/cjs/api/types/TranscribeFlushedMessage.js +5 -0
  22. package/dist/cjs/api/types/index.d.ts +4 -0
  23. package/dist/cjs/api/types/index.js +4 -0
  24. package/dist/cjs/custom/CortiAuth.d.ts +6 -6
  25. package/dist/cjs/custom/CortiAuth.js +10 -10
  26. package/dist/cjs/custom/CortiClient.js +11 -10
  27. package/dist/cjs/custom/CustomStream.d.ts +1 -1
  28. package/dist/cjs/custom/CustomStream.js +15 -14
  29. package/dist/cjs/custom/CustomStreamSocket.d.ts +1 -1
  30. package/dist/cjs/custom/CustomStreamSocket.js +1 -1
  31. package/dist/cjs/custom/CustomTranscribe.d.ts +1 -1
  32. package/dist/cjs/custom/CustomTranscribe.js +12 -12
  33. package/dist/cjs/custom/CustomTranscribeSocket.d.ts +1 -1
  34. package/dist/cjs/custom/CustomTranscribeSocket.js +1 -1
  35. package/dist/cjs/custom/RefreshBearerProvider.d.ts +1 -1
  36. package/dist/cjs/custom/utils/decodeToken.js +6 -8
  37. package/dist/cjs/custom/utils/localStorage.js +3 -1
  38. package/dist/cjs/custom/utils/pkce.js +2 -5
  39. package/dist/cjs/custom/utils/resolveClientOptions.js +1 -2
  40. package/dist/cjs/serialization/resources/stream/client/socket/StreamSocketResponse.d.ts +3 -2
  41. package/dist/cjs/serialization/resources/stream/client/socket/StreamSocketResponse.js +2 -0
  42. package/dist/cjs/serialization/resources/transcribe/client/socket/TranscribeSocketResponse.d.ts +3 -2
  43. package/dist/cjs/serialization/resources/transcribe/client/socket/TranscribeSocketResponse.js +2 -0
  44. package/dist/cjs/serialization/types/StreamFlushMessage.d.ts +12 -0
  45. package/dist/cjs/serialization/types/StreamFlushMessage.js +43 -0
  46. package/dist/cjs/serialization/types/StreamFlushedMessage.d.ts +12 -0
  47. package/dist/cjs/serialization/types/StreamFlushedMessage.js +43 -0
  48. package/dist/cjs/serialization/types/TranscribeFlushMessage.d.ts +12 -0
  49. package/dist/cjs/serialization/types/TranscribeFlushMessage.js +43 -0
  50. package/dist/cjs/serialization/types/TranscribeFlushedMessage.d.ts +12 -0
  51. package/dist/cjs/serialization/types/TranscribeFlushedMessage.js +43 -0
  52. package/dist/cjs/serialization/types/index.d.ts +4 -0
  53. package/dist/cjs/serialization/types/index.js +4 -0
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/esm/Client.mjs +2 -2
  57. package/dist/esm/api/errors/InternalServerError.d.mts +2 -1
  58. package/dist/esm/api/resources/documents/client/Client.mjs +35 -5
  59. package/dist/esm/api/resources/facts/client/Client.mjs +7 -1
  60. package/dist/esm/api/resources/interactions/client/Client.mjs +7 -1
  61. package/dist/esm/api/resources/recordings/client/Client.mjs +28 -4
  62. package/dist/esm/api/resources/stream/client/Socket.d.mts +2 -1
  63. package/dist/esm/api/resources/stream/client/Socket.mjs +13 -3
  64. package/dist/esm/api/resources/templates/client/Client.mjs +21 -3
  65. package/dist/esm/api/resources/transcribe/client/Socket.d.mts +2 -1
  66. package/dist/esm/api/resources/transcribe/client/Socket.mjs +13 -3
  67. package/dist/esm/api/resources/transcripts/client/Client.mjs +28 -4
  68. package/dist/esm/api/types/StreamFlushMessage.d.mts +6 -0
  69. package/dist/esm/api/types/StreamFlushMessage.mjs +4 -0
  70. package/dist/esm/api/types/StreamFlushedMessage.d.mts +6 -0
  71. package/dist/esm/api/types/StreamFlushedMessage.mjs +4 -0
  72. package/dist/esm/api/types/TranscribeFlushMessage.d.mts +6 -0
  73. package/dist/esm/api/types/TranscribeFlushMessage.mjs +4 -0
  74. package/dist/esm/api/types/TranscribeFlushedMessage.d.mts +6 -0
  75. package/dist/esm/api/types/TranscribeFlushedMessage.mjs +4 -0
  76. package/dist/esm/api/types/index.d.mts +4 -0
  77. package/dist/esm/api/types/index.mjs +4 -0
  78. package/dist/esm/custom/CortiAuth.d.mts +6 -6
  79. package/dist/esm/custom/CortiAuth.mjs +10 -10
  80. package/dist/esm/custom/CortiClient.mjs +11 -10
  81. package/dist/esm/custom/CustomStream.d.mts +1 -1
  82. package/dist/esm/custom/CustomStream.mjs +15 -14
  83. package/dist/esm/custom/CustomStreamSocket.d.mts +1 -1
  84. package/dist/esm/custom/CustomStreamSocket.mjs +2 -2
  85. package/dist/esm/custom/CustomTranscribe.d.mts +1 -1
  86. package/dist/esm/custom/CustomTranscribe.mjs +12 -12
  87. package/dist/esm/custom/CustomTranscribeSocket.d.mts +1 -1
  88. package/dist/esm/custom/CustomTranscribeSocket.mjs +2 -2
  89. package/dist/esm/custom/RefreshBearerProvider.d.mts +1 -1
  90. package/dist/esm/custom/utils/decodeToken.mjs +6 -8
  91. package/dist/esm/custom/utils/localStorage.mjs +3 -1
  92. package/dist/esm/custom/utils/pkce.mjs +2 -5
  93. package/dist/esm/custom/utils/resolveClientOptions.mjs +1 -2
  94. package/dist/esm/serialization/resources/stream/client/socket/StreamSocketResponse.d.mts +3 -2
  95. package/dist/esm/serialization/resources/stream/client/socket/StreamSocketResponse.mjs +2 -0
  96. package/dist/esm/serialization/resources/transcribe/client/socket/TranscribeSocketResponse.d.mts +3 -2
  97. package/dist/esm/serialization/resources/transcribe/client/socket/TranscribeSocketResponse.mjs +2 -0
  98. package/dist/esm/serialization/types/StreamFlushMessage.d.mts +12 -0
  99. package/dist/esm/serialization/types/StreamFlushMessage.mjs +7 -0
  100. package/dist/esm/serialization/types/StreamFlushedMessage.d.mts +12 -0
  101. package/dist/esm/serialization/types/StreamFlushedMessage.mjs +7 -0
  102. package/dist/esm/serialization/types/TranscribeFlushMessage.d.mts +12 -0
  103. package/dist/esm/serialization/types/TranscribeFlushMessage.mjs +7 -0
  104. package/dist/esm/serialization/types/TranscribeFlushedMessage.d.mts +12 -0
  105. package/dist/esm/serialization/types/TranscribeFlushedMessage.mjs +7 -0
  106. package/dist/esm/serialization/types/index.d.mts +4 -0
  107. package/dist/esm/serialization/types/index.mjs +4 -0
  108. package/dist/esm/version.d.mts +1 -1
  109. package/dist/esm/version.mjs +1 -1
  110. package/package.json +1 -1
@@ -42,7 +42,7 @@ export class Auth extends FernAuth {
42
42
  * Patch: Generate PKCE authorization URL with automatic code verifier generation
43
43
  */
44
44
  authorizePkceUrl(_a, options_1) {
45
- return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, }, options) {
45
+ return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri }, options) {
46
46
  const codeVerifier = generateCodeVerifier();
47
47
  setLocalStorageItem(CODE_VERIFIER_KEY, codeVerifier);
48
48
  const codeChallenge = yield generateCodeChallenge(codeVerifier);
@@ -69,20 +69,20 @@ export class Auth extends FernAuth {
69
69
  * Patch: added method to get Authorization URL for Authorization code flow and PKCE flow
70
70
  */
71
71
  authorizeURL(_a, options_1) {
72
- return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge, }, options) {
72
+ return __awaiter(this, arguments, void 0, function* ({ clientId, redirectUri, codeChallenge }, options) {
73
73
  var _b;
74
74
  const authUrl = new URL(core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment)).login, yield core.Supplier.get(this._options.tenantName), "protocol/openid-connect/auth"));
75
- authUrl.searchParams.set('response_type', 'code');
76
- authUrl.searchParams.set('scope', 'openid profile');
75
+ authUrl.searchParams.set("response_type", "code");
76
+ authUrl.searchParams.set("scope", "openid profile");
77
77
  if (clientId !== undefined) {
78
- authUrl.searchParams.set('client_id', clientId);
78
+ authUrl.searchParams.set("client_id", clientId);
79
79
  }
80
80
  if (redirectUri !== undefined) {
81
- authUrl.searchParams.set('redirect_uri', redirectUri);
81
+ authUrl.searchParams.set("redirect_uri", redirectUri);
82
82
  }
83
83
  if (codeChallenge !== undefined) {
84
- authUrl.searchParams.set('code_challenge', codeChallenge);
85
- authUrl.searchParams.set('code_challenge_method', 'S256');
84
+ authUrl.searchParams.set("code_challenge", codeChallenge);
85
+ authUrl.searchParams.set("code_challenge_method", "S256");
86
86
  }
87
87
  const authUrlString = authUrl.toString();
88
88
  if (typeof window !== "undefined" && !(options === null || options === void 0 ? void 0 : options.skipRedirect)) {
@@ -106,8 +106,8 @@ export class Auth extends FernAuth {
106
106
  if (!codeVerifier) {
107
107
  throw new ParseError([
108
108
  {
109
- path: ['codeVerifier'],
110
- message: 'Code verifier was not provided and not found in localStorage.',
109
+ path: ["codeVerifier"],
110
+ message: "Code verifier was not provided and not found in localStorage.",
111
111
  },
112
112
  ]);
113
113
  }
@@ -72,16 +72,17 @@ export class CortiClient {
72
72
  /**
73
73
  * Patch: if `clientId` is provided, use OAuthTokenProvider, otherwise use BearerProvider
74
74
  */
75
- this._oauthTokenProvider = "clientId" in _options.auth ?
76
- new core.OAuthTokenProvider({
77
- clientId: _options.auth.clientId,
78
- clientSecret: _options.auth.clientSecret,
79
- /**
80
- * Patch: provide whole `options` object to the Auth client, since it depends on both tenantName and environment
81
- */
82
- authClient: new Auth(this._options),
83
- }) :
84
- new RefreshBearerProvider(Object.assign(Object.assign({}, _options.auth), { initialTokenResponse }));
75
+ this._oauthTokenProvider =
76
+ "clientId" in _options.auth
77
+ ? new core.OAuthTokenProvider({
78
+ clientId: _options.auth.clientId,
79
+ clientSecret: _options.auth.clientSecret,
80
+ /**
81
+ * Patch: provide whole `options` object to the Auth client, since it depends on both tenantName and environment
82
+ */
83
+ authClient: new Auth(this._options),
84
+ })
85
+ : new RefreshBearerProvider(Object.assign(Object.assign({}, _options.auth), { initialTokenResponse }));
85
86
  }
86
87
  get interactions() {
87
88
  var _a;
@@ -14,7 +14,7 @@ export declare class Stream extends FernStream {
14
14
  /**
15
15
  * Patch: use custom connect method to support passing _options parameters
16
16
  */
17
- connect({ configuration, ...args }: Omit<FernStream.ConnectArgs, 'token' | 'tenantName'> & {
17
+ connect({ configuration, ...args }: Omit<FernStream.ConnectArgs, "token" | "tenantName"> & {
18
18
  configuration?: api.StreamConfig;
19
19
  }): Promise<StreamSocket>;
20
20
  }
@@ -40,18 +40,18 @@ export class Stream extends FernStream {
40
40
  });
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
42
  var { configuration } = _a, args = __rest(_a, ["configuration"]);
43
- const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || '', tenantName: yield core.Supplier.get(this._options.tenantName) }));
43
+ const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }));
44
44
  const ws = new StreamSocket({ socket: fernWs.socket });
45
45
  if (!configuration) {
46
46
  return ws;
47
47
  }
48
- ws.socket.addEventListener('open', () => {
48
+ ws.socket.addEventListener("open", () => {
49
49
  ws.sendConfiguration({
50
- type: 'config',
50
+ type: "config",
51
51
  configuration,
52
52
  });
53
53
  });
54
- ws.socket.addEventListener('message', (event) => {
54
+ ws.socket.addEventListener("message", (event) => {
55
55
  const data = fromJson(event.data);
56
56
  const parsedResponse = serializers.StreamSocketResponse.parse(data, {
57
57
  unrecognizedObjectKeys: "passthrough",
@@ -60,29 +60,30 @@ export class Stream extends FernStream {
60
60
  skipValidation: true,
61
61
  omitUndefined: true,
62
62
  });
63
- if (parsedResponse.ok && parsedResponse.value.type === 'CONFIG_ACCEPTED') {
63
+ if (parsedResponse.ok && parsedResponse.value.type === "CONFIG_ACCEPTED") {
64
64
  return;
65
65
  }
66
- if (parsedResponse.ok && (parsedResponse.value.type === 'CONFIG_DENIED'
67
- || parsedResponse.value.type === 'CONFIG_MISSING'
68
- || parsedResponse.value.type === 'CONFIG_TIMEOUT'
69
- || parsedResponse.value.type === 'CONFIG_NOT_PROVIDED')) {
66
+ if (parsedResponse.ok &&
67
+ (parsedResponse.value.type === "CONFIG_DENIED" ||
68
+ parsedResponse.value.type === "CONFIG_MISSING" ||
69
+ parsedResponse.value.type === "CONFIG_TIMEOUT" ||
70
+ parsedResponse.value.type === "CONFIG_NOT_PROVIDED")) {
70
71
  ws.socket.dispatchEvent(new ErrorEvent({
71
72
  name: parsedResponse.value.type,
72
73
  message: JSON.stringify(parsedResponse.value),
73
- }, ''));
74
+ }, ""));
74
75
  ws.close();
75
76
  return;
76
77
  }
77
- if (parsedResponse.ok && parsedResponse.value.type === 'error') {
78
+ if (parsedResponse.ok && parsedResponse.value.type === "error") {
78
79
  ws.socket.dispatchEvent(new ErrorEvent({
79
- name: 'error',
80
+ name: "error",
80
81
  message: JSON.stringify(parsedResponse.value),
81
- }, ''));
82
+ }, ""));
82
83
  ws.close();
83
84
  return;
84
85
  }
85
- if (parsedResponse.ok && parsedResponse.value.type === 'ENDED') {
86
+ if (parsedResponse.ok && parsedResponse.value.type === "ENDED") {
86
87
  ws.close();
87
88
  return;
88
89
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
- import { StreamSocket as FernStreamSocket } from '../api/resources/stream/client/Socket.mjs';
4
+ import { StreamSocket as FernStreamSocket } from "../api/resources/stream/client/Socket.mjs";
5
5
  export declare class StreamSocket extends FernStreamSocket {
6
6
  sendAudio(message: ArrayBufferLike | Blob | ArrayBufferView | string): void;
7
7
  /**
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
- import { StreamSocket as FernStreamSocket } from '../api/resources/stream/client/Socket.mjs';
4
+ import { StreamSocket as FernStreamSocket } from "../api/resources/stream/client/Socket.mjs";
5
5
  import * as core from "../core/index.mjs";
6
6
  export class StreamSocket extends FernStreamSocket {
7
7
  sendAudio(message) {
8
- if (typeof message === 'string') {
8
+ if (typeof message === "string") {
9
9
  return super.sendAudio(message);
10
10
  }
11
11
  this.__assertSocketIsOpen();
@@ -14,7 +14,7 @@ export declare class Transcribe extends FernTranscribe {
14
14
  /**
15
15
  * Patch: use custom connect method to support passing _options parameters
16
16
  */
17
- connect({ configuration, ...args }?: Omit<FernTranscribe.ConnectArgs, 'token' | 'tenantName'> & {
17
+ connect({ configuration, ...args }?: Omit<FernTranscribe.ConnectArgs, "token" | "tenantName"> & {
18
18
  configuration?: api.TranscribeConfig;
19
19
  }): Promise<TranscribeSocket>;
20
20
  }
@@ -40,18 +40,18 @@ export class Transcribe extends FernTranscribe {
40
40
  });
41
41
  return __awaiter(this, arguments, void 0, function* (_a = {}) {
42
42
  var { configuration } = _a, args = __rest(_a, ["configuration"]);
43
- const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || '', tenantName: yield core.Supplier.get(this._options.tenantName) }));
43
+ const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield core.Supplier.get(this._options.tenantName) }));
44
44
  const ws = new TranscribeSocket({ socket: fernWs.socket });
45
45
  if (!configuration) {
46
46
  return ws;
47
47
  }
48
- ws.socket.addEventListener('open', () => {
48
+ ws.socket.addEventListener("open", () => {
49
49
  ws.sendConfiguration({
50
- type: 'config',
50
+ type: "config",
51
51
  configuration,
52
52
  });
53
53
  });
54
- ws.socket.addEventListener('message', (event) => {
54
+ ws.socket.addEventListener("message", (event) => {
55
55
  const data = fromJson(event.data);
56
56
  const parsedResponse = serializers.TranscribeSocketResponse.parse(data, {
57
57
  unrecognizedObjectKeys: "passthrough",
@@ -60,27 +60,27 @@ export class Transcribe extends FernTranscribe {
60
60
  skipValidation: true,
61
61
  omitUndefined: true,
62
62
  });
63
- if (parsedResponse.ok && parsedResponse.value.type === 'CONFIG_ACCEPTED') {
63
+ if (parsedResponse.ok && parsedResponse.value.type === "CONFIG_ACCEPTED") {
64
64
  return;
65
65
  }
66
- if (parsedResponse.ok && (parsedResponse.value.type === 'CONFIG_DENIED'
67
- || parsedResponse.value.type === 'CONFIG_TIMEOUT')) {
66
+ if (parsedResponse.ok &&
67
+ (parsedResponse.value.type === "CONFIG_DENIED" || parsedResponse.value.type === "CONFIG_TIMEOUT")) {
68
68
  ws.socket.dispatchEvent(new ErrorEvent({
69
69
  name: parsedResponse.value.type,
70
70
  message: JSON.stringify(parsedResponse.value),
71
- }, ''));
71
+ }, ""));
72
72
  ws.close();
73
73
  return;
74
74
  }
75
- if (parsedResponse.ok && parsedResponse.value.type === 'error') {
75
+ if (parsedResponse.ok && parsedResponse.value.type === "error") {
76
76
  ws.socket.dispatchEvent(new ErrorEvent({
77
- name: 'error',
77
+ name: "error",
78
78
  message: JSON.stringify(parsedResponse.value),
79
- }, ''));
79
+ }, ""));
80
80
  ws.close();
81
81
  return;
82
82
  }
83
- if (parsedResponse.ok && parsedResponse.value.type === 'ended') {
83
+ if (parsedResponse.ok && parsedResponse.value.type === "ended") {
84
84
  ws.close();
85
85
  return;
86
86
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
- import { TranscribeSocket as FernTranscribeSocket } from '../api/resources/transcribe/client/Socket.mjs';
4
+ import { TranscribeSocket as FernTranscribeSocket } from "../api/resources/transcribe/client/Socket.mjs";
5
5
  export declare class TranscribeSocket extends FernTranscribeSocket {
6
6
  sendAudio(message: ArrayBufferLike | Blob | ArrayBufferView | string): void;
7
7
  /**
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Patch: file patches disability of auto-generating binary data methods for sending data to the socket
3
3
  */
4
- import { TranscribeSocket as FernTranscribeSocket } from '../api/resources/transcribe/client/Socket.mjs';
4
+ import { TranscribeSocket as FernTranscribeSocket } from "../api/resources/transcribe/client/Socket.mjs";
5
5
  import * as core from "../core/index.mjs";
6
6
  export class TranscribeSocket extends FernTranscribeSocket {
7
7
  sendAudio(message) {
8
- if (typeof message === 'string') {
8
+ if (typeof message === "string") {
9
9
  return super.sendAudio(message);
10
10
  }
11
11
  this.__assertSocketIsOpen();
@@ -7,7 +7,7 @@ export type ExpectedTokenResponse = Omit<api.GetTokenResponse, "tokenType" | "ex
7
7
  expiresIn?: number;
8
8
  };
9
9
  type RefreshAccessTokenFunction = (refreshToken?: string) => Promise<ExpectedTokenResponse> | ExpectedTokenResponse;
10
- export type BearerOptions = Partial<Omit<api.GetTokenResponse, 'accessToken'>> & ({
10
+ export type BearerOptions = Partial<Omit<api.GetTokenResponse, "accessToken">> & ({
11
11
  refreshAccessToken?: RefreshAccessTokenFunction;
12
12
  accessToken: string;
13
13
  } | {
@@ -21,21 +21,21 @@
21
21
  */
22
22
  export function decodeToken(token) {
23
23
  // Validate the token structure (should contain at least header and payload parts)
24
- const parts = token ? token.split('.') : '';
24
+ const parts = token ? token.split(".") : "";
25
25
  if (parts.length < 2) {
26
26
  return null;
27
27
  }
28
28
  // Retrieve the payload (second part) of the JWT token
29
29
  const base64Url = parts[1];
30
30
  // Replace URL-safe characters to match standard base64 encoding
31
- const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
31
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
32
32
  // Decode the base64 string into a JSON string
33
33
  let jsonPayload;
34
34
  try {
35
35
  jsonPayload = decodeURIComponent(atob(base64)
36
- .split('')
37
- .map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
38
- .join(''));
36
+ .split("")
37
+ .map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2))
38
+ .join(""));
39
39
  }
40
40
  catch (error) {
41
41
  return null;
@@ -60,9 +60,7 @@ export function decodeToken(token) {
60
60
  const match = issuerUrl.match(regex);
61
61
  // If the issuer URL matches the expected pattern, return the extracted values along with the token
62
62
  if (match) {
63
- const expiresAt = tokenDetails.exp && typeof tokenDetails.exp === 'number'
64
- ? tokenDetails.exp
65
- : undefined;
63
+ const expiresAt = tokenDetails.exp && typeof tokenDetails.exp === "number" ? tokenDetails.exp : undefined;
66
64
  return {
67
65
  environment: match[2],
68
66
  tenantName: match[3],
@@ -2,7 +2,9 @@ import { CortiSDKError, CortiSDKErrorCodes } from "../CortiSDKError.mjs";
2
2
  export const LOCAL_STORAGE_ERROR_CODE = "local_storage_error";
3
3
  export const requireLocalStorage = () => {
4
4
  if (typeof window === "undefined" || !window.localStorage) {
5
- throw new CortiSDKError("LocalStorage operation failed: storage is not available in this environment.", { code: CortiSDKErrorCodes.LOCAL_STORAGE_ERROR });
5
+ throw new CortiSDKError("LocalStorage operation failed: storage is not available in this environment.", {
6
+ code: CortiSDKErrorCodes.LOCAL_STORAGE_ERROR,
7
+ });
6
8
  }
7
9
  return window.localStorage;
8
10
  };
@@ -9,10 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  const base64URLEncode = (buffer) => {
11
11
  const base64 = btoa(String.fromCharCode(...buffer));
12
- return base64
13
- .replace(/\+/g, '-')
14
- .replace(/\//g, '_')
15
- .replace(/=/g, '');
12
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
16
13
  };
17
14
  export const generateCodeVerifier = () => {
18
15
  const array = new Uint8Array(32);
@@ -22,6 +19,6 @@ export const generateCodeVerifier = () => {
22
19
  export const generateCodeChallenge = (verifier) => __awaiter(void 0, void 0, void 0, function* () {
23
20
  const encoder = new TextEncoder();
24
21
  const data = encoder.encode(verifier);
25
- const hash = yield crypto.subtle.digest('SHA-256', data);
22
+ const hash = yield crypto.subtle.digest("SHA-256", data);
26
23
  return base64URLEncode(new Uint8Array(hash));
27
24
  });
@@ -64,8 +64,7 @@ export function resolveClientOptions(options) {
64
64
  };
65
65
  }))();
66
66
  return {
67
- tenantName: options.tenantName ||
68
- tokenResponsePromise.then(({ tenantName }) => tenantName),
67
+ tenantName: options.tenantName || tokenResponsePromise.then(({ tenantName }) => tenantName),
69
68
  environment: options.environment ||
70
69
  tokenResponsePromise.then(({ environment }) => core.Supplier.get(getEnvironment(environment))),
71
70
  initialTokenResponse: tokenResponsePromise.then((result) => result.tokenResponse),
@@ -7,10 +7,11 @@ import * as core from "../../../../../core/index.mjs";
7
7
  import { StreamConfigStatusMessage } from "../../../../types/StreamConfigStatusMessage.mjs";
8
8
  import { StreamTranscriptMessage } from "../../../../types/StreamTranscriptMessage.mjs";
9
9
  import { StreamFactsMessage } from "../../../../types/StreamFactsMessage.mjs";
10
+ import { StreamFlushedMessage } from "../../../../types/StreamFlushedMessage.mjs";
10
11
  import { StreamEndedMessage } from "../../../../types/StreamEndedMessage.mjs";
11
12
  import { StreamUsageMessage } from "../../../../types/StreamUsageMessage.mjs";
12
13
  import { StreamErrorMessage } from "../../../../types/StreamErrorMessage.mjs";
13
- export declare const StreamSocketResponse: core.serialization.Schema<serializers.StreamSocketResponse.Raw, Corti.StreamConfigStatusMessage | Corti.StreamTranscriptMessage | Corti.StreamFactsMessage | Corti.StreamEndedMessage | Corti.StreamUsageMessage | Corti.StreamErrorMessage>;
14
+ export declare const StreamSocketResponse: core.serialization.Schema<serializers.StreamSocketResponse.Raw, Corti.StreamConfigStatusMessage | Corti.StreamTranscriptMessage | Corti.StreamFactsMessage | Corti.StreamFlushedMessage | Corti.StreamEndedMessage | Corti.StreamUsageMessage | Corti.StreamErrorMessage>;
14
15
  export declare namespace StreamSocketResponse {
15
- type Raw = StreamConfigStatusMessage.Raw | StreamTranscriptMessage.Raw | StreamFactsMessage.Raw | StreamEndedMessage.Raw | StreamUsageMessage.Raw | StreamErrorMessage.Raw;
16
+ type Raw = StreamConfigStatusMessage.Raw | StreamTranscriptMessage.Raw | StreamFactsMessage.Raw | StreamFlushedMessage.Raw | StreamEndedMessage.Raw | StreamUsageMessage.Raw | StreamErrorMessage.Raw;
16
17
  }
@@ -5,6 +5,7 @@ import * as core from "../../../../../core/index.mjs";
5
5
  import { StreamConfigStatusMessage } from "../../../../types/StreamConfigStatusMessage.mjs";
6
6
  import { StreamTranscriptMessage } from "../../../../types/StreamTranscriptMessage.mjs";
7
7
  import { StreamFactsMessage } from "../../../../types/StreamFactsMessage.mjs";
8
+ import { StreamFlushedMessage } from "../../../../types/StreamFlushedMessage.mjs";
8
9
  import { StreamEndedMessage } from "../../../../types/StreamEndedMessage.mjs";
9
10
  import { StreamUsageMessage } from "../../../../types/StreamUsageMessage.mjs";
10
11
  import { StreamErrorMessage } from "../../../../types/StreamErrorMessage.mjs";
@@ -12,6 +13,7 @@ export const StreamSocketResponse = core.serialization.undiscriminatedUnion([
12
13
  StreamConfigStatusMessage,
13
14
  StreamTranscriptMessage,
14
15
  StreamFactsMessage,
16
+ StreamFlushedMessage,
15
17
  StreamEndedMessage,
16
18
  StreamUsageMessage,
17
19
  StreamErrorMessage,
@@ -6,11 +6,12 @@ import * as Corti from "../../../../../api/index.mjs";
6
6
  import * as core from "../../../../../core/index.mjs";
7
7
  import { TranscribeConfigStatusMessage } from "../../../../types/TranscribeConfigStatusMessage.mjs";
8
8
  import { TranscribeUsageMessage } from "../../../../types/TranscribeUsageMessage.mjs";
9
+ import { TranscribeFlushedMessage } from "../../../../types/TranscribeFlushedMessage.mjs";
9
10
  import { TranscribeEndedMessage } from "../../../../types/TranscribeEndedMessage.mjs";
10
11
  import { TranscribeErrorMessage } from "../../../../types/TranscribeErrorMessage.mjs";
11
12
  import { TranscribeTranscriptMessage } from "../../../../types/TranscribeTranscriptMessage.mjs";
12
13
  import { TranscribeCommandMessage } from "../../../../types/TranscribeCommandMessage.mjs";
13
- export declare const TranscribeSocketResponse: core.serialization.Schema<serializers.TranscribeSocketResponse.Raw, Corti.TranscribeConfigStatusMessage | Corti.TranscribeUsageMessage | Corti.TranscribeEndedMessage | Corti.TranscribeErrorMessage | Corti.TranscribeTranscriptMessage | Corti.TranscribeCommandMessage>;
14
+ export declare const TranscribeSocketResponse: core.serialization.Schema<serializers.TranscribeSocketResponse.Raw, Corti.TranscribeConfigStatusMessage | Corti.TranscribeUsageMessage | Corti.TranscribeFlushedMessage | Corti.TranscribeEndedMessage | Corti.TranscribeErrorMessage | Corti.TranscribeTranscriptMessage | Corti.TranscribeCommandMessage>;
14
15
  export declare namespace TranscribeSocketResponse {
15
- type Raw = TranscribeConfigStatusMessage.Raw | TranscribeUsageMessage.Raw | TranscribeEndedMessage.Raw | TranscribeErrorMessage.Raw | TranscribeTranscriptMessage.Raw | TranscribeCommandMessage.Raw;
16
+ type Raw = TranscribeConfigStatusMessage.Raw | TranscribeUsageMessage.Raw | TranscribeFlushedMessage.Raw | TranscribeEndedMessage.Raw | TranscribeErrorMessage.Raw | TranscribeTranscriptMessage.Raw | TranscribeCommandMessage.Raw;
16
17
  }
@@ -4,6 +4,7 @@
4
4
  import * as core from "../../../../../core/index.mjs";
5
5
  import { TranscribeConfigStatusMessage } from "../../../../types/TranscribeConfigStatusMessage.mjs";
6
6
  import { TranscribeUsageMessage } from "../../../../types/TranscribeUsageMessage.mjs";
7
+ import { TranscribeFlushedMessage } from "../../../../types/TranscribeFlushedMessage.mjs";
7
8
  import { TranscribeEndedMessage } from "../../../../types/TranscribeEndedMessage.mjs";
8
9
  import { TranscribeErrorMessage } from "../../../../types/TranscribeErrorMessage.mjs";
9
10
  import { TranscribeTranscriptMessage } from "../../../../types/TranscribeTranscriptMessage.mjs";
@@ -11,6 +12,7 @@ import { TranscribeCommandMessage } from "../../../../types/TranscribeCommandMes
11
12
  export const TranscribeSocketResponse = core.serialization.undiscriminatedUnion([
12
13
  TranscribeConfigStatusMessage,
13
14
  TranscribeUsageMessage,
15
+ TranscribeFlushedMessage,
14
16
  TranscribeEndedMessage,
15
17
  TranscribeErrorMessage,
16
18
  TranscribeTranscriptMessage,
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as serializers from "../index.mjs";
5
+ import * as Corti from "../../api/index.mjs";
6
+ import * as core from "../../core/index.mjs";
7
+ export declare const StreamFlushMessage: core.serialization.ObjectSchema<serializers.StreamFlushMessage.Raw, Corti.StreamFlushMessage>;
8
+ export declare namespace StreamFlushMessage {
9
+ interface Raw {
10
+ type: "flush";
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as core from "../../core/index.mjs";
5
+ export const StreamFlushMessage = core.serialization.object({
6
+ type: core.serialization.stringLiteral("flush"),
7
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as serializers from "../index.mjs";
5
+ import * as Corti from "../../api/index.mjs";
6
+ import * as core from "../../core/index.mjs";
7
+ export declare const StreamFlushedMessage: core.serialization.ObjectSchema<serializers.StreamFlushedMessage.Raw, Corti.StreamFlushedMessage>;
8
+ export declare namespace StreamFlushedMessage {
9
+ interface Raw {
10
+ type: "flushed";
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as core from "../../core/index.mjs";
5
+ export const StreamFlushedMessage = core.serialization.object({
6
+ type: core.serialization.stringLiteral("flushed"),
7
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as serializers from "../index.mjs";
5
+ import * as Corti from "../../api/index.mjs";
6
+ import * as core from "../../core/index.mjs";
7
+ export declare const TranscribeFlushMessage: core.serialization.ObjectSchema<serializers.TranscribeFlushMessage.Raw, Corti.TranscribeFlushMessage>;
8
+ export declare namespace TranscribeFlushMessage {
9
+ interface Raw {
10
+ type: "flush";
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as core from "../../core/index.mjs";
5
+ export const TranscribeFlushMessage = core.serialization.object({
6
+ type: core.serialization.stringLiteral("flush"),
7
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as serializers from "../index.mjs";
5
+ import * as Corti from "../../api/index.mjs";
6
+ import * as core from "../../core/index.mjs";
7
+ export declare const TranscribeFlushedMessage: core.serialization.ObjectSchema<serializers.TranscribeFlushedMessage.Raw, Corti.TranscribeFlushedMessage>;
8
+ export declare namespace TranscribeFlushedMessage {
9
+ interface Raw {
10
+ type: "flushed";
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as core from "../../core/index.mjs";
5
+ export const TranscribeFlushedMessage = core.serialization.object({
6
+ type: core.serialization.stringLiteral("flushed"),
7
+ });
@@ -71,6 +71,7 @@ export * from "./StreamConfigMode.mjs";
71
71
  export * from "./StreamConfigStatusMessageType.mjs";
72
72
  export * from "./StreamConfigStatusMessage.mjs";
73
73
  export * from "./StreamEndedMessage.mjs";
74
+ export * from "./StreamFlushedMessage.mjs";
74
75
  export * from "./StreamUsageMessage.mjs";
75
76
  export * from "./StreamErrorMessage.mjs";
76
77
  export * from "./StreamErrorDetail.mjs";
@@ -83,6 +84,7 @@ export * from "./StreamTranscriptTime.mjs";
83
84
  export * from "./StreamFactsMessage.mjs";
84
85
  export * from "./StreamFact.mjs";
85
86
  export * from "./StreamEndMessage.mjs";
87
+ export * from "./StreamFlushMessage.mjs";
86
88
  export * from "./StreamSupportedLanguage.mjs";
87
89
  export * from "./TranscribeSupportedLanguage.mjs";
88
90
  export * from "./TranscribeConfig.mjs";
@@ -92,8 +94,10 @@ export * from "./TranscribeCommandVariable.mjs";
92
94
  export * from "./TranscribeConfigStatusMessageType.mjs";
93
95
  export * from "./TranscribeConfigStatusMessage.mjs";
94
96
  export * from "./TranscribeEndMessage.mjs";
97
+ export * from "./TranscribeFlushMessage.mjs";
95
98
  export * from "./TranscribeUsageMessage.mjs";
96
99
  export * from "./TranscribeEndedMessage.mjs";
100
+ export * from "./TranscribeFlushedMessage.mjs";
97
101
  export * from "./TranscribeErrorMessageError.mjs";
98
102
  export * from "./TranscribeErrorMessage.mjs";
99
103
  export * from "./TranscribeTranscriptData.mjs";
@@ -71,6 +71,7 @@ export * from "./StreamConfigMode.mjs";
71
71
  export * from "./StreamConfigStatusMessageType.mjs";
72
72
  export * from "./StreamConfigStatusMessage.mjs";
73
73
  export * from "./StreamEndedMessage.mjs";
74
+ export * from "./StreamFlushedMessage.mjs";
74
75
  export * from "./StreamUsageMessage.mjs";
75
76
  export * from "./StreamErrorMessage.mjs";
76
77
  export * from "./StreamErrorDetail.mjs";
@@ -83,6 +84,7 @@ export * from "./StreamTranscriptTime.mjs";
83
84
  export * from "./StreamFactsMessage.mjs";
84
85
  export * from "./StreamFact.mjs";
85
86
  export * from "./StreamEndMessage.mjs";
87
+ export * from "./StreamFlushMessage.mjs";
86
88
  export * from "./StreamSupportedLanguage.mjs";
87
89
  export * from "./TranscribeSupportedLanguage.mjs";
88
90
  export * from "./TranscribeConfig.mjs";
@@ -92,8 +94,10 @@ export * from "./TranscribeCommandVariable.mjs";
92
94
  export * from "./TranscribeConfigStatusMessageType.mjs";
93
95
  export * from "./TranscribeConfigStatusMessage.mjs";
94
96
  export * from "./TranscribeEndMessage.mjs";
97
+ export * from "./TranscribeFlushMessage.mjs";
95
98
  export * from "./TranscribeUsageMessage.mjs";
96
99
  export * from "./TranscribeEndedMessage.mjs";
100
+ export * from "./TranscribeFlushedMessage.mjs";
97
101
  export * from "./TranscribeErrorMessageError.mjs";
98
102
  export * from "./TranscribeErrorMessage.mjs";
99
103
  export * from "./TranscribeTranscriptData.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.6.0";
1
+ export declare const SDK_VERSION = "0.7.0-rc";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.6.0";
1
+ export const SDK_VERSION = "0.7.0-rc";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corti/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-rc",
4
4
  "private": false,
5
5
  "repository": "github:corticph/corti-sdk-javascript",
6
6
  "license": "MIT",