You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developers/actions/README.mdx
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,14 @@ The payload contains:
62
62
-`event`: The production authentication event. Its shape depends on the action type.
63
63
-`environmentVariables`: The string values configured for this action. These values are passed through the function payload; they are not available through `process.env`.
64
64
65
-
The editor provides type information, but the saved script is executed as JavaScript. The script may be asynchronous and can use the injected `fetch` function to call external HTTPS APIs. It cannot import packages or access Node.js globals such as `require` or `process`.
65
+
The editor provides type information, but the saved script is executed as JavaScript. The script may be asynchronous and can use these standard Web APIs in both Logto Cloud and self-hosted Logto:
66
+
67
+
-`fetch`, `Request`, `Response`, and `Headers`
68
+
- Web Crypto through `crypto` and `crypto.subtle`
69
+
-`TextEncoder` and `TextDecoder`
70
+
-`URL` and `URLSearchParams`
71
+
72
+
Scripts cannot import packages. Avoid Node.js-specific globals and modules because they are not portable between self-hosted Logto and Logto Cloud and are not part of the supported script contract.
66
73
67
74
The supported result is different for each action type; see the corresponding reference page before enabling an Action.
The `api.denyAccess()` function allows you to deny the token issuing process with a custom message. You may use this function to enforce additional access validation over the token issuing process.
259
259
260
+
## Runtime APIs \{#runtime-apis}
261
+
262
+
Custom access token scripts can use these standard Web APIs in both Logto Cloud and self-hosted Logto:
263
+
264
+
-`fetch`, `Request`, `Response`, and `Headers`
265
+
- Web Crypto through `crypto` and `crypto.subtle`
266
+
-`TextEncoder` and `TextDecoder`
267
+
-`URL` and `URLSearchParams`
268
+
269
+
For example, you can compute SHA-256 and HMAC-SHA-256 values with Web Crypto:
Scripts cannot import packages. Avoid Node.js-specific globals and modules because they are not portable between self-hosted Logto and Logto Cloud and are not part of the supported script contract.
293
+
260
294
## Step 3: Fetch external data \{#step-3-fetch-external-data}
261
295
262
-
You may use the node built-in`fetch` function to fetch external data in your script. The `fetch` function is a promise-based function that allows you to make HTTP requests to external APIs.
296
+
You may use the standard`fetch` function to fetch external data in your script. The `fetch` function is a promise-based function that allows you to make HTTP requests to external APIs.
0 commit comments