@trigger.dev/sdk 4.8.2 → 4.8.3
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/auth.d.ts +10 -1
- package/dist/commonjs/v3/auth.js +8 -0
- package/dist/commonjs/v3/auth.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 +22 -0
- package/dist/commonjs/v3/oidc/aws.js +43 -0
- package/dist/commonjs/v3/oidc/aws.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/auth.d.ts +10 -1
- package/dist/esm/v3/auth.js +8 -0
- package/dist/esm/v3/auth.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 +22 -0
- package/dist/esm/v3/oidc/aws.js +40 -0
- package/dist/esm/v3/oidc/aws.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/docs/ai-chat/frontend.mdx +1 -1
- package/docs/apikeys.mdx +5 -0
- package/docs/cli-login-commands.mdx +7 -1
- package/docs/cli-webhooks-commands.mdx +115 -0
- package/docs/config/config-file.mdx +2 -2
- package/docs/github-integration.mdx +21 -0
- package/docs/oidc.mdx +262 -0
- package/docs/webhooks/connect.mdx +12 -0
- package/package.json +22 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "CLI webhooks commands"
|
|
3
|
+
sidebarTitle: "webhooks"
|
|
4
|
+
description: "Set or generate the signing secret of a hosted webhook endpoint from your terminal, without printing it."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import CommonOptions from "/snippets/cli-options-common.mdx";
|
|
8
|
+
import ConfigFileOptions from "/snippets/cli-options-config-file.mdx";
|
|
9
|
+
import ProjectRefOptions from "/snippets/cli-options-project-ref.mdx";
|
|
10
|
+
|
|
11
|
+
**These commands store a [webhook endpoint's](/webhooks/overview) signing secret without printing it, so the value stays out of your terminal history, logs and AI agent transcripts.** `endpoint` is the endpoint's declared id (the `id` passed to `webhooks.endpoint.define`) or its `wh_` id.
|
|
12
|
+
|
|
13
|
+
## Replacing an existing secret
|
|
14
|
+
|
|
15
|
+
When the endpoint already has a secret, both commands ask how long the old one keeps working, with the same choices as the dashboard: stop immediately, 1 hour, 24 hours (the default) or 7 days. In a script or an AI agent, where there's no prompt, pass `--previous-secret-ttl` instead; the command refuses to replace the secret without it, so a rotation can't cut the provider off by accident:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx trigger.dev@latest webhooks set-secret stripe --env prod --from-env STRIPE_WEBHOOK_SECRET --previous-secret-ttl 24h
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## webhooks set-secret
|
|
22
|
+
|
|
23
|
+
Stores the signing secret or public key a provider issued, such as the `whsec_` secret Stripe returns when you create a webhook endpoint. It replaces the endpoint's current secret.
|
|
24
|
+
|
|
25
|
+
Pipe the secret in from the provider's CLI or a file:
|
|
26
|
+
|
|
27
|
+
<CodeGroup>
|
|
28
|
+
|
|
29
|
+
```bash npm
|
|
30
|
+
stripe webhook_endpoints create -d url="$WEBHOOK_URL" -d "enabled_events[]=checkout.session.completed" \
|
|
31
|
+
| jq -r .secret \
|
|
32
|
+
| npx trigger.dev@latest webhooks set-secret stripe --env prod
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```bash pnpm
|
|
36
|
+
stripe webhook_endpoints create -d url="$WEBHOOK_URL" -d "enabled_events[]=checkout.session.completed" \
|
|
37
|
+
| jq -r .secret \
|
|
38
|
+
| pnpm dlx trigger.dev@latest webhooks set-secret stripe --env prod
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```bash bun
|
|
42
|
+
stripe webhook_endpoints create -d url="$WEBHOOK_URL" -d "enabled_events[]=checkout.session.completed" \
|
|
43
|
+
| jq -r .secret \
|
|
44
|
+
| bunx trigger.dev@latest webhooks set-secret stripe --env prod
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
</CodeGroup>
|
|
48
|
+
|
|
49
|
+
Or read it from an environment variable. Without `--from-file`, the command checks the shell environment, then the project's `.env`, `.env.development`, `.env.local` and `.env.development.local` files:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx trigger.dev@latest webhooks set-secret stripe --env prod --from-env STRIPE_WEBHOOK_SECRET
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run it in a terminal without either option and it asks for the secret with a masked prompt.
|
|
56
|
+
|
|
57
|
+
<ParamField body="From env" type="--from-env">
|
|
58
|
+
Read the secret from this environment variable.
|
|
59
|
+
</ParamField>
|
|
60
|
+
|
|
61
|
+
<ParamField body="From file" type="--from-file">
|
|
62
|
+
With `--from-env`, read the variable from this `.env` file only.
|
|
63
|
+
</ParamField>
|
|
64
|
+
|
|
65
|
+
<ParamField body="Previous secret TTL" type="--previous-secret-ttl">
|
|
66
|
+
When the endpoint already has a secret, how long the old one keeps working while the provider switches to the new one: seconds (`3600`) or a duration (`1h`, `24h`, `7d`), at most 7 days. `0` stops it straight away, for a secret that leaked.
|
|
67
|
+
</ParamField>
|
|
68
|
+
|
|
69
|
+
## webhooks generate-secret
|
|
70
|
+
|
|
71
|
+
Generates a new signing secret, for providers that accept a secret you choose, such as GitHub. It replaces the endpoint's current secret.
|
|
72
|
+
|
|
73
|
+
Save it to an env file, then hand it to the provider by variable name:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx trigger.dev@latest webhooks generate-secret github --env prod --to-env GITHUB_WEBHOOK_SECRET
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The command writes `GITHUB_WEBHOOK_SECRET` to `.env.local`, creating the file if needed, and prints only where it saved the value. Or pipe it straight into the provider's CLI with `--print`, which outputs the secret and nothing else.
|
|
80
|
+
|
|
81
|
+
When the output isn't a terminal, the command refuses to print the secret unless you pass `--to-env` or `--print`, so an AI agent running it doesn't capture the value by accident.
|
|
82
|
+
|
|
83
|
+
<ParamField body="To env" type="--to-env">
|
|
84
|
+
Save the secret as this variable in an env file.
|
|
85
|
+
</ParamField>
|
|
86
|
+
|
|
87
|
+
<ParamField body="To file" type="--to-file">
|
|
88
|
+
With `--to-env`, the file to save to. Defaults to `.env.local`.
|
|
89
|
+
</ParamField>
|
|
90
|
+
|
|
91
|
+
<ParamField body="Print" type="--print">
|
|
92
|
+
Print only the secret, for piping it into another command.
|
|
93
|
+
</ParamField>
|
|
94
|
+
|
|
95
|
+
<ParamField body="Previous secret TTL" type="--previous-secret-ttl">
|
|
96
|
+
When the endpoint already has a secret, how long the old one keeps working while the provider switches to the new one: seconds (`3600`) or a duration (`1h`, `24h`, `7d`), at most 7 days. `0` stops it straight away, for a secret that leaked.
|
|
97
|
+
</ParamField>
|
|
98
|
+
|
|
99
|
+
## Options
|
|
100
|
+
|
|
101
|
+
<ParamField body="Environment" type="--env | -e">
|
|
102
|
+
The environment to use: `dev`, `prod`, `staging` or `preview`. Defaults to `prod`.
|
|
103
|
+
</ParamField>
|
|
104
|
+
|
|
105
|
+
<ConfigFileOptions />
|
|
106
|
+
<ProjectRefOptions />
|
|
107
|
+
<ParamField body="Branch" type="--branch | -b">
|
|
108
|
+
The branch to use. Required with `--env preview`.
|
|
109
|
+
</ParamField>
|
|
110
|
+
|
|
111
|
+
### Common options
|
|
112
|
+
|
|
113
|
+
These options are available on most commands.
|
|
114
|
+
|
|
115
|
+
<CommonOptions />
|
|
@@ -337,11 +337,11 @@ import { defineConfig } from "@trigger.dev/sdk";
|
|
|
337
337
|
export default defineConfig({
|
|
338
338
|
project: "<project ref>",
|
|
339
339
|
// Your other config settings...
|
|
340
|
-
runtime: "bun",
|
|
340
|
+
runtime: "bun-1.4",
|
|
341
341
|
});
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
`bun` runs on Bun 1.3 with a Node.js binary alongside it
|
|
344
|
+
`bun-1.4` runs on a Bun-only image with no Node.js binary. `bun` (Bun 1.3 with a Node.js binary alongside it) is deprecated, and deploys that use it will be rejected from January 5, 2027. See our [Bun guide](/guides/frameworks/bun) for the differences.
|
|
345
345
|
|
|
346
346
|
### Node.js versions
|
|
347
347
|
|
|
@@ -72,6 +72,27 @@ The name of the preview branch matches the branch name of the pull request.
|
|
|
72
72
|
Preview branch deployments require the preview environment to be enabled on your project. Learn more about [preview branches](/deployment/preview-branches).
|
|
73
73
|
</Note>
|
|
74
74
|
|
|
75
|
+
## Ignored paths
|
|
76
|
+
|
|
77
|
+
Skip builds for pushes that only touch files your tasks do not depend on, such as docs or another app in a monorepo.
|
|
78
|
+
|
|
79
|
+
Open **Integrations** in your project settings and add the patterns in the git settings panel below the branch fields, one per line. A push builds unless every file changed by the pushed commits matches a pattern. A newly opened pull request compares every file it changes against its base branch in the same way. Some pushes build regardless of the patterns, such as force pushes or pushes that change 300 or more files. Use **Test a path** to check which pattern, if any, ignores a given file.
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
docs/**
|
|
83
|
+
**/*.md
|
|
84
|
+
apps/web/**
|
|
85
|
+
.github/**
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Patterns are globs relative to the repository root and match like `paths-ignore` in GitHub Actions. `**` matches across folders and also matches dotfiles, so `**/*.md` ignores `.github/PULL_REQUEST_TEMPLATE.md`. Negation (`!`), braces (`{a,b}`), extglob groups like `+(...)` and `[!...]` are not supported; use `[^...]` to exclude characters. You can add up to 100 patterns of up to 256 characters each.
|
|
89
|
+
|
|
90
|
+
When a build is skipped, no deployment is created and the commit's Trigger.dev check is marked as skipped, with the matched patterns in its summary. Re-run that check from GitHub to build the commit anyway.
|
|
91
|
+
|
|
92
|
+
<Note>
|
|
93
|
+
Projects connected to Vercel always build. See [production waits for your tasks](/vercel-integration#production-waits-for-your-tasks).
|
|
94
|
+
</Note>
|
|
95
|
+
|
|
75
96
|
## Version skew protection
|
|
76
97
|
|
|
77
98
|
Every deployment the GitHub integration creates is tagged with the commit SHA it was built from. That is the deploy half of [version skew protection](/deployment/atomic-deployment) — you get it for free.
|
package/docs/oidc.mdx
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "OpenID Connect (OIDC)"
|
|
3
|
+
description: "Access AWS and other services from deployed tasks using short-lived credentials instead of stored cloud keys."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<Note>
|
|
7
|
+
OIDC is in private beta on Trigger.dev Cloud. [Contact us](https://trigger.dev/contact) to request
|
|
8
|
+
access.
|
|
9
|
+
</Note>
|
|
10
|
+
|
|
11
|
+
OIDC lets a deployed task on Trigger.dev Cloud prove its identity to an external service without storing a long-lived cloud key. Trigger.dev issues a short-lived identity token. The service validates that token and grants only the permissions you configured for that identity.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Use `@trigger.dev/sdk` and the Trigger.dev CLI (`trigger.dev`) **4.8.3 or later**, including the CLI used by your CI or deployment integration.
|
|
16
|
+
- **Redeploy after upgrading the CLI**, then start a new run on the new deployment. Updating the SDK alone does not update the runner in an existing deployment. Replaying a run against an old deployment does not upgrade it.
|
|
17
|
+
- Request tokens inside the executing task attempt, in Production, Staging, or a Preview environment. Development runs do not receive internal run tokens.
|
|
18
|
+
|
|
19
|
+
## Set up AWS
|
|
20
|
+
|
|
21
|
+
<Steps>
|
|
22
|
+
<Step title="Select your deployed environment">
|
|
23
|
+
Open your project in the dashboard, select the Production, Staging, or Preview environment that
|
|
24
|
+
needs AWS access, then open [**OIDC**](https://cloud.trigger.dev/_/oidc) in the environment menu. Configure each environment separately.
|
|
25
|
+
</Step>
|
|
26
|
+
<Step title="Create an IAM OIDC identity provider">
|
|
27
|
+
In the AWS IAM console, open **Identity providers → Add provider → OpenID Connect**. Paste the
|
|
28
|
+
**Issuer URL** from the dashboard into **Provider URL** and use `sts.amazonaws.com` as the
|
|
29
|
+
**Audience**. You only need one provider per issuer in an AWS account; reuse it if it already exists.
|
|
30
|
+
|
|
31
|
+
Alternatively, use the AWS CLI with the exact issuer URL from the dashboard:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
aws iam create-open-id-connect-provider \
|
|
35
|
+
--url "https://oidc.trigger.dev" \
|
|
36
|
+
--client-id-list sts.amazonaws.com
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For Terraform-managed infrastructure, see [Terraform setup](#terraform-setup) below.
|
|
40
|
+
</Step>
|
|
41
|
+
<Step title="Create an IAM role with the exact trust policy">
|
|
42
|
+
Enter your AWS account ID in the dashboard setup page, then copy its trust policy into an IAM
|
|
43
|
+
role's **Trust relationships**. The policy allows `sts:AssumeRoleWithWebIdentity` only when both
|
|
44
|
+
the audience and the complete environment subject match.
|
|
45
|
+
|
|
46
|
+
Exact matching is the default. Keep the organization ID, project reference, environment type,
|
|
47
|
+
and audience fixed. To share a role across all Preview branches in one project, keep the
|
|
48
|
+
audience under `StringEquals` and use `StringLike` for only the subject. Replace the trust
|
|
49
|
+
policy's `Condition` with:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"StringEquals": {
|
|
54
|
+
"oidc.trigger.dev:aud": "sts.amazonaws.com"
|
|
55
|
+
},
|
|
56
|
+
"StringLike": {
|
|
57
|
+
"oidc.trigger.dev:sub": "org:YOUR_ORG_ID:project:YOUR_PROJECT_REF:env:PREVIEW:*"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Replace the organization ID and project reference with the exact values from your dashboard
|
|
63
|
+
subject. This deliberately trusts all
|
|
64
|
+
current and future Preview branches in that project, including anyone allowed to deploy them.
|
|
65
|
+
Never wildcard the organization or project portions. Keep `PREVIEW` fixed so the role does not
|
|
66
|
+
also trust Production or Staging.
|
|
67
|
+
|
|
68
|
+
For a single Preview branch, use its persisted environment slug, not the parent environment's
|
|
69
|
+
identity or a branch display name. No session tags or `sts:TagSession` permission are required.
|
|
70
|
+
</Step>
|
|
71
|
+
<Step title="Attach a least-privilege permissions policy">
|
|
72
|
+
The trust policy controls who can assume the role. Attach a separate permissions policy that
|
|
73
|
+
controls what the role can do. For example, to read objects under one S3 prefix:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"Version": "2012-10-17",
|
|
78
|
+
"Statement": [
|
|
79
|
+
{
|
|
80
|
+
"Effect": "Allow",
|
|
81
|
+
"Action": "s3:GetObject",
|
|
82
|
+
"Resource": "arn:aws:s3:::YOUR_BUCKET/trigger/*"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
</Step>
|
|
88
|
+
<Step title="Install the SDK and AWS dependencies">
|
|
89
|
+
```bash
|
|
90
|
+
npm install @trigger.dev/sdk@latest @aws-sdk/client-sts @aws-sdk/client-s3
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`@aws-sdk/client-sts` is an optional peer dependency of the Trigger.dev SDK. Install it explicitly
|
|
94
|
+
when using the AWS credential provider. Install the AWS service clients your task uses as well.
|
|
95
|
+
</Step>
|
|
96
|
+
<Step title="Use the credential provider and redeploy">
|
|
97
|
+
Replace the role ARN, AWS region, bucket, and object key below, or copy the personalized code
|
|
98
|
+
from the dashboard:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { task } from "@trigger.dev/sdk";
|
|
102
|
+
import { awsCredentialProvider } from "@trigger.dev/sdk/oidc/aws";
|
|
103
|
+
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
104
|
+
|
|
105
|
+
export const readFromS3 = task({
|
|
106
|
+
id: "read-from-s3",
|
|
107
|
+
run: async () => {
|
|
108
|
+
const s3 = new S3Client({
|
|
109
|
+
region: "us-east-1",
|
|
110
|
+
credentials: awsCredentialProvider({
|
|
111
|
+
roleArn: "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/YOUR_ROLE_NAME",
|
|
112
|
+
region: "us-east-1",
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const result = await s3.send(
|
|
117
|
+
new GetObjectCommand({ Bucket: "YOUR_BUCKET", Key: "trigger/example.txt" })
|
|
118
|
+
);
|
|
119
|
+
return { contents: await result.Body?.transformToString() };
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npx trigger.dev@latest deploy
|
|
126
|
+
```
|
|
127
|
+
</Step>
|
|
128
|
+
</Steps>
|
|
129
|
+
|
|
130
|
+
<Warning>
|
|
131
|
+
Create the AWS client inside `run` and reuse it only within that run. A module-scope client can
|
|
132
|
+
reuse a previous run's cached credentials and attribute AWS activity to that run.
|
|
133
|
+
</Warning>
|
|
134
|
+
|
|
135
|
+
The provider requires `roleArn` and `region`, and accepts optional `roleSessionName` and `durationSeconds`. The AWS service client's region does not configure the separate STS client. AWS sessions default to 3,600 seconds (one hour), subject to the role's allowed session duration. The default role session name is the current run ID, sanitized to AWS's allowed characters and limited to 64 characters, so AWS activity can be attributed to a run. A role session name is not a session tag.
|
|
136
|
+
|
|
137
|
+
## Terraform setup
|
|
138
|
+
|
|
139
|
+
Use these resources instead of creating the provider and role through the console. Copy the exact
|
|
140
|
+
issuer URL and subject from the environment's OIDC page into the input variables. This example uses
|
|
141
|
+
exact subject matching; attach a least-privilege permissions policy to the role separately, as in
|
|
142
|
+
the setup steps above.
|
|
143
|
+
|
|
144
|
+
```hcl
|
|
145
|
+
terraform {
|
|
146
|
+
required_providers {
|
|
147
|
+
aws = {
|
|
148
|
+
source = "hashicorp/aws"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
provider "aws" {
|
|
154
|
+
region = "us-east-1"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
variable "trigger_oidc_issuer" {
|
|
158
|
+
type = string
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
variable "trigger_oidc_subject" {
|
|
162
|
+
type = string
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
locals {
|
|
166
|
+
issuer_host = trimsuffix(trimprefix(var.trigger_oidc_issuer, "https://"), "/")
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
resource "aws_iam_openid_connect_provider" "trigger" {
|
|
170
|
+
url = var.trigger_oidc_issuer
|
|
171
|
+
client_id_list = ["sts.amazonaws.com"]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
resource "aws_iam_role" "trigger" {
|
|
175
|
+
name = "trigger-s3-reader"
|
|
176
|
+
|
|
177
|
+
assume_role_policy = jsonencode({
|
|
178
|
+
Version = "2012-10-17"
|
|
179
|
+
Statement = [{
|
|
180
|
+
Effect = "Allow"
|
|
181
|
+
Action = "sts:AssumeRoleWithWebIdentity"
|
|
182
|
+
Principal = {
|
|
183
|
+
Federated = aws_iam_openid_connect_provider.trigger.arn
|
|
184
|
+
}
|
|
185
|
+
Condition = {
|
|
186
|
+
StringEquals = {
|
|
187
|
+
"${local.issuer_host}:aud" = "sts.amazonaws.com"
|
|
188
|
+
"${local.issuer_host}:sub" = var.trigger_oidc_subject
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}]
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If the IAM provider already exists, import it into Terraform state rather than creating a duplicate:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
terraform import aws_iam_openid_connect_provider.trigger \
|
|
200
|
+
arn:aws:iam::YOUR_AWS_ACCOUNT_ID:oidc-provider/oidc.trigger.dev
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Other OIDC integrations
|
|
204
|
+
|
|
205
|
+
<Note>
|
|
206
|
+
More first-party OIDC integrations will be added soon.
|
|
207
|
+
</Note>
|
|
208
|
+
|
|
209
|
+
For a service that accepts OIDC, request a token with that service's expected audience inside your task:
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { auth, task } from "@trigger.dev/sdk";
|
|
213
|
+
|
|
214
|
+
export const federatedTask = task({
|
|
215
|
+
id: "federated-task",
|
|
216
|
+
run: async () => {
|
|
217
|
+
const { token } = await auth.getOIDCToken({ audience: "https://service.example.com" });
|
|
218
|
+
// Exchange this token using your service's federation API. Never log the token.
|
|
219
|
+
const response = await fetch("https://service.example.com/federated-resource", {
|
|
220
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
221
|
+
});
|
|
222
|
+
if (!response.ok) throw new Error(`Service request failed: ${response.status}`);
|
|
223
|
+
return response.json();
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
`auth.getOIDCToken({ audience })` returns `Promise<{ token: string; expiresAt: Date }>`. If you cache tokens, leave enough time before `expiresAt` to complete the exchange. Configure the external service to validate the issuer's signature, audience, expiry, and exact environment subject. Do not use an OIDC token to call Trigger.dev APIs.
|
|
229
|
+
|
|
230
|
+
Token-request failures throw `OIDCTokenError`, exported from `@trigger.dev/sdk`, for both local validation and API errors. It extends `ApiError` and preserves the error code, message, HTTP status and headers; API failures retain the original error as `cause`.
|
|
231
|
+
|
|
232
|
+
## Local development
|
|
233
|
+
|
|
234
|
+
`trigger dev` does not receive internal run tokens and cannot mint external OIDC tokens. Use your own development credentials, such as an AWS SSO profile. If the same task needs to work locally and deployed, explicitly choose local credentials for Development:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import { task } from "@trigger.dev/sdk";
|
|
238
|
+
import { awsCredentialProvider } from "@trigger.dev/sdk/oidc/aws";
|
|
239
|
+
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
240
|
+
|
|
241
|
+
export const readFromS3 = task({
|
|
242
|
+
id: "read-from-s3",
|
|
243
|
+
run: async (_, { ctx }) => {
|
|
244
|
+
const s3 = new S3Client({
|
|
245
|
+
region: "us-east-1",
|
|
246
|
+
credentials:
|
|
247
|
+
ctx.environment.type === "DEVELOPMENT"
|
|
248
|
+
? undefined // Use your own local AWS credential chain, for example AWS_PROFILE.
|
|
249
|
+
: awsCredentialProvider({
|
|
250
|
+
roleArn: "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/YOUR_ROLE_NAME",
|
|
251
|
+
region: "us-east-1",
|
|
252
|
+
}),
|
|
253
|
+
});
|
|
254
|
+
const result = await s3.send(
|
|
255
|
+
new GetObjectCommand({ Bucket: "YOUR_BUCKET", Key: "trigger/example.txt" })
|
|
256
|
+
);
|
|
257
|
+
return { contents: await result.Body?.transformToString() };
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Authenticate locally with your AWS tooling before running the task. Do not catch OIDC errors and fall back to static credentials in deployed environments.
|
|
@@ -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 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.3",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,6 +31,7 @@
|
|
|
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",
|
|
34
35
|
"./ai/skills-runtime": "./src/v3/agentSkillsRuntime.ts",
|
|
35
36
|
"./ai/test": "./src/v3/test/index.ts",
|
|
36
37
|
"./chat": "./src/v3/chat.ts",
|
|
@@ -49,6 +50,9 @@
|
|
|
49
50
|
"ai": [
|
|
50
51
|
"dist/commonjs/v3/ai.d.ts"
|
|
51
52
|
],
|
|
53
|
+
"oidc/aws": [
|
|
54
|
+
"dist/commonjs/v3/oidc/aws.d.ts"
|
|
55
|
+
],
|
|
52
56
|
"ai/skills-runtime": [
|
|
53
57
|
"dist/commonjs/v3/agentSkillsRuntime.d.ts"
|
|
54
58
|
],
|
|
@@ -69,12 +73,13 @@
|
|
|
69
73
|
"dependencies": {
|
|
70
74
|
"@opentelemetry/api": "1.9.1",
|
|
71
75
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
72
|
-
"@trigger.dev/core": "4.8.
|
|
76
|
+
"@trigger.dev/core": "4.8.3",
|
|
73
77
|
"uncrypto": "^0.1.3"
|
|
74
78
|
},
|
|
75
79
|
"devDependencies": {
|
|
76
80
|
"@ai-sdk/provider": "3.0.8",
|
|
77
81
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
82
|
+
"@aws-sdk/client-sts": "3.840.0",
|
|
78
83
|
"@opentelemetry/sdk-trace-base": "2.8.0",
|
|
79
84
|
"@types/react": "^19.2.14",
|
|
80
85
|
"ai": "^6.0.116",
|
|
@@ -87,12 +92,16 @@
|
|
|
87
92
|
"zod": "4.5.4"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
95
|
+
"@aws-sdk/client-sts": "^3.840.0",
|
|
90
96
|
"@ai-sdk/otel": ">=1.0.0-0 <2",
|
|
91
97
|
"ai": "^5.0.0 || ^6.0.0 || >=7.0.0-canary <8",
|
|
92
98
|
"react": "^18.0 || ^19.0",
|
|
93
99
|
"zod": "^3.25.56 || ^4.0.0"
|
|
94
100
|
},
|
|
95
101
|
"peerDependenciesMeta": {
|
|
102
|
+
"@aws-sdk/client-sts": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
96
105
|
"@ai-sdk/otel": {
|
|
97
106
|
"optional": true
|
|
98
107
|
},
|
|
@@ -141,6 +150,17 @@
|
|
|
141
150
|
"default": "./dist/commonjs/v3/ai.js"
|
|
142
151
|
}
|
|
143
152
|
},
|
|
153
|
+
"./oidc/aws": {
|
|
154
|
+
"import": {
|
|
155
|
+
"@triggerdotdev/source": "./src/v3/oidc/aws.ts",
|
|
156
|
+
"types": "./dist/esm/v3/oidc/aws.d.ts",
|
|
157
|
+
"default": "./dist/esm/v3/oidc/aws.js"
|
|
158
|
+
},
|
|
159
|
+
"require": {
|
|
160
|
+
"types": "./dist/commonjs/v3/oidc/aws.d.ts",
|
|
161
|
+
"default": "./dist/commonjs/v3/oidc/aws.js"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
144
164
|
"./ai/skills-runtime": {
|
|
145
165
|
"import": {
|
|
146
166
|
"@triggerdotdev/source": "./src/v3/agentSkillsRuntime.ts",
|