assemblyai 4.7.0 → 4.8.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -4
  3. package/dist/assemblyai.streaming.umd.js +5 -1
  4. package/dist/assemblyai.streaming.umd.min.js +1 -1
  5. package/dist/assemblyai.umd.js +12 -6
  6. package/dist/assemblyai.umd.min.js +1 -1
  7. package/dist/browser.mjs +11 -5
  8. package/dist/bun.mjs +1 -6
  9. package/dist/deno.mjs +1 -6
  10. package/dist/index.cjs +8 -6
  11. package/dist/index.mjs +8 -6
  12. package/dist/node.cjs +1 -6
  13. package/dist/node.mjs +1 -6
  14. package/dist/polyfills/websocket/index.d.ts +1 -0
  15. package/dist/streaming.browser.mjs +4 -0
  16. package/dist/streaming.cjs +1 -1
  17. package/dist/streaming.mjs +1 -1
  18. package/dist/types/openapi.generated.d.ts +193 -36
  19. package/dist/utils/conditions/browser.d.ts +2 -0
  20. package/dist/utils/conditions/bun.d.ts +2 -0
  21. package/dist/utils/conditions/conditions.d.ts +10 -0
  22. package/dist/utils/conditions/default.d.ts +2 -0
  23. package/dist/utils/conditions/deno.d.ts +2 -0
  24. package/dist/utils/conditions/node.d.ts +2 -0
  25. package/dist/utils/conditions/react-native.d.ts +2 -0
  26. package/dist/utils/conditions/workerd.d.ts +2 -0
  27. package/dist/workerd.mjs +1 -6
  28. package/package.json +36 -23
  29. package/src/services/base.ts +7 -4
  30. package/src/services/realtime/service.ts +8 -0
  31. package/src/types/openapi.generated.ts +193 -36
  32. package/src/utils/conditions/browser.ts +12 -0
  33. package/src/utils/conditions/bun.ts +12 -0
  34. package/src/utils/conditions/conditions.ts +10 -0
  35. package/src/utils/conditions/default.ts +12 -0
  36. package/src/utils/conditions/deno.ts +12 -0
  37. package/src/utils/conditions/node.ts +12 -0
  38. package/src/utils/conditions/react-native.ts +12 -0
  39. package/src/utils/conditions/workerd.ts +12 -0
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
@@ -0,0 +1,10 @@
1
+ export type Conditions = {
2
+ name: string;
3
+ default: boolean;
4
+ node: boolean;
5
+ browser: boolean;
6
+ bun: boolean;
7
+ deno: boolean;
8
+ workerd: boolean;
9
+ reactNative: boolean;
10
+ };
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
@@ -0,0 +1,2 @@
1
+ import { Conditions } from "./conditions";
2
+ export declare const conditions: Conditions;
package/dist/workerd.mjs CHANGED
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
15
15
  defaultUserAgentString += navigator.userAgent;
16
16
  }
17
17
  const defaultUserAgent = {
18
- sdk: { name: "JavaScript", version: "4.7.0" },
18
+ sdk: { name: "JavaScript", version: "4.8.0" },
19
19
  };
20
20
  if (typeof process !== "undefined") {
21
21
  if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
@@ -66,11 +66,6 @@ class BaseService {
66
66
  headers = { ...headers, ...init.headers };
67
67
  if (this.userAgent) {
68
68
  headers["User-Agent"] = this.userAgent;
69
- // chromium browsers have a bug where the user agent can't be modified
70
- if (typeof window !== "undefined" && "chrome" in window) {
71
- headers["AssemblyAI-Agent"] =
72
- this.userAgent;
73
- }
74
69
  }
75
70
  init.headers = headers;
76
71
  if (!input.startsWith("http"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -56,6 +56,15 @@
56
56
  "browser": "./src/polyfills/websocket/browser.ts",
57
57
  "node": "./src/polyfills/websocket/default.ts",
58
58
  "default": "./src/polyfills/websocket/default.ts"
59
+ },
60
+ "#conditions": {
61
+ "bun": "./src/utils/conditions/bun.ts",
62
+ "deno": "./src/utils/conditions/deno.ts",
63
+ "workerd": "./src/utils/conditions/workerd.ts",
64
+ "react-native": "./src/utils/conditions/react-native.ts",
65
+ "browser": "./src/utils/conditions/browser.ts",
66
+ "node": "./src/utils/conditions/node.ts",
67
+ "default": "./src/utils/conditions/default.ts"
59
68
  }
60
69
  },
61
70
  "type": "commonjs",
@@ -90,7 +99,9 @@
90
99
  "generate:types": "tsx ./scripts/generate-types.ts && prettier 'src/types/*.generated.ts' --write",
91
100
  "generate:reference": "typedoc",
92
101
  "copybara:dry-run": "./copybara.sh dry_run --init-history",
93
- "copybara:pr": "./copybara.sh sync_out --init-history"
102
+ "copybara:pr": "./copybara.sh sync_out --init-history",
103
+ "copybara:dry-run-in": "./copybara.sh dry_run_in --init-history",
104
+ "copybara:pr-in": "./copybara.sh sync_in --init-history"
94
105
  },
95
106
  "keywords": [
96
107
  "AssemblyAI",
@@ -115,19 +126,19 @@
115
126
  "docs"
116
127
  ],
117
128
  "devDependencies": {
118
- "@babel/preset-env": "^7.24.7",
129
+ "@babel/preset-env": "^7.25.4",
119
130
  "@babel/preset-typescript": "^7.24.7",
120
- "@rollup/plugin-node-resolve": "^15.2.3",
121
- "@rollup/plugin-replace": "^5.0.7",
131
+ "@rollup/plugin-node-resolve": "^15.3.0",
132
+ "@rollup/plugin-replace": "^6.0.1",
122
133
  "@rollup/plugin-terser": "^0.4.4",
123
- "@rollup/plugin-typescript": "^11.1.6",
124
- "@types/jest": "^29.5.12",
125
- "@types/node": "^18.19.38",
134
+ "@rollup/plugin-typescript": "^12.1.0",
135
+ "@types/jest": "^29.5.13",
136
+ "@types/node": "^18.19.53",
126
137
  "@types/websocket": "^1.0.10",
127
- "@types/ws": "^8.5.10",
128
- "@typescript-eslint/eslint-plugin": "^7.13.1",
138
+ "@types/ws": "^8.5.12",
139
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
129
140
  "dotenv": "^16.4.5",
130
- "eslint": "^8.57.0",
141
+ "eslint": "^8.57.1",
131
142
  "eslint-plugin-tsdoc": "^0.3.0",
132
143
  "jest": "^29.7.0",
133
144
  "jest-cli": "^29.7.0",
@@ -135,31 +146,33 @@
135
146
  "jest-junit": "^16.0.0",
136
147
  "jest-websocket-mock": "^2.5.0",
137
148
  "mock-socket": "^9.3.1",
138
- "openapi-typescript": "^6.7.5",
139
- "prettier": "^3.3.2",
140
- "publint": "^0.2.8",
141
- "rimraf": "^5.0.7",
142
- "rollup": "^4.18.0",
143
- "ts-jest": "^29.1.5",
144
- "tslib": "^2.6.3",
145
- "typedoc": "^0.25.13",
146
- "typedoc-plugin-extras": "^3.0.0",
149
+ "openapi-typescript": "^6.7.6",
150
+ "prettier": "^3.3.3",
151
+ "publint": "^0.2.11",
152
+ "rimraf": "^6.0.1",
153
+ "rollup": "^4.22.4",
154
+ "ts-jest": "^29.2.5",
155
+ "tslib": "^2.7.0",
156
+ "typedoc": "^0.26.7",
157
+ "typedoc-plugin-extras": "^3.1.0",
147
158
  "typescript": "^5.4.5"
148
159
  },
149
160
  "dependencies": {
150
- "ws": "^8.17.1"
161
+ "ws": "^8.18.0"
151
162
  },
152
163
  "pnpm": {
153
164
  "packageExtensions": {
154
165
  "ws": {
155
166
  "peerDependencies": {
156
- "@types/ws": "^8.5.10"
167
+ "@types/ws": "^8.5.12"
157
168
  }
158
169
  }
159
170
  },
160
171
  "overrides": {
161
172
  "undici@<5.28.4": ">=5.28.4",
162
- "braces@<3.0.3": ">=3.0.3"
173
+ "braces@<3.0.3": ">=3.0.3",
174
+ "micromatch@<4.0.8": ">=4.0.8",
175
+ "rollup@<2.79.2": ">=2.79.2"
163
176
  }
164
177
  }
165
178
  }
@@ -1,3 +1,4 @@
1
+ import { conditions } from "#conditions";
1
2
  import { DEFAULT_FETCH_INIT } from "#fetch";
2
3
  import { BaseServiceParams, Error as JsonError } from "..";
3
4
  import { buildUserAgent } from "../utils/userAgent";
@@ -33,10 +34,12 @@ export abstract class BaseService {
33
34
 
34
35
  if (this.userAgent) {
35
36
  (headers as Record<string, string>)["User-Agent"] = this.userAgent;
36
- // chromium browsers have a bug where the user agent can't be modified
37
- if (typeof window !== "undefined" && "chrome" in window) {
38
- (headers as Record<string, string>)["AssemblyAI-Agent"] =
39
- this.userAgent;
37
+ if (conditions.browser || conditions.default) {
38
+ // chromium browsers have a bug where the user agent can't be modified
39
+ if (typeof window !== "undefined" && "chrome" in window) {
40
+ (headers as Record<string, string>)["AssemblyAI-Agent"] =
41
+ this.userAgent;
42
+ }
40
43
  }
41
44
  }
42
45
  init.headers = headers;
@@ -1,4 +1,5 @@
1
1
  import { WritableStream } from "#streams";
2
+ import { conditions } from "#conditions";
2
3
  import {
3
4
  PolyfillWebSocket,
4
5
  factory as polyfillWebSocketFactory,
@@ -190,6 +191,13 @@ export class RealtimeTranscriber {
190
191
  if (this.token) {
191
192
  this.socket = polyfillWebSocketFactory(url.toString());
192
193
  } else {
194
+ if (conditions.browser) {
195
+ console.warn(
196
+ `API key authentication is not supported for the RealtimeTranscriber in browser environment. Use temporary token authentication instead.
197
+ Learn more at https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/docs/compat.md#browser-compatibility.`,
198
+ );
199
+ }
200
+
193
201
  this.socket = polyfillWebSocketFactory(url.toString(), {
194
202
  headers: { Authorization: this.apiKey },
195
203
  });