@interop/edv-client 17.0.0

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.
Files changed (47) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +276 -0
  3. package/dist/EdvClient.d.ts +412 -0
  4. package/dist/EdvClient.d.ts.map +1 -0
  5. package/dist/EdvClient.js +663 -0
  6. package/dist/EdvClient.js.map +1 -0
  7. package/dist/EdvClientCore.d.ts +264 -0
  8. package/dist/EdvClientCore.d.ts.map +1 -0
  9. package/dist/EdvClientCore.js +698 -0
  10. package/dist/EdvClientCore.js.map +1 -0
  11. package/dist/EdvDocument.d.ts +92 -0
  12. package/dist/EdvDocument.d.ts.map +1 -0
  13. package/dist/EdvDocument.js +149 -0
  14. package/dist/EdvDocument.js.map +1 -0
  15. package/dist/HttpsTransport.d.ts +87 -0
  16. package/dist/HttpsTransport.d.ts.map +1 -0
  17. package/dist/HttpsTransport.js +415 -0
  18. package/dist/HttpsTransport.js.map +1 -0
  19. package/dist/IndexHelper.d.ts +163 -0
  20. package/dist/IndexHelper.d.ts.map +1 -0
  21. package/dist/IndexHelper.js +539 -0
  22. package/dist/IndexHelper.js.map +1 -0
  23. package/dist/LegacyIndexHelperVersion1.d.ts +150 -0
  24. package/dist/LegacyIndexHelperVersion1.d.ts.map +1 -0
  25. package/dist/LegacyIndexHelperVersion1.js +475 -0
  26. package/dist/LegacyIndexHelperVersion1.js.map +1 -0
  27. package/dist/Transport.d.ts +142 -0
  28. package/dist/Transport.d.ts.map +1 -0
  29. package/dist/Transport.js +181 -0
  30. package/dist/Transport.js.map +1 -0
  31. package/dist/assert.d.ts +6 -0
  32. package/dist/assert.d.ts.map +1 -0
  33. package/dist/assert.js +61 -0
  34. package/dist/assert.js.map +1 -0
  35. package/dist/baseX.d.ts +7 -0
  36. package/dist/baseX.d.ts.map +1 -0
  37. package/dist/baseX.js +8 -0
  38. package/dist/baseX.js.map +1 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +9 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/util.d.ts +3 -0
  44. package/dist/util.d.ts.map +1 -0
  45. package/dist/util.js +13 -0
  46. package/dist/util.js.map +1 -0
  47. package/package.json +112 -0
@@ -0,0 +1,264 @@
1
+ import { Cipher } from '@interop/minimal-cipher';
2
+ import type { IHMAC, IKeyAgreementKey, IKeyResolver, IRecipient } from '@interop/data-integrity-core';
3
+ export declare class EdvClientCore {
4
+ hmac?: IHMAC;
5
+ id?: string;
6
+ keyAgreementKey?: IKeyAgreementKey;
7
+ keyResolver?: IKeyResolver;
8
+ cipher: Cipher;
9
+ indexHelper: any;
10
+ /**
11
+ * Creates the core of an EdvClient. The core must be coupled with a
12
+ * Transport layer.
13
+ *
14
+ * @param {object} options - The options to use.
15
+ * @param {object} [options.hmac] - A default HMAC API for blinding
16
+ * indexable attributes.
17
+ * @param {string} [options.id] - The ID of the EDV.
18
+ * @param {object} [options.keyAgreementKey] - A default KeyAgreementKey
19
+ * API for deriving shared KEKs for wrapping content encryption keys.
20
+ * @param {Function} [options.keyResolver] - A default function that returns
21
+ * a Promise that resolves a key ID to a DH public key.
22
+ * @param {string} [options.cipherVersion='recommended'] - Sets the cipher
23
+ * version to either "recommended" or "fips".
24
+ * @param {string} [options._attributeVersion=2] - Sets the blinded attribute
25
+ * version to use; for internal use only.
26
+ *
27
+ * @returns {EdvClientCore} An EdvClientCore instance.
28
+ */
29
+ constructor({ hmac, id, keyAgreementKey, keyResolver, cipherVersion, _attributeVersion }?: any);
30
+ /**
31
+ * Ensures that future documents inserted or updated using this Edv
32
+ * instance will be indexed according to the given attribute, provided that
33
+ * they contain that attribute. Compound indexes can be specified by
34
+ * providing an array for `attribute`.
35
+ *
36
+ * @param {object} options - The options to use.
37
+ * @param {string|Array} options.attribute - The attribute name or an array of
38
+ * attribute names to create a unique compound index.
39
+ * @param {boolean} [options.unique=false] - Should be `true` if the index is
40
+ * considered unique, `false` if not.
41
+ */
42
+ ensureIndex({ attribute, unique }?: any): void;
43
+ /**
44
+ * Encrypts and inserts a document into the EDV if it does not already
45
+ * exist. If a document matching its ID already exists, a `DuplicateError` is
46
+ * thrown. If a `stream` is given, the document will be inserted, then
47
+ * the stream will be read, chunked, and stored. Finally, the document will
48
+ * be updated to include meta data about the stored data from the stream,
49
+ * including a message digest.
50
+ *
51
+ * @param {object} options - The options to use.
52
+ * @param {object} options.doc - The document to insert.
53
+ * @param {ReadableStream} [options.stream] - A WHATWG Readable stream to read
54
+ * from to associate chunked data with this document.
55
+ * @param {number} [options.chunkSize=1048576] - The size, in bytes, of the
56
+ * chunks to break the incoming stream data into.
57
+ * @param {object[]} [options.recipients=[]] - A set of JWE recipients
58
+ * to encrypt the document for; if not present, a default recipient will
59
+ * be added using `this.keyAgreementKey` and if no `keyAgreementKey` is
60
+ * set, an error will be thrown.
61
+ * @param {Function} [options.keyResolver=this.keyResolver] - A function that
62
+ * returns a Promise that resolves a key ID to a DH public key.
63
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
64
+ * KeyAgreementKey API for deriving shared KEKs for wrapping content
65
+ * encryption keys.
66
+ * @param {object} [options.hmac=this.hmac] - An HMAC API for blinding
67
+ * indexable attributes.
68
+ * @param {object} options.transport - The Transport instance to use.
69
+ *
70
+ * @returns {Promise<object>} - Resolves to the inserted document.
71
+ */
72
+ insert({ doc, stream, chunkSize, recipients, keyResolver, keyAgreementKey, hmac, transport }?: any): Promise<any>;
73
+ /**
74
+ * Encrypts and updates a document in the EDV. If the document does not
75
+ * already exist, it is created. If a `stream` is provided, the document
76
+ * will be updated twice, once using the given update and a second time
77
+ * once the stream has been read, chunked, and stored to include meta data
78
+ * information such as the stream data's message digest.
79
+ *
80
+ * @param {object} options - The options to use.
81
+ * @param {object} options.doc - The document to insert.
82
+ * @param {ReadableStream} [options.stream] - A WHATWG Readable stream to read
83
+ * from to associate chunked data with this document.
84
+ * @param {number} [options.chunkSize=1048576] - The size, in bytes, of the
85
+ * chunks to break the incoming stream data into.
86
+ * @param {object} [options.recipients=[]] - A set of JWE recipients to
87
+ * encrypt the document for; if present, recipients will be added to any
88
+ * existing recipients; to remove existing recipients, modify the
89
+ * `encryptedDoc.jwe.recipients` field.
90
+ * @param {Function} [options.keyResolver=this.keyResolver] - A function that
91
+ * returns a Promise that resolves a key ID to a DH public key.
92
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
93
+ * KeyAgreementKey API for deriving shared KEKs for wrapping content
94
+ * encryption keys.
95
+ * @param {object} [options.hmac=this.hmac] - An HMAC API for blinding
96
+ * indexable attributes.
97
+ * @param {object} options.transport - The Transport instance to use.
98
+ *
99
+ * @returns {Promise<object>} - Resolves to the updated document.
100
+ */
101
+ update({ doc, stream, chunkSize, recipients, keyResolver, keyAgreementKey, hmac, transport }?: any): Promise<any>;
102
+ /**
103
+ * Updates an index for the given document, without updating the document
104
+ * contents itself. An index entry will be updated and sent to the EDV; its
105
+ * sequence number must match the document's current sequence number or the
106
+ * update will be rejected with an `InvalidStateError`. Recovery from this
107
+ * error requires fetching the latest document and trying again.
108
+ *
109
+ * Note: If the index does not exist or the document does not have an
110
+ * existing entry for the index, it will be added.
111
+ *
112
+ * @param {object} options - The options to use.
113
+ * @param {object} options.doc - The document to create or update an index
114
+ * for.
115
+ * @param {object} [options.hmac=this.hmac] - An HMAC API for blinding
116
+ * indexable attributes.
117
+ * @param {object} options.transport - The Transport instance to use.
118
+ *
119
+ * @returns {Promise} - Resolves once the operation completes.
120
+ */
121
+ updateIndex({ doc, hmac, transport }?: any): Promise<void>;
122
+ /**
123
+ * Deletes a document from the EDV.
124
+ *
125
+ * @param {object} options - The options to use.
126
+ * @param {object} options.doc - The document to delete.
127
+ * @param {object} [options.recipients=[]] - A set of JWE recipients to
128
+ * encrypt the document for; if present, recipients will be added to
129
+ * any existing recipients; to remove existing recipients, modify
130
+ * the `encryptedDoc.jwe.recipients` field.
131
+ * @param {Function} [options.keyResolver=this.keyResolver] - A function that
132
+ * returns a Promise that resolves a key ID to a DH public key.
133
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
134
+ * KeyAgreementKey API for deriving shared KEKs for wrapping content
135
+ * encryption keys.
136
+ * @param {object} options.transport - The Transport instance to use.
137
+ *
138
+ * @returns {Promise<boolean>} - Resolves to `true` if the document was
139
+ * deleted.
140
+ */
141
+ delete({ doc, recipients, keyResolver, keyAgreementKey, transport }?: any): Promise<boolean>;
142
+ /**
143
+ * Gets a document from the EDV by its ID.
144
+ *
145
+ * @param {object} options - The options to use.
146
+ * @param {string} options.id - The ID of the document to get.
147
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
148
+ * KeyAgreementKey API for deriving a shared KEK to unwrap the content
149
+ * encryption key.
150
+ * @param {object} options.transport - The Transport instance to use.
151
+ *
152
+ * @returns {Promise<object>} - Resolves to the document.
153
+ */
154
+ get({ id, keyAgreementKey, transport }?: any): Promise<any>;
155
+ /**
156
+ * Gets a `ReadableStream` to read the chunked data associated with a
157
+ * document.
158
+ *
159
+ * @param {object} options - The options to use.
160
+ * @param {object} options.doc - The document to get a stream for.
161
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
162
+ * KeyAgreementKey API for deriving a shared KEK to unwrap the content
163
+ * encryption key.
164
+ * @param {object} options.transport - The Transport instance to use.
165
+ *
166
+ * @returns {Promise<ReadableStream>} - Resolves to a `ReadableStream` to read
167
+ * the chunked data from.
168
+ */
169
+ getStream({ doc, keyAgreementKey, transport }?: any): Promise<ReadableStream<any>>;
170
+ /**
171
+ * Counts how many documents match a query in an EDV.
172
+ *
173
+ * @see find - For more detailed documentation on the search options.
174
+ *
175
+ * @param {object} options - The options to use.
176
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
177
+ * KeyAgreementKey API for deriving a shared KEK to unwrap the content
178
+ * encryption key.
179
+ * @param {object} [options.hmac=this.hmac] - An HMAC API for blinding
180
+ * indexable attributes.
181
+ * @param {object|Array} [options.equals] - An object with key-value
182
+ * attribute pairs to match or an array of such objects.
183
+ * @param {string|Array} [options.has] - A string with an attribute name to
184
+ * match or an array of such strings.
185
+ * @param {object} options.transport - The Transport instance to use.
186
+ *
187
+ * @returns {Promise<number>} - Resolves to the number of matching documents.
188
+ */
189
+ count({ keyAgreementKey, hmac, equals, has, transport }?: any): Promise<any>;
190
+ /**
191
+ * Finds documents based on their attributes. Currently, matching can be
192
+ * performed using an `equals` or a `has` filter (but not both at once).
193
+ *
194
+ * The `equals` filter is an object with key-value attribute pairs. Any
195
+ * document that matches *all* given key-value attribute pairs will be
196
+ * returned. If equals is an array, it may contain multiple such filters --
197
+ * whereby the results will be all documents that matched any one of the
198
+ * filters. If the document's value for a matching a key is an array and
199
+ * the array contains a matching value, the document will be considered
200
+ * a match (provided that other key-value attribute pairs also match).
201
+ *
202
+ * The `has` filter is a string representing the attribute name or an
203
+ * array of such strings. If an array is used, then the results will only
204
+ * contain documents that possess *all* of the attributes listed.
205
+ *
206
+ * @param {object} options - The options to use.
207
+ * @param {object} [options.keyAgreementKey=this.keyAgreementKey] - A
208
+ * KeyAgreementKey API for deriving a shared KEK to unwrap the content
209
+ * encryption key.
210
+ * @param {object} [options.hmac=this.hmac] - An HMAC API for blinding
211
+ * indexable attributes.
212
+ * @param {object|Array} [options.equals] - An object with key-value
213
+ * attribute pairs to match or an array of such objects.
214
+ * @param {string|Array} [options.has] - A string with an attribute name to
215
+ * match or an array of such strings.
216
+ * @param {boolean} [options.returnDocuments] - Set to `false` to
217
+ * request only document IDs from the server (not full documents); note
218
+ * that a server that does not accept this option will return full
219
+ * documents, so either return value is possible.
220
+ * @param {boolean} [options.count] - Set to `false` to find all documents
221
+ * that match a query or to `true` to give a count of documents.
222
+ * @param {number} [options.limit] - Set to limit the number of documents
223
+ * to be returned from a query (min=1, max=1000).
224
+ * @param {object} options.transport - The Transport instance to use.
225
+ *
226
+ * @returns {Promise<object>} - Resolves to the matching documents:
227
+ * {documents: [...]}.
228
+ */
229
+ find({ keyAgreementKey, hmac, equals, has, returnDocuments, count, limit, transport }?: any): Promise<any>;
230
+ /**
231
+ * Gets the configuration for an EDV.
232
+ *
233
+ * @param {object} options - The options to use.
234
+ * @param {string} [options.id] - The ID of the EDV config.
235
+ * @param {object} options.transport - The Transport instance to use.
236
+ *
237
+ * @returns {Promise<object>} - Resolves to the configuration for the EDV.
238
+ */
239
+ getConfig({ id, transport }?: any): Promise<any>;
240
+ /**
241
+ * Updates an EDV configuration. The new configuration `sequence` must
242
+ * be incremented by `1` over the previous configuration or the update will
243
+ * fail.
244
+ *
245
+ * @param {object} options - The options to use.
246
+ * @param {object} options.config - The new EDV config.
247
+ * @param {object} options.transport - The Transport instance to use.
248
+ *
249
+ * @returns {Promise} - Resolves once the operation completes.
250
+ */
251
+ updateConfig({ config, transport }?: any): Promise<any>;
252
+ /**
253
+ * Generates a multibase encoded random 128-bit identifier for a document.
254
+ *
255
+ * @returns {Promise<string>} - Resolves to the identifier.
256
+ */
257
+ static generateId(): Promise<string>;
258
+ generateId(): Promise<string>;
259
+ _createDefaultRecipients(keyAgreementKey: IKeyAgreementKey): IRecipient[];
260
+ _decrypt({ encryptedDoc, keyAgreementKey }: any): Promise<any>;
261
+ _encrypt({ doc, recipients, keyResolver, hmac, update }: any): Promise<any>;
262
+ _updateStream({ doc, stream, chunkSize, recipients, keyResolver, keyAgreementKey, hmac, transport }: any): Promise<any>;
263
+ }
264
+ //# sourceMappingURL=EdvClientCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdvClientCore.d.ts","sourceRoot":"","sources":["../src/EdvClientCore.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,EACV,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACX,MAAM,8BAA8B,CAAA;AAQrC,qBAAa,aAAa;IACxB,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,EAAE,CAAC,EAA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