@interop/did-method-webvh 3.1.0 → 3.3.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/CHANGELOG.md +195 -0
- package/README.md +2 -11
- package/dist/assertions.js +19 -2
- package/dist/constants.d.ts +21 -0
- package/dist/constants.js +28 -0
- package/dist/cryptography.d.ts +5 -3
- package/dist/cryptography.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.d.ts +8 -7
- package/dist/method.d.ts +7 -5
- package/dist/method.js +3 -3
- package/dist/method_versions/method.v1.0.d.ts +6 -5
- package/dist/method_versions/method.v1.0.js +296 -133
- package/dist/utils/iso8601-datetime.d.ts +55 -0
- package/dist/utils/iso8601-datetime.js +116 -0
- package/dist/utils/multiformats.d.ts +2 -0
- package/dist/utils/multiformats.js +4 -0
- package/dist/utils.d.ts +15 -2
- package/dist/utils.js +182 -95
- package/dist/witness.js +12 -5
- package/package.json +3 -7
- package/dist/cli.d.ts +0 -21
- package/dist/cli.js +0 -533
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,198 @@
|
|
|
1
|
+
## 3.3.0 - 2026-06-24
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
* `src/utils/iso8601-datetime.ts` with strict, calendar-correct ISO8601
|
|
6
|
+
validation (`ISO8601_DATETIME_REGEX`, `parseUtcIso8601VersionTime`,
|
|
7
|
+
`validateUtcIso8601NotInFuture`, `createNextVersionTime`). `versionTime` values
|
|
8
|
+
must now be UTC (`Z` or `+00:00`) with full calendar correctness (leap years,
|
|
9
|
+
per-month day ranges). Ported from upstream PRs
|
|
10
|
+
[#120](https://github.com/decentralized-identity/didwebvh-ts/pull/120) and
|
|
11
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
12
|
+
* `validateMethodSpecificPathSegments` and `parseDidWebvhIdentifier` (the latter
|
|
13
|
+
returning a structured `{ scid, didDomainComponent, paths, locationKey }`) in
|
|
14
|
+
`src/utils.ts`. Ported from upstream PR
|
|
15
|
+
[#120](https://github.com/decentralized-identity/didwebvh-ts/pull/120).
|
|
16
|
+
* SCID multihash algorithm enforcement: SCIDs must use SHA-256 (multihash code
|
|
17
|
+
`0x12`); other algorithms are rejected in `scidIsFromHash`. Ported from
|
|
18
|
+
upstream PR
|
|
19
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
20
|
+
* `serviceFragmentExists` in `src/utils.ts`, matching both `#files`/`#whois`
|
|
21
|
+
fragment form and the absolute `did:webvh:...#files` form when deciding whether
|
|
22
|
+
to inject implicit services. New method-version constants in
|
|
23
|
+
`src/constants.ts` (`METHOD_VERSION_1_0`, `METHOD_PROTOCOL_V1_0`,
|
|
24
|
+
`METHOD_PARAMETER_KEYS`, `ServiceFragment`, service-type/context/error-type
|
|
25
|
+
constants). Ported from upstream PR
|
|
26
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
27
|
+
* `requestedDid` resolution option: when set, resolution fails unless some log
|
|
28
|
+
version's `state.id` matches it. Threaded through `resolveDID`. Ported from
|
|
29
|
+
upstream PR
|
|
30
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
31
|
+
* `address` and `paths` options on `updateDID` (for parity with `createDID`). A
|
|
32
|
+
portable DID can now move to a new location: the controller is rebuilt from the
|
|
33
|
+
requested `address`/`domain`/`paths` while preserving the SCID. Re-passing a
|
|
34
|
+
bare domain on a pathed DID preserves the prior paths instead of dropping them.
|
|
35
|
+
Ported from upstream PR
|
|
36
|
+
[#127](https://github.com/decentralized-identity/didwebvh-ts/pull/127).
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
* Ported straggling runtime type-safety hardening from upstream to `src/utils.ts`:
|
|
41
|
+
`validateDidKeyMultibase` now extracts the caught error message defensively
|
|
42
|
+
(`error instanceof Error ? error.message : String(error)`); `resolveVM` throws
|
|
43
|
+
a "not found" error when `resolveDIDFromLog` yields no document instead of
|
|
44
|
+
passing it on; `findVerificationMethod` is typed `(doc: DIDDoc, ...)` and guards
|
|
45
|
+
relationship-array entries against non-objects; and `writeVerificationMethodToEnv`
|
|
46
|
+
guards the decoded env payload with `Array.isArray` before reuse.
|
|
47
|
+
* Implicit `#files`/`#whois` services now reference the `SERVICE_TYPE_RELATIVE_REF`,
|
|
48
|
+
`SERVICE_TYPE_LINKED_VP`, and `CONTEXT_LINKED_VP` constants from
|
|
49
|
+
`src/constants.ts` instead of hardcoded string literals, matching upstream.
|
|
50
|
+
* `updateDID` parameter and DID-document handling now match upstream:
|
|
51
|
+
- Sparse updates preserve prior DID document state: the previous entry's
|
|
52
|
+
`state` is carried forward and only the fields an update actually supplies
|
|
53
|
+
(`verificationMethods`, `services`, `authentication`, `assertionMethod`,
|
|
54
|
+
`keyAgreement`, `alsoKnownAs`) are overlaid, instead of rebuilding the
|
|
55
|
+
document from scratch. Ported from upstream
|
|
56
|
+
`keep prior DIDDoc state with sparse updateDID() calls` (commit `1459ed6`).
|
|
57
|
+
- `updateKeys` is omitted from an update entry's `parameters` when unchanged
|
|
58
|
+
and not under active pre-rotation (and inherited from the prior entry while
|
|
59
|
+
pre-rotation is active), rather than always being written; resolution tracks
|
|
60
|
+
it via the presence of the key. `nextKeyHashes` is likewise only written
|
|
61
|
+
when explicitly supplied, so an omitted value inherits the prior
|
|
62
|
+
pre-rotation state. Ported from upstream `track updateKeys` (commit
|
|
63
|
+
`5bc85bf`).
|
|
64
|
+
- Pre-rotation key commitment is now enforced at write time: `updateDID`
|
|
65
|
+
rejects an omitted `updateKeys` while pre-rotation is active
|
|
66
|
+
(`updateKeys must be provided while pre-rotation is active`) and rejects
|
|
67
|
+
update keys not committed in the prior entry's `nextKeyHashes`
|
|
68
|
+
(`Invalid update key`) before the entry is produced, in addition to the
|
|
69
|
+
existing read-time check. Ported from upstream
|
|
70
|
+
`enforce pre-rotation key commitment` (commit `b40eb06`).
|
|
71
|
+
* Type-safety hardening across the public surface (no behavior change). `Signer`
|
|
72
|
+
and `SigningInput` are now generic over a `SignableDocument` union;
|
|
73
|
+
`createDocumentSigner` is generic and returns `TDocument & { proof }`;
|
|
74
|
+
`VerificationMethod.publicKeyJwk` is typed `JsonObject` and
|
|
75
|
+
`ServiceEndpoint.serviceEndpoint` is typed with `JsonValue` instead of `any`.
|
|
76
|
+
`catch (e: any)` blocks now use `e instanceof Error` narrowing. `updateDID`
|
|
77
|
+
service params are typed `ServiceEndpoint[]`. The CLI gains
|
|
78
|
+
`requirePublicKeyMultibase`/`parseExplicitPaths` helpers, typed
|
|
79
|
+
`resolutionOptions`/`envVMs`, and honors `--update-key` when selecting the
|
|
80
|
+
signing verification method. Ported from upstream PR
|
|
81
|
+
[#119](https://github.com/decentralized-identity/didwebvh-ts/pull/119).
|
|
82
|
+
* `updateDID` now rejects `portable: true` in an update entry (portability can
|
|
83
|
+
only be enabled in the first entry) and refuses to move a DID whose
|
|
84
|
+
portability is disabled (`Cannot move DID: portability is disabled`).
|
|
85
|
+
`portable: false` in an update is permitted and permanently locks portability
|
|
86
|
+
off. `verificationMethod` is included in the historical-selector determination
|
|
87
|
+
so a requested-but-absent VM resolves to the last valid document plus an error
|
|
88
|
+
rather than `null`. Ported from upstream PR
|
|
89
|
+
[#129](https://github.com/decentralized-identity/didwebvh-ts/pull/129).
|
|
90
|
+
|
|
91
|
+
* **Breaking:** `resolveDIDFromLog` now returns `doc: DIDDoc | null`. A
|
|
92
|
+
deactivated DID resolved without an explicit historical selector returns
|
|
93
|
+
`doc: null`, and an explicit selector (`versionNumber` / `versionId` /
|
|
94
|
+
`versionTime` / `verificationMethod`) that matches no entry returns
|
|
95
|
+
`doc: null` with a `NotFound` error rather than falling back to the last valid
|
|
96
|
+
document. Ported from upstream PR
|
|
97
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
98
|
+
* resolution enforces strict `versionId` structure (`parseAndValidateVersionId`:
|
|
99
|
+
exactly one `-`, numeric version prefix, non-empty hash, version equal to the
|
|
100
|
+
entry index + 1) and stricter method-parameter rules for entries after the
|
|
101
|
+
first: `scid` must not reappear, `method` must not change away from
|
|
102
|
+
`did:webvh:1.0`, `portable: true` may only be enabled in the first entry, and
|
|
103
|
+
`portable: false` permanently locks portability off. Each entry's `state.id`
|
|
104
|
+
SCID must match the log's SCID. Ported from upstream PR
|
|
105
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
106
|
+
* `did:key` verification-method parsing now rejects a fragment that does not
|
|
107
|
+
equal the key multibase. Ported from upstream PR
|
|
108
|
+
[#121](https://github.com/decentralized-identity/didwebvh-ts/pull/121).
|
|
109
|
+
* witness-parameter validation now rejects any witness `did:key` whose multikey
|
|
110
|
+
is not Ed25519 (multicodec `0xed01`), per did:webvh v1.0. Ported from upstream
|
|
111
|
+
PR [#120](https://github.com/decentralized-identity/didwebvh-ts/pull/120).
|
|
112
|
+
|
|
113
|
+
* resolution now enforces `versionTime` on every log entry: it is **required**
|
|
114
|
+
(a log entry missing `versionTime` is rejected), must be **strictly
|
|
115
|
+
increasing** across entries (reordering defense), and must not be more than 5
|
|
116
|
+
minutes in the future (clock-skew tolerance).
|
|
117
|
+
* address / host / path-segment parsing is hardened against path-traversal and
|
|
118
|
+
injection: `parseCanonicalAddress` (and therefore `createDID` path handling)
|
|
119
|
+
now rejects `.`/`..` dot-segments, decoded `/`/`\`/NUL within a single path
|
|
120
|
+
segment, leading/trailing whitespace, malformed percent-encoding, and `?`/`#`
|
|
121
|
+
query/fragment components in address, DID-domain, and path contexts. Pre-encoded
|
|
122
|
+
`%3a` port separators are accepted case-insensitively. The fork's
|
|
123
|
+
`http://localhost` affordance for local testing is preserved (upstream enforces
|
|
124
|
+
HTTPS-only).
|
|
125
|
+
* `createDID` / `updateDID` validate any caller-supplied `created` / `updated`
|
|
126
|
+
timestamp is not in the future, and `updateDID` / `deactivateDID` now derive a
|
|
127
|
+
strictly monotonic `versionTime` via `createNextVersionTime`.
|
|
128
|
+
* `createDate()` now emits full millisecond precision (`toISOString()`) instead
|
|
129
|
+
of truncating to whole seconds, so consecutive entries generated in the same
|
|
130
|
+
second remain strictly increasing.
|
|
131
|
+
|
|
132
|
+
### Removed
|
|
133
|
+
|
|
134
|
+
* **Breaking:** the standalone CLI (`src/cli.ts`, the `didwebvh` `bin`, the `cli`
|
|
135
|
+
npm script, and `test/cli-e2e.test.ts`). CLI workflows now live in the separate
|
|
136
|
+
`did-cli-typescript` project, which consumes this library's public API. As a
|
|
137
|
+
result `@stablelib/ed25519` -- previously a runtime dependency only because the
|
|
138
|
+
unbundled CLI imported it -- moved to `devDependencies`, shrinking the published
|
|
139
|
+
package's runtime closure to `@noble/hashes` and `json-canonicalize`.
|
|
140
|
+
* **Breaking:** the non-normative `fastResolve` resolution option. The spec
|
|
141
|
+
mandates full verification of every log entry, so resolution always verifies
|
|
142
|
+
every entry's proof; there is no opt-in fast path. Ported from upstream PR
|
|
143
|
+
[#120](https://github.com/decentralized-identity/didwebvh-ts/pull/120).
|
|
144
|
+
|
|
145
|
+
### Tests
|
|
146
|
+
|
|
147
|
+
* Backfilled `method.v1.0` coverage: `updateDID` with explicit
|
|
148
|
+
`assertionMethod`/`keyAgreement` options (`happy-path`), resolution of a log
|
|
149
|
+
using the legacy `witnesses`/`witnessThreshold` parameter format
|
|
150
|
+
(`witness`), and error-case coverage in `not-so-happy-path` (missing
|
|
151
|
+
`updateKeys`, missing `address`/`domain`, missing `verificationMethods`,
|
|
152
|
+
out-of-order version number, missing/non-monotonic `versionTime`, mismatched
|
|
153
|
+
`scid` option, matching `requestedDid`, and update/deactivate of an
|
|
154
|
+
already-deactivated DID). `resolve` now asserts a non-existent
|
|
155
|
+
`verificationMethod` resolves to `doc: null` with a `NotFound` error, and
|
|
156
|
+
`watchers` asserts the cleared-watchers (`[]`) shape. Ported from upstream PRs
|
|
157
|
+
[#129](https://github.com/decentralized-identity/didwebvh-ts/pull/129) and
|
|
158
|
+
[#131](https://github.com/decentralized-identity/didwebvh-ts/pull/131).
|
|
159
|
+
* Further backfilled `method.v1.0` coverage against upstream's
|
|
160
|
+
`enhance test coverage of method.v1.0` change: `versionTime` clock-skew
|
|
161
|
+
tolerance (accepts up to, rejects beyond, 5 minutes in the future, via a new
|
|
162
|
+
`createFutureDIDLog` test helper), `versionId` structural validation
|
|
163
|
+
(missing/multiple `-` separators, empty hash component), rejection of unknown,
|
|
164
|
+
downgraded, or `scid`-bearing `method`/parameters in later entries, rejection
|
|
165
|
+
of a non-SHA-256 SCID multihash, `requestedDid` mismatch and not-present
|
|
166
|
+
cases, the empty-log "no entries to process" case, and historical
|
|
167
|
+
`versionId`/`versionTime` selectors that stay successful when a later entry is
|
|
168
|
+
corrupted (`not-so-happy-path`); explicit `versionId`/`versionTime` misses
|
|
169
|
+
returning `NotFound` without a latest fallback, explicit empty
|
|
170
|
+
`nextKeyHashes` disabling pre-rotation, and absolute service IDs preventing
|
|
171
|
+
implicit `#files` duplication (`features`); the `did:key` verificationMethod
|
|
172
|
+
fragment-mismatch rejection (`witness`); rejection of a pass-through
|
|
173
|
+
`didDocument` whose substituted id does not match the created DID
|
|
174
|
+
(`did-document-passthrough`); and rejection of DID identifiers containing
|
|
175
|
+
fragment/query contamination or traversal-style path segments (`resolve`).
|
|
176
|
+
* Coverage for the `updateDID` behavior changes above (see _Changed_): sparse
|
|
177
|
+
updates preserving prior `alsoKnownAs`/`service` state and omitted
|
|
178
|
+
`updateKeys` staying omitted from update parameters (`happy-path`); omitted
|
|
179
|
+
`nextKeyHashes` inheriting prior pre-rotation state and omitted `updateKeys`
|
|
180
|
+
being rejected while pre-rotation is active (`features`). The existing
|
|
181
|
+
pre-rotation tests were updated for write-time enforcement: `updateKeys MUST
|
|
182
|
+
be in previous nextKeyHashes when updating` now asserts `updateDID` itself
|
|
183
|
+
rejects, `updateKeys MUST be in nextKeyHashes when reading` hand-builds the
|
|
184
|
+
offending entry to still exercise the read-time check, and the now-redundant
|
|
185
|
+
`Require nextKeyHashes to continue if previously set` test was removed.
|
|
186
|
+
|
|
187
|
+
## 3.2.0 - 2026-06-24
|
|
188
|
+
|
|
189
|
+
### Added
|
|
190
|
+
|
|
191
|
+
* export `deriveNextKeyHash` from the package entry, so callers implementing
|
|
192
|
+
key pre-rotation can compute the committed `nextKeyHashes` value
|
|
193
|
+
(`base58btc(multihash_sha2_256(sha256(utf8Bytes(publicKeyMultibase))))`)
|
|
194
|
+
without reaching into internal module paths.
|
|
195
|
+
|
|
1
196
|
## 3.1.0 - 2026-06-15
|
|
2
197
|
|
|
3
198
|
### Added
|
package/README.md
CHANGED
|
@@ -98,22 +98,13 @@ This command runs: `tsx watch examples/express-resolver.ts`
|
|
|
98
98
|
npm run test:log
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
5. `
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
npm run cli
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
The CLI accepts a `--watcher` option during create and update operations to
|
|
108
|
-
specify one or more watcher URLs.
|
|
109
|
-
|
|
110
|
-
6. `build`: Build the package.
|
|
101
|
+
5. `build`: Build the package.
|
|
111
102
|
|
|
112
103
|
```bash
|
|
113
104
|
npm run build
|
|
114
105
|
```
|
|
115
106
|
|
|
116
|
-
|
|
107
|
+
6. `build:clean`: Clean the build directory.
|
|
117
108
|
|
|
118
109
|
```bash
|
|
119
110
|
npm run build:clean
|
package/dist/assertions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { concatBuffers } from './utils/buffer.js';
|
|
2
2
|
import { canonicalizeStrict } from './utils/canonicalize.js';
|
|
3
3
|
import { createHash } from './utils/crypto.js';
|
|
4
|
-
import { multibaseDecode } from './utils/multiformats.js';
|
|
4
|
+
import { decodeBase58Btc, decodeMultihash, isEd25519Multikey, MultihashAlgorithm, multibaseDecode, } from './utils/multiformats.js';
|
|
5
5
|
import { createSCID, deriveNextKeyHash, parseDidKeyVerificationMethod, resolveVM } from './utils.js';
|
|
6
6
|
import { validateWitnessParameter } from './witness.js';
|
|
7
7
|
const isKeyAuthorized = (verificationMethod, updateKeys) => {
|
|
@@ -48,7 +48,7 @@ export const documentStateIsValid = async (doc, updateKeys, witness, skipWitness
|
|
|
48
48
|
throw new Error(`Verification Method ${proof.verificationMethod} not found`);
|
|
49
49
|
}
|
|
50
50
|
const publicKey = multibaseDecode(vm.publicKeyMultibase).bytes;
|
|
51
|
-
if (publicKey
|
|
51
|
+
if (!isEd25519Multikey(publicKey)) {
|
|
52
52
|
throw new Error(`multiKey doesn't include ed25519 header (0xed01)`);
|
|
53
53
|
}
|
|
54
54
|
const { proofValue, ...restProof } = proof;
|
|
@@ -77,6 +77,23 @@ export const newKeysAreInNextKeys = async (updateKeys, previousNextKeyHashes) =>
|
|
|
77
77
|
}
|
|
78
78
|
return true;
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Validate that SCID uses SHA-256 (0x12) multihash algorithm.
|
|
82
|
+
* Per spec: "SHA-256 [[spec:rfc6234]] (multihash code `0x12`) **only**"
|
|
83
|
+
*/
|
|
84
|
+
const validateScidAlgorithmIsSha256 = (scid) => {
|
|
85
|
+
let algorithm;
|
|
86
|
+
try {
|
|
87
|
+
algorithm = decodeMultihash(decodeBase58Btc(scid)).algorithm;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new Error(`Invalid SCID format: ${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
+
}
|
|
92
|
+
if (algorithm !== MultihashAlgorithm.SHA2_256) {
|
|
93
|
+
throw new Error(`SCID multihash algorithm must be SHA-256 (0x12), but got 0x${algorithm.toString(16)}`);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
80
96
|
export const scidIsFromHash = async (scid, hash) => {
|
|
97
|
+
validateScidAlgorithmIsSha256(scid);
|
|
81
98
|
return scid === (await createSCID(hash));
|
|
82
99
|
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
export declare const PLACEHOLDER = "{SCID}";
|
|
2
2
|
export declare const METHOD = "webvh";
|
|
3
3
|
export declare const BASE_CONTEXT: string[];
|
|
4
|
+
export declare const METHOD_VERSION_1_0 = "1.0";
|
|
5
|
+
export declare const METHOD_PROTOCOL_V1_0 = "did:webvh:1.0";
|
|
6
|
+
export declare const METHOD_PARAMETER_KEYS: {
|
|
7
|
+
readonly scid: "scid";
|
|
8
|
+
readonly method: "method";
|
|
9
|
+
readonly portable: "portable";
|
|
10
|
+
readonly updateKeys: "updateKeys";
|
|
11
|
+
readonly nextKeyHashes: "nextKeyHashes";
|
|
12
|
+
readonly witness: "witness";
|
|
13
|
+
readonly watchers: "watchers";
|
|
14
|
+
readonly ttl: "ttl";
|
|
15
|
+
};
|
|
16
|
+
export declare enum ServiceFragment {
|
|
17
|
+
Files = "files",
|
|
18
|
+
Whois = "whois"
|
|
19
|
+
}
|
|
20
|
+
export declare const SERVICE_TYPE_RELATIVE_REF = "relativeRef";
|
|
21
|
+
export declare const SERVICE_TYPE_LINKED_VP = "LinkedVerifiablePresentation";
|
|
22
|
+
export declare const CONTEXT_LINKED_VP = "https://identity.foundation/linked-vp/contexts/v1";
|
|
23
|
+
export declare const ERROR_TYPE_INVALID_DID = "https://w3id.org/security#INVALID_CONTROLLED_IDENTIFIER_DOCUMENT_ID";
|
|
24
|
+
export declare const ERROR_TYPE_NOT_FOUND = "https://w3id.org/security#NOT_FOUND";
|
package/dist/constants.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
1
|
export const PLACEHOLDER = '{SCID}';
|
|
2
2
|
export const METHOD = 'webvh';
|
|
3
3
|
export const BASE_CONTEXT = ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/multikey/v1'];
|
|
4
|
+
// Version 1.0 method constants
|
|
5
|
+
export const METHOD_VERSION_1_0 = '1.0';
|
|
6
|
+
export const METHOD_PROTOCOL_V1_0 = `did:${METHOD}:${METHOD_VERSION_1_0}`;
|
|
7
|
+
// Method parameter keys
|
|
8
|
+
export const METHOD_PARAMETER_KEYS = {
|
|
9
|
+
scid: 'scid',
|
|
10
|
+
method: 'method',
|
|
11
|
+
portable: 'portable',
|
|
12
|
+
updateKeys: 'updateKeys',
|
|
13
|
+
nextKeyHashes: 'nextKeyHashes',
|
|
14
|
+
witness: 'witness',
|
|
15
|
+
watchers: 'watchers',
|
|
16
|
+
ttl: 'ttl',
|
|
17
|
+
};
|
|
18
|
+
// Service fragments for implicit services
|
|
19
|
+
export var ServiceFragment;
|
|
20
|
+
(function (ServiceFragment) {
|
|
21
|
+
ServiceFragment["Files"] = "files";
|
|
22
|
+
ServiceFragment["Whois"] = "whois";
|
|
23
|
+
})(ServiceFragment || (ServiceFragment = {}));
|
|
24
|
+
// Service type constants
|
|
25
|
+
export const SERVICE_TYPE_RELATIVE_REF = 'relativeRef';
|
|
26
|
+
export const SERVICE_TYPE_LINKED_VP = 'LinkedVerifiablePresentation';
|
|
27
|
+
// Context URLs
|
|
28
|
+
export const CONTEXT_LINKED_VP = 'https://identity.foundation/linked-vp/contexts/v1';
|
|
29
|
+
// Error type URLs
|
|
30
|
+
export const ERROR_TYPE_INVALID_DID = 'https://w3id.org/security#INVALID_CONTROLLED_IDENTIFIER_DOCUMENT_ID';
|
|
31
|
+
export const ERROR_TYPE_NOT_FOUND = 'https://w3id.org/security#NOT_FOUND';
|
package/dist/cryptography.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataIntegrityProofTemplate, Signer, SignerOptions, SigningInput, SigningOutput, VerificationMethod, Verifier } from './interfaces.js';
|
|
1
|
+
import type { DataIntegrityProof, DataIntegrityProofTemplate, SignableDocument, Signer, SignerOptions, SigningInput, SigningOutput, VerificationMethod, Verifier } from './interfaces.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a proof object for a document
|
|
4
4
|
* @param verificationMethodId - The verification method ID to use in the proof
|
|
@@ -45,8 +45,10 @@ export declare abstract class AbstractCrypto implements Signer, Verifier {
|
|
|
45
45
|
* @param verificationMethodId - The verification method ID to use in proofs
|
|
46
46
|
* @returns A function that signs a document and returns the document with proof
|
|
47
47
|
*/
|
|
48
|
-
export declare const createDocumentSigner: (signer: Signer
|
|
48
|
+
export declare const createDocumentSigner: <TDocument extends SignableDocument>(signer: Signer<TDocument>, verificationMethodId: string) => (doc: TDocument) => Promise<TDocument & {
|
|
49
|
+
proof: DataIntegrityProof;
|
|
50
|
+
}>;
|
|
49
51
|
/**
|
|
50
52
|
* @deprecated Use createDocumentSigner with your own Signer implementation instead
|
|
51
53
|
*/
|
|
52
|
-
export declare const createSigner: (vm: VerificationMethod, useStatic?: boolean) => (doc:
|
|
54
|
+
export declare const createSigner: (vm: VerificationMethod, useStatic?: boolean) => (doc: SignableDocument) => Promise<never>;
|
package/dist/cryptography.js
CHANGED
|
@@ -68,7 +68,8 @@ export const createDocumentSigner = (signer, verificationMethodId) => {
|
|
|
68
68
|
}
|
|
69
69
|
catch (e) {
|
|
70
70
|
console.error(e);
|
|
71
|
-
|
|
71
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
72
|
+
throw new Error(`Document signing failure: ${message}`);
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
};
|
|
@@ -89,7 +90,8 @@ export const createSigner = (vm, useStatic = true) => {
|
|
|
89
90
|
}
|
|
90
91
|
catch (e) {
|
|
91
92
|
console.error(e);
|
|
92
|
-
|
|
93
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
94
|
+
throw new Error(`Document signing failure: ${message}`);
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
97
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { AbstractCrypto, createDocumentSigner, createProof, createSigner, prepar
|
|
|
2
2
|
export * from './interfaces.js';
|
|
3
3
|
export { createDID, deactivateDID, resolveDID, resolveDIDFromLog, updateDID } from './method.js';
|
|
4
4
|
export { MultibaseEncoding, multibaseDecode, multibaseEncode } from './utils/multiformats.js';
|
|
5
|
-
export { createVMID, DID_PLACEHOLDER, generateParallelDidWeb, parseDidKeyDid, parseDidKeyVerificationMethod, } from './utils.js';
|
|
5
|
+
export { createVMID, DID_PLACEHOLDER, deriveNextKeyHash, generateParallelDidWeb, parseDidKeyDid, parseDidKeyVerificationMethod, } from './utils.js';
|
|
6
6
|
export { createWitnessProof, signWitnessProofEntries, signWitnessProofEntry, } from './witness.js';
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,5 @@ export { AbstractCrypto, createDocumentSigner, createProof, createSigner, prepar
|
|
|
2
2
|
export * from './interfaces.js';
|
|
3
3
|
export { createDID, deactivateDID, resolveDID, resolveDIDFromLog, updateDID } from './method.js';
|
|
4
4
|
export { MultibaseEncoding, multibaseDecode, multibaseEncode } from './utils/multiformats.js';
|
|
5
|
-
export { createVMID, DID_PLACEHOLDER, generateParallelDidWeb, parseDidKeyDid, parseDidKeyVerificationMethod, } from './utils.js';
|
|
5
|
+
export { createVMID, DID_PLACEHOLDER, deriveNextKeyHash, generateParallelDidWeb, parseDidKeyDid, parseDidKeyVerificationMethod, } from './utils.js';
|
|
6
6
|
export { createWitnessProof, signWitnessProofEntries, signWitnessProofEntry, } from './witness.js';
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -14,15 +14,16 @@ export interface DataIntegrityProofTemplate {
|
|
|
14
14
|
created: string;
|
|
15
15
|
proofPurpose: DataIntegrityProofPurpose;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
17
|
+
export type SignableDocument = DIDLogEntry | DIDDoc | Pick<DIDLogEntry, 'versionId'>;
|
|
18
|
+
export interface SigningInput<TDocument = SignableDocument> {
|
|
19
|
+
document: TDocument;
|
|
19
20
|
proof: DataIntegrityProofTemplate;
|
|
20
21
|
}
|
|
21
22
|
export interface SigningOutput {
|
|
22
23
|
proofValue: string;
|
|
23
24
|
}
|
|
24
|
-
export interface Signer {
|
|
25
|
-
sign(input: SigningInput): Promise<SigningOutput>;
|
|
25
|
+
export interface Signer<TDocument = SignableDocument> {
|
|
26
|
+
sign(input: SigningInput<TDocument>): Promise<SigningOutput>;
|
|
26
27
|
getVerificationMethodId(): string;
|
|
27
28
|
}
|
|
28
29
|
export interface Verifier {
|
|
@@ -90,7 +91,7 @@ export interface VerificationMethod {
|
|
|
90
91
|
publicKeyMultibase?: string;
|
|
91
92
|
secretKeyMultibase?: string;
|
|
92
93
|
purpose?: DataIntegrityProofPurpose | DataIntegrityProofPurpose[];
|
|
93
|
-
publicKeyJwk?:
|
|
94
|
+
publicKeyJwk?: JsonObject;
|
|
94
95
|
use?: string;
|
|
95
96
|
}
|
|
96
97
|
export interface WitnessEntry {
|
|
@@ -148,7 +149,7 @@ export type DIDLog = DIDLogEntry[];
|
|
|
148
149
|
export interface ServiceEndpoint {
|
|
149
150
|
id?: string;
|
|
150
151
|
type: string | string[];
|
|
151
|
-
serviceEndpoint?: string | string[] |
|
|
152
|
+
serviceEndpoint?: string | string[] | JsonValue;
|
|
152
153
|
[key: string]: unknown;
|
|
153
154
|
}
|
|
154
155
|
export interface CreateDIDResult {
|
|
@@ -227,7 +228,7 @@ export interface ResolutionOptions {
|
|
|
227
228
|
verificationMethod?: string;
|
|
228
229
|
verifier?: Verifier;
|
|
229
230
|
scid?: string;
|
|
230
|
-
|
|
231
|
+
requestedDid?: string;
|
|
231
232
|
}
|
|
232
233
|
export interface WitnessProofFileEntry {
|
|
233
234
|
versionId: string;
|
package/dist/method.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateDIDInterface, CreateDIDResult, DeactivateDIDInterface, DIDLog, ResolutionOptions, UpdateDIDInterface, UpdateDIDResult, WitnessProofFileEntry } from './interfaces.js';
|
|
1
|
+
import type { CreateDIDInterface, CreateDIDResult, DeactivateDIDInterface, DIDLog, ResolutionOptions, ServiceEndpoint, UpdateDIDInterface, UpdateDIDResult, WitnessProofFileEntry } from './interfaces.js';
|
|
2
2
|
import { DidResolutionError } from './interfaces.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new did:webvh DID and initial DID log.
|
|
@@ -18,7 +18,7 @@ export declare const resolveDID: (did: string, options?: ResolutionOptions & {
|
|
|
18
18
|
witnessProofs?: WitnessProofFileEntry[];
|
|
19
19
|
}) => Promise<{
|
|
20
20
|
did: string;
|
|
21
|
-
doc:
|
|
21
|
+
doc: import("./interfaces.js").DIDDoc | null;
|
|
22
22
|
meta: import("./interfaces.js").DIDResolutionMeta;
|
|
23
23
|
} | {
|
|
24
24
|
did: string;
|
|
@@ -43,7 +43,7 @@ export declare const resolveDIDFromLog: (log: DIDLog, options?: ResolutionOption
|
|
|
43
43
|
witnessProofs?: WitnessProofFileEntry[];
|
|
44
44
|
}) => Promise<{
|
|
45
45
|
did: string;
|
|
46
|
-
doc:
|
|
46
|
+
doc: import("./interfaces.js").DIDDoc | null;
|
|
47
47
|
meta: import("./interfaces.js").DIDResolutionMeta;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
@@ -53,8 +53,10 @@ export declare const resolveDIDFromLog: (log: DIDLog, options?: ResolutionOption
|
|
|
53
53
|
* @returns The updated DID, resolved document, and DID log.
|
|
54
54
|
*/
|
|
55
55
|
export declare const updateDID: (options: UpdateDIDInterface & {
|
|
56
|
-
services?:
|
|
56
|
+
services?: ServiceEndpoint[];
|
|
57
57
|
domain?: string;
|
|
58
|
+
address?: string;
|
|
59
|
+
paths?: string[];
|
|
58
60
|
updated?: string;
|
|
59
61
|
}) => Promise<UpdateDIDResult>;
|
|
60
62
|
/**
|
|
@@ -67,7 +69,7 @@ export declare const deactivateDID: (options: DeactivateDIDInterface & {
|
|
|
67
69
|
updateKeys?: string[];
|
|
68
70
|
}) => Promise<{
|
|
69
71
|
did: string;
|
|
70
|
-
doc:
|
|
72
|
+
doc: import("./interfaces.js").DIDDoc;
|
|
71
73
|
meta: import("./interfaces.js").DIDResolutionMeta;
|
|
72
74
|
log: DIDLog;
|
|
73
75
|
}>;
|
package/dist/method.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { METHOD_PROTOCOL_V1_0 } from './constants.js';
|
|
1
2
|
import { DidResolutionError } from './interfaces.js';
|
|
2
3
|
import * as v1 from './method_versions/method.v1.0.js';
|
|
3
4
|
import { fetchLogFromIdentifier, maybeWriteTestLog } from './utils.js';
|
|
4
|
-
const SUPPORTED_METHOD = 'did:webvh:1.0';
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new did:webvh DID and initial DID log.
|
|
7
7
|
*
|
|
@@ -10,7 +10,7 @@ const SUPPORTED_METHOD = 'did:webvh:1.0';
|
|
|
10
10
|
*/
|
|
11
11
|
export const createDID = async (options) => {
|
|
12
12
|
const method = options.method;
|
|
13
|
-
if (method && method !==
|
|
13
|
+
if (method && method !== METHOD_PROTOCOL_V1_0) {
|
|
14
14
|
throw new Error(`'${method}' is not a supported method version.`);
|
|
15
15
|
}
|
|
16
16
|
const result = await v1.createDID(options);
|
|
@@ -31,7 +31,7 @@ export const resolveDID = async (did, options = {}) => {
|
|
|
31
31
|
const scid = didParts.length > 2 && didParts[0] === 'did' && didParts[1] === 'webvh' ? didParts[2] : undefined;
|
|
32
32
|
try {
|
|
33
33
|
const log = await fetchLogFromIdentifier(did);
|
|
34
|
-
const result = await v1.resolveDIDFromLog(log, { ...options, scid });
|
|
34
|
+
const result = await v1.resolveDIDFromLog(log, { ...options, scid, requestedDid: did });
|
|
35
35
|
maybeWriteTestLog(result.did, log);
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type { CreateDIDInterface, CreateDIDResult, DeactivateDIDInterface, DIDLog, DIDResolutionMeta, ResolutionOptions, UpdateDIDInterface, UpdateDIDResult, WitnessProofFileEntry } from '../interfaces.js';
|
|
1
|
+
import type { CreateDIDInterface, CreateDIDResult, DeactivateDIDInterface, DIDDoc, DIDLog, DIDResolutionMeta, ResolutionOptions, ServiceEndpoint, UpdateDIDInterface, UpdateDIDResult, WitnessProofFileEntry } from '../interfaces.js';
|
|
2
2
|
export declare const createDID: (options: CreateDIDInterface) => Promise<CreateDIDResult>;
|
|
3
3
|
export declare const resolveDIDFromLog: (log: DIDLog, options?: ResolutionOptions & {
|
|
4
4
|
witnessProofs?: WitnessProofFileEntry[];
|
|
5
|
-
fastResolve?: boolean;
|
|
6
5
|
}) => Promise<{
|
|
7
6
|
did: string;
|
|
8
|
-
doc:
|
|
7
|
+
doc: DIDDoc | null;
|
|
9
8
|
meta: DIDResolutionMeta;
|
|
10
9
|
}>;
|
|
11
10
|
export declare const updateDID: (options: UpdateDIDInterface & {
|
|
12
|
-
services?:
|
|
11
|
+
services?: ServiceEndpoint[];
|
|
13
12
|
domain?: string;
|
|
13
|
+
address?: string;
|
|
14
|
+
paths?: string[];
|
|
14
15
|
updated?: string;
|
|
15
16
|
}) => Promise<UpdateDIDResult>;
|
|
16
17
|
export declare const deactivateDID: (options: DeactivateDIDInterface & {
|
|
17
18
|
updateKeys?: string[];
|
|
18
19
|
}) => Promise<{
|
|
19
20
|
did: string;
|
|
20
|
-
doc:
|
|
21
|
+
doc: DIDDoc;
|
|
21
22
|
meta: DIDResolutionMeta;
|
|
22
23
|
log: DIDLog;
|
|
23
24
|
}>;
|