Skip to content

feat(protect): add protect config object#146

Merged
calvinbrewer merged 4 commits into
mainfrom
static-config
Jun 4, 2025
Merged

feat(protect): add protect config object#146
calvinbrewer merged 4 commits into
mainfrom
static-config

Conversation

@calvinbrewer

Copy link
Copy Markdown
Contributor

Implemented a more configurable pattern for the Protect client.

This release introduces a new ProtectClientConfig type that can be used to configure the Protect client.
This is useful if you want to configure the Protect client specific to your application, and will future proof any additional configuration options that are added in the future.

import { protect, type ProtectClientConfig } from "@cipherstash/protect";

const config: ProtectClientConfig = {
  schemas: [users, orders],
  workspaceCrn: "your-workspace-crn",
  accessKey: "your-access-key",
  clientId: "your-client-id",
  clientKey: "your-client-key",
}

const protectClient = await protect(config);

The now deprecated method of passing your tables to the protect client is no longer supported.

import { protect, type ProtectClientConfig } from "@cipherstash/protect";

// old method (no longer supported)
const protectClient = await protect(users, orders);

// required method
const config: ProtectClientConfig = {
  schemas: [users, orders],
}

const protectClient = await protect(config);

@calvinbrewer calvinbrewer requested review from CDThomas and Copilot June 3, 2025 17:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new configuration object (ProtectClientConfig) for the Protect client, replacing the deprecated approach of passing csTable parameters directly. Key changes include updating the Protect client API, propagating the new config object through tests and examples, and updating documentation to reflect these changes.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/utils/config/index.ts Updated loadWorkSpaceId to accept an optional workspace CRN argument.
packages/protect/src/index.ts Refactored protect() to accept a config object and pass client config accordingly.
packages/protect/src/ffi/index.ts Updated ProtectClient constructor and init() to align with new config usage.
packages/protect/package.json Upgraded protect-ffi dependency version.
tests/.test.ts, examples/, docs/* Adjusted instantiation of protectClient to use the new config object.
.changeset/shaggy-points-sink.md Added changeset documenting the breaking API change for protectClient.

Comment thread packages/protect/src/index.ts Outdated
Comment thread packages/protect/package.json Outdated
"dependencies": {
"@byteslice/result": "^0.2.0",
"@cipherstash/protect-ffi": "0.14.2",
"@cipherstash/protect-ffi": "0.15.0-0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@cipherstash/protect-ffi": "0.15.0-0",
"@cipherstash/protect-ffi": "0.15.0",

Heads up that I just released 0.15.0 of protect-ffi, so you don't need to use the prerelease anymore.

@calvinbrewer calvinbrewer merged commit c3fa823 into main Jun 4, 2025
1 check passed
@calvinbrewer calvinbrewer deleted the static-config branch June 4, 2025 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants