Node.js - secret.version()

Returns a reference to a known version of a secret.

import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyVersionRef = keyRef.version('the-version-id')

Parameters

  • Name
    version
    Required
    Required
    Type
    string
    Description

    The version ID. This value is returned from secret.put().

Examples

Return a reference to a known secret version

import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyVersionRef = keyRef.version('the-version-id')

Access the value of a known secret version

import { secret } from '@nitric/sdk'

const keyRef = secret('encryptionKey').allow('access')

const keyValue = await keyRef.version('the-version-id').access()

keyValue.asString()

See also