The Obj
parameter is an object that contains
+key-value pairs, where the keys are numbers and the values are Uint8Array values.
The function Access
is a TypeScript function that decrypts and retrieves a specific
+view from a stored data object using a provided key and unique identifier.
The Key
parameter is of type JsonWebKey["k"]
, which means it expects
+a value that is a string representing a JSON Web Key. This key will be used for
+decryption.
The Identifier parameter is a unique identifier generated using the
+randomUUID
function from the Crypto
object. It is used to retrieve data from the
+KV namespace.
KV is an instance of the KVNamespace class, which is used +to interact with the Workers KV storage. It provides methods for reading, writing, +and deleting data from the KV storage.
+The View
parameter is a string that represents the specific
+view or property of the decrypted data that you want to access. It is used to
+retrieve a specific value from the decrypted data object.
The function Decrypt
is a TypeScript function that uses the Web Crypto API to
+decrypt data using the AES-GCM algorithm.
Data is the encrypted data that needs to be decrypted. It +is of type Uint8Array, which is an array-like object representing an array of 8-bit +unsigned integers.
+The Key
parameter is a string that represents the encryption
+key used for decrypting the data. It should be a valid key value for the specified
+encryption algorithm (AES-GCM).
The Vector
(Initialization Vector) is a random value used in the
+encryption process to ensure that the same plaintext does not produce the same
+ciphertext. It is a fixed-size random or pseudo-random value that is typically
+required for symmetric encryption algorithms like AES-GCM (Advanced Encryption
+Standard - Galois/Counter Mode
The Encrypt function encrypts data using the AES-GCM algorithm with a given key.
+The Data
parameter is the data that you want to encrypt. It
+can be of any type, but it will be converted to a JSON string before encryption.
The Key
parameter is a string that represents the encryption
+key used to encrypt the data. It is used to derive a symmetric encryption key that is
+compatible with the AES-GCM algorithm.
The Get function recursively converts an object into a Map data structure.
+The Instance
parameter is an object that contains key-value pairs. The keys can
+be any string, and the values can be of any type.
biome-ignore lint/suspicious/noExplicitAny:
+The function converts a nested Map object into a nested plain JavaScript object.
+The Instance
parameter is of type unknown
, which means it can be any
+type. It is used to represent an instance of a class or an object.
The function Uint8ArrayFromObject
converts an object with keys as numbers and
+values as Uint8Array elements into a sorted Uint8Array.
The Obj
parameter is an object that contains
+key-value pairs, where the keys are numbers and the values are Uint8Array values.
First, install the Common
component like so:
npm install -D -E @codeeditorland/common
+
+Component.ts
import {
Access,
Decrypt,
Encrypt,
Get,
Put,
Redirect,
Response,
Uint8ArrayFromObject,
} from "@codeeditorland/common";
+
+See CHANGELOG.md for a history of changes to this component.
+The function Access
is a TypeScript function that decrypts and retrieves a specific
+view from a stored data object using a provided key and unique identifier.
The Key
parameter is of type JsonWebKey["k"]
, which means it expects
+a value that is a string representing a JSON Web Key. This key will be used for
+decryption.
The Identifier parameter is a unique identifier generated using the
+randomUUID
function from the Crypto
object. It is used to retrieve data from the
+KV namespace.
KV is an instance of the KVNamespace class, which is used +to interact with the Workers KV storage. It provides methods for reading, writing, +and deleting data from the KV storage.
+The View
parameter is a string that represents the specific
+view or property of the decrypted data that you want to access. It is used to
+retrieve a specific value from the decrypted data object.
The function Decrypt
is a TypeScript function that uses the Web Crypto API to
+decrypt data using the AES-GCM algorithm.
Data is the encrypted data that needs to be decrypted. It +is of type Uint8Array, which is an array-like object representing an array of 8-bit +unsigned integers.
+The Key
parameter is a string that represents the encryption
+key used for decrypting the data. It should be a valid key value for the specified
+encryption algorithm (AES-GCM).
The Vector
(Initialization Vector) is a random value used in the
+encryption process to ensure that the same plaintext does not produce the same
+ciphertext. It is a fixed-size random or pseudo-random value that is typically
+required for symmetric encryption algorithms like AES-GCM (Advanced Encryption
+Standard - Galois/Counter Mode
The Encrypt function encrypts data using the AES-GCM algorithm with a given key.
+The Data
parameter is the data that you want to encrypt. It
+can be of any type, but it will be converted to a JSON string before encryption.
The Key
parameter is a string that represents the encryption
+key used to encrypt the data. It is used to derive a symmetric encryption key that is
+compatible with the AES-GCM algorithm.
The Get function recursively converts an object into a Map data structure.
+The Instance
parameter is an object that contains key-value pairs. The keys can
+be any string, and the values can be of any type.
biome-ignore lint/suspicious/noExplicitAny:
+The function converts a nested Map object into a nested plain JavaScript object.
+The Instance
parameter is of type unknown
, which means it can be any
+type. It is used to represent an instance of a class or an object.
The function Uint8ArrayFromObject
converts an object with keys as numbers and
+values as Uint8Array elements into a sorted Uint8Array.
The Obj
parameter is an object that contains
+key-value pairs, where the keys are numbers and the values are Uint8Array values.
The function
+Uint8ArrayFromObject
converts an object with keys as numbers and +values as Uint8Array elements into a sorted Uint8Array.