streamby-core 0.33.0 → 0.35.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 (54) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/LICENSE +661 -0
  3. package/README.md +111 -11
  4. package/dist/adapters/database/connectionManager.js +18 -0
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.js +4 -1
  7. package/dist/middleware/createRouter.js +19 -2
  8. package/dist/middleware/routes/ai.js +3 -3
  9. package/dist/middleware/routes/{credential.d.ts → apiToken.d.ts} +1 -1
  10. package/dist/middleware/routes/apiToken.js +58 -0
  11. package/dist/middleware/routes/connection.js +3 -12
  12. package/dist/middleware/routes/dbConnection.js +7 -26
  13. package/dist/middleware/routes/distribution.js +12 -5
  14. package/dist/middleware/routes/export.js +5 -4
  15. package/dist/middleware/routes/media.js +27 -10
  16. package/dist/middleware/routes/member.js +3 -12
  17. package/dist/middleware/routes/pipeline.js +3 -3
  18. package/dist/middleware/routes/production.js +9 -9
  19. package/dist/middleware/routes/project.js +12 -25
  20. package/dist/middleware/routes/renderFarm.js +13 -6
  21. package/dist/middleware/routes/review.js +4 -4
  22. package/dist/middleware/routes/rights.js +1 -1
  23. package/dist/middleware/routes/storage.js +21 -15
  24. package/dist/middleware/routes/storageConnection.js +2 -8
  25. package/dist/middleware/routes/workflow.js +1 -1
  26. package/dist/services/apiTokens.d.ts +47 -0
  27. package/dist/services/apiTokens.js +110 -0
  28. package/dist/services/auth.d.ts +5 -3
  29. package/dist/services/auth.js +49 -11
  30. package/dist/services/connectionResolver.js +2 -2
  31. package/dist/services/executor.d.ts +4 -1
  32. package/dist/services/executor.js +29 -11
  33. package/dist/services/reencryptCredentials.d.ts +5 -0
  34. package/dist/services/reencryptCredentials.js +74 -0
  35. package/dist/services/userIntegration.d.ts +2 -2
  36. package/dist/services/userIntegration.js +7 -1
  37. package/dist/services/wsHub.js +6 -0
  38. package/dist/types/index.d.ts +9 -0
  39. package/dist/utils/auth.d.ts +15 -1
  40. package/dist/utils/auth.js +21 -6
  41. package/dist/utils/encryption.d.ts +6 -1
  42. package/dist/utils/encryption.js +80 -27
  43. package/dist/utils/serviceEndpoints.d.ts +2 -0
  44. package/dist/utils/serviceEndpoints.js +26 -0
  45. package/package.json +4 -3
  46. package/dist/middleware/routes/apiConnection.d.ts +0 -3
  47. package/dist/middleware/routes/apiConnection.js +0 -100
  48. package/dist/middleware/routes/credential.js +0 -80
  49. package/dist/services/apiConnection.d.ts +0 -18
  50. package/dist/services/apiConnection.js +0 -65
  51. package/dist/services/credential.d.ts +0 -8
  52. package/dist/services/credential.js +0 -70
  53. package/dist/services/pipeline.d.ts +0 -2
  54. package/dist/services/pipeline.js +0 -292
package/CHANGELOG.md ADDED
@@ -0,0 +1,100 @@
1
+ # Changelog
2
+
3
+ ## 0.35.0
4
+
5
+ ### Added
6
+
7
+ - **API tokens**, so agents and services can work with StreamBy as a user without the user's
8
+ browser session. The README has the details.
9
+ - `GET`, `POST` and `DELETE /user/api-tokens` let a user list, make and revoke their own
10
+ tokens. These routes need a session: a token can't manage tokens.
11
+ - A token is `sbt_` followed by 32 random bytes. It's shown once, when it's made.
12
+ - **Scope:** each token is `read` (only reads) or `write` (reads and writes). It reaches a
13
+ list of projects, or `'*'` for every project its owner is a member of, including ones they
14
+ join later. It expires in 7, 30, 90 or 365 days, or never.
15
+ - A request made with a token reaches only its scope:
16
+ - a `read` token can't write;
17
+ - a project outside its scope answers 404, and the project list and jobs show only its
18
+ projects;
19
+ - outside a project, it can only make a few reads.
20
+
21
+ The owner's role in each project still applies on top, so a token never does more than
22
+ its owner can, and it stops reaching a project once its owner leaves it.
23
+ - **`resolveApiToken`** (exported, with `API_TOKEN_PREFIX`) is for the host's
24
+ `authProvider`. It turns `Authorization: Bearer sbt_...` into the token's owner and scope,
25
+ or `null` once the token is revoked or expired. The `authProvider` returns the scope as
26
+ `Auth.apiToken`. Without it, a token would have all of its owner's access.
27
+ - **New table: `api_tokens`.** It's created at startup in the main database, and it keeps
28
+ only each token's SHA-256 hash, never the token itself.
29
+
30
+ ### Security
31
+
32
+ - A connection authenticated with an API token can't open the WebSocket. It's closed with
33
+ code 1008. The WebSocket belongs to the browser session and receives every event of its
34
+ user, from any project.
35
+
36
+ ## 0.34.0
37
+
38
+ ### ⚠️ Migration and deploy
39
+
40
+ Read this before deploying 0.34.0.
41
+
42
+ - **Stored credentials are converted at startup.** The first time 0.34.0 starts, every stored
43
+ credential is re-encrypted in the new format (`v2`, AES-256-GCM). This covers project API,
44
+ database and storage connections, export credentials, and user integrations. Distribution and
45
+ render farm credentials, which were stored unencrypted, are encrypted. The conversion is
46
+ non-destructive: a value is only replaced by its own re-encryption, and one that can't be
47
+ decrypted with the configured keys is left as it is and logged.
48
+ - **There's no going back after the conversion.** Versions before 0.34.0 can't read the `v2`
49
+ format. Once 0.34.0 has started against your databases, don't roll back to 0.33.x. If you run
50
+ several instances, deploy all of them together, so that no older instance reads converted
51
+ credentials.
52
+ - **Don't rotate the encryption key in the same deploy that does the conversion.** The old
53
+ format (AES-256-CBC) doesn't record which key encrypted a value. Deploy 0.34.0 with your
54
+ current key first. Rotate afterwards, with the new `encryptPreviousKeys` option (see the
55
+ README).
56
+
57
+ ### Breaking changes
58
+
59
+ - **Permissions depend on the member's role in the project**, not on the platform role that
60
+ `authProvider` returns (`Auth.role`). Only active members count (`status: 'active'`); a
61
+ pending invitation gives no access.
62
+ - **Editing a project requires being an editor or an admin of it.** This covers its content,
63
+ connections, exports, files, jobs, workflow, pipelines, production, reviews and rights, and
64
+ the upload URLs.
65
+ - **Deleting a project and managing its members requires being an admin of it.** A platform
66
+ admin who isn't an admin of the project can't do either.
67
+ - **The public export route doesn't run nodes that use credentials, nor nodes that start
68
+ jobs.** A request to `GET /:projectId/export/:exportName` has no session, so only nodes that
69
+ read data run: static JSON, the built-in databases and storage, and the project's own
70
+ connections. A node using an account integration (Claude, Jira, Google, or a user's own
71
+ database or storage), or one that starts a job (transcode, render, AI and the like), fails
72
+ with an error.
73
+ - **`getDecryptedIntegrationCredentialById` now takes the project** as its third argument:
74
+ `getDecryptedIntegrationCredentialById(integrationId, config, project)`. It resolves the
75
+ credential only while the integration's owner is an active member of that project.
76
+ - **`GET /users/search` requires a session.**
77
+
78
+ ### Security
79
+
80
+ - An account integration's credential is tied to its owner. It resolves only for a project its
81
+ owner is an active member of.
82
+ - An integration node sends its credential only to its own provider's API: `api.anthropic.com`
83
+ for Claude, `api.atlassian.com` or `*.atlassian.net` for Jira, and `*.googleapis.com` for
84
+ Google. It does so over https, never to a URL with a port or credentials in it, and without
85
+ following redirects.
86
+ - Only the public export route goes without a session. Before, any path containing `/export/`
87
+ skipped authentication.
88
+ - A job is visible only to whoever started it, or to a member of its project.
89
+ - Stored credentials are encrypted with AES-256-GCM (authenticated, so an altered value fails
90
+ to decrypt), and each value records the id of the key that encrypted it, so keys can be
91
+ rotated.
92
+ - Distribution and render farm connections encrypt their credential when they're saved.
93
+
94
+ ### Added
95
+
96
+ - `encryptPreviousKeys` (in the router config): keys stored credentials may still be encrypted
97
+ with. They're used only to decrypt, and what they hold is re-encrypted with `encrypt` at
98
+ startup.
99
+ - Distribution and render farm connections take their credential as `credential`. The old name,
100
+ `encryptedCredential`, is still accepted for the same plain value.