@cipherstash/protect-ffi 0.16.0-0 → 0.16.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1,27 +1,11 @@
1
1
  "use strict";
2
2
  // This module is the CJS entry point for the library.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.decryptBulk = exports.newClient = exports.encryptBulk = exports.encrypt = void 0;
5
- exports.decrypt = decrypt;
6
- exports.decryptBulkFallible = decryptBulkFallible;
4
+ exports.decryptBulkFallible = exports.decryptBulk = exports.decrypt = exports.encryptBulk = exports.encrypt = exports.newClient = void 0;
7
5
  var load_cjs_1 = require("./load.cjs");
6
+ Object.defineProperty(exports, "newClient", { enumerable: true, get: function () { return load_cjs_1.newClient; } });
8
7
  Object.defineProperty(exports, "encrypt", { enumerable: true, get: function () { return load_cjs_1.encrypt; } });
9
8
  Object.defineProperty(exports, "encryptBulk", { enumerable: true, get: function () { return load_cjs_1.encryptBulk; } });
10
- Object.defineProperty(exports, "newClient", { enumerable: true, get: function () { return load_cjs_1.newClient; } });
9
+ Object.defineProperty(exports, "decrypt", { enumerable: true, get: function () { return load_cjs_1.decrypt; } });
11
10
  Object.defineProperty(exports, "decryptBulk", { enumerable: true, get: function () { return load_cjs_1.decryptBulk; } });
12
- const load_cjs_2 = require("./load.cjs");
13
- function decrypt(client, ciphertext, lockContext, ctsToken) {
14
- if (ctsToken) {
15
- return (0, load_cjs_2.decrypt)(client, ciphertext, lockContext, ctsToken);
16
- }
17
- if (lockContext) {
18
- return (0, load_cjs_2.decrypt)(client, ciphertext, lockContext);
19
- }
20
- return (0, load_cjs_2.decrypt)(client, ciphertext);
21
- }
22
- function decryptBulkFallible(client, ciphertexts, ctsToken) {
23
- if (ctsToken) {
24
- return (0, load_cjs_2.decryptBulkFallible)(client, ciphertexts, ctsToken);
25
- }
26
- return (0, load_cjs_2.decryptBulkFallible)(client, ciphertexts);
27
- }
11
+ Object.defineProperty(exports, "decryptBulkFallible", { enumerable: true, get: function () { return load_cjs_1.decryptBulkFallible; } });
package/lib/index.d.cts CHANGED
@@ -1,18 +1,16 @@
1
- export { encrypt, encryptBulk, newClient, decryptBulk } from './load.cjs';
1
+ export { newClient, encrypt, encryptBulk, decrypt, decryptBulk, decryptBulkFallible, } from './load.cjs';
2
2
  declare const sym: unique symbol;
3
3
  export type Client = {
4
4
  readonly [sym]: unknown;
5
5
  };
6
6
  declare module './load.cjs' {
7
- function newClient(encryptSchema: string, clientOpts?: string): Promise<Client>;
8
- function encrypt(client: Client, plaintext: EncryptPayload, ctsToken?: CtsToken): Promise<Encrypted>;
9
- function decrypt(client: Client, ciphertext: string, context?: Context, ctsToken?: CtsToken): Promise<string>;
10
- function encryptBulk(client: Client, plaintextTargets: EncryptPayload[], ctsToken?: CtsToken): Promise<Encrypted[]>;
11
- function decryptBulk(client: Client, ciphertexts: BulkDecryptPayload[], ctsToken?: CtsToken): Promise<string[]>;
12
- function decryptBulkFallible(client: Client, ciphertexts: BulkDecryptPayload[], ctsToken?: CtsToken): Promise<DecryptResult[]>;
7
+ function newClient(opts: NewClientOptions): Promise<Client>;
8
+ function encrypt(client: Client, opts: EncryptOptions): Promise<Encrypted>;
9
+ function decrypt(client: Client, opts: DecryptOptions): Promise<string>;
10
+ function encryptBulk(client: Client, opts: EncryptBulkOptions): Promise<Encrypted[]>;
11
+ function decryptBulk(client: Client, opts: DecryptBulkOptions): Promise<string[]>;
12
+ function decryptBulkFallible(client: Client, opts: DecryptBulkOptions): Promise<DecryptResult[]>;
13
13
  }
14
- export declare function decrypt(client: Client, ciphertext: string, lockContext?: Context, ctsToken?: CtsToken): Promise<string>;
15
- export declare function decryptBulkFallible(client: Client, ciphertexts: BulkDecryptPayload[], ctsToken?: CtsToken): Promise<DecryptResult[]>;
16
14
  export type DecryptResult = {
17
15
  data: string;
18
16
  } | {
@@ -47,3 +45,75 @@ export type Encrypted = {
47
45
  };
48
46
  v: number;
49
47
  };
48
+ export type EncryptConfig = {
49
+ v: number;
50
+ tables: Record<string, Record<string, Column>>;
51
+ };
52
+ export type Column = {
53
+ cast_as?: CastAs;
54
+ indexes?: Indexes;
55
+ };
56
+ export type CastAs = 'big_int' | 'boolean' | 'date' | 'real' | 'double' | 'int' | 'small_int' | 'text' | 'jsonb';
57
+ export type Indexes = {
58
+ ore?: OreIndexOpts;
59
+ unique?: UniqueIndexOpts;
60
+ match?: MatchIndexOpts;
61
+ ste_vec?: SteVecIndexOpts;
62
+ };
63
+ export type OreIndexOpts = Record<string, never>;
64
+ export type UniqueIndexOpts = {
65
+ token_filters?: TokenFilter[];
66
+ };
67
+ export type MatchIndexOpts = {
68
+ tokenizer?: Tokenizer;
69
+ token_filters?: TokenFilter[];
70
+ k?: number;
71
+ m?: number;
72
+ include_original?: boolean;
73
+ };
74
+ export type SteVecIndexOpts = {
75
+ prefix: string;
76
+ };
77
+ export type Tokenizer = {
78
+ kind: 'standard';
79
+ } | {
80
+ kind: 'ngram';
81
+ token_length: number;
82
+ };
83
+ export type TokenFilter = {
84
+ kind: 'downcase';
85
+ };
86
+ export type NewClientOptions = {
87
+ encryptConfig: EncryptConfig;
88
+ clientOpts?: ClientOpts;
89
+ };
90
+ export type ClientOpts = {
91
+ workspaceCrn?: string;
92
+ accessKey?: string;
93
+ clientId?: string;
94
+ clientKey?: string;
95
+ };
96
+ export type EncryptOptions = {
97
+ plaintext: string;
98
+ column: string;
99
+ table: string;
100
+ lockContext?: Context;
101
+ serviceToken?: CtsToken;
102
+ unverifiedContext?: Record<string, unknown>;
103
+ };
104
+ export type EncryptBulkOptions = {
105
+ plaintexts: EncryptPayload[];
106
+ serviceToken?: CtsToken;
107
+ unverifiedContext?: Record<string, unknown>;
108
+ };
109
+ export type DecryptOptions = {
110
+ ciphertext: string;
111
+ lockContext?: Context;
112
+ serviceToken?: CtsToken;
113
+ unverifiedContext?: Record<string, unknown>;
114
+ };
115
+ export type DecryptBulkOptions = {
116
+ ciphertexts: BulkDecryptPayload[];
117
+ serviceToken?: CtsToken;
118
+ unverifiedContext?: Record<string, unknown>;
119
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cipherstash/protect-ffi",
3
- "version": "0.16.0-0",
3
+ "version": "0.16.0-2",
4
4
  "description": "",
5
5
  "main": "./lib/index.cjs",
6
6
  "scripts": {
@@ -61,10 +61,10 @@
61
61
  "@neon-rs/load": "^0.1.82"
62
62
  },
63
63
  "optionalDependencies": {
64
- "@cipherstash/protect-ffi-win32-x64-msvc": "0.16.0-0",
65
- "@cipherstash/protect-ffi-darwin-x64": "0.16.0-0",
66
- "@cipherstash/protect-ffi-darwin-arm64": "0.16.0-0",
67
- "@cipherstash/protect-ffi-linux-x64-gnu": "0.16.0-0",
68
- "@cipherstash/protect-ffi-linux-arm64-gnu": "0.16.0-0"
64
+ "@cipherstash/protect-ffi-win32-x64-msvc": "0.16.0-2",
65
+ "@cipherstash/protect-ffi-darwin-x64": "0.16.0-2",
66
+ "@cipherstash/protect-ffi-darwin-arm64": "0.16.0-2",
67
+ "@cipherstash/protect-ffi-linux-x64-gnu": "0.16.0-2",
68
+ "@cipherstash/protect-ffi-linux-arm64-gnu": "0.16.0-2"
69
69
  }
70
70
  }