Hi all, I am using this approach (Vue2): <https://...
# ask-questions
b
Hi all, I am using this approach (Vue2): https://docs.growthbook.io/lib/vue Does anyone know how to correctly pass in the decryptionKey? Supplying it to the growthBook instance doesn't seem to work, and I wonder if there is a way to pass it in when features are retrieved or set? In this method I've already retrieved the features in encrypted form, before the growthBook instance is created.
s
Hi @limited-ghost-77841, the growthbook constructor in the JS SDK does accept a
decryptionKey
property
Sorry - I misread your comment. Strange that that isn't working. Our method
setEncryptedFeatures
accepts it as an argument as well.
b
Thanks Adnan, I can't see that method in the docs, what arguments does it take?
s
Copy code
public async setEncryptedFeatures(
    encryptedString: string,
    decryptionKey?: string,
    subtle?: SubtleCrypto
  ): Promise<void>
b
Ok thank you that looks promising I will give that go
Is there any more documentation on this function? I have tried supplying the features as JSON as for setFeatures, and get the error "Failed to decrypt"
Copy code
const setFeaturePromise = new Promise(() => {
            growthBook.setEncryptedFeatures(json.features, decryptionKey)
          })
          await setFeaturePromise.then(() => {
            console.log(growthBook)
          })
Sorry the formatting is messed up there
s
Is json.features an encrypted string?
Are you sure you've enabled encryption at the SDK connection level?
b
Thanks for your help, the issue was to use json.encryptedFeatures (clear from checking the endpoint), and this now works:
Copy code
await growthBook.setEncryptedFeatures(
            json.encryptedFeatures,
            decryptionKey
          )
I couldn't see this specific function in docs but it is useful to know about