@trigger.dev/sdk 4.8.2 → 4.8.4
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/commonjs/v3/ai-shared.d.ts +3 -2
- package/dist/commonjs/v3/ai-shared.js +219 -28
- package/dist/commonjs/v3/ai-shared.js.map +1 -1
- package/dist/commonjs/v3/ai.d.ts +4 -0
- package/dist/commonjs/v3/ai.js +97 -87
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +11 -4
- package/dist/commonjs/v3/auth.js +9 -8
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-server.js +3 -1
- package/dist/commonjs/v3/chat-server.js.map +1 -1
- package/dist/commonjs/v3/chat.js +26 -6
- package/dist/commonjs/v3/chat.js.map +1 -1
- package/dist/commonjs/v3/index.d.ts +1 -1
- package/dist/commonjs/v3/index.js +2 -1
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/v3/oidc/aws.d.ts +24 -0
- package/dist/commonjs/v3/oidc/aws.js +46 -0
- package/dist/commonjs/v3/oidc/aws.js.map +1 -0
- package/dist/commonjs/v3/oidc/infisical.d.ts +16 -0
- package/dist/commonjs/v3/oidc/infisical.js +43 -0
- package/dist/commonjs/v3/oidc/infisical.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai-shared.d.ts +3 -2
- package/dist/esm/v3/ai-shared.js +214 -28
- package/dist/esm/v3/ai-shared.js.map +1 -1
- package/dist/esm/v3/ai.d.ts +4 -0
- package/dist/esm/v3/ai.js +98 -88
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +11 -4
- package/dist/esm/v3/auth.js +9 -8
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-server.js +4 -2
- package/dist/esm/v3/chat-server.js.map +1 -1
- package/dist/esm/v3/chat.js +26 -6
- package/dist/esm/v3/chat.js.map +1 -1
- package/dist/esm/v3/index.d.ts +1 -1
- package/dist/esm/v3/index.js +1 -1
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/v3/oidc/aws.d.ts +24 -0
- package/dist/esm/v3/oidc/aws.js +43 -0
- package/dist/esm/v3/oidc/aws.js.map +1 -0
- package/dist/esm/v3/oidc/infisical.d.ts +16 -0
- package/dist/esm/v3/oidc/infisical.js +40 -0
- package/dist/esm/v3/oidc/infisical.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/backend.mdx +2 -2
- package/docs/ai-chat/custom-agents.mdx +8 -1
- package/docs/ai-chat/frontend.mdx +1 -1
- package/docs/ai-chat/lifecycle-hooks.mdx +4 -0
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +1 -1
- package/docs/ai-chat/transcript-storage.mdx +3 -1
- package/docs/apikeys/custom-access.mdx +209 -0
- package/docs/apikeys.mdx +54 -13
- package/docs/cli-login-commands.mdx +7 -1
- package/docs/cli-preview-archive.mdx +8 -0
- package/docs/cli-webhooks-commands.mdx +115 -0
- package/docs/config/config-file.mdx +2 -2
- package/docs/deployment/overview.mdx +2 -0
- package/docs/deployment/trusted-publishing.mdx +140 -0
- package/docs/github-actions.mdx +2 -2
- package/docs/github-integration.mdx +21 -0
- package/docs/oidc/anthropic.mdx +187 -0
- package/docs/oidc/aws.mdx +219 -0
- package/docs/oidc/custom.mdx +48 -0
- package/docs/oidc/infisical.mdx +59 -0
- package/docs/oidc.mdx +75 -0
- package/docs/self-hosting/env/webapp.mdx +7 -0
- package/docs/webhooks/connect.mdx +12 -0
- package/docs/webhooks/public-beta.mdx +70 -0
- package/package.json +37 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to AWS"
|
|
3
|
+
sidebarTitle: "AWS"
|
|
4
|
+
description: "Assume an IAM role from your tasks without storing AWS access keys."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use `awsCredentialProvider` to exchange a Trigger.dev OIDC token for temporary AWS credentials through STS. Pass it to your AWS SDK client to obtain and refresh credentials automatically.
|
|
8
|
+
|
|
9
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
10
|
+
|
|
11
|
+
## Configure AWS
|
|
12
|
+
|
|
13
|
+
### Create an OIDC identity provider
|
|
14
|
+
|
|
15
|
+
In AWS IAM, add an OpenID Connect identity provider with:
|
|
16
|
+
|
|
17
|
+
- **Provider URL**: your issuer URL, `https://oidc.trigger.dev/YOUR_ORG_SLUG`.
|
|
18
|
+
- **Audience**: `sts.amazonaws.com`, the audience used by the SDK's AWS helper.
|
|
19
|
+
|
|
20
|
+
Reuse the provider if one already exists for this issuer in your AWS account.
|
|
21
|
+
|
|
22
|
+
### Create an IAM role
|
|
23
|
+
|
|
24
|
+
Create a role with this trust policy. Replace the AWS account ID and organization slug, and replace `YOUR_ENVIRONMENT_SUBJECT` with the **complete subject copied from the dashboard**.
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"Version": "2012-10-17",
|
|
29
|
+
"Statement": [
|
|
30
|
+
{
|
|
31
|
+
"Effect": "Allow",
|
|
32
|
+
"Principal": {
|
|
33
|
+
"Federated": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:oidc-provider/oidc.trigger.dev/YOUR_ORG_SLUG"
|
|
34
|
+
},
|
|
35
|
+
"Action": "sts:AssumeRoleWithWebIdentity",
|
|
36
|
+
"Condition": {
|
|
37
|
+
"StringEquals": {
|
|
38
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:aud": "sts.amazonaws.com",
|
|
39
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:sub": "YOUR_ENVIRONMENT_SUBJECT"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Attach a permissions policy for the operations your task needs. For the S3 example below, allow `s3:GetObject` on `arn:aws:s3:::YOUR_BUCKET/trigger/*`. The trust policy controls who can assume the role; it does not grant S3 permissions. No session tags are required.
|
|
48
|
+
|
|
49
|
+
## Use the role in your task
|
|
50
|
+
|
|
51
|
+
Install the STS peer dependency and the AWS clients your task uses:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @trigger.dev/sdk@latest @aws-sdk/client-sts @aws-sdk/client-s3
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Replace the role ARN, region, bucket, and object key:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { task } from "@trigger.dev/sdk";
|
|
61
|
+
import { awsCredentialProvider } from "@trigger.dev/sdk/oidc/aws";
|
|
62
|
+
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
63
|
+
|
|
64
|
+
export const readFromS3 = task({
|
|
65
|
+
id: "read-from-s3",
|
|
66
|
+
run: async () => {
|
|
67
|
+
const s3 = new S3Client({
|
|
68
|
+
region: "us-east-1",
|
|
69
|
+
credentials: awsCredentialProvider({
|
|
70
|
+
roleArn: "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/YOUR_ROLE_NAME",
|
|
71
|
+
region: "us-east-1",
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const result = await s3.send(
|
|
76
|
+
new GetObjectCommand({
|
|
77
|
+
Bucket: "YOUR_BUCKET",
|
|
78
|
+
Key: "trigger/example.txt",
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
return { contents: await result.Body?.transformToString() };
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Redeploy with CLI 4.8.3 or later and start a new run on that deployment.
|
|
87
|
+
|
|
88
|
+
<Warning>
|
|
89
|
+
Create the AWS client inside `run` and reuse it only within that run. A
|
|
90
|
+
module-scope client can reuse a previous run's cached credentials and
|
|
91
|
+
attribute AWS activity to that run.
|
|
92
|
+
</Warning>
|
|
93
|
+
|
|
94
|
+
### Provider options
|
|
95
|
+
|
|
96
|
+
| Option | Required | Behavior |
|
|
97
|
+
| ----------------- | -------- | --------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `roleArn` | Yes | IAM role to assume. |
|
|
99
|
+
| `region` | Yes | Region for STS. The AWS service client's region does not configure STS. |
|
|
100
|
+
| `roleSessionName` | No | Defaults to the current run ID, sanitized to AWS's allowed characters and limited to 64 characters. |
|
|
101
|
+
| `durationSeconds` | No | Defaults to 3,600 seconds (one hour), subject to the role's allowed session duration. |
|
|
102
|
+
| `sessionTags` | No | Defaults to `false`. Set to `true` to include verified identity tags. Requires `sts:TagSession` in the role trust policy. |
|
|
103
|
+
|
|
104
|
+
For local development, use your own AWS credential chain, such as an AWS SSO profile. If a task runs both locally and deployed, select local credentials explicitly when `ctx.environment.type === "DEVELOPMENT"`.
|
|
105
|
+
|
|
106
|
+
## Session tags and task-level access
|
|
107
|
+
|
|
108
|
+
By default, a role's trust policy only checks the environment subject, so **every task in that environment** can assume the role. Session tags let you restrict a role to specific tasks, or scope resource permissions by task. They are off by default; existing roles keep working unchanged.
|
|
109
|
+
|
|
110
|
+
Trigger.dev adds these tags to the signed token. Values come from the verified run, never from payloads or caller input:
|
|
111
|
+
|
|
112
|
+
| Tag | Value |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `TriggerOrganizationId` | Organization ID |
|
|
115
|
+
| `TriggerProjectRef` | Project reference, such as `proj_...` |
|
|
116
|
+
| `TriggerEnvironmentId` | Environment ID |
|
|
117
|
+
| `TriggerEnvironmentType` | `PRODUCTION`, `STAGING`, or `PREVIEW` |
|
|
118
|
+
| `TriggerTaskId` | Task identifier, such as `read-from-s3` |
|
|
119
|
+
|
|
120
|
+
These are AWS session tags, not Trigger.dev run tags. They are not transitive across role chaining.
|
|
121
|
+
|
|
122
|
+
### Restrict a role to one task
|
|
123
|
+
|
|
124
|
+
1. Update the trust policy. Add `sts:TagSession` to `Action` and a `TriggerTaskId` condition. AWS rejects tagged tokens if `sts:TagSession` is missing.
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"Version": "2012-10-17",
|
|
129
|
+
"Statement": [
|
|
130
|
+
{
|
|
131
|
+
"Effect": "Allow",
|
|
132
|
+
"Principal": {
|
|
133
|
+
"Federated": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:oidc-provider/oidc.trigger.dev/YOUR_ORG_SLUG"
|
|
134
|
+
},
|
|
135
|
+
"Action": ["sts:AssumeRoleWithWebIdentity", "sts:TagSession"],
|
|
136
|
+
"Condition": {
|
|
137
|
+
"StringEquals": {
|
|
138
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:aud": "sts.amazonaws.com",
|
|
139
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:sub": "YOUR_ENVIRONMENT_SUBJECT",
|
|
140
|
+
"aws:RequestTag/TriggerTaskId": "read-from-s3"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
2. Enable tags in the task with `@trigger.dev/sdk` 4.8.4 or later, then redeploy:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
awsCredentialProvider({
|
|
152
|
+
roleArn: "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/YOUR_ROLE_NAME",
|
|
153
|
+
region: "us-east-1",
|
|
154
|
+
sessionTags: true,
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Older SDKs reject `sessionTags` in TypeScript and silently ignore it in JavaScript, which sends untagged tokens that this policy rejects.
|
|
159
|
+
|
|
160
|
+
<Warning>
|
|
161
|
+
Don't keep another statement that allows untagged assumption for the same subject, or any
|
|
162
|
+
task can bypass the restriction. This protects against other tasks in the environment, not
|
|
163
|
+
against people who can deploy: anyone who can deploy to the environment can deploy a task
|
|
164
|
+
with the trusted ID.
|
|
165
|
+
</Warning>
|
|
166
|
+
|
|
167
|
+
To use tags only in permissions (below) without restricting tasks, add `sts:TagSession` to `Action` and omit the `aws:RequestTag` condition.
|
|
168
|
+
|
|
169
|
+
### Use tags in resource permissions
|
|
170
|
+
|
|
171
|
+
Tags are available in the role's permissions as `aws:PrincipalTag/...`. For example, one role can give each task its own S3 prefix:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"Version": "2012-10-17",
|
|
176
|
+
"Statement": [
|
|
177
|
+
{
|
|
178
|
+
"Effect": "Allow",
|
|
179
|
+
"Action": "s3:GetObject",
|
|
180
|
+
"Resource": "arn:aws:s3:::YOUR_BUCKET/${aws:PrincipalTag/TriggerTaskId}/*"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Without the helper
|
|
187
|
+
|
|
188
|
+
Request tags with `auth.getOIDCToken({ audience: "sts.amazonaws.com", awsSessionTags: true })`. Other audiences are rejected. Task IDs are sent unchanged, so a task ID that exceeds [AWS session tag limits](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html) makes the STS call fail.
|
|
189
|
+
|
|
190
|
+
## Trust all Preview branches
|
|
191
|
+
|
|
192
|
+
For a single Preview environment, use its exact subject. To allow **any task** across **all current and future Preview branches** in one project, start with the basic trust policy in [Create an IAM role](#create-an-iam-role) and replace its `Condition` with:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"StringEquals": {
|
|
197
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:aud": "sts.amazonaws.com"
|
|
198
|
+
},
|
|
199
|
+
"StringLike": {
|
|
200
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:sub": "org:YOUR_ORG_ID:project:YOUR_PROJECT_REF:env:PREVIEW:*"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
For a task-restricted Preview role, keep `sts:TagSession` in `Action` and add the task condition to `StringEquals`:
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"StringEquals": {
|
|
210
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:aud": "sts.amazonaws.com",
|
|
211
|
+
"aws:RequestTag/TriggerTaskId": "read-from-s3"
|
|
212
|
+
},
|
|
213
|
+
"StringLike": {
|
|
214
|
+
"oidc.trigger.dev/YOUR_ORG_SLUG:sub": "org:YOUR_ORG_ID:project:YOUR_PROJECT_REF:env:PREVIEW:*"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Keep the organization ID, project reference, `PREVIEW` environment type, and audience fixed. This deliberately grants access to anyone allowed to deploy a Preview branch in that project. Never wildcard the organization or project, or use this policy for a role intended only for Production or Staging.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Custom OIDC integrations"
|
|
3
|
+
sidebarTitle: "Custom integrations"
|
|
4
|
+
description: "Connect tasks to services without an official Trigger.dev OIDC integration."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use `auth.getOIDCToken()` with a service that accepts external OIDC identities for workload authentication. You configure trust in that service and implement its authentication flow.
|
|
8
|
+
|
|
9
|
+
Support for OIDC user login does not necessarily mean a service accepts workload identities. Check the service's federation documentation before starting.
|
|
10
|
+
|
|
11
|
+
## Configure trust
|
|
12
|
+
|
|
13
|
+
Follow the [OIDC prerequisites](/oidc#prerequisites), then go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment and copy the issuer URL and subject.
|
|
14
|
+
|
|
15
|
+
In the receiving service:
|
|
16
|
+
|
|
17
|
+
1. Register your organization's issuer, `https://oidc.trigger.dev/YOUR_ORG_SLUG`, using its [discovery endpoint](/oidc#how-tokens-work) or signing keys as required.
|
|
18
|
+
2. Configure the expected audience. Use the service's required value, or choose one if it allows you to.
|
|
19
|
+
3. Restrict access to the exact environment subject, directly or through the service's identity-mapping rules.
|
|
20
|
+
4. Grant the identity only the permissions your task needs.
|
|
21
|
+
|
|
22
|
+
The service must verify the signature, issuer, audience, and expiry, and enforce the subject restriction. Trusting the issuer and audience alone does not isolate access to one environment.
|
|
23
|
+
|
|
24
|
+
## Request a token
|
|
25
|
+
|
|
26
|
+
Request a token inside your task with the exact audience configured in the receiving service:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
30
|
+
|
|
31
|
+
export const federatedTask = task({
|
|
32
|
+
id: "federated-task",
|
|
33
|
+
run: async () => {
|
|
34
|
+
const { token } = await auth.getOIDCToken({
|
|
35
|
+
audience: "https://service.example.com",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Use the service's documented token exchange or authentication flow here.
|
|
39
|
+
// Never log or return the token.
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`auth.getOIDCToken({ audience })` returns `Promise<{ token: string; expiresAt: Date }>`.
|
|
45
|
+
|
|
46
|
+
Most services exchange the token for service-specific credentials. Follow their documentation for the endpoint, request format, and credential refresh behavior. Send the OIDC token directly as a bearer token only if the service explicitly supports that flow.
|
|
47
|
+
|
|
48
|
+
Keep tokens and credentials within the executing run and refresh before expiry. Redeploy with the updated CLI and SDK, then start a new run. For local Development runs, use the service's own development credentials instead.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Connect to Infisical"
|
|
3
|
+
sidebarTitle: "Infisical"
|
|
4
|
+
description: "Read secrets from Infisical using your task's workload identity."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Infisical support was added in **4.8.4**. Use `@trigger.dev/sdk` and the Trigger.dev CLI (`trigger.dev`) **4.8.4 or later**, then follow the [OIDC prerequisites](/oidc#prerequisites).
|
|
8
|
+
|
|
9
|
+
## Configure Infisical
|
|
10
|
+
|
|
11
|
+
1. In Infisical, create a **Machine Identity** and enable [OIDC Auth](https://infisical.com/docs/documentation/platform/identities/oidc-auth/general).
|
|
12
|
+
2. Go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your Trigger.dev environment and configure the identity with:
|
|
13
|
+
|
|
14
|
+
| Infisical field | Value |
|
|
15
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
+
| **OIDC Discovery URL** | Your issuer URL, `https://oidc.trigger.dev/YOUR_ORG_SLUG`. Use the base URL, without `/.well-known/openid-configuration`. |
|
|
17
|
+
| **Issuer** | The same issuer URL. |
|
|
18
|
+
| **Subject** | The exact subject copied from the dashboard. No wildcard is needed. |
|
|
19
|
+
| **Audiences** | Your Infisical site URL, for example `https://us.infisical.com`. |
|
|
20
|
+
|
|
21
|
+
Leave **CA Certificate** blank. Set **Access Token TTL** and **Access Token Max TTL** to **900 seconds (15 minutes)** rather than relying on the defaults.
|
|
22
|
+
|
|
23
|
+
3. Add the identity to your Infisical project with read access only to the environments and secrets your task needs.
|
|
24
|
+
|
|
25
|
+
## Read a secret in your task
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @trigger.dev/sdk@latest @infisical/sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { task } from "@trigger.dev/sdk";
|
|
33
|
+
import { infisicalAccessToken } from "@trigger.dev/sdk/oidc/infisical";
|
|
34
|
+
import { InfisicalSDK } from "@infisical/sdk";
|
|
35
|
+
|
|
36
|
+
export const useSecret = task({
|
|
37
|
+
id: "use-secret",
|
|
38
|
+
run: async () => {
|
|
39
|
+
const siteUrl = "https://us.infisical.com";
|
|
40
|
+
const { accessToken } = await infisicalAccessToken({
|
|
41
|
+
identityId: "YOUR_INFISICAL_MACHINE_IDENTITY_ID",
|
|
42
|
+
siteUrl,
|
|
43
|
+
});
|
|
44
|
+
const client = new InfisicalSDK({ siteUrl });
|
|
45
|
+
client.auth().accessToken(accessToken);
|
|
46
|
+
|
|
47
|
+
const secret = await client.secrets().getSecret({
|
|
48
|
+
projectId: "YOUR_INFISICAL_PROJECT_ID",
|
|
49
|
+
environment: "prod",
|
|
50
|
+
secretName: "API_KEY",
|
|
51
|
+
});
|
|
52
|
+
// Use secret.secretValue here. Never log or return it.
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`siteUrl` defaults to `https://us.infisical.com`. Set it to `https://eu.infisical.com` for EU, or your self-hosted instance's URL. The audience defaults to `siteUrl` without a trailing slash; pass `audience` if your identity expects a different value. Optional `organizationSlug` scopes the session to an **Infisical** organization the identity can access.
|
|
58
|
+
|
|
59
|
+
The helper returns `{ accessToken, tokenType, expiresAt }` and does not cache tokens. Authenticate inside `run`, and call it again before `expiresAt` if your task needs access for longer than the configured token lifetime.
|
package/docs/oidc.mdx
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "OpenID Connect (OIDC)"
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
description: "Use workload identity to access external services from your tasks without storing long-lived credentials."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Trigger.dev uses **workload identity** in an OpenID Connect (OIDC) flow to let your tasks authenticate to external services without storing long-lived access keys.
|
|
8
|
+
|
|
9
|
+
Instead of saving a service's credentials as environment variables, configure it to trust Trigger.dev as an identity provider. Your task requests a signed, short-lived token that identifies its environment. The service verifies that identity and grants the permissions you configure, usually by exchanging the token for temporary credentials.
|
|
10
|
+
|
|
11
|
+
This gives you:
|
|
12
|
+
|
|
13
|
+
- **No stored access keys**: tasks obtain short-lived credentials when they need them.
|
|
14
|
+
- **Environment-specific access**: grant different permissions to Production, Staging, and individual Preview environments.
|
|
15
|
+
- **Organization-scoped trust**: each organization has its own issuer URL, `https://oidc.trigger.dev/YOUR_ORG_SLUG`.
|
|
16
|
+
|
|
17
|
+
## Get started
|
|
18
|
+
|
|
19
|
+
Choose an official integration, or connect a service that supports external OIDC workload identities yourself.
|
|
20
|
+
|
|
21
|
+
### Official integrations
|
|
22
|
+
|
|
23
|
+
<CardGroup cols={2}>
|
|
24
|
+
<Card title="AWS" href="/oidc/aws">
|
|
25
|
+
Assume an IAM role using the SDK's AWS credential provider.
|
|
26
|
+
</Card>
|
|
27
|
+
<Card title="Anthropic" href="/oidc/anthropic">
|
|
28
|
+
Call Claude from tasks and chat agents without an API key.
|
|
29
|
+
</Card>
|
|
30
|
+
<Card title="Infisical" href="/oidc/infisical">
|
|
31
|
+
Read secrets using your task's workload identity.
|
|
32
|
+
</Card>
|
|
33
|
+
</CardGroup>
|
|
34
|
+
|
|
35
|
+
For other services, follow [Custom integrations](/oidc/custom) to request a token and implement the service's authentication flow.
|
|
36
|
+
|
|
37
|
+
## Prerequisites
|
|
38
|
+
|
|
39
|
+
- Use `@trigger.dev/sdk` and the Trigger.dev CLI (`trigger.dev`) **4.8.3 or later**, including the CLI used in CI.
|
|
40
|
+
- **Redeploy after upgrading the CLI**, then start a new run on that deployment. Updating the SDK alone or replaying a run against an old deployment does not update its runner.
|
|
41
|
+
- Request tokens inside an executing task attempt in Production, Staging, or Preview. Local Development runs cannot mint OIDC tokens; use the service's local credentials instead.
|
|
42
|
+
|
|
43
|
+
## Connection details
|
|
44
|
+
|
|
45
|
+
Go to the [OIDC](https://cloud.trigger.dev/_/oidc) page for your environment. Copy the exact values from that page when configuring your service.
|
|
46
|
+
|
|
47
|
+
| Value | Purpose |
|
|
48
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| **Issuer URL** (`iss`) | Your organization's identity provider URL, such as `https://oidc.trigger.dev/YOUR_ORG_SLUG`. The service uses it to verify who issued the token. |
|
|
50
|
+
| **Subject** (`sub`) | Identifies your organization, project, and environment. The service uses it to decide which identity receives access. |
|
|
51
|
+
| **Audience** (`aud`) | Identifies the intended recipient. Request the value the service expects and configure it to require the same value. The AWS helper uses `sts.amazonaws.com`; other services may require something different. |
|
|
52
|
+
|
|
53
|
+
The audience is supplied when requesting a token, not a fixed setting on your environment. Some services require a particular value; others let you choose one. Checking only the issuer and audience is not enough to restrict access to one environment: configure an exact subject match or the service's equivalent identity mapping too.
|
|
54
|
+
|
|
55
|
+
Subjects have this format:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
org:YOUR_ORG_ID:project:YOUR_PROJECT_REF:env:ENVIRONMENT_TYPE:ENVIRONMENT_SLUG
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Copy the full subject rather than constructing it. For Preview environments, it uses the individual environment's persisted slug, not a branch display name. The subject stays the same across integrations and identifies every task in that environment, not an individual task.
|
|
62
|
+
|
|
63
|
+
## How tokens work
|
|
64
|
+
|
|
65
|
+
Tokens are signed with `RS256` and expire after five minutes. They include the issuer, subject, audience, issue time (`iat`), and expiry (`exp`). Credentials issued by the receiving service can have a different lifetime.
|
|
66
|
+
|
|
67
|
+
Services can discover your organization's issuer at:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
https://oidc.trigger.dev/YOUR_ORG_SLUG/.well-known/openid-configuration
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Public signing keys are available at `https://oidc.trigger.dev/YOUR_ORG_SLUG/.well-known/jwks.json`. Configure the service to validate the token's signature, issuer, audience, expiry, and authorized subject. Merely decoding a token does not verify it.
|
|
74
|
+
|
|
75
|
+
Keep tokens and credentials within the executing run. Do not log them, return them as task output, or silently fall back to static credentials if OIDC fails in a deployed environment. OIDC tokens for external services cannot be used to call Trigger.dev APIs.
|
|
@@ -12,6 +12,8 @@ mode: "wide"
|
|
|
12
12
|
| `MAGIC_LINK_SECRET` | Yes | — | Magic link encryption secret. Run: `openssl rand -hex 16` |
|
|
13
13
|
| `ENCRYPTION_KEY` | Yes | — | Secret store encryption key. Run: `openssl rand -hex 16` |
|
|
14
14
|
| `MANAGED_WORKER_SECRET` | Yes | — | Managed worker secret. Must be set and match supervisor. Run: `openssl rand -hex 32` |
|
|
15
|
+
| `PUBLIC_TOKEN_SUBJECT_SECRET` | No | `ENCRYPTION_KEY` | Key that encrypts the environment id inside public access tokens. Set it to keep this separate from the secret store key. Run: `openssl rand -hex 32` |
|
|
16
|
+
| `PUBLIC_TOKEN_SEALED_SUBJECT_ENABLED` | No | false | Encrypt the environment id inside newly minted public access tokens. Turn on only once every webapp instance runs a version that can read them. |
|
|
15
17
|
| `ALLOW_INSECURE_DEFAULT_SECRETS` | No | false | Boot even if a secret is still a known-insecure published default. Temporary escape hatch for values you can't safely rotate yet (see [Secrets](/self-hosting/kubernetes#secrets)). |
|
|
16
18
|
| **Domains & ports** | | | |
|
|
17
19
|
| `REMIX_APP_PORT` | No | 3030 | Remix app port. |
|
|
@@ -45,6 +47,10 @@ mode: "wide"
|
|
|
45
47
|
| `BLOCKED_EMAIL_DOMAINS` | No | — | Comma-separated email domains that can't sign in or sign up, including their subdomains. |
|
|
46
48
|
| `LOGIN_RATE_LIMITS_ENABLED` | No | true | Enable rate limiting on magic-link login. |
|
|
47
49
|
| `MAGIC_LINK_SAME_BROWSER_REQUIRED` | No | true | Only accept a magic link opened in the browser that requested it. Set to false to allow opening it on another device.|
|
|
50
|
+
| `PERSONAL_ACCESS_TOKEN_EXPIRY_DAYS` | No | 30,90,365 | Lifetimes, in days (1 to 3650), offered when creating a personal access token on the dashboard. Comma-separated. |
|
|
51
|
+
| `PERSONAL_ACCESS_TOKEN_DEFAULT_EXPIRY_DAYS` | No | 90 | The lifetime preselected when creating a personal access token. If it isn't one of the offered lifetimes, the shortest is preselected. |
|
|
52
|
+
| `CLI_LOGIN_IDLE_TIMEOUT_DAYS` | No | 7 | A token minted by a CLI or MCP login stops working after this many days without use. Set to 0 to turn this off. Each token keeps the value it was minted with. |
|
|
53
|
+
| `PERSONAL_ACCESS_TOKEN_EXPIRY_EMAILS_ENABLED` | No | true | Email the owner 7 days before a dashboard-created personal access token expires, and again when it has. Only runs when `EMAIL_TRANSPORT` is set. |
|
|
48
54
|
| `TURNSTILE_SITE_KEY` | No | — | Cloudflare Turnstile site key. With `TURNSTILE_SECRET_KEY`, adds a bot check to the magic-link sign-in form. |
|
|
49
55
|
| `TURNSTILE_SECRET_KEY` | No | — | Cloudflare Turnstile secret key, used to verify the check on the server. Turnstile is off unless both keys are set.|
|
|
50
56
|
| `AUTH_GITHUB_CLIENT_ID` | No | — | GitHub client ID. |
|
|
@@ -88,6 +94,7 @@ mode: "wide"
|
|
|
88
94
|
| `API_RATE_LIMIT_METRICS_MAX_ENTRIES` | No | 10000 | Cap on distinct (environment, bucket) entries held between flushes. |
|
|
89
95
|
| `API_RATE_LIMIT_METRICS_WAIT_FOR_ASYNC_INSERT` | No | 0 | Wait for ClickHouse to write each async insert of API rate limit metrics, surfacing write failures. |
|
|
90
96
|
| `API_RATE_LIMIT_METRICS_INSERT_BUSY_TIMEOUT_MS` | No | 10000 | How long ClickHouse buffers API rate limit metric inserts before writing a part. |
|
|
97
|
+
| `API_KEY_ALLOW_PRIVATE_IP_RANGES` | No | 0 | Allow private and reserved ranges in API key IP allowlists. |
|
|
91
98
|
| `WEBHOOK_METRICS_FLUSH_INTERVAL_MS` | No | 10000 | How often aggregated webhook limit metrics are flushed to ClickHouse. |
|
|
92
99
|
| `WEBHOOK_METRICS_MAX_ENTRIES` | No | 10000 | Cap on distinct (environment, bucket) entries held between flushes. |
|
|
93
100
|
| `WEBHOOK_METRICS_MAX_ENDPOINTS` | No | 500 | Cap on endpoints with their own webhook metric rows per environment and bucket; environment totals still count all. |
|
|
@@ -21,6 +21,18 @@ The prompt tells the agent to use the Trigger.dev MCP server (`npx trigger.dev@l
|
|
|
21
21
|
| `generate_webhook_secret` | Generates a signing secret and returns it once, for providers where you choose the secret. Optionally keeps accepting the old secret (`previousSecretTtlSeconds`). |
|
|
22
22
|
| `set_webhook_secret` | Stores a secret the provider issued. Optionally keeps accepting the old secret (`previousSecretTtlSeconds`). |
|
|
23
23
|
|
|
24
|
+
### Keep the secret out of the agent's context
|
|
25
|
+
|
|
26
|
+
A secret passed to `set_webhook_secret`, or returned by `generate_webhook_secret`, becomes part of the agent's conversation. The [CLI webhooks commands](/cli-webhooks-commands) store the secret without printing it, and the MCP tool descriptions point agents that can run shell commands to them:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Store a secret the provider issued, from an env file or a pipe
|
|
30
|
+
npx trigger.dev@latest webhooks set-secret stripe --env prod --from-env STRIPE_WEBHOOK_SECRET
|
|
31
|
+
|
|
32
|
+
# Generate one and save it to .env.local for the agent to pass to the provider by name
|
|
33
|
+
npx trigger.dev@latest webhooks generate-secret github --env prod --to-env GITHUB_WEBHOOK_SECRET
|
|
34
|
+
```
|
|
35
|
+
|
|
24
36
|
Without the MCP server, the same operations are available on the REST API with the environment's secret key:
|
|
25
37
|
|
|
26
38
|
| Request | What it does |
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Webhooks public beta"
|
|
3
|
+
description: "Webhooks are available to every organization in the normal Trigger.dev release. Install the packages, see what may change before general availability, and send feedback."
|
|
4
|
+
sidebarTitle: "Public beta"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Webhooks are in public beta: every organization can use them, and they ship in the normal Trigger.dev release.** Endpoints you declare sync when you deploy or run `trigger dev`, and they show up on each environment's **Webhooks** page.
|
|
8
|
+
|
|
9
|
+
## What public beta means
|
|
10
|
+
|
|
11
|
+
- The API may still change before general availability. We announce changes in the [changelog](https://trigger.dev/changelog).
|
|
12
|
+
- Webhooks are open source, so they work self-hosted too. See [Self-hosting webhooks](/self-hosting/env/webapp#webhooks) to turn them on.
|
|
13
|
+
|
|
14
|
+
## Install the packages
|
|
15
|
+
|
|
16
|
+
Webhooks are in `@trigger.dev/sdk` 4.8.1 and later. Install the SDK and the CLI from `@latest`:
|
|
17
|
+
|
|
18
|
+
<CodeGroup>
|
|
19
|
+
|
|
20
|
+
```bash npm
|
|
21
|
+
npm i @trigger.dev/sdk@latest
|
|
22
|
+
npm i -D trigger.dev@latest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```bash pnpm
|
|
26
|
+
pnpm add @trigger.dev/sdk@latest
|
|
27
|
+
pnpm add -D trigger.dev@latest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash bun
|
|
31
|
+
bun add @trigger.dev/sdk@latest
|
|
32
|
+
bun add -D trigger.dev@latest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
</CodeGroup>
|
|
36
|
+
|
|
37
|
+
Add the connector packages if you're building Slack or Linear agents:
|
|
38
|
+
|
|
39
|
+
<CodeGroup>
|
|
40
|
+
|
|
41
|
+
```bash npm
|
|
42
|
+
npm i @trigger.dev/slack@latest @trigger.dev/linear@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```bash pnpm
|
|
46
|
+
pnpm add @trigger.dev/slack@latest @trigger.dev/linear@latest
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```bash bun
|
|
50
|
+
bun add @trigger.dev/slack@latest @trigger.dev/linear@latest
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
</CodeGroup>
|
|
54
|
+
|
|
55
|
+
The webhook tools in the [MCP server](/mcp-introduction) come with the CLI, so a current `trigger.dev` install has them.
|
|
56
|
+
|
|
57
|
+
## Moving from a private beta build
|
|
58
|
+
|
|
59
|
+
If you installed from the `webhooks` npm tag, switch every Trigger.dev package to `@latest`, including `@trigger.dev/build` if your project has it. Versions like `4.8.0-webhooks.20261020092920` are older than 4.8.1. You can also remove any minimum release age exemption you added for the beta builds, and reinstall the MCP server without `--tag webhooks`.
|
|
60
|
+
|
|
61
|
+
## Get started
|
|
62
|
+
|
|
63
|
+
- [Overview](/webhooks/overview): endpoints, sources, and what can subscribe.
|
|
64
|
+
- [Connect a provider](/webhooks/connect): register the URL and signing secret, then check that events arrive.
|
|
65
|
+
- [Slack agents](/webhooks/slack) and [Linear agents](/webhooks/linear): turn a `chat.agent` into an agent that lives in Slack or Linear.
|
|
66
|
+
- [Deliveries and endpoints](/webhooks/deliveries): inspect payloads, replay deliveries, and see the runs each one started.
|
|
67
|
+
|
|
68
|
+
## Feedback
|
|
69
|
+
|
|
70
|
+
Send bugs, questions and ideas to [eric@trigger.dev](mailto:eric@trigger.dev). Delivery ids (`whd_...`) and run ids help us find what happened.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
".": "./src/v3/index.ts",
|
|
32
32
|
"./v3": "./src/v3/index.ts",
|
|
33
33
|
"./ai": "./src/v3/ai.ts",
|
|
34
|
+
"./oidc/aws": "./src/v3/oidc/aws.ts",
|
|
35
|
+
"./oidc/infisical": "./src/v3/oidc/infisical.ts",
|
|
34
36
|
"./ai/skills-runtime": "./src/v3/agentSkillsRuntime.ts",
|
|
35
37
|
"./ai/test": "./src/v3/test/index.ts",
|
|
36
38
|
"./chat": "./src/v3/chat.ts",
|
|
@@ -49,6 +51,12 @@
|
|
|
49
51
|
"ai": [
|
|
50
52
|
"dist/commonjs/v3/ai.d.ts"
|
|
51
53
|
],
|
|
54
|
+
"oidc/aws": [
|
|
55
|
+
"dist/commonjs/v3/oidc/aws.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"oidc/infisical": [
|
|
58
|
+
"dist/commonjs/v3/oidc/infisical.d.ts"
|
|
59
|
+
],
|
|
52
60
|
"ai/skills-runtime": [
|
|
53
61
|
"dist/commonjs/v3/agentSkillsRuntime.d.ts"
|
|
54
62
|
],
|
|
@@ -69,12 +77,13 @@
|
|
|
69
77
|
"dependencies": {
|
|
70
78
|
"@opentelemetry/api": "1.9.1",
|
|
71
79
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
72
|
-
"@trigger.dev/core": "4.8.
|
|
80
|
+
"@trigger.dev/core": "4.8.4",
|
|
73
81
|
"uncrypto": "^0.1.3"
|
|
74
82
|
},
|
|
75
83
|
"devDependencies": {
|
|
76
84
|
"@ai-sdk/provider": "3.0.8",
|
|
77
85
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
86
|
+
"@aws-sdk/client-sts": "3.840.0",
|
|
78
87
|
"@opentelemetry/sdk-trace-base": "2.8.0",
|
|
79
88
|
"@types/react": "^19.2.14",
|
|
80
89
|
"ai": "^6.0.116",
|
|
@@ -87,12 +96,16 @@
|
|
|
87
96
|
"zod": "4.5.4"
|
|
88
97
|
},
|
|
89
98
|
"peerDependencies": {
|
|
99
|
+
"@aws-sdk/client-sts": "^3.840.0",
|
|
90
100
|
"@ai-sdk/otel": ">=1.0.0-0 <2",
|
|
91
101
|
"ai": "^5.0.0 || ^6.0.0 || >=7.0.0-canary <8",
|
|
92
102
|
"react": "^18.0 || ^19.0",
|
|
93
103
|
"zod": "^3.25.56 || ^4.0.0"
|
|
94
104
|
},
|
|
95
105
|
"peerDependenciesMeta": {
|
|
106
|
+
"@aws-sdk/client-sts": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
96
109
|
"@ai-sdk/otel": {
|
|
97
110
|
"optional": true
|
|
98
111
|
},
|
|
@@ -141,6 +154,28 @@
|
|
|
141
154
|
"default": "./dist/commonjs/v3/ai.js"
|
|
142
155
|
}
|
|
143
156
|
},
|
|
157
|
+
"./oidc/aws": {
|
|
158
|
+
"import": {
|
|
159
|
+
"@triggerdotdev/source": "./src/v3/oidc/aws.ts",
|
|
160
|
+
"types": "./dist/esm/v3/oidc/aws.d.ts",
|
|
161
|
+
"default": "./dist/esm/v3/oidc/aws.js"
|
|
162
|
+
},
|
|
163
|
+
"require": {
|
|
164
|
+
"types": "./dist/commonjs/v3/oidc/aws.d.ts",
|
|
165
|
+
"default": "./dist/commonjs/v3/oidc/aws.js"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"./oidc/infisical": {
|
|
169
|
+
"import": {
|
|
170
|
+
"@triggerdotdev/source": "./src/v3/oidc/infisical.ts",
|
|
171
|
+
"types": "./dist/esm/v3/oidc/infisical.d.ts",
|
|
172
|
+
"default": "./dist/esm/v3/oidc/infisical.js"
|
|
173
|
+
},
|
|
174
|
+
"require": {
|
|
175
|
+
"types": "./dist/commonjs/v3/oidc/infisical.d.ts",
|
|
176
|
+
"default": "./dist/commonjs/v3/oidc/infisical.js"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
144
179
|
"./ai/skills-runtime": {
|
|
145
180
|
"import": {
|
|
146
181
|
"@triggerdotdev/source": "./src/v3/agentSkillsRuntime.ts",
|