Skip to content

Commit 95ff13b

Browse files
chore(main): release 3.15.0 (#793)
1 parent 7d2b7b7 commit 95ff13b

File tree

698 files changed

+25510
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

698 files changed

+25510
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 3.15.0 (2024-06-03)
4+
5+
### Added
6+
7+
* dynamic backends clientCertificate with SecretStore fromBytes, rawbytes ([#796](https://github.com/fastly/js-compute-runtime/issues/796)) ([7d2b7b7](https://github.com/fastly/js-compute-runtime/commit/7d2b7b781ed808d9bcf1fe9584aa31f788b980a2))
8+
* support default timeout configurations for dynamic backends ([#792](https://github.com/fastly/js-compute-runtime/issues/792)) ([4dfa8d7](https://github.com/fastly/js-compute-runtime/commit/4dfa8d76aeb4364ed5267ed22de0b9a891781589))
9+
310
## 3.14.2 (2024-05-21)
411

512
### Fixed

documentation/docs/fastly:backend/Backend/Backend.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ new Backend(backendConfiguration)
9191
- `sniHostname` _: string_ _**optional**_
9292
- The SNI hostname to use on connections to this backend.
9393
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
94+
- `clientCertificate` _: object_ _**optional**_
95+
- The client certificate to provide for the TLS handshake
96+
- `certificate` _: string_
97+
- The PEM certificate string.
98+
- `key` _: SecretStoreEntry_
99+
- The `SecretStoreEntry` to use for the key, created via [`SecretStore.prototype.get`](../../fastly:secret-store/SecretStore/prototype/get.mdx) or alteratively via [`SecretStore.fromBytes`](../../fastly:secret-store/SecretStore/fromBytes.mdx).
94100

95101
### Return value
96102

documentation/docs/fastly:experimental/allowDynamicBackends.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,30 @@ By default, Dynamic Backends are disabled within a JavaScript application as it
1717
## Syntax
1818

1919
```js
20-
allowDynamicBackends(enabled)
20+
allowDynamicBackends(enabledOrConfig)
2121
```
2222

2323
### Parameters
2424

25-
- `enabled` _: boolean_
25+
- `enabledOrConfig` _: boolean_
2626
- Whether or not to allow Dynamic Backends
2727

28+
or
29+
30+
- `enabledOrConfig` _: object_
31+
- `connectTimeout` _: number_ _**optional**_
32+
- Maximum duration in milliseconds to wait for a connection to this backend to be established.
33+
- If exceeded, the connection is aborted and a 503 response will be presented instead.
34+
- Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
35+
- `firstByteTimeout` _: number_ _**optional**_
36+
- Maximum duration in milliseconds to wait for the server response to begin after a TCP connection is established and the request has been sent.
37+
- If exceeded, the connection is aborted and a 503 response will be presented instead.
38+
- Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
39+
- `betweenBytesTimeout` _: number_ _**optional**_
40+
- Maximum duration in milliseconds that Fastly will wait while receiving no data on a download from a backend.
41+
- If exceeded, the response received so far will be considered complete and the fetch will end.
42+
- Throws a [`RangeError`](../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
43+
2844
### Return value
2945

3046
`undefined`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
# fromBytes
8+
9+
The **`fromBytes()`** function is used to create an in-memory secret from an array buffer.
10+
11+
>**Note**: This API should be avoided when possible, by instead using [SecretStore.prototype.get](./prototype/get.mdx) to obtain secure secrets.
12+
13+
## Syntax
14+
15+
```js
16+
fromBytes(new Uint8Array([1, 2, 3]))
17+
```
18+
19+
### Parameters
20+
21+
None.
22+
23+
### Return value
24+
25+
Returns a `SecretStoreEntry`.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
# SecretStoreEntry.prototype.rawBytes
8+
9+
**rawBytes**(): `ArrayBuffer`
10+
11+
Returns the raw byte contents of the SecretStoreEntry instance as an ArrayBuffer.
12+
13+
## Syntax
14+
15+
```js
16+
rawBytes()
17+
```
18+
19+
### Parameters
20+
21+
None.
22+
23+
### Return value
24+
25+
An ArrayBuffer
26+
27+
### Exceptions
28+
29+
The `rawBytes()` method requires its `this` value to be a `SecretStoreEntry` object.
30+
If the `this` value does not inherit from `SecretStoreEntry.prototype`, a [`TypeError`](../../../globals/TypeError/TypeError.mdx) is thrown.
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
import {Fiddle} from '@site/src/components/fiddle';
8+
9+
# `Backend()`
10+
11+
The **`Backend` constructor** lets you dynamically create new [Fastly Backends](https://developer.fastly.com/reference/api/services/backend/) for your Fastly Compute service.
12+
13+
Dynamically creating new [Fastly Backends](https://developer.fastly.com/reference/api/services/backend/) is disabled by default for Fastly Services. Please contact [Fastly Support](https://support.fastly.com/hc/requests/new?ticket_form_id=360000269711) to request the feature be enabled on the Fastly Services which require Dynamic Backends.
14+
15+
By default, Dynamic Backends are disabled within a JavaScript application as it can be a potential avenue for third-party JavaScript code to send requests, potentially including sensitive/secret data, off to destinations that the JavaScript project was not intending, which could be a security issue.
16+
17+
To enable Dynamic Backends the application will need to explicitly allow Dynamic Backends via:
18+
19+
```js
20+
import { allowDynamicBackends } from "fastly:experimental";
21+
allowDynamicBackends(true);
22+
```
23+
24+
**Note**: Backend constructors can only be used when processing requests, not during build-time initialization.
25+
26+
## Syntax
27+
28+
```js
29+
new Backend(backendConfiguration)
30+
```
31+
32+
> **Note:** `Backend()` can only be constructed with `new`. Attempting to call it without `new` throws a [`TypeError`](../../globals/TypeError/TypeError.mdx).
33+
34+
### Parameters
35+
36+
- `backendConfiguration`
37+
38+
- : An Object which contains all the configuration options to apply to the newly created Backend.
39+
40+
- `name` _: string_
41+
- The name of the backend.
42+
- The name has to be between 1 and 254 characters inclusive.
43+
- The name can be whatever you would like, as long as it does not match the name of any of the static service backends nor match any other dynamic backends built during a single execution of the application.
44+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is not valid. I.E. The value is null, undefined, an empty string or a string with more than 254 characters.
45+
- `target` _: string_
46+
- A hostname, IPv4, or IPv6 address for the backend as well as an optional port.
47+
- The target has to be at-least 1 character.
48+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is not valid. I.E. Is null, undefined, an empty string, not a valid IP address or host, or is the string `::`
49+
- `hostOverride` _: string_ _**optional**_
50+
- If set, will force the HTTP Host header on connections to this backend to be the supplied value.
51+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
52+
- `connectTimeout` _: number_ _**optional**_
53+
- Maximum duration in milliseconds to wait for a connection to this backend to be established.
54+
- If exceeded, the connection is aborted and a 503 response will be presented instead.
55+
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
56+
- `firstByteTimeout` _: number_ _**optional**_
57+
- Maximum duration in milliseconds to wait for the server response to begin after a TCP connection is established and the request has been sent.
58+
- If exceeded, the connection is aborted and a 503 response will be presented instead.
59+
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
60+
- `betweenBytesTimeout` _: number_ _**optional**_
61+
- Maximum duration in milliseconds that Fastly will wait while receiving no data on a download from a backend.
62+
- If exceeded, the response received so far will be considered complete and the fetch will end.
63+
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is negative or greater than or equal to 2^32
64+
- `useSSL` _: boolean_ _**optional**_
65+
- Whether or not to require TLS for connections to this backend.
66+
- `dontPool` _: boolean_ _**optional**_
67+
- Determine whether or not connections to the same backend should be pooled across different sessions.
68+
- Fastly considers two backends “the same” if they're registered with the same name and the exact same settings.
69+
- In those cases, when pooling is enabled, if Session 1 opens a connection to this backend it will be left open, and can be re-used by Session 2.
70+
- This can help improve backend latency, by removing the need for the initial network / TLS handshake(s).
71+
- By default, pooling is enabled for dynamic backends.
72+
- `tlsMinVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
73+
- Minimum allowed TLS version on SSL connections to this backend.
74+
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
75+
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
76+
- `tlsMaxVersion` _: 1 | 1.1 | 1.2 | 1.3_ _**optional**_
77+
- Maximum allowed TLS version on SSL connections to this backend.
78+
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
79+
- Throws a [`RangeError`](../../globals/RangeError/RangeError.mdx) if the value is not 1, 1.1, 1.2, or 1.3
80+
- `certificateHostname` _: string_ _**optional**_
81+
- Define the hostname that the server certificate should declare.
82+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
83+
- `caCertificate` _: string_ _**optional**_
84+
- The CA certificate to use when checking the validity of the backend.
85+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
86+
- `ciphers` _: string_ _**optional**_
87+
- List of OpenSSL ciphers to support for connections to this origin.
88+
- If the backend server is not able to negotiate a connection meeting this constraint, a 503 response will be presented instead.
89+
- [List of ciphers supported by Fastly](https://developer.fastly.com/learning/concepts/routing-traffic-to-fastly/#use-a-tls-configuration).
90+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
91+
- `sniHostname` _: string_ _**optional**_
92+
- The SNI hostname to use on connections to this backend.
93+
- Throws a [`TypeError`](../../globals/TypeError/TypeError.mdx) if the value is an empty string.
94+
- `clientCertificate` _: object_ _**optional**_
95+
- The client certificate to provide for the TLS handshake
96+
- `certificate` _: string_
97+
- The PEM certificate string.
98+
- `key` _: SecretStoreEntry_
99+
- The `SecretStoreEntry` to use for the key, created via [`SecretStore.prototype.get`](../../fastly:secret-store/SecretStore/prototype/get.mdx) or alteratively via [`SecretStore.fromBytes`](../../fastly:secret-store/SecretStore/fromBytes.mdx).
100+
101+
### Return value
102+
103+
A new `Backend` object.
104+
105+
## Examples
106+
107+
In this example an implicit Dynamic Backend is created when making the fetch request to <https://www.fastly.com/> and the response is then returned to the client.
108+
<Fiddle config={{
109+
"type": "javascript",
110+
"title": "Implicit Dynamic Backend Example",
111+
"origins": [
112+
"https://http-me.glitch.me"
113+
],
114+
"src": {
115+
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}",
116+
"main": `
117+
/// <reference types="@fastly/js-compute" />
118+
import { allowDynamicBackends } from "fastly:experimental";
119+
allowDynamicBackends(true);
120+
async function app() {
121+
// For any request, return the fastly homepage -- without defining a backend!
122+
return fetch('https://www.fastly.com/');
123+
}
124+
addEventListener("fetch", event => event.respondWith(app(event)));
125+
`
126+
},
127+
"requests": [
128+
{
129+
"enableCluster": true,
130+
"enableShield": false,
131+
"enableWAF": false,
132+
"method": "GET",
133+
"path": "/status=200",
134+
"useFreshCache": false,
135+
"followRedirects": false,
136+
"tests": "",
137+
"delay": 0
138+
}
139+
],
140+
"srcVersion": 1
141+
}}>
142+
143+
```js
144+
/// <reference types="@fastly/js-compute" />
145+
import { allowDynamicBackends } from "fastly:experimental";
146+
allowDynamicBackends(true);
147+
async function app() {
148+
// For any request, return the fastly homepage -- without defining a backend!
149+
return fetch('https://www.fastly.com/');
150+
}
151+
addEventListener("fetch", event => event.respondWith(app(event)));
152+
```
153+
154+
</Fiddle>
155+
156+
In this example an explicit Dynamic Backend is created and supplied to the fetch request, the response is then returned to the client.
157+
158+
159+
<Fiddle config={{
160+
"type": "javascript",
161+
"title": "Explicit Dynamic Backend Example",
162+
"origins": [
163+
"https://http-me.glitch.me"
164+
],
165+
"src": {
166+
"deps": "{\n \"@fastly/js-compute\": \"^1.0.1\"\n}",
167+
"main": `
168+
/// <reference types="@fastly/js-compute" />
169+
import { allowDynamicBackends } from "fastly:experimental";
170+
import { Backend } from "fastly:backend";
171+
allowDynamicBackends(true);
172+
async function app() {
173+
// For any request, return the fastly homepage -- without defining a backend!
174+
const backend = new Backend({
175+
name: 'fastly',
176+
target: 'fastly.com',
177+
hostOverride: "www.fastly.com",
178+
connectTimeout: 1000,
179+
firstByteTimeout: 15000,
180+
betweenBytesTimeout: 10000,
181+
useSSL: true,
182+
sslMinVersion: 1.3,
183+
sslMaxVersion: 1.3,
184+
});
185+
return fetch('https://www.fastly.com/', {
186+
backend // Here we are configuring this request to use the backend from above.
187+
});
188+
}
189+
addEventListener("fetch", event => event.respondWith(app(event)));
190+
`
191+
},
192+
"requests": [
193+
{
194+
"enableCluster": true,
195+
"enableShield": false,
196+
"enableWAF": false,
197+
"method": "GET",
198+
"path": "/status=200",
199+
"useFreshCache": false,
200+
"followRedirects": false,
201+
"tests": "",
202+
"delay": 0
203+
}
204+
],
205+
"srcVersion": 1
206+
}}>
207+
208+
```js
209+
/// <reference types="@fastly/js-compute" />
210+
import { allowDynamicBackends } from "fastly:experimental";
211+
import { Backend } from "fastly:backend";
212+
allowDynamicBackends(true);
213+
async function app() {
214+
// For any request, return the fastly homepage -- without defining a backend!
215+
const backend = new Backend({
216+
name: 'fastly',
217+
target: 'fastly.com',
218+
hostOverride: "www.fastly.com",
219+
connectTimeout: 1000,
220+
firstByteTimeout: 15000,
221+
betweenBytesTimeout: 10000,
222+
useSSL: true,
223+
sslMinVersion: 1.3,
224+
sslMaxVersion: 1.3,
225+
});
226+
return fetch('https://www.fastly.com/', {
227+
backend // Here we are configuring this request to use the backend from above.
228+
});
229+
}
230+
addEventListener("fetch", event => event.respondWith(app(event)));
231+
```
232+
233+
</Fiddle>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# Backend.exists()
9+
10+
The **`Backend.exists()`** method returns a boolean indicating if a Backend with the given name exists or not.
11+
12+
## Syntax
13+
14+
```js
15+
exists(name)
16+
```
17+
18+
### Return value
19+
20+
A boolean indicating if a Backend with the given name exists or not.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# Backend.fromName()
9+
10+
Returns the `Backend` instance with the given name, if one exists. If one does not exist, an error is thrown.
11+
12+
## Syntax
13+
14+
```js
15+
fromName(name)
16+
```
17+
18+
### Return value
19+
20+
A `Backend` instance.

0 commit comments

Comments
 (0)