@interop/was-react 0.3.5 → 0.4.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.
- package/dist/identity/agents.d.ts +19 -49
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +21 -79
- package/dist/identity/agents.js.map +1 -1
- package/dist/identity/seedStore.d.ts +11 -1
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +9 -0
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +33 -3
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +52 -1
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +166 -16
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +24 -2
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +40 -0
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +6 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +27 -1
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/sync/docCipher.d.ts +16 -1
- package/dist/sync/docCipher.d.ts.map +1 -1
- package/dist/sync/docCipher.js +21 -57
- package/dist/sync/docCipher.js.map +1 -1
- package/package.json +4 -3
package/dist/sync/docCipher.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* storage layer above needs no encrypted-vs-plaintext fork.
|
|
17
17
|
*/
|
|
18
18
|
import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
|
|
19
|
+
import type { CollectionEncryption } from '@interop/was-client';
|
|
19
20
|
import type { Json } from './types.js';
|
|
20
21
|
/**
|
|
21
22
|
* A per-collection document cipher. `encrypt` is the create path (mints a random
|
|
@@ -76,15 +77,29 @@ export declare function createPlaintextDocCodec({ collectionId }: {
|
|
|
76
77
|
* place via `sequence` -- the mutable head-document model every entity here uses
|
|
77
78
|
* (constant bump / toggle / re-categorize edits).
|
|
78
79
|
*
|
|
80
|
+
* Delegates to `@interop/was-client`'s `createEdvDocCipher`: with no
|
|
81
|
+
* `encryption` marker (or a marker with no key epochs) the cipher is
|
|
82
|
+
* single-recipient (the key-agreement key encrypts and decrypts directly, the
|
|
83
|
+
* behavior every collection has had); with epochs on the marker the cipher
|
|
84
|
+
* becomes multi-recipient -- writes stamp the marker's current epoch and reads
|
|
85
|
+
* route by the envelope's recipient key id, while a pre-epoch envelope still
|
|
86
|
+
* decrypts through the single-key path (a permanent tolerance, not a migration
|
|
87
|
+
* shim). The returned cipher's shape matches {@link DocCipher} exactly; only the
|
|
88
|
+
* nominal `Json` origin differs, so it crosses the boundary with a cast.
|
|
89
|
+
*
|
|
79
90
|
* @param options {object}
|
|
80
91
|
* @param options.keyAgreementKey {IKeyAgreementKey}
|
|
81
92
|
* @param options.keyResolver {IKeyResolver}
|
|
82
93
|
* @param options.collectionId {string} labels errors; the codec is agnostic
|
|
94
|
+
* @param [options.encryption] {CollectionEncryption} the collection's
|
|
95
|
+
* encryption marker; when it carries key epochs the cipher becomes
|
|
96
|
+
* multi-recipient
|
|
83
97
|
* @returns {Promise<DocCipher>}
|
|
84
98
|
*/
|
|
85
|
-
export declare function createDocCipher({ keyAgreementKey, keyResolver, collectionId }: {
|
|
99
|
+
export declare function createDocCipher({ keyAgreementKey, keyResolver, collectionId, encryption }: {
|
|
86
100
|
keyAgreementKey: IKeyAgreementKey;
|
|
87
101
|
keyResolver: IKeyResolver;
|
|
88
102
|
collectionId: string;
|
|
103
|
+
encryption?: CollectionEncryption;
|
|
89
104
|
}): Promise<DocCipher>;
|
|
90
105
|
//# sourceMappingURL=docCipher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.d.ts","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAAA;;GA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ACpC,eAAe,EACf,WAAW,EACX,YAAY,EACZ,UAAU,EACX,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,oBAAoB,CAAA;CAClC,GAAG,OAAO,CAAC,SAAS,CAAC,CASrB"}
|
package/dist/sync/docCipher.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createEdvDocCipher } from '@interop/was-client/edv';
|
|
2
2
|
/**
|
|
3
3
|
* Whether a stored body is an EDV encryption envelope (carries an object `jwe`)
|
|
4
4
|
* rather than plaintext. Lets read paths stay tolerant of any legacy plaintext
|
|
@@ -63,69 +63,33 @@ export function createPlaintextDocCodec({ collectionId }) {
|
|
|
63
63
|
* place via `sequence` -- the mutable head-document model every entity here uses
|
|
64
64
|
* (constant bump / toggle / re-categorize edits).
|
|
65
65
|
*
|
|
66
|
+
* Delegates to `@interop/was-client`'s `createEdvDocCipher`: with no
|
|
67
|
+
* `encryption` marker (or a marker with no key epochs) the cipher is
|
|
68
|
+
* single-recipient (the key-agreement key encrypts and decrypts directly, the
|
|
69
|
+
* behavior every collection has had); with epochs on the marker the cipher
|
|
70
|
+
* becomes multi-recipient -- writes stamp the marker's current epoch and reads
|
|
71
|
+
* route by the envelope's recipient key id, while a pre-epoch envelope still
|
|
72
|
+
* decrypts through the single-key path (a permanent tolerance, not a migration
|
|
73
|
+
* shim). The returned cipher's shape matches {@link DocCipher} exactly; only the
|
|
74
|
+
* nominal `Json` origin differs, so it crosses the boundary with a cast.
|
|
75
|
+
*
|
|
66
76
|
* @param options {object}
|
|
67
77
|
* @param options.keyAgreementKey {IKeyAgreementKey}
|
|
68
78
|
* @param options.keyResolver {IKeyResolver}
|
|
69
79
|
* @param options.collectionId {string} labels errors; the codec is agnostic
|
|
80
|
+
* @param [options.encryption] {CollectionEncryption} the collection's
|
|
81
|
+
* encryption marker; when it carries key epochs the cipher becomes
|
|
82
|
+
* multi-recipient
|
|
70
83
|
* @returns {Promise<DocCipher>}
|
|
71
84
|
*/
|
|
72
|
-
export async function createDocCipher({ keyAgreementKey, keyResolver, collectionId }) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
const codec = await provider.codecFor({
|
|
78
|
-
spaceId: 'local',
|
|
85
|
+
export async function createDocCipher({ keyAgreementKey, keyResolver, collectionId, encryption }) {
|
|
86
|
+
const cipher = await createEdvDocCipher({
|
|
87
|
+
keyAgreementKey,
|
|
88
|
+
keyResolver,
|
|
79
89
|
collectionId,
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
idDerivation: 'random',
|
|
91
|
+
...(encryption && { encryption })
|
|
82
92
|
});
|
|
83
|
-
|
|
84
|
-
throw new Error(`Could not build the EDV cipher for collection "${collectionId}".`);
|
|
85
|
-
}
|
|
86
|
-
// Parses the codec's `EncodedWrite` (id + envelope body bytes) into the
|
|
87
|
-
// stored `{ id, envelope }` shape. Shared by the create and update paths.
|
|
88
|
-
const readEncoded = (encoded) => {
|
|
89
|
-
if (typeof encoded.id !== 'string' ||
|
|
90
|
-
!(encoded.body instanceof Uint8Array)) {
|
|
91
|
-
throw new Error(`EDV encrypt for collection "${collectionId}" returned no id/envelope body.`);
|
|
92
|
-
}
|
|
93
|
-
const envelope = JSON.parse(new TextDecoder().decode(encoded.body));
|
|
94
|
-
return { id: encoded.id, envelope };
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
async encrypt({ data }) {
|
|
98
|
-
// `encode` with no caller id is the create path: encrypt, then use the
|
|
99
|
-
// minted random id.
|
|
100
|
-
const encoded = await codec.encode({
|
|
101
|
-
data: data
|
|
102
|
-
});
|
|
103
|
-
return readEncoded(encoded);
|
|
104
|
-
},
|
|
105
|
-
async encryptUpdate({ id, data, current }) {
|
|
106
|
-
// The update path: hand the codec the prior stored envelope so it advances
|
|
107
|
-
// `sequence` from it and re-encrypts under the same id. The codec reads
|
|
108
|
-
// `current.data` (the prior envelope) and its `etag` header (unused here;
|
|
109
|
-
// the wire `If-Match` is derived from the synced-doc `version`, not this).
|
|
110
|
-
const priorResponse = {
|
|
111
|
-
data: current,
|
|
112
|
-
json: async () => current,
|
|
113
|
-
headers: { get: () => null }
|
|
114
|
-
};
|
|
115
|
-
const encoded = await codec.encode({
|
|
116
|
-
id,
|
|
117
|
-
data: data,
|
|
118
|
-
current: priorResponse
|
|
119
|
-
});
|
|
120
|
-
return readEncoded(encoded);
|
|
121
|
-
},
|
|
122
|
-
async decrypt({ envelope }) {
|
|
123
|
-
const response = {
|
|
124
|
-
data: envelope,
|
|
125
|
-
json: async () => envelope
|
|
126
|
-
};
|
|
127
|
-
return (await codec.decode(response));
|
|
128
|
-
}
|
|
129
|
-
};
|
|
93
|
+
return cipher;
|
|
130
94
|
}
|
|
131
95
|
//# sourceMappingURL=docCipher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docCipher.js","sourceRoot":"","sources":["../../src/sync/docCipher.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAmB5D;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAsB;IACxD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpE,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,GAAG,GAAI,IAA0B,CAAC,GAAG,CAAA;IAC3C,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAA;AAChD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,YAAY,EAGb;IACC,MAAM,SAAS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C,CAAC,CAAA;IACF,OAAO,MAA8B,CAAA;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-react",
|
|
3
3
|
"description": "React library for building 'Bring Your Own Everything' (BYOE) apps on Wallet Attached Storage: DID Auth login via CHAPI wallet, local-first encrypted storage, and background sync to a WAS server.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -46,13 +46,14 @@
|
|
|
46
46
|
"types": "dist/index.d.ts",
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@interop/data-integrity-core": "^8.
|
|
49
|
+
"@interop/data-integrity-core": "^8.4.0",
|
|
50
50
|
"@interop/ed25519-signature": "^7.1.4",
|
|
51
51
|
"@interop/ezcap": "^7.4.1",
|
|
52
52
|
"@interop/security-document-loader": "^9.4.4",
|
|
53
53
|
"@interop/vc": "^11.0.6",
|
|
54
54
|
"@interop/verifier-core": "^3.4.1",
|
|
55
|
-
"@interop/
|
|
55
|
+
"@interop/wallet-core": "^0.5.0",
|
|
56
|
+
"@interop/was-client": "^0.20.0",
|
|
56
57
|
"@interop/webkms-client": "^14.7.1",
|
|
57
58
|
"@interop/x25519-key-agreement-key": "^5.2.1",
|
|
58
59
|
"@scure/base": "^2.2.0",
|