Skip to content

Example code for generateDataKey #465

@monscamus

Description

@monscamus

Hi, I've been using the SDK and I can encrypt and decrypt in javascript but now I'd like to generateDataKey(s) for each of my departments - there doesn't seem to be an example and following the same style doesn't seem to work. I've tried following some of the code I found in one of the Mocha tests but it appears to use a helper? Any chance of adding an example or extending the current encrypt-browser example?

The code below is an example of what I think should work but throws "generateDataKey is not a function".

       const { encrypt, generateDataKey } = buildClient(
            CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT
        );
        let clientProvider = getClient(KMS, { credentials: this.creds });

        let params = {
            "KeyId": this.generatorKeyId,
            "EncryptionContext": {"department": "test"},
            "NumberOfBytes": 256,
            "KeySpec": AES_256,
            "Client": clientProvider
        }

        let dek = await generateDataKey(params);


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions