Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 0 additions & 118 deletions ENVOY.md

This file was deleted.

27 changes: 27 additions & 0 deletions assembly/fastedge/dictionary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as imports from "../imports";

import { globalArrayBufferReference, WasmResultValues } from "../runtime";

/**
* Function to get the value for the provided environment variable name.
* @param {string} name - The name of the environment variable.
* @returns {string} The value of the environment variable.
*/
function getEnv(name: string): string {
const buffer = String.UTF8.encode(name);
const status = imports.proxy_dictionary_get(
changetype<usize>(buffer),
Comment thread
godronus marked this conversation as resolved.
buffer.byteLength,
globalArrayBufferReference.bufferPtr(),
globalArrayBufferReference.sizePtr(),
);
Comment thread
godronus marked this conversation as resolved.
if (status == WasmResultValues.Ok) {
const arrBuff = globalArrayBufferReference.toArrayBuffer();
if (arrBuff.byteLength > 0) {
return String.UTF8.decode(arrBuff);
}
}
return "";
}

export { getEnv };
2 changes: 1 addition & 1 deletion assembly/fastedge/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Function to get the value for the provided environment variable name.
* @deprecated Use {@link getEnv} instead. This function will be removed in a future version.
Comment thread
godronus marked this conversation as resolved.
* @param {string} name - The name of the environment variable.
* @returns {string} The value of the environment variable.
*/
Expand Down
1 change: 1 addition & 0 deletions assembly/fastedge/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./dictionary";
Comment thread
godronus marked this conversation as resolved.
export * from "./env";
export * from "./kvStore";
export * from "./secrets";
Expand Down
34 changes: 29 additions & 5 deletions assembly/fastedge/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { globalArrayBufferReference, WasmResultValues } from "../runtime";
* @param {string} name - The name of the secret variable.
* @returns {string} The value of the secret variable.
*/
function getSecretVar(name: string): string {
function getSecret(name: string): string {
const buffer = String.UTF8.encode(name);
const status = imports.proxy_get_secret(
changetype<usize>(buffer),
buffer.byteLength,
globalArrayBufferReference.bufferPtr(),
globalArrayBufferReference.sizePtr()
globalArrayBufferReference.sizePtr(),
);
if (status == WasmResultValues.Ok) {
const arrBuff = globalArrayBufferReference.toArrayBuffer();
Expand All @@ -30,14 +30,14 @@ function getSecretVar(name: string): string {
* @param {u32} effectiveAt - The slot index of the secret. (effectiveAt >= secret_slots.slot)
* @returns {string} The value of the secret variable.
*/
function getSecretVarEffectiveAt(name: string, effectiveAt: u32): string {
function getSecretEffectiveAt(name: string, effectiveAt: u32): string {
const buffer = String.UTF8.encode(name);
const status = imports.proxy_get_effective_at_secret(
changetype<usize>(buffer),
buffer.byteLength,
effectiveAt,
globalArrayBufferReference.bufferPtr(),
globalArrayBufferReference.sizePtr()
globalArrayBufferReference.sizePtr(),
);
if (status == WasmResultValues.Ok) {
const arrBuff = globalArrayBufferReference.toArrayBuffer();
Expand All @@ -48,4 +48,28 @@ function getSecretVarEffectiveAt(name: string, effectiveAt: u32): string {
return "";
}

export { getSecretVar, getSecretVarEffectiveAt };
/**
* @deprecated Use {@link getSecret} instead. This function will be removed in a future version.
* @param {string} name - The name of the secret variable.
* @returns {string} The value of the secret variable.
*/
function getSecretVar(name: string): string {
return getSecret(name);
}

/**
* @deprecated Use {@link getSecretEffectiveAt} instead. This function will be removed in a future version.
* @param {string} name - The name of the secret variable.
* @param {u32} effectiveAt - The slot index of the secret. (effectiveAt >= secret_slots.slot)
* @returns {string} The value of the secret variable.
*/
function getSecretVarEffectiveAt(name: string, effectiveAt: u32): string {
return getSecretEffectiveAt(name, effectiveAt);
}

export {
getSecret,
getSecretEffectiveAt,
getSecretVar,
getSecretVarEffectiveAt,
};
10 changes: 10 additions & 0 deletions assembly/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ export declare function proxy_call_foreign_function(function_name: ptr<char>,

// FastEdge HOST Apis

// Dictionary
// @ts-ignore: decorator
@external("env", "proxy_dictionary_get")
export declare function proxy_dictionary_get(
key_data: usize,
key_size: usize,
return_value_data: usize,
return_value_size: usize
): u32;

// Secrets
// @ts-ignore: decorator
@external("env", "proxy_get_secret")
Expand Down