listSecretInfo( )
Gets a list of objects containing information about all secrets stored in the Secrets Manager.
Description
The listSecretInfo()
function returns a Promise that resolves to a list containing information about all secrets stored on your site.
The secret's value is omitted for security reasons, and can be retrieved using the getSecret()
function for each individual secret.
Note: Do not use
listSecretInfo()
in a .jsw file with anonymous permissions! This is a serious security risk which exposes your secrets to potential leaks. To prevent this, implementlistSecretInfo()
in a separate .js file to block frontend access. If you must includelistSecretInfo()
in a .jsw file, make sure the exported function has permissions set to Admin.
Syntax
function listSecretInfo(): Promise<Array<SecretInfo>>
listSecretInfo Parameters
This function does not take any parameters.
Returns
Fulfilled - A list of objects with information about your site secrets. Rejected - Error message.
Return Type:
NAME
TYPE
DESCRIPTION
The secret's ID.
An optional text describing the secret's purpose or any other notes about it.
The date and time the secret was created.
The date and time the secret was last updated.
Was this helpful?
1import wixSecretsBackend from 'wix-secrets-backend';23export function getSecretInfo() {4 return wixSecretsBackend.listSecretInfo()5 .then((secrets) => {6 return secrets;7 })8 .catch((error) => {9 console.error(error);10 });11}1213/* Returns a Promise that resolves to:14 *15 * [16 * {17 * "id": "2eebccce-6c01-469d-a278-433fd96ba111",18 * "createdDate": "2020-05-26T06:16:46.000Z",19 * "updatedDate": "2020-05-28T12:21:10.000Z",20 * "name": "MyFirstSecret",21 * "description": "This is my first secret"22 * },23 * {24 * "id": "ef4b43d4-851d-4b52-a07f-9a500a888371",25 * "createdDate": "2020-06-02T08:23:54.000Z",26 * "updatedDate": "2020-06-02T08:23:54.000Z",27 * "name": "MySecondSecret",28 * "description": "This is my second secret"29 * }30 * ]31 */
1import wixSecretsBackend from 'wix-secrets-backend';23export function getFirstSecretValue() {4 return wixSecretsBackend.listSecretInfo()5 .then((secrets) => {6 return wixSecretsBackend.getSecret(secrets[0].name);7 })8 .catch((error) => {9 console.error(error);10 });11}1213/*14 * Returns a Promise that resolves to:15 *16 * "Fm8OfflH6bJOwWjenqAtLurLbkiMNvmhQHZV+118"17 */
1import wixSecretsBackend from 'wix-secrets-backend';23export function deleteFirstSecret() {4 return wixSecretsBackend.listSecretInfo()5 .then((secrets) => {6 return wixSecretsBackend.deleteSecret(secrets[0].id);7 })8 .then(() => {9 console.log("Secret deleted");10 })11 .catch((error) => {12 console.error(error);13 });14}