@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,142 @@
1
+ /*!
2
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ export declare class Transport {
5
+ /**
6
+ * Creates a Transport layer for an EDV client.
7
+ *
8
+ * @returns {Transport} A Transport instance.
9
+ */
10
+ constructor();
11
+ /**
12
+ * Creates a new EDV using the given configuration.
13
+ *
14
+ * @param {object} options - The options to use.
15
+ * @param {string} options.url - The url to post the configuration to.
16
+ * @param {string} options.config - The EDV's configuration.
17
+ *
18
+ * @returns {Promise<object>} - Resolves to the configuration for the newly
19
+ * created EDV.
20
+ */
21
+ createEdv({ url, config }?: any): Promise<void>;
22
+ /**
23
+ * Gets the configuration for an EDV from the server.
24
+ *
25
+ * @param {object} options - The options to use.
26
+ * @param {string} options.id - The ID of the EDV.
27
+ *
28
+ * @returns {Promise<object>} - Resolves to the configuration for the EDV.
29
+ */
30
+ getConfig({ id }?: any): Promise<void>;
31
+ /**
32
+ * Sends an updated EDV configuration to the server. The new configuration
33
+ * `sequence` must be incremented by `1` over the previous configuration or
34
+ * the update will fail.
35
+ *
36
+ * @param {object} options - The options to use.
37
+ * @param {object} options.config - The new EDV config.
38
+ *
39
+ * @returns {Promise<void>} - Settles once the operation completes.
40
+ */
41
+ updateConfig({ config }?: any): Promise<void>;
42
+ /**
43
+ * Get all EDV configurations matching a query.
44
+ *
45
+ * @param {object} options - The options to use.
46
+ * @param {string} options.controller - The EDV's controller.
47
+ * @param {string} [options.referenceId] - A controller-unique reference ID.
48
+ * @param {string} [options.after] - An EDV's ID.
49
+ * @param {number} [options.limit] - How many EDV configs to return.
50
+ *
51
+ * @returns {Promise<Array>} - Resolves to the matching EDV configurations.
52
+ */
53
+ findConfigs({ controller, referenceId, after, limit }?: any): Promise<void>;
54
+ /**
55
+ * Sends a new encrypted document to an EDV server. If the server reports
56
+ * that a document with a matching ID already exists, a `DuplicateError` is
57
+ * thrown.
58
+ *
59
+ * @param {object} options - The options to use.
60
+ * @param {object} options.encrypted - The encrypted document to insert.
61
+ *
62
+ * @returns {Promise} - Settles once the operation completes.
63
+ */
64
+ insert({ encrypted }?: any): Promise<void>;
65
+ /**
66
+ * Sends an encrypted document to an EDV server. If the document does not
67
+ * already exist, it will be created. If the update is rejected because of a
68
+ * conflict, then an `InvalidStateError` will be thrown.
69
+ *
70
+ * @param {object} options - The options to use.
71
+ * @param {object} options.encrypted - The encrypted document to insert.
72
+ *
73
+ * @returns {Promise} - Settles once the operation completes.
74
+ */
75
+ update({ encrypted }?: any): Promise<void>;
76
+ /**
77
+ * Sends an update for an index for the given document, without updating the
78
+ * document itself. If the index entry's sequence number does not match the
79
+ * document's current sequence number, update will be rejected with an
80
+ * `InvalidStateError`.
81
+ *
82
+ * Note: If the index does not exist or the document does not have an
83
+ * existing entry for the index, it will be added.
84
+ *
85
+ * @param {object} options - The options to use.
86
+ * @param {string} options.docId - The ID of the document.
87
+ * @param {object} options.entry - The index entry to send.
88
+ *
89
+ * @returns {Promise} - Settles once the operation completes.
90
+ */
91
+ updateIndex({ docId, entry }?: any): Promise<void>;
92
+ /**
93
+ * Gets an encrypted document from an EDV server by its ID.
94
+ *
95
+ * @param {object} options - The options to use.
96
+ * @param {string} options.id - The ID of the document to get.
97
+ *
98
+ * @returns {Promise<object>} - Resolves to the encrypted document.
99
+ */
100
+ get({ id }?: any): Promise<void>;
101
+ /**
102
+ * Sends a query to an EDV server to find encrypted documents based on their
103
+ * attributes.
104
+ *
105
+ * @param {object} options - The options to use.
106
+ * @param {object} options.query - The query to send.
107
+ *
108
+ * @returns {Promise<object>} - Resolves to the matching encrypted documents:
109
+ * `{documents: [...]}` or `{count: docCount}` if `query.count === true`.
110
+ */
111
+ find({ query }?: any): Promise<void>;
112
+ /**
113
+ * Store a capability revocation.
114
+ *
115
+ * @param {object} options - The options to use.
116
+ * @param {object} options.capabilityToRevoke - The capability to revoke.
117
+ *
118
+ * @returns {Promise<object>} Resolves once the operation completes.
119
+ */
120
+ revokeCapability({ capabilityToRevoke }?: any): Promise<void>;
121
+ /**
122
+ * Sends an encrypted document chunk to an EDV server.
123
+ *
124
+ * @param {object} options - The options to use.
125
+ * @param {string} options.docId - The document ID.
126
+ * @param {number} options.chunk - The encrypted chunk.
127
+ *
128
+ * @returns {Promise} - Settles once the operation completes.
129
+ */
130
+ storeChunk({ docId, chunk }: any): Promise<void>;
131
+ /**
132
+ * Gets an encrypted document chunk from an EDV server.
133
+ *
134
+ * @param {object} options - The options to use.
135
+ * @param {string} options.docId - The document ID.
136
+ * @param {number} options.chunkIndex - The index of the chunk.
137
+ *
138
+ * @returns {Promise<object>} - Resolves to the chunk data.
139
+ */
140
+ getChunk({ docId, chunkIndex }?: any): Promise<void>;
141
+ }
142
+ //# sourceMappingURL=Transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;;IAGH;;;;;;;;;OASG;IAEG,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAE,GAAQ;IAIzC;;;;;;;OAOG;IAEG,SAAS,CAAC,EAAE,EAAE,EAAE,GAAE,GAAQ;IAIhC;;;;;;;;;OASG;IAEG,YAAY,CAAC,EAAE,MAAM,EAAE,GAAE,GAAQ;IAIvC;;;;;;;;;;OAUG;IAEG,WAAW,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,GAAE,GAAQ;IAIrE;;;;;;;;;OASG;IAEG,MAAM,CAAC,EAAE,SAAS,EAAE,GAAE,GAAQ;IAIpC;;;;;;;;;OASG;IAEG,MAAM,CAAC,EAAE,SAAS,EAAE,GAAE,GAAQ;IAIpC;;;;;;;;;;;;;;OAcG;IAEG,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAE,GAAQ;IAI5C;;;;;;;OAOG;IAEG,GAAG,CAAC,EAAE,EAAE,EAAE,GAAE,GAAQ;IAI1B;;;;;;;;;OASG;IAEG,IAAI,CAAC,EAAE,KAAK,EAAE,GAAE,GAAQ;IAI9B;;;;;;;OAOG;IAEG,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,GAAE,GAAQ;IAIvD;;;;;;;;OAQG;IAEG,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG;IAItC;;;;;;;;OAQG;IAEG,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAE,GAAQ;CAG/C"}
@@ -0,0 +1,181 @@
1
+ /*!
2
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ export class Transport {
5
+ /**
6
+ * Creates a Transport layer for an EDV client.
7
+ *
8
+ * @returns {Transport} A Transport instance.
9
+ */
10
+ constructor() { }
11
+ /**
12
+ * Creates a new EDV using the given configuration.
13
+ *
14
+ * @param {object} options - The options to use.
15
+ * @param {string} options.url - The url to post the configuration to.
16
+ * @param {string} options.config - The EDV's configuration.
17
+ *
18
+ * @returns {Promise<object>} - Resolves to the configuration for the newly
19
+ * created EDV.
20
+ */
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ async createEdv({ url, config } = {}) {
23
+ _throwNotImplemented();
24
+ }
25
+ /**
26
+ * Gets the configuration for an EDV from the server.
27
+ *
28
+ * @param {object} options - The options to use.
29
+ * @param {string} options.id - The ID of the EDV.
30
+ *
31
+ * @returns {Promise<object>} - Resolves to the configuration for the EDV.
32
+ */
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
+ async getConfig({ id } = {}) {
35
+ _throwNotImplemented();
36
+ }
37
+ /**
38
+ * Sends an updated EDV configuration to the server. The new configuration
39
+ * `sequence` must be incremented by `1` over the previous configuration or
40
+ * the update will fail.
41
+ *
42
+ * @param {object} options - The options to use.
43
+ * @param {object} options.config - The new EDV config.
44
+ *
45
+ * @returns {Promise<void>} - Settles once the operation completes.
46
+ */
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ async updateConfig({ config } = {}) {
49
+ _throwNotImplemented();
50
+ }
51
+ /**
52
+ * Get all EDV configurations matching a query.
53
+ *
54
+ * @param {object} options - The options to use.
55
+ * @param {string} options.controller - The EDV's controller.
56
+ * @param {string} [options.referenceId] - A controller-unique reference ID.
57
+ * @param {string} [options.after] - An EDV's ID.
58
+ * @param {number} [options.limit] - How many EDV configs to return.
59
+ *
60
+ * @returns {Promise<Array>} - Resolves to the matching EDV configurations.
61
+ */
62
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
+ async findConfigs({ controller, referenceId, after, limit } = {}) {
64
+ _throwNotImplemented();
65
+ }
66
+ /**
67
+ * Sends a new encrypted document to an EDV server. If the server reports
68
+ * that a document with a matching ID already exists, a `DuplicateError` is
69
+ * thrown.
70
+ *
71
+ * @param {object} options - The options to use.
72
+ * @param {object} options.encrypted - The encrypted document to insert.
73
+ *
74
+ * @returns {Promise} - Settles once the operation completes.
75
+ */
76
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
77
+ async insert({ encrypted } = {}) {
78
+ _throwNotImplemented();
79
+ }
80
+ /**
81
+ * Sends an encrypted document to an EDV server. If the document does not
82
+ * already exist, it will be created. If the update is rejected because of a
83
+ * conflict, then an `InvalidStateError` will be thrown.
84
+ *
85
+ * @param {object} options - The options to use.
86
+ * @param {object} options.encrypted - The encrypted document to insert.
87
+ *
88
+ * @returns {Promise} - Settles once the operation completes.
89
+ */
90
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
91
+ async update({ encrypted } = {}) {
92
+ _throwNotImplemented();
93
+ }
94
+ /**
95
+ * Sends an update for an index for the given document, without updating the
96
+ * document itself. If the index entry's sequence number does not match the
97
+ * document's current sequence number, update will be rejected with an
98
+ * `InvalidStateError`.
99
+ *
100
+ * Note: If the index does not exist or the document does not have an
101
+ * existing entry for the index, it will be added.
102
+ *
103
+ * @param {object} options - The options to use.
104
+ * @param {string} options.docId - The ID of the document.
105
+ * @param {object} options.entry - The index entry to send.
106
+ *
107
+ * @returns {Promise} - Settles once the operation completes.
108
+ */
109
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
+ async updateIndex({ docId, entry } = {}) {
111
+ _throwNotImplemented();
112
+ }
113
+ /**
114
+ * Gets an encrypted document from an EDV server by its ID.
115
+ *
116
+ * @param {object} options - The options to use.
117
+ * @param {string} options.id - The ID of the document to get.
118
+ *
119
+ * @returns {Promise<object>} - Resolves to the encrypted document.
120
+ */
121
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
+ async get({ id } = {}) {
123
+ _throwNotImplemented();
124
+ }
125
+ /**
126
+ * Sends a query to an EDV server to find encrypted documents based on their
127
+ * attributes.
128
+ *
129
+ * @param {object} options - The options to use.
130
+ * @param {object} options.query - The query to send.
131
+ *
132
+ * @returns {Promise<object>} - Resolves to the matching encrypted documents:
133
+ * `{documents: [...]}` or `{count: docCount}` if `query.count === true`.
134
+ */
135
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
136
+ async find({ query } = {}) {
137
+ _throwNotImplemented();
138
+ }
139
+ /**
140
+ * Store a capability revocation.
141
+ *
142
+ * @param {object} options - The options to use.
143
+ * @param {object} options.capabilityToRevoke - The capability to revoke.
144
+ *
145
+ * @returns {Promise<object>} Resolves once the operation completes.
146
+ */
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
+ async revokeCapability({ capabilityToRevoke } = {}) {
149
+ _throwNotImplemented();
150
+ }
151
+ /**
152
+ * Sends an encrypted document chunk to an EDV server.
153
+ *
154
+ * @param {object} options - The options to use.
155
+ * @param {string} options.docId - The document ID.
156
+ * @param {number} options.chunk - The encrypted chunk.
157
+ *
158
+ * @returns {Promise} - Settles once the operation completes.
159
+ */
160
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
161
+ async storeChunk({ docId, chunk }) {
162
+ _throwNotImplemented();
163
+ }
164
+ /**
165
+ * Gets an encrypted document chunk from an EDV server.
166
+ *
167
+ * @param {object} options - The options to use.
168
+ * @param {string} options.docId - The document ID.
169
+ * @param {number} options.chunkIndex - The index of the chunk.
170
+ *
171
+ * @returns {Promise<object>} - Resolves to the chunk data.
172
+ */
173
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
174
+ async getChunk({ docId, chunkIndex } = {}) {
175
+ _throwNotImplemented();
176
+ }
177
+ }
178
+ function _throwNotImplemented() {
179
+ throw new Error('Not implemented.');
180
+ }
181
+ //# sourceMappingURL=Transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transport.js","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,gBAAe,CAAC;IAEhB;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,KAAU,EAAE;QACvC,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,KAAU,EAAE;QAC9B,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,KAAK,CAAC,YAAY,CAAC,EAAE,MAAM,KAAU,EAAE;QACrC,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;;OAUG;IACH,6DAA6D;IAC7D,KAAK,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,KAAU,EAAE;QACnE,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,KAAU,EAAE;QAClC,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,KAAU,EAAE;QAClC,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,6DAA6D;IAC7D,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,KAAU,EAAE;QAC1C,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,6DAA6D;IAC7D,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,KAAU,EAAE;QACxB,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,KAAU,EAAE;QAC5B,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,6DAA6D;IAC7D,KAAK,CAAC,gBAAgB,CAAC,EAAE,kBAAkB,KAAU,EAAE;QACrD,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;OAQG;IACH,6DAA6D;IAC7D,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAO;QACpC,oBAAoB,EAAE,CAAA;IACxB,CAAC;IAED;;;;;;;;OAQG;IACH,6DAA6D;IAC7D,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,KAAU,EAAE;QAC5C,oBAAoB,EAAE,CAAA;IACxB,CAAC;CACF;AAED,SAAS,oBAAoB;IAC3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function assert(variable: any, name: string, types: string | string[]): void;
2
+ export declare function assertDocument(doc: any): void;
3
+ export declare function assertDocId(id: any): void;
4
+ export declare function assertInvocationSigner(invocationSigner: any): void;
5
+ export declare function assertTransport(transport: any): void;
6
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAKA,wBAAgB,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAmB3E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,QAWtC;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,GAAG,QAuBlC;AAED,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,GAAG,QAK3D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,QAE7C"}
package/dist/assert.js ADDED
@@ -0,0 +1,61 @@
1
+ /*!
2
+ * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ import { base58btc } from './baseX.js';
5
+ export function assert(variable, name, types) {
6
+ if (!Array.isArray(types)) {
7
+ types = [types];
8
+ }
9
+ const type = variable instanceof Uint8Array ? 'Uint8Array' : typeof variable;
10
+ if (!types.includes(type) ||
11
+ // an object must not falsey nor an array
12
+ (type === 'object' && (!variable || Array.isArray(variable)))) {
13
+ let article;
14
+ if (types.length === 1) {
15
+ article = types[0] === 'object' ? 'an' : 'a';
16
+ }
17
+ throw new TypeError(`"${name}" must be ${types.length === 1 ? article : 'one of'} ` +
18
+ `${types.join(', ')}.`);
19
+ }
20
+ }
21
+ export function assertDocument(doc) {
22
+ assert(doc, 'doc', 'object');
23
+ const { id, content, meta = {}, stream } = doc;
24
+ if (id !== undefined) {
25
+ assertDocId(doc.id);
26
+ }
27
+ assert(content, 'content', 'object');
28
+ assert(meta, 'meta', 'object');
29
+ if (stream !== undefined) {
30
+ assert(stream, 'stream', 'object');
31
+ }
32
+ }
33
+ export function assertDocId(id) {
34
+ try {
35
+ // verify ID is multibase base58-encoded 16 bytes
36
+ const buf = base58btc.decode(id.substr(1));
37
+ // multibase base58 (starts with 'z')
38
+ // 128-bit random number, multibase encoded
39
+ // 0x00 = identity tag, 0x10 = length (16 bytes) + 16 random bytes
40
+ if (!(id.startsWith('z') &&
41
+ buf.length === 18 &&
42
+ buf[0] === 0x00 &&
43
+ buf[1] === 0x10)) {
44
+ throw new Error('Invalid document ID.');
45
+ }
46
+ }
47
+ catch {
48
+ throw new Error(`Document ID "${id}" must be a multibase, base58-encoded ` +
49
+ 'array of 16 random bytes.');
50
+ }
51
+ }
52
+ export function assertInvocationSigner(invocationSigner) {
53
+ assert(invocationSigner, 'invocationSigner', 'object');
54
+ const { id, sign } = invocationSigner;
55
+ assert(id, 'invocationSigner.id', 'string');
56
+ assert(sign, 'invocationSigner.sign', 'function');
57
+ }
58
+ export function assertTransport(transport) {
59
+ assert(transport, 'transport', 'object');
60
+ }
61
+ //# sourceMappingURL=assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ export declare const base58btc: import("@scure/base").BytesCoder;
2
+ /**
3
+ * base64url must be RFC 4648 compliant for interop, and the unpadded form is
4
+ * used here, hence `base64urlnopad`.
5
+ */
6
+ export declare const base64url: import("@scure/base").BytesCoder;
7
+ //# sourceMappingURL=baseX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseX.d.ts","sourceRoot":"","sources":["../src/baseX.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,kCAAS,CAAA;AAE/B;;;GAGG;AACH,eAAO,MAAM,SAAS,kCAAiB,CAAA"}
package/dist/baseX.js ADDED
@@ -0,0 +1,8 @@
1
+ import { base58, base64urlnopad } from '@scure/base';
2
+ export const base58btc = base58;
3
+ /**
4
+ * base64url must be RFC 4648 compliant for interop, and the unpadded form is
5
+ * used here, hence `base64urlnopad`.
6
+ */
7
+ export const base64url = base64urlnopad;
8
+ //# sourceMappingURL=baseX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseX.js","sourceRoot":"","sources":["../src/baseX.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAA;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CAAA"}
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ export { EdvClient } from './EdvClient.js';
5
+ export { EdvDocument } from './EdvDocument.js';
6
+ export { EdvClientCore } from './EdvClientCore.js';
7
+ export { HttpsTransport } from './HttpsTransport.js';
8
+ export { Transport } from './Transport.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
3
+ */
4
+ export { EdvClient } from './EdvClient.js';
5
+ export { EdvDocument } from './EdvDocument.js';
6
+ export { EdvClientCore } from './EdvClientCore.js';
7
+ export { HttpsTransport } from './HttpsTransport.js';
8
+ export { Transport } from './Transport.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare function getRandomBytes(buf: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>;
2
+ export declare function sha256(buf: Uint8Array): Promise<Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>>;
3
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAQA,wBAAsB,cAAc,CAAC,GAAG,EAAE,UAAU,wCAEnD;AAED,wBAAsB,MAAM,CAAC,GAAG,EAAE,UAAU,kEAE3C"}
package/dist/util.js ADDED
@@ -0,0 +1,13 @@
1
+ import { sha256 as _sha256 } from '@noble/hashes/sha2.js';
2
+ // Isomorphic crypto helpers. `getRandomValues` is provided natively by Node
3
+ // (>=24), browsers, and Deno; React Native consumers must install the
4
+ // `react-native-get-random-values` polyfill (see the README). SHA-256 uses the
5
+ // pure-JS `@noble/hashes` implementation so it works everywhere without a
6
+ // WebCrypto `subtle` shim.
7
+ export async function getRandomBytes(buf) {
8
+ return globalThis.crypto.getRandomValues(buf);
9
+ }
10
+ export async function sha256(buf) {
11
+ return _sha256(buf);
12
+ }
13
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEzD,4EAA4E;AAC5E,sEAAsE;AACtE,+EAA+E;AAC/E,0EAA0E;AAC1E,2BAA2B;AAE3B,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAe;IAClD,OAAO,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAe;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;AACrB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,112 @@
1
+ {
2
+ "name": "@interop/edv-client",
3
+ "version": "17.0.0",
4
+ "description": "JavaScript Encrypted Data Vault",
5
+ "license": "BSD-3-Clause",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "react-native": "./dist/index.js",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "module": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "pnpm run clear && tsc",
25
+ "clear": "rimraf dist/*",
26
+ "dev": "vite",
27
+ "fix": "eslint --fix src test && pnpm run format",
28
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.md\"",
29
+ "lint": "eslint src test",
30
+ "prepare": "pnpm run build",
31
+ "rebuild": "pnpm run clear && pnpm run build",
32
+ "test": "pnpm run fix && pnpm run lint && pnpm run test:node && pnpm run test:browser",
33
+ "test:browser": "playwright test",
34
+ "test:node": "vitest run",
35
+ "test:coverage": "vitest run --coverage"
36
+ },
37
+ "dependencies": {
38
+ "@interop/data-integrity-core": "^6.4.0",
39
+ "@interop/http-client": "^1.0.3",
40
+ "@interop/http-signature-zcap-invoke": "^6.2.1",
41
+ "@interop/lru-memoize": "^4.0.3",
42
+ "@interop/minimal-cipher": "^7.1.0",
43
+ "@noble/hashes": "^2.2.0",
44
+ "@scure/base": "^2.2.0",
45
+ "canonicalize": "^3.0.0",
46
+ "split-string": "^6.1.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react-native-get-random-values": "^2.0.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "react-native-get-random-values": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "devDependencies": {
57
+ "@eslint/js": "^10.0.1",
58
+ "@interop/did-method-key": "^7.2.0",
59
+ "@interop/ecdsa-multikey": "^2.2.0",
60
+ "@interop/ed25519-signature": "^7.1.0",
61
+ "@interop/ed25519-verification-key": "^7.0.2",
62
+ "@interop/security-document-loader": "^9.2.2",
63
+ "@interop/x25519-key-agreement-key": "^4.0.2",
64
+ "@interop/zcap": "^11.0.1",
65
+ "@playwright/test": "^1.60.0",
66
+ "@types/node": "^25.9.2",
67
+ "@vitest/coverage-v8": "^4.1.8",
68
+ "ajv": "^8.11.0",
69
+ "chai": "^6.2.2",
70
+ "eslint": "^10.4.1",
71
+ "eslint-config-prettier": "^10.1.8",
72
+ "globals": "^17.6.0",
73
+ "jsonld-signatures": "^11.2.1",
74
+ "path-to-regexp": "^8.0.0",
75
+ "prettier": "^3.8.3",
76
+ "rimraf": "^6.1.3",
77
+ "route-params": "^0.2.0",
78
+ "typescript": "^5.9.3",
79
+ "typescript-eslint": "^8.60.1",
80
+ "uuid": "^14.0.0",
81
+ "vite": "^8.0.16",
82
+ "vitest": "^4.1.8"
83
+ },
84
+ "repository": {
85
+ "type": "git",
86
+ "url": "https://github.com/interop-alliance/edv-client"
87
+ },
88
+ "keywords": [
89
+ "edv",
90
+ "edv client",
91
+ "encrypted data vault",
92
+ "encrypted data vault client",
93
+ "data hub",
94
+ "datahub"
95
+ ],
96
+ "author": {
97
+ "name": "Digital Bazaar, Inc.",
98
+ "email": "support@digitalbazaar.com",
99
+ "url": "https://digitalbazaar.com/"
100
+ },
101
+ "bugs": {
102
+ "url": "https://github.com/interop-alliance/edv-client/issues"
103
+ },
104
+ "homepage": "https://github.com/interop-alliance/edv-client",
105
+ "packageManager": "pnpm@11.5.0",
106
+ "engines": {
107
+ "node": ">=24.0"
108
+ },
109
+ "publishConfig": {
110
+ "access": "public"
111
+ }
112
+ }