@interop/was-client 0.25.0 → 0.26.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/edv/didKeyRecipient.d.ts +23 -0
- package/dist/edv/didKeyRecipient.d.ts.map +1 -0
- package/dist/edv/didKeyRecipient.js +68 -0
- package/dist/edv/didKeyRecipient.js.map +1 -0
- package/dist/edv/index.d.ts +6 -0
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +6 -0
- package/dist/edv/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RecipientPublicKey } from './epochCrypto.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a string is an Ed25519 `did:key` DID -- the only controller shape a
|
|
4
|
+
* recipient key can be derived from (an X25519 twin exists only for an Ed25519
|
|
5
|
+
* key). A key id (a DID with a fragment) is not one: the derivation is defined
|
|
6
|
+
* over the DID itself.
|
|
7
|
+
*
|
|
8
|
+
* @param did {string | undefined}
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export declare function isEd25519DidKey(did: string | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Derives the X25519 epoch-recipient public key for an Ed25519 `did:key`
|
|
14
|
+
* controller.
|
|
15
|
+
*
|
|
16
|
+
* @param options {object}
|
|
17
|
+
* @param options.did {string} the grantee's Ed25519 `did:key` DID
|
|
18
|
+
* @returns {RecipientPublicKey}
|
|
19
|
+
*/
|
|
20
|
+
export declare function x25519RecipientFromDidKey({ did }: {
|
|
21
|
+
did: string;
|
|
22
|
+
}): RecipientPublicKey;
|
|
23
|
+
//# sourceMappingURL=didKeyRecipient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didKeyRecipient.d.ts","sourceRoot":"","sources":["../../src/edv/didKeyRecipient.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAQ1D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAOhE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,GAAG,EACJ,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,kBAAkB,CAqBrB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Derives a grantee's epoch-recipient key from the `did:key` DID a capability
|
|
6
|
+
* request already names as its `controller`. An Ed25519 `did:key` has a
|
|
7
|
+
* canonical X25519 twin (the Montgomery form) -- the same conversion a wallet
|
|
8
|
+
* applies to its own key-agreement key. So the recipient key never travels on
|
|
9
|
+
* the wire: it is derived locally from the controller DID.
|
|
10
|
+
*
|
|
11
|
+
* Deriving beats accepting an explicit `{ id, publicKeyMultibase }` field. An
|
|
12
|
+
* explicit key would let a request pair controller DID A with recipient key B,
|
|
13
|
+
* and the granting side would have to verify the binding anyway -- which for a
|
|
14
|
+
* `did:key` means performing this exact derivation. Deriving makes key
|
|
15
|
+
* substitution impossible by construction and keeps both axes of a share (the
|
|
16
|
+
* pull zcap and the epoch roster entry) pointing at the same entity.
|
|
17
|
+
*
|
|
18
|
+
* The resulting recipient `id` is `did:key:z6Mk...#z6LS...` -- byte-identical
|
|
19
|
+
* to what the grantee derives on its own side from the same key material, so
|
|
20
|
+
* its `kid` matches the epoch roster entry that gets written, and it resolves
|
|
21
|
+
* through the default `did:key` recipient resolver.
|
|
22
|
+
*/
|
|
23
|
+
import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key';
|
|
24
|
+
const DID_KEY_PREFIX = 'did:key:';
|
|
25
|
+
// Multibase base58btc + multicodec ed25519-pub: every Ed25519 did:key
|
|
26
|
+
// identifier starts with these four characters.
|
|
27
|
+
const ED25519_MULTIBASE_PREFIX = 'z6Mk';
|
|
28
|
+
/**
|
|
29
|
+
* Whether a string is an Ed25519 `did:key` DID -- the only controller shape a
|
|
30
|
+
* recipient key can be derived from (an X25519 twin exists only for an Ed25519
|
|
31
|
+
* key). A key id (a DID with a fragment) is not one: the derivation is defined
|
|
32
|
+
* over the DID itself.
|
|
33
|
+
*
|
|
34
|
+
* @param did {string | undefined}
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export function isEd25519DidKey(did) {
|
|
38
|
+
return (!!did &&
|
|
39
|
+
did.startsWith(DID_KEY_PREFIX) &&
|
|
40
|
+
did.slice(DID_KEY_PREFIX.length).startsWith(ED25519_MULTIBASE_PREFIX) &&
|
|
41
|
+
!did.includes('#'));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Derives the X25519 epoch-recipient public key for an Ed25519 `did:key`
|
|
45
|
+
* controller.
|
|
46
|
+
*
|
|
47
|
+
* @param options {object}
|
|
48
|
+
* @param options.did {string} the grantee's Ed25519 `did:key` DID
|
|
49
|
+
* @returns {RecipientPublicKey}
|
|
50
|
+
*/
|
|
51
|
+
export function x25519RecipientFromDidKey({ did }) {
|
|
52
|
+
if (!isEd25519DidKey(did)) {
|
|
53
|
+
throw new Error(`Cannot derive a recipient key: "${did}" is not an Ed25519 did:key DID.`);
|
|
54
|
+
}
|
|
55
|
+
const keyAgreementKey = X25519KeyAgreementKey2020.fromEd25519VerificationKey2020({
|
|
56
|
+
keyPair: {
|
|
57
|
+
controller: did,
|
|
58
|
+
publicKeyMultibase: did.slice(DID_KEY_PREFIX.length)
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const { id, publicKeyMultibase, type } = keyAgreementKey;
|
|
62
|
+
if (typeof id !== 'string' || typeof publicKeyMultibase !== 'string') {
|
|
63
|
+
throw new Error('Cannot derive a recipient key: the converted key-agreement key lacks ' +
|
|
64
|
+
'an id or publicKeyMultibase.');
|
|
65
|
+
}
|
|
66
|
+
return { id, publicKeyMultibase, type };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=didKeyRecipient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didKeyRecipient.js","sourceRoot":"","sources":["../../src/edv/didKeyRecipient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAG7E,MAAM,cAAc,GAAG,UAAU,CAAA;AAEjC,sEAAsE;AACtE,gDAAgD;AAChD,MAAM,wBAAwB,GAAG,MAAM,CAAA;AAEvC;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAuB;IACrD,OAAO,CACL,CAAC,CAAC,GAAG;QACL,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC;QAC9B,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,wBAAwB,CAAC;QACrE,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CACnB,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,GAAG,EAGJ;IACC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mCAAmC,GAAG,kCAAkC,CACzE,CAAA;IACH,CAAC;IACD,MAAM,eAAe,GACnB,yBAAyB,CAAC,8BAA8B,CAAC;QACvD,OAAO,EAAE;YACP,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC;SACrD;KACF,CAAC,CAAA;IACJ,MAAM,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAA;IACxD,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,uEAAuE;YACrE,8BAA8B,CACjC,CAAA;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC"}
|
package/dist/edv/index.d.ts
CHANGED
|
@@ -24,12 +24,18 @@
|
|
|
24
24
|
* They mutate the descriptor through the descriptor-store seam: the Collection
|
|
25
25
|
* Description by default, or any `EncryptionDescriptorStore` -- e.g.
|
|
26
26
|
* `resourceDescriptorStore` for a descriptor hosted as a plain JSON Resource.
|
|
27
|
+
*
|
|
28
|
+
* `x25519RecipientFromDidKey` is the one rule for turning a grantee named only
|
|
29
|
+
* by its Ed25519 `did:key` controller into a `RecipientPublicKey`, so a
|
|
30
|
+
* recipient key is always derived from an identifier both sides already hold
|
|
31
|
+
* rather than transmitted.
|
|
27
32
|
*/
|
|
28
33
|
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
29
34
|
export type { EdvKeys } from './EdvCodec.js';
|
|
30
35
|
export { WasTransport, JOSE_CONTENT_TYPE } from './WasTransport.js';
|
|
31
36
|
export { initRecipients, addRecipient, removeRecipient, replaceRecipient } from './recipients.js';
|
|
32
37
|
export type { OwnerKey, RecipientPublicKey } from './recipients.js';
|
|
38
|
+
export { isEd25519DidKey, x25519RecipientFromDidKey } from './didKeyRecipient.js';
|
|
33
39
|
export { collectionDescriptorStore, resourceDescriptorStore } from './descriptorStore.js';
|
|
34
40
|
export type { EncryptionDescriptorStore } from './descriptorStore.js';
|
|
35
41
|
export { mintEpoch, epochKeyIdFor, unwrapEpochSecret } from './epochCrypto.js';
|
package/dist/edv/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7D,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EACL,eAAe,EACf,yBAAyB,EAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/edv/index.js
CHANGED
|
@@ -24,10 +24,16 @@
|
|
|
24
24
|
* They mutate the descriptor through the descriptor-store seam: the Collection
|
|
25
25
|
* Description by default, or any `EncryptionDescriptorStore` -- e.g.
|
|
26
26
|
* `resourceDescriptorStore` for a descriptor hosted as a plain JSON Resource.
|
|
27
|
+
*
|
|
28
|
+
* `x25519RecipientFromDidKey` is the one rule for turning a grantee named only
|
|
29
|
+
* by its Ed25519 `did:key` controller into a `RecipientPublicKey`, so a
|
|
30
|
+
* recipient key is always derived from an identifier both sides already hold
|
|
31
|
+
* rather than transmitted.
|
|
27
32
|
*/
|
|
28
33
|
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
29
34
|
export { WasTransport, JOSE_CONTENT_TYPE } from './WasTransport.js';
|
|
30
35
|
export { initRecipients, addRecipient, removeRecipient, replaceRecipient } from './recipients.js';
|
|
36
|
+
export { isEd25519DidKey, x25519RecipientFromDidKey } from './didKeyRecipient.js';
|
|
31
37
|
export { collectionDescriptorStore, resourceDescriptorStore } from './descriptorStore.js';
|
|
32
38
|
export { mintEpoch, epochKeyIdFor, unwrapEpochSecret } from './epochCrypto.js';
|
|
33
39
|
export { verifyEpochsMac } from './epochMac.js';
|
package/dist/edv/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,eAAe,EACf,yBAAyB,EAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-client",
|
|
3
3
|
"description": "A developer-friendly client for Wallet Attached Storage (WAS) servers.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@interop/edv-client": "^17.8.0",
|
|
54
54
|
"@interop/ezcap": "^7.4.1",
|
|
55
55
|
"@interop/http-client": "^1.0.4",
|
|
56
|
-
"@interop/minimal-cipher": "^7.8.
|
|
56
|
+
"@interop/minimal-cipher": "^7.8.1",
|
|
57
57
|
"@interop/storage-core": "^0.3.12",
|
|
58
58
|
"@interop/x25519-key-agreement-key": "^5.2.1",
|
|
59
59
|
"@noble/hashes": "^2.2.0",
|