@gcoredev/proxy-wasm-sdk-as 1.2.2 → 1.2.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.
@@ -3,11 +3,36 @@ import * as imports from "../imports";
3
3
  import { globalArrayBufferReference, WasmResultValues } from "../runtime";
4
4
 
5
5
  /**
6
- * Function to get the value for the provided environment variable name.
6
+ * Reads an environment variable by name using the WASI environment interface.
7
+ *
8
+ * Use this for normal-sized environment variables (under 64 KB). For values
9
+ * that may exceed the WASI 64 KB limit, use {@link getDictionary} instead.
10
+ *
7
11
  * @param {string} name - The name of the environment variable.
8
- * @returns {string} The value of the environment variable.
12
+ * @returns {string} The value, or an empty string if not found.
9
13
  */
10
14
  function getEnv(name: string): string {
15
+ const hasKey = process.env.has(name);
16
+ if (hasKey) {
17
+ return process.env.get(name);
18
+ }
19
+ return "";
20
+ }
21
+
22
+ /**
23
+ * Reads a dictionary value by name using the proxy-wasm dictionary API
24
+ * (`proxy_dictionary_get`).
25
+ *
26
+ * This bypasses the WASI 64 KB environment variable size limit and should
27
+ * be used when a value may be larger than 64 KB (e.g. large JSON configs,
28
+ * PEM certificates, policy documents).
29
+ *
30
+ * For normal-sized environment variables, prefer {@link getEnv}.
31
+ *
32
+ * @param {string} name - The dictionary key to look up.
33
+ * @returns {string} The value, or an empty string if not found.
34
+ */
35
+ function getDictionary(name: string): string {
11
36
  const buffer = String.UTF8.encode(name);
12
37
  const status = imports.proxy_dictionary_get(
13
38
  changetype<usize>(buffer),
@@ -24,4 +49,4 @@ function getEnv(name: string): string {
24
49
  return "";
25
50
  }
26
51
 
27
- export { getEnv };
52
+ export { getEnv, getDictionary };
@@ -27,7 +27,7 @@ function getSecret(name: string): string {
27
27
  /**
28
28
  * Function to get the value for the provided secret variable name from a specific slot.
29
29
  * @param {string} name - The name of the secret variable.
30
- * @param {u32} effectiveAt - The slot index of the secret. (effectiveAt >= secret_slots.slot)
30
+ * @param {u32} effectiveAt - The numeric slot index to retrieve. Slots are defined in the FastEdge UI and are always numeric (e.g. incremental integers, or Date.now()-style values to represent a point in time).
31
31
  * @returns {string} The value of the secret variable.
32
32
  */
33
33
  function getSecretEffectiveAt(name: string, effectiveAt: u32): string {
@@ -60,7 +60,7 @@ function getSecretVar(name: string): string {
60
60
  /**
61
61
  * @deprecated Use {@link getSecretEffectiveAt} instead. This function will be removed in a future version.
62
62
  * @param {string} name - The name of the secret variable.
63
- * @param {u32} effectiveAt - The slot index of the secret. (effectiveAt >= secret_slots.slot)
63
+ * @param {u32} effectiveAt - The numeric slot index to retrieve. Slots are defined in the FastEdge UI and are always numeric (e.g. incremental integers, or Date.now()-style values to represent a point in time).
64
64
  * @returns {string} The value of the secret variable.
65
65
  */
66
66
  function getSecretVarEffectiveAt(name: string, effectiveAt: u32): string {
@@ -490,7 +490,7 @@ class HeaderStreamManipulator {
490
490
  }
491
491
 
492
492
  /**
493
- * Replace a header.
493
+ * Replace a header value. No-op if the header is not present.
494
494
  * @param key the header name.
495
495
  * @param value the header value.
496
496
  */
@@ -1125,7 +1125,7 @@ export function deleteContext(context_id: u32): void {
1125
1125
  /**
1126
1126
  * Register a root context factory and make it available to the runtime.
1127
1127
  * @param root_context_factory A function that creates a new root context.
1128
- * @param name Paremeter kept for backwards compatibility. It will be ignored.
1128
+ * @param name Accepted for API compatibility with the proxy-wasm spec but ignored by the FastEdge runtime. The value does not need to match any configuration — pass any descriptive string.
1129
1129
  */
1130
1130
  export function registerRootContext(
1131
1131
  context_factory: (context_id: u32) => RootContext,
package/package.json CHANGED
@@ -1,25 +1,18 @@
1
1
  {
2
2
  "name": "@gcoredev/proxy-wasm-sdk-as",
3
3
  "description": "Use this SDK to write extensions for the proxy WASM ABI",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "main": "assembly/index.ts",
6
6
  "scripts": {
7
7
  "asbuild:debug": "asc assembly/index.ts --target debug",
8
8
  "asbuild:release": "asc assembly/index.ts --target release",
9
9
  "asbuild": "npm run asbuild:debug && npm run asbuild:release",
10
- "server": "ws --log.format dev",
11
- "docs": "typedoc"
10
+ "generate:docs": "./fastedge-plugin-source/generate-docs.sh"
12
11
  },
13
12
  "devDependencies": {
14
13
  "@assemblyscript/wasi-shim": "^0.1.0",
15
14
  "@semantic-release/changelog": "^6.0.3",
16
- "assemblyscript": "^0.28.9",
17
- "http-server": "^14.1.1",
18
- "local-web-server": "^5.4.0",
19
- "typedoc": "^0.28.16"
20
- },
21
- "directories": {
22
- "doc": "docs"
15
+ "assemblyscript": "^0.28.9"
23
16
  },
24
17
  "repository": {
25
18
  "type": "git",