@pattform/api-kit 2.6.5 → 2.6.7

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.
@@ -46,5 +46,7 @@ export interface FormComponentArgs {
46
46
  brevoApiKey?: pulumi.Input<string>;
47
47
  turnstileSiteKey?: pulumi.Input<string>;
48
48
  turnstileSecret?: pulumi.Input<string>;
49
+ cloudflareApiToken?: pulumi.Input<string>;
50
+ cloudflareAccountId?: pulumi.Input<string>;
49
51
  reservedConcurrency?: number;
50
52
  }
@@ -15,7 +15,7 @@ const pattformHelper_1 = require("./pattformHelper");
15
15
  */
16
16
  class FormComponent extends pulumi.ComponentResource {
17
17
  constructor(name, args, opts) {
18
- var _a, _b;
18
+ var _a, _b, _c, _d;
19
19
  super("custom:pattform:FormComponent", name, args, opts);
20
20
  const awsConfig = new pulumi.Config("aws");
21
21
  const awsRegion = awsConfig.require("region");
@@ -37,10 +37,13 @@ class FormComponent extends pulumi.ComponentResource {
37
37
  sessionName: `pattform-form-${appName}-${env}`,
38
38
  },
39
39
  } : {})));
40
- // Turnstile widgets are account-level in Cloudflare (not zone-bound),
41
- // so they live in the Pattform Cloudflare account regardless of where
42
- // the client's domain is hosted. Pass turnstileSiteKey/turnstileSecret
43
- // to use a pre-existing widget instead.
40
+ // Turnstile widgets are account-level in Cloudflare (not zone-bound), so
41
+ // the widget can live in whichever account the caller points at — by
42
+ // default the one in `cloudflare:*` config (the same token AppComponent
43
+ // uses for DNS). When a client's DNS token and Turnstile token differ
44
+ // (per-client Cloudflare accounts, or narrowly scoped tokens), pass
45
+ // cloudflareApiToken/cloudflareAccountId to override just this widget.
46
+ // Pass turnstileSiteKey/turnstileSecret to reuse an existing widget.
44
47
  let turnstileSiteKey;
45
48
  let turnstileSecret;
46
49
  if (args.turnstileSiteKey && args.turnstileSecret) {
@@ -49,12 +52,13 @@ class FormComponent extends pulumi.ComponentResource {
49
52
  }
50
53
  else {
51
54
  const cloudFlareConfig = new pulumi.Config("cloudflare");
52
- const cloudFlareToken = cloudFlareConfig.getSecret("apiToken");
53
- const cloudFlareAccountId = cloudFlareConfig.get("accountId");
55
+ const cloudFlareToken = (_c = args.cloudflareApiToken) !== null && _c !== void 0 ? _c : cloudFlareConfig.getSecret("apiToken");
56
+ const cloudFlareAccountId = (_d = args.cloudflareAccountId) !== null && _d !== void 0 ? _d : cloudFlareConfig.get("accountId");
54
57
  if (!cloudFlareToken || !cloudFlareAccountId) {
55
- throw new Error(`${appName}: creating a Turnstile widget needs cloudflare:apiToken (with Turnstile edit ` +
56
- `permission) and cloudflare:accountId config. Alternatively pass an existing widget's ` +
57
- `turnstileSiteKey and turnstileSecret.`);
58
+ throw new Error(`${appName}: creating a Turnstile widget needs a Cloudflare token with Turnstile edit ` +
59
+ `permission and an account id — from cloudflare:apiToken + cloudflare:accountId config, ` +
60
+ `or the cloudflareApiToken/cloudflareAccountId args. Alternatively pass an existing ` +
61
+ `widget's turnstileSiteKey and turnstileSecret.`);
58
62
  }
59
63
  const cloudFlareProvider = new cloudflare.Provider(`pattform-form-cloudflare-${baseName}-${env}`, {
60
64
  apiToken: cloudFlareToken,
@@ -126,6 +130,22 @@ class FormComponent extends pulumi.ComponentResource {
126
130
  provider: awsProvider,
127
131
  parent: this,
128
132
  });
133
+ // Since October 2025, public NONE function URLs require BOTH
134
+ // lambda:InvokeFunctionUrl and lambda:InvokeFunction in the resource
135
+ // policy — with only the former, every invoke returns 403 Forbidden
136
+ // (AccessDeniedException) despite AuthType NONE. AWS's default policy
137
+ // scopes this with a lambda:InvokedViaFunctionUrl=true condition, which
138
+ // aws.lambda.Permission can't express; omitting it is safe here because
139
+ // anonymous callers can't reach the Invoke API and the handler validates
140
+ // every request (Turnstile + schema) regardless of invocation path.
141
+ const invokePermission = new aws.lambda.Permission(`${baseName}-invoke-public-${env}`, {
142
+ action: "lambda:InvokeFunction",
143
+ function: this.lambda.name,
144
+ principal: "*",
145
+ }, {
146
+ provider: awsProvider,
147
+ parent: this,
148
+ });
129
149
  // Preflight OPTIONS requests are answered by the Function URL itself;
130
150
  // only same-configured origins can read responses from the browser.
131
151
  // deleteBeforeReplace: a function may have only one URL config, so a
@@ -142,7 +162,7 @@ class FormComponent extends pulumi.ComponentResource {
142
162
  }, {
143
163
  provider: awsProvider,
144
164
  parent: this,
145
- dependsOn: [urlPermission],
165
+ dependsOn: [urlPermission, invokePermission],
146
166
  deleteBeforeReplace: true,
147
167
  });
148
168
  this.endpoint = this.functionUrl.functionUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pattform/api-kit",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "description": "Pulumi infra library for building and deploying an API",
5
5
  "author": "Pattform <contact@pattform.io>",
6
6
  "license": "SEE LICENSE IN LICENSE",