Will CloudKit’s encrypted fields work with CloudKit JS?

Does the new encrypted fields work with CloudKit JS? I have checked the API for CloudKit JS, and under CloudKit.Record there is no mentioning of encrypted fields. It feels like this API has not been updated for a while. Does this mean that if I use field-level encryption, I will not be able to use CloudKit JS?

Replies

In the "What's New in CloudKit" video from WWDC21, there is talk about how the encryption works, namely, it uses iCloud Keychain on device. Based on this, I'd have to assume that no, encrypted fields are not supported by the CloudKit JS library OR CloudKit Web Services (I'm writing a swift library for this).

You can use CKTool JS to access encrypted field values. CKTool JS supports authentication with CloudKit Web Auth and CloudKit API tokens.

You can see an example of how to query records with CKTool JS here: https://developer.apple.com/documentation/cktooljs/promisesapi/3905593-queryrecords

In the example on that page, you can substitute this security object instead of the one in the example:

    security: {
      "CloudKitAPITokenAuth": "<YourCKApiToken>",
      "CloudKitWebAuthTokenAuth": "<YourCKWebAuthToken>"
    }

The field value types you can access are listed here: https://developer.apple.com/documentation/cktooljs/promisesapi/field_values