@midnight-ntwrk/midnight-did-api 0.5.0-rc1 → 0.5.0-rc2
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/README.md +43 -2
- package/dist/config-profiles.d.ts +6 -6
- package/dist/config-profiles.js +6 -6
- package/dist/controller-authorization.d.ts +9 -0
- package/dist/controller-authorization.js +20 -0
- package/dist/controller-authorization.js.map +1 -0
- package/dist/controller-operations.js +4 -2
- package/dist/controller-operations.js.map +1 -1
- package/dist/document-operations.d.ts +4 -4
- package/dist/document-operations.js +10 -6
- package/dist/document-operations.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/release-artifacts.d.ts +1 -1
- package/dist/release-artifacts.js +1 -1
- package/dist/release-artifacts.js.map +1 -1
- package/dist/resolution.d.ts +6 -9
- package/dist/resolution.js +17 -33
- package/dist/resolution.js.map +1 -1
- package/dist/service-operations.d.ts +4 -4
- package/dist/service-operations.js +12 -6
- package/dist/service-operations.js.map +1 -1
- package/dist/update.d.ts +1 -1
- package/dist/update.js +1 -1
- package/dist/update.js.map +1 -1
- package/dist/verification-method-operations.d.ts +4 -4
- package/dist/verification-method-operations.js +27 -12
- package/dist/verification-method-operations.js.map +1 -1
- package/dist/verification-method-relations.d.ts +1 -1
- package/dist/verification-method-relations.js +6 -3
- package/dist/verification-method-relations.js.map +1 -1
- package/dist/zk-artifacts.d.ts +91 -0
- package/dist/zk-artifacts.js +402 -0
- package/dist/zk-artifacts.js.map +1 -0
- package/examples/README.md +4 -0
- package/examples/bootstrap-issuer-did.ts +4 -4
- package/examples/update-did.ts +3 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -50,7 +50,8 @@ sequenceDiagram
|
|
|
50
50
|
|
|
51
51
|
Caller->>API: addService / addVerificationMethod / ...
|
|
52
52
|
API->>API: validate + normalize
|
|
53
|
-
API->>
|
|
53
|
+
API->>API: sign controller authorization digest for current contract version
|
|
54
|
+
API->>Contract: submit circuit tx + controller signature
|
|
54
55
|
Contract-->>API: accepted tx
|
|
55
56
|
API->>Indexer: fetch current state
|
|
56
57
|
API-->>Caller: updated DID state or DID Resolution Result
|
|
@@ -62,7 +63,8 @@ API enforces lifecycle rules around:
|
|
|
62
63
|
|
|
63
64
|
- active DID: allows updates
|
|
64
65
|
- deactivated DID: mutating operations rejected
|
|
65
|
-
- controller
|
|
66
|
+
- controller authorization: signs a domain-separated digest containing contract id, current version, operation name, and operation arguments before each controller-gated mutation
|
|
67
|
+
- controller rotation: generates a new wallet-local secret, derives the next controller public key locally, submits the rotation circuit with a current-version controller signature, and stores the new secret after the transaction succeeds
|
|
66
68
|
|
|
67
69
|
(Exact schema/canonicalization rules live in `domain`.)
|
|
68
70
|
|
|
@@ -76,6 +78,14 @@ Successful abstract `resolve` responses must not set
|
|
|
76
78
|
`didResolutionMetadata.contentType`; that field is reserved for
|
|
77
79
|
`resolveRepresentation` responses where the body is a DID Document byte stream.
|
|
78
80
|
|
|
81
|
+
The API package also exports `resolveRepresentation(providers, didContract,
|
|
82
|
+
options)`. It delegates to the shared `MidnightDIDResolver` and returns
|
|
83
|
+
`didDocumentStream` as a `Uint8Array | null` (null on resolution errors),
|
|
84
|
+
`didDocumentMetadata`, and `didResolutionMetadata`. This is the package boundary intended for
|
|
85
|
+
`midnight-did-resolver`: the downstream service owns HTTP routing and status
|
|
86
|
+
codes, while this package owns ledger access, representation selection, and DID
|
|
87
|
+
resolution errors.
|
|
88
|
+
|
|
79
89
|
## Build & Test
|
|
80
90
|
|
|
81
91
|
- Build: `pnpm --filter ./packages/api build`
|
|
@@ -107,6 +117,10 @@ Defaults:
|
|
|
107
117
|
- `MainnetConfig` defaults to local proof server (`http://127.0.0.1:6300`) so it can be used with local proving while targeting mainnet indexer/node.
|
|
108
118
|
- constructing any profile config calls `setNetworkId()` through `applyMidnightNetworkProfile()`, so wallet and contract operations see the correct Midnight network before they start.
|
|
109
119
|
|
|
120
|
+
The docs site publishes the generated endpoint matrix at
|
|
121
|
+
<https://midnightntwrk.github.io/midnight-did/guide/network-endpoints>; it is
|
|
122
|
+
generated from `src/config-profiles.ts` during docs preparation and validation.
|
|
123
|
+
|
|
110
124
|
You can still override `MainnetConfig` endpoints explicitly when needed. New
|
|
111
125
|
tooling should use `ProfileConfig` when the profile name is data-driven rather
|
|
112
126
|
than hard-coded in a class constructor. Every `ProfileConfig` instance exposes
|
|
@@ -152,6 +166,33 @@ CI tooling. RC and final release versions also include
|
|
|
152
166
|
`locations.githubRelease.archiveUrl`; snapshot versions publish workflow
|
|
153
167
|
artifacts and GHCR artifacts only, so `locations.githubRelease` is `null`.
|
|
154
168
|
|
|
169
|
+
Node consumers can download, verify, and unpack GitHub Release assets directly:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import {
|
|
173
|
+
downloadMidnightDidGithubReleaseZkArtifacts,
|
|
174
|
+
MIDNIGHT_DID_API_VERSION,
|
|
175
|
+
} from "@midnight-ntwrk/midnight-did-api";
|
|
176
|
+
|
|
177
|
+
const bundle = await downloadMidnightDidGithubReleaseZkArtifacts({
|
|
178
|
+
version: MIDNIGHT_DID_API_VERSION,
|
|
179
|
+
outputDir: ".midnight-did-zk",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
process.env.MIDNIGHT_DID_ZK_CONFIG_PATH = bundle.zkConfigPath;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`bundle.zkConfigPath` is the directory to pass to `NodeZkConfigProvider` or to
|
|
186
|
+
expose from an HTTP server for `FetchZkConfigProvider`. The helper verifies the
|
|
187
|
+
release `.sha256` file, checks that the downloaded manifest matches the embedded
|
|
188
|
+
archive manifest, and validates every circuit file checksum before returning.
|
|
189
|
+
When `outputDir`, `tempDir`, or `pullDir` are omitted, helper-created
|
|
190
|
+
directories are retained because `bundle.archivePath` and `bundle.zkConfigPath`
|
|
191
|
+
point into them. Callers that need deterministic cleanup should pass explicit
|
|
192
|
+
directories and remove them after the ZK provider no longer needs the files.
|
|
193
|
+
For GHCR OCI artifacts, use `pullMidnightDidGhcrZkArtifacts()` in an environment
|
|
194
|
+
with the `oras` CLI available.
|
|
195
|
+
|
|
155
196
|
When the ZK bundle is unpacked outside the installed package, set
|
|
156
197
|
`MIDNIGHT_DID_ZK_CONFIG_PATH` to the directory containing `manifest.json`,
|
|
157
198
|
`keys/`, and `zkir/` before importing `@midnight-ntwrk/midnight-did-api`.
|
|
@@ -16,8 +16,8 @@ export declare const MIDNIGHT_NETWORK_PROFILES: {
|
|
|
16
16
|
readonly name: "testnet-local";
|
|
17
17
|
readonly networkId: "testnet";
|
|
18
18
|
readonly endpoints: {
|
|
19
|
-
readonly indexer: "http://127.0.0.1:8088/api/
|
|
20
|
-
readonly indexerWS: "ws://127.0.0.1:8088/api/
|
|
19
|
+
readonly indexer: "http://127.0.0.1:8088/api/v4/graphql";
|
|
20
|
+
readonly indexerWS: "ws://127.0.0.1:8088/api/v4/graphql/ws";
|
|
21
21
|
readonly node: "http://127.0.0.1:9944";
|
|
22
22
|
readonly proofServer: "http://127.0.0.1:6300";
|
|
23
23
|
};
|
|
@@ -26,8 +26,8 @@ export declare const MIDNIGHT_NETWORK_PROFILES: {
|
|
|
26
26
|
readonly name: "standalone";
|
|
27
27
|
readonly networkId: "undeployed";
|
|
28
28
|
readonly endpoints: {
|
|
29
|
-
readonly indexer: "http://127.0.0.1:8088/api/
|
|
30
|
-
readonly indexerWS: "ws://127.0.0.1:8088/api/
|
|
29
|
+
readonly indexer: "http://127.0.0.1:8088/api/v4/graphql";
|
|
30
|
+
readonly indexerWS: "ws://127.0.0.1:8088/api/v4/graphql/ws";
|
|
31
31
|
readonly node: "http://127.0.0.1:9944";
|
|
32
32
|
readonly proofServer: "http://127.0.0.1:6300";
|
|
33
33
|
};
|
|
@@ -36,8 +36,8 @@ export declare const MIDNIGHT_NETWORK_PROFILES: {
|
|
|
36
36
|
readonly name: "testnet-remote";
|
|
37
37
|
readonly networkId: "testnet";
|
|
38
38
|
readonly endpoints: {
|
|
39
|
-
readonly indexer: "https://indexer.testnet-02.midnight.network/api/
|
|
40
|
-
readonly indexerWS: "wss://indexer.testnet-02.midnight.network/api/
|
|
39
|
+
readonly indexer: "https://indexer.testnet-02.midnight.network/api/v4/graphql";
|
|
40
|
+
readonly indexerWS: "wss://indexer.testnet-02.midnight.network/api/v4/graphql/ws";
|
|
41
41
|
readonly node: "https://rpc.testnet-02.midnight.network";
|
|
42
42
|
readonly proofServer: "http://127.0.0.1:6300";
|
|
43
43
|
};
|
package/dist/config-profiles.js
CHANGED
|
@@ -5,8 +5,8 @@ export const MIDNIGHT_NETWORK_PROFILES = {
|
|
|
5
5
|
name: "testnet-local",
|
|
6
6
|
networkId: "testnet",
|
|
7
7
|
endpoints: {
|
|
8
|
-
indexer: "http://127.0.0.1:8088/api/
|
|
9
|
-
indexerWS: "ws://127.0.0.1:8088/api/
|
|
8
|
+
indexer: "http://127.0.0.1:8088/api/v4/graphql",
|
|
9
|
+
indexerWS: "ws://127.0.0.1:8088/api/v4/graphql/ws",
|
|
10
10
|
node: "http://127.0.0.1:9944",
|
|
11
11
|
proofServer: "http://127.0.0.1:6300",
|
|
12
12
|
},
|
|
@@ -15,8 +15,8 @@ export const MIDNIGHT_NETWORK_PROFILES = {
|
|
|
15
15
|
name: "standalone",
|
|
16
16
|
networkId: "undeployed",
|
|
17
17
|
endpoints: {
|
|
18
|
-
indexer: "http://127.0.0.1:8088/api/
|
|
19
|
-
indexerWS: "ws://127.0.0.1:8088/api/
|
|
18
|
+
indexer: "http://127.0.0.1:8088/api/v4/graphql",
|
|
19
|
+
indexerWS: "ws://127.0.0.1:8088/api/v4/graphql/ws",
|
|
20
20
|
node: "http://127.0.0.1:9944",
|
|
21
21
|
proofServer: "http://127.0.0.1:6300",
|
|
22
22
|
},
|
|
@@ -25,8 +25,8 @@ export const MIDNIGHT_NETWORK_PROFILES = {
|
|
|
25
25
|
name: "testnet-remote",
|
|
26
26
|
networkId: "testnet",
|
|
27
27
|
endpoints: {
|
|
28
|
-
indexer: "https://indexer.testnet-02.midnight.network/api/
|
|
29
|
-
indexerWS: "wss://indexer.testnet-02.midnight.network/api/
|
|
28
|
+
indexer: "https://indexer.testnet-02.midnight.network/api/v4/graphql",
|
|
29
|
+
indexerWS: "wss://indexer.testnet-02.midnight.network/api/v4/graphql/ws",
|
|
30
30
|
node: "https://rpc.testnet-02.midnight.network",
|
|
31
31
|
proofServer: "http://127.0.0.1:6300",
|
|
32
32
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDProviders, type SchnorrJubjubDigest, type SchnorrJubjubSignature } from "./types.js";
|
|
3
|
+
export type ControllerAuthorization = readonly [
|
|
4
|
+
signature: SchnorrJubjubSignature,
|
|
5
|
+
expectedVersion: bigint
|
|
6
|
+
];
|
|
7
|
+
export type ControllerAuthorizationDigestFactory = (ledgerState: DIDContract.Ledger) => SchnorrJubjubDigest;
|
|
8
|
+
export declare const asSchnorrJubjubDigest: (value: readonly bigint[]) => SchnorrJubjubDigest;
|
|
9
|
+
export declare const createControllerAuthorization: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, digestFactory: ControllerAuthorizationDigestFactory) => Promise<ControllerAuthorization>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { signControllerAuthorization, } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { requireDeployedMidnightDIDLedgerState } from "./ledger-state.js";
|
|
3
|
+
import { requirePrivateState } from "./private-state.js";
|
|
4
|
+
export const asSchnorrJubjubDigest = (value) => {
|
|
5
|
+
if (value.length !== 4) {
|
|
6
|
+
throw new Error("Controller authorization digest must have exactly 4 fields");
|
|
7
|
+
}
|
|
8
|
+
return [value[0], value[1], value[2], value[3]];
|
|
9
|
+
};
|
|
10
|
+
export const createControllerAuthorization = async (didContract, providers, digestFactory) => {
|
|
11
|
+
const [privateState, ledgerState] = await Promise.all([
|
|
12
|
+
requirePrivateState(providers),
|
|
13
|
+
requireDeployedMidnightDIDLedgerState(providers, didContract),
|
|
14
|
+
]);
|
|
15
|
+
return [
|
|
16
|
+
signControllerAuthorization(privateState.secretKey, digestFactory(ledgerState)),
|
|
17
|
+
ledgerState.version,
|
|
18
|
+
];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=controller-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-authorization.js","sourceRoot":"","sources":["../src/controller-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAiBzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAwB,EACH,EAAE;IACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,EAChD,WAAwC,EACxC,SAA+B,EAC/B,aAAmD,EACjB,EAAE;IACpC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpD,mBAAmB,CAAC,SAAS,CAAC;QAC9B,qCAAqC,CAAC,SAAS,EAAE,WAAW,CAAC;KAC9D,CAAC,CAAC;IACH,OAAO;QACL,2BAA2B,CACzB,YAAY,CAAC,SAAS,EACtB,aAAa,CAAC,WAAW,CAAC,CAC3B;QACD,WAAW,CAAC,OAAO;KACpB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { deriveControllerPublicKey } from "@midnight-ntwrk/midnight-did-contract";
|
|
1
|
+
import { deriveControllerPublicKey, DIDContract, } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
2
|
import { getLogger } from "./api-logger.js";
|
|
3
|
+
import { asSchnorrJubjubDigest, createControllerAuthorization, } from "./controller-authorization.js";
|
|
3
4
|
import { randomBytes } from "./lightweight.js";
|
|
4
5
|
import { clearPendingControllerPrivateState, savePendingControllerPrivateState, savePrivateState, } from "./private-state.js";
|
|
5
6
|
const privateStateFromSecret = (secretKey) => {
|
|
@@ -20,7 +21,8 @@ export const rotateControllerKey = async (didContract, providers, newSecretKey =
|
|
|
20
21
|
await savePendingControllerPrivateState(providers, nextPrivateState);
|
|
21
22
|
let finalized = false;
|
|
22
23
|
try {
|
|
23
|
-
const
|
|
24
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.rotateControllerKeyAuthorizationDigest(ledgerState.id, ledgerState.version, nextControllerPublicKey)));
|
|
25
|
+
const result = await didContract.callTx.rotateControllerKey(nextControllerPublicKey, signature, expectedVersion);
|
|
24
26
|
finalized = true;
|
|
25
27
|
await savePrivateState(providers, nextPrivateState);
|
|
26
28
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-operations.js","sourceRoot":"","sources":["../src/controller-operations.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"controller-operations.js","sourceRoot":"","sources":["../src/controller-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,WAAW,GACZ,MAAM,uCAAuC,CAAC;AAG/C,OAA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,mBAAmB,CACzD,uBAAuB,EACvB,SAAS,EACT,eAAe,CAChB,CAAC;QACF,SAAS,GAAG,IAAI,CAAC;QAEjB,MAAM,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACpD,IAAI,CAAC;YACH,MAAM,kCAAkC,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,SAAS,EAAE,CAAC,IAAI,CACd,EAAE,KAAK,EAAE,EACT,8EAA8E,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,kCAAkC,CAAC,SAAS,CAAC,CAAC;YACtD,CAAC;YAAC,OAAO,YAAqB,EAAE,CAAC;gBAC/B,SAAS,EAAE,CAAC,IAAI,CACd,EAAE,KAAK,EAAE,YAAY,EAAE,EACvB,+FAA+F,CAChG,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,SAAS,EAAE,CAAC,KAAK,CACf,EAAE,KAAK,EAAE,EACT,2KAA2K,CAC5K,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FinalizedTxData } from "@midnight-ntwrk/midnight-js-types";
|
|
2
|
-
import { type DeployedMidnightDIDContract } from "./types.js";
|
|
3
|
-
export declare const addAlsoKnownAs: (didContract: DeployedMidnightDIDContract, aliasUri: string) => Promise<FinalizedTxData>;
|
|
4
|
-
export declare const removeAlsoKnownAs: (didContract: DeployedMidnightDIDContract, aliasUri: string) => Promise<FinalizedTxData>;
|
|
5
|
-
export declare const deactivate: (didContract: DeployedMidnightDIDContract) => Promise<FinalizedTxData>;
|
|
2
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDProviders } from "./types.js";
|
|
3
|
+
export declare const addAlsoKnownAs: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, aliasUri: string) => Promise<FinalizedTxData>;
|
|
4
|
+
export declare const removeAlsoKnownAs: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, aliasUri: string) => Promise<FinalizedTxData>;
|
|
5
|
+
export declare const deactivate: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders) => Promise<FinalizedTxData>;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
2
|
import { assertAbsoluteUri } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
-
|
|
3
|
+
import { asSchnorrJubjubDigest, createControllerAuthorization, } from "./controller-authorization.js";
|
|
4
|
+
export const addAlsoKnownAs = async (didContract, providers, aliasUri) => {
|
|
4
5
|
const alias = assertAbsoluteUri(aliasUri, "aliasUri");
|
|
5
|
-
const
|
|
6
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.setAlsoKnownAsAuthorizationDigest(ledgerState.id, ledgerState.version, alias, DIDContract.SetMutation.Insert)));
|
|
7
|
+
const result = await didContract.callTx.setAlsoKnownAs(alias, DIDContract.SetMutation.Insert, signature, expectedVersion);
|
|
6
8
|
return result.public;
|
|
7
9
|
};
|
|
8
|
-
export const removeAlsoKnownAs = async (didContract, aliasUri) => {
|
|
10
|
+
export const removeAlsoKnownAs = async (didContract, providers, aliasUri) => {
|
|
9
11
|
const alias = assertAbsoluteUri(aliasUri, "aliasUri");
|
|
10
|
-
const
|
|
12
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.setAlsoKnownAsAuthorizationDigest(ledgerState.id, ledgerState.version, alias, DIDContract.SetMutation.Remove)));
|
|
13
|
+
const result = await didContract.callTx.setAlsoKnownAs(alias, DIDContract.SetMutation.Remove, signature, expectedVersion);
|
|
11
14
|
return result.public;
|
|
12
15
|
};
|
|
13
|
-
export const deactivate = async (didContract) => {
|
|
14
|
-
const
|
|
16
|
+
export const deactivate = async (didContract, providers) => {
|
|
17
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.deactivateAuthorizationDigest(ledgerState.id, ledgerState.version)));
|
|
18
|
+
const result = await didContract.callTx.deactivate(signature, expectedVersion);
|
|
15
19
|
return result.public;
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=document-operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-operations.js","sourceRoot":"","sources":["../src/document-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"document-operations.js","sourceRoot":"","sources":["../src/document-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,+BAA+B,CAAC;AAMvC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,WAAwC,EACxC,SAA+B,EAC/B,QAAgB,EACU,EAAE;IAC5B,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,MAAM,6BAA6B,CACtE,WAAW,EACX,SAAS,EACT,CAAC,WAAW,EAAE,EAAE,CACd,qBAAqB,CACnB,WAAW,CAAC,YAAY,CAAC,iCAAiC,CACxD,WAAW,CAAC,EAAE,EACd,WAAW,CAAC,OAAO,EACnB,KA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MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,UAAU,CAChD,SAAS,EACT,eAAe,CAChB,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAKlC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAKlC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
package/dist/lib.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-opera
|
|
|
8
8
|
export { getMidnightDIDLedgerState } from "./ledger-state.js";
|
|
9
9
|
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
|
10
10
|
export { configureProviders, createWalletAndMidnightProvider, } from "./providers.js";
|
|
11
|
-
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
11
|
+
export { resolve, resolveDIDResolutionResult, resolveRepresentation, } from "./resolution.js";
|
|
12
12
|
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
13
13
|
export { addSchnorrJubjubVerificationMethod, addVerificationMethod, addVerificationMethodRelation, removeSchnorrJubjubVerificationMethod, removeVerificationMethod, removeVerificationMethodRelation, updateSchnorrJubjubVerificationMethod, updateVerificationMethod, verifySchnorrJubjubDigestSignature, } from "./verification-method-operations.js";
|
|
14
14
|
export { buildFreshWallet, buildWallet, buildWalletAndWaitForFunds, getWalletBalances, registerForDustGeneration, restoreWalletFromState, serializeWalletState, waitForWalletFunds, waitForWalletSync, } from "./wallet.js";
|
package/dist/lib.js
CHANGED
|
@@ -8,7 +8,7 @@ export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-opera
|
|
|
8
8
|
export { getMidnightDIDLedgerState } from "./ledger-state.js";
|
|
9
9
|
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
|
10
10
|
export { configureProviders, createWalletAndMidnightProvider, } from "./providers.js";
|
|
11
|
-
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
11
|
+
export { resolve, resolveDIDResolutionResult, resolveRepresentation, } from "./resolution.js";
|
|
12
12
|
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
13
13
|
export { addSchnorrJubjubVerificationMethod, addVerificationMethod, addVerificationMethodRelation, removeSchnorrJubjubVerificationMethod, removeVerificationMethod, removeVerificationMethodRelation, updateSchnorrJubjubVerificationMethod, updateVerificationMethod, verifySchnorrJubjubDigestSignature, } from "./verification-method-operations.js";
|
|
14
14
|
export { buildFreshWallet, buildWallet, buildWalletAndWaitForFunds, getWalletBalances, registerForDustGeneration, restoreWalletFromState, serializeWalletState, waitForWalletFunds, waitForWalletSync, } from "./wallet.js";
|
package/dist/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO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,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kCAAkC,EAClC,qBAAqB,EACrB,6BAA6B,EAC7B,qCAAqC,EACrC,wBAAwB,EACxB,gCAAgC,EAChC,qCAAqC,EACrC,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const MIDNIGHT_DID_API_VERSION: "0.5.0-
|
|
1
|
+
export declare const MIDNIGHT_DID_API_VERSION: "0.5.0-rc2";
|
|
2
2
|
export declare const MIDNIGHT_DID_PACKAGE_NAME: "@midnight-ntwrk/midnight-did-api";
|
|
3
3
|
export declare const MIDNIGHT_DID_NPM_REGISTRY: "https://registry.npmjs.org/";
|
|
4
4
|
export declare const MIDNIGHT_DID_GITHUB_REPOSITORY: "midnightntwrk/midnight-did";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const MIDNIGHT_DID_API_VERSION = "0.5.0-
|
|
1
|
+
export const MIDNIGHT_DID_API_VERSION = "0.5.0-rc2";
|
|
2
2
|
export const MIDNIGHT_DID_PACKAGE_NAME = "@midnight-ntwrk/midnight-did-api";
|
|
3
3
|
export const MIDNIGHT_DID_NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
4
4
|
export const MIDNIGHT_DID_GITHUB_REPOSITORY = "midnightntwrk/midnight-did";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-artifacts.js","sourceRoot":"","sources":["../src/release-artifacts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,WA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AAW,SAAS,CAAC;IACtE,MAAM,YAAY,GAAG,6BAA6B,WAAW,gBAAgB,CAAC;IAC9E,MAAM,UAAU,GAAG,GAAG,WAAW,SAAS,CAAC;IAC3C,MAAM,oBAAoB,GAAG,6BAA6B,OAAO,EAAE,CAAC;IACpE,MAAM,UAAU,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;IACjE,MAAM,aAAa,GAAG,UAAU;QAC9B,CAAC,CAAC;YACE,UAAU,EAAE,8BAA8B;YAC1C,GAAG,EAAE,UAAU;YACf,UAAU,EAAE,sBAAsB,8BAA8B,sBAAsB,UAAU,IAAI,WAAW,EAAE;YACjH,WAAW,EAAE,sBAAsB,8BAA8B,sBAAsB,UAAU,IAAI,YAAY,EAAE;YACnH,SAAS,EAAE,sBAAsB,8BAA8B,sBAAsB,UAAU,IAAI,UAAU,EAAE;SAChH;QACH,CAAC,CAAC,IAAI,CAAC;IAET,OAAO;QACL,OAAO;QACP,OAAO;QACP,GAAG,EAAE;YACH,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,yBAAyB;SACpC;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,qCAAqC;YACjD,SAAS,EAAE,GAAG,qCAAqC,IAAI,OAAO,EAAE;SACjE;QACD,aAAa;QACb,oBAAoB;QACpB,WAAW;QACX,YAAY;QACZ,UAAU;QACV,cAAc,EAAE;YACd,SAAS,EAAE,yBAAyB;YACpC,WAAW,EAAE,2BAA2B;YACxC,IAAI,EAAE,wBAAwB;SAC/B;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAC7C,oCAAoC,EAAE,CAAC"}
|
package/dist/resolution.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { MidnightDIDDocument } from "@midnight-ntwrk/midnight-did";
|
|
2
|
-
import { type
|
|
1
|
+
import { MidnightDIDDocument, type MidnightDIDRepresentationResult as ResolverDIDRepresentationResult, type MidnightDIDResolutionOptions as ResolverDIDResolutionOptions, type MidnightDIDResolutionResult as ResolverDIDResolutionResult } from "@midnight-ntwrk/midnight-did";
|
|
2
|
+
import { type DIDDocumentMetadata } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
3
|
import { type DeployedMidnightDIDContract, type MidnightDIDProviders } from "./types.js";
|
|
4
4
|
export declare const resolve: (providers: MidnightDIDProviders, didContract: DeployedMidnightDIDContract) => Promise<{
|
|
5
5
|
didDocument: MidnightDIDDocument;
|
|
6
6
|
didDocumentMetadata: DIDDocumentMetadata;
|
|
7
7
|
} | null>;
|
|
8
|
-
export type MidnightDIDResolutionResult =
|
|
9
|
-
didDocument: MidnightDIDDocument | null;
|
|
10
|
-
didDocumentMetadata: DIDDocumentMetadata;
|
|
11
|
-
didResolutionMetadata: {
|
|
12
|
-
error?: DIDResolutionErrorCode;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
8
|
+
export type MidnightDIDResolutionResult = ResolverDIDResolutionResult;
|
|
15
9
|
export declare const resolveDIDResolutionResult: (providers: MidnightDIDProviders, didContract: DeployedMidnightDIDContract) => Promise<MidnightDIDResolutionResult>;
|
|
10
|
+
export type MidnightDIDRepresentationResult = ResolverDIDRepresentationResult;
|
|
11
|
+
export type MidnightDIDResolutionOptions = ResolverDIDResolutionOptions;
|
|
12
|
+
export declare const resolveRepresentation: (providers: MidnightDIDProviders, didContract: DeployedMidnightDIDContract, options?: MidnightDIDResolutionOptions) => Promise<MidnightDIDRepresentationResult>;
|
package/dist/resolution.js
CHANGED
|
@@ -1,46 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MidnightDIDResolver, } from "@midnight-ntwrk/midnight-did";
|
|
2
2
|
import { parseContractAddress } from "@midnight-ntwrk/midnight-did/midnight";
|
|
3
3
|
import { getLogger } from "./api-logger.js";
|
|
4
|
-
import { getMidnightNetwork } from "./did-subject.js";
|
|
4
|
+
import { getDidSubject, getMidnightNetwork } from "./did-subject.js";
|
|
5
5
|
import { getMidnightDIDLedgerState } from "./ledger-state.js";
|
|
6
6
|
import { BigIntReplacer } from "./logger-utils.js";
|
|
7
|
+
const createResolver = (providers) => new MidnightDIDResolver({
|
|
8
|
+
expectedNetwork: getMidnightNetwork(),
|
|
9
|
+
ledgerReader: async (ledgerContractAddress) => await getMidnightDIDLedgerState(providers, parseContractAddress(ledgerContractAddress)),
|
|
10
|
+
});
|
|
7
11
|
export const resolve = async (providers, didContract) => {
|
|
8
|
-
const network = getMidnightNetwork();
|
|
9
12
|
const contractAddress = didContract.deployTxData.public.contractAddress;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
+
const resolver = createResolver(providers);
|
|
14
|
+
const result = await resolver.resolveResult(getDidSubject(didContract));
|
|
15
|
+
if (result === null) {
|
|
13
16
|
getLogger().info(`There is no Midnight DID contract deployed at ${contractAddress}.`);
|
|
14
17
|
return null;
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getLogger().info(`MidnightDID Resolution Result:\n ${JSON.stringify({ didDocument, didDocumentMetadata }, BigIntReplacer, 2)}`);
|
|
19
|
-
return { didDocument, didDocumentMetadata };
|
|
19
|
+
getLogger().info(`MidnightDID Resolution Result:\n ${JSON.stringify(result, BigIntReplacer, 2)}`);
|
|
20
|
+
return result;
|
|
20
21
|
};
|
|
21
22
|
export const resolveDIDResolutionResult = async (providers, didContract) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
didResolutionMetadata: { error: "notFound" },
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
didDocument: result.didDocument,
|
|
33
|
-
didDocumentMetadata: result.didDocumentMetadata,
|
|
34
|
-
didResolutionMetadata: {},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
getLogger().error(`MidnightDID resolution failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
39
|
-
return {
|
|
40
|
-
didDocument: null,
|
|
41
|
-
didDocumentMetadata: {},
|
|
42
|
-
didResolutionMetadata: { error: "internalError" },
|
|
43
|
-
};
|
|
44
|
-
}
|
|
23
|
+
const resolver = createResolver(providers);
|
|
24
|
+
return await resolver.resolveDIDResolutionResult(getDidSubject(didContract));
|
|
25
|
+
};
|
|
26
|
+
export const resolveRepresentation = async (providers, didContract, options) => {
|
|
27
|
+
const resolver = createResolver(providers);
|
|
28
|
+
return await resolver.resolveRepresentation(getDidSubject(didContract), options);
|
|
45
29
|
};
|
|
46
30
|
//# sourceMappingURL=resolution.js.map
|
package/dist/resolution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMnD,MAAM,cAAc,GAAG,CAAC,SAA+B,EAAuB,EAAE,CAC9E,IAAI,mBAAmB,CAAC;IACtB,eAAe,EAAE,kBAAkB,EAAE;IACrC,YAAY,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,CAC5C,MAAM,yBAAyB,CAC7B,SAAS,EACT,oBAAoB,CAAC,qBAAqB,CAAC,CAC5C;CACJ,CAAC,CAAC;AAEL,MAAM,CAAC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-
import { type DeployedMidnightDIDContract } from "./types.js";
|
|
4
|
-
export declare const addService: (didContract: DeployedMidnightDIDContract, service: Service) => Promise<FinalizedTxData>;
|
|
5
|
-
export declare const updateService: (didContract: DeployedMidnightDIDContract, service: Service) => Promise<FinalizedTxData>;
|
|
6
|
-
export declare const removeService: (didContract: DeployedMidnightDIDContract, serviceId: string) => Promise<FinalizedTxData>;
|
|
3
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDProviders } from "./types.js";
|
|
4
|
+
export declare const addService: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, service: Service) => Promise<FinalizedTxData>;
|
|
5
|
+
export declare const updateService: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, service: Service) => Promise<FinalizedTxData>;
|
|
6
|
+
export declare const removeService: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, serviceId: string) => Promise<FinalizedTxData>;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { asSchnorrJubjubDigest, createControllerAuthorization, } from "./controller-authorization.js";
|
|
2
3
|
import { normalizeBoundFragmentId } from "./did-subject.js";
|
|
3
4
|
import { serviceToLedger } from "./ledger-mappers.js";
|
|
4
|
-
export const addService = async (didContract, service) => {
|
|
5
|
-
const
|
|
5
|
+
export const addService = async (didContract, providers, service) => {
|
|
6
|
+
const ledgerService = serviceToLedger(didContract, service);
|
|
7
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.setServiceAuthorizationDigest(ledgerState.id, ledgerState.version, ledgerService, DIDContract.MapMutation.Insert)));
|
|
8
|
+
const result = await didContract.callTx.setService(ledgerService, DIDContract.MapMutation.Insert, signature, expectedVersion);
|
|
6
9
|
return result.public;
|
|
7
10
|
};
|
|
8
|
-
export const updateService = async (didContract, service) => {
|
|
9
|
-
const
|
|
11
|
+
export const updateService = async (didContract, providers, service) => {
|
|
12
|
+
const ledgerService = serviceToLedger(didContract, service);
|
|
13
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.setServiceAuthorizationDigest(ledgerState.id, ledgerState.version, ledgerService, DIDContract.MapMutation.Update)));
|
|
14
|
+
const result = await didContract.callTx.setService(ledgerService, DIDContract.MapMutation.Update, signature, expectedVersion);
|
|
10
15
|
return result.public;
|
|
11
16
|
};
|
|
12
|
-
export const removeService = async (didContract, serviceId) => {
|
|
17
|
+
export const removeService = async (didContract, providers, serviceId) => {
|
|
13
18
|
const normalizedServiceId = normalizeBoundFragmentId(didContract, serviceId, "serviceId");
|
|
14
|
-
const
|
|
19
|
+
const [signature, expectedVersion] = await createControllerAuthorization(didContract, providers, (ledgerState) => asSchnorrJubjubDigest(DIDContract.pureCircuits.removeServiceAuthorizationDigest(ledgerState.id, ledgerState.version, normalizedServiceId)));
|
|
20
|
+
const result = await didContract.callTx.removeService(normalizedServiceId, signature, expectedVersion);
|
|
15
21
|
return result.public;
|
|
16
22
|
};
|
|
17
23
|
//# sourceMappingURL=service-operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-operations.js","sourceRoot":"","sources":["../src/service-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAIpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-operations.js","sourceRoot":"","sources":["../src/service-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAIpE,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D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AC,MAAM,EAC9B,SAAS,EACT,eAAe,CAChB,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,WAAwC,EACxC,SAA+B,EAC/B,SAAiB,EACS,EAAE;IAC5B,MAAM,mBAAmB,GAAG,wBAAwB,CAClD,WAAW,EACX,SAAS,EACT,WAAW,CACZ,CAAC;IACF,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,MAAM,6BAA6B,CACtE,WAAW,EACX,SAAS,EACT,CAAC,WAAW,EAAE,EAAE,CACd,qBAAqB,CACnB,WAAW,CAAC,YAAY,CAAC,gCAAgC,CACvD,WAAW,CAAC,EAAE,EACd,WAAW,CAAC,OAAO,EACnB,mBAAmB,CACpB,CACF,CACJ,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,aAAa,CACnD,mBAAmB,EACnB,SAAS,EACT,eAAe,CAChB,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC"}
|
package/dist/update.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import "./polyfills.js";
|
|
|
2
2
|
export { rotateControllerKey } from "./controller-operations.js";
|
|
3
3
|
export { getMidnightNetwork } from "./did-subject.js";
|
|
4
4
|
export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-operations.js";
|
|
5
|
-
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
5
|
+
export { resolve, resolveDIDResolutionResult, resolveRepresentation, } from "./resolution.js";
|
|
6
6
|
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
7
7
|
export { addVerificationMethod, addVerificationMethodRelation, removeVerificationMethod, removeVerificationMethodRelation, updateVerificationMethod, } from "./verification-method-operations.js";
|
package/dist/update.js
CHANGED
|
@@ -2,7 +2,7 @@ import "./polyfills.js";
|
|
|
2
2
|
export { rotateControllerKey } from "./controller-operations.js";
|
|
3
3
|
export { getMidnightNetwork } from "./did-subject.js";
|
|
4
4
|
export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-operations.js";
|
|
5
|
-
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
5
|
+
export { resolve, resolveDIDResolutionResult, resolveRepresentation, } from "./resolution.js";
|
|
6
6
|
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
7
7
|
export { addVerificationMethod, addVerificationMethodRelation, removeVerificationMethod, removeVerificationMethodRelation, updateVerificationMethod, } from "./verification-method-operations.js";
|
|
8
8
|
//# sourceMappingURL=update.js.map
|
package/dist/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,EACP,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,wBAAwB,EACxB,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,qCAAqC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { VerificationMethod, VerificationMethodRelationType } from "@midnight-ntwrk/midnight-did-domain";
|
|
2
2
|
import { type FinalizedTxData } from "@midnight-ntwrk/midnight-js-types";
|
|
3
3
|
import { type DeployedMidnightDIDContract, type MidnightDIDProviders, type SchnorrJubjubDigest, type SchnorrJubjubSignature, type SchnorrJubjubVerificationMethod } from "./types.js";
|
|
4
|
-
export declare const addVerificationMethod: (didContract: DeployedMidnightDIDContract, verificationMethod: VerificationMethod) => Promise<FinalizedTxData>;
|
|
5
|
-
export declare const updateVerificationMethod: (didContract: DeployedMidnightDIDContract, verificationMethod: VerificationMethod) => Promise<FinalizedTxData>;
|
|
4
|
+
export declare const addVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, verificationMethod: VerificationMethod) => Promise<FinalizedTxData>;
|
|
5
|
+
export declare const updateVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, verificationMethod: VerificationMethod) => Promise<FinalizedTxData>;
|
|
6
6
|
export declare const removeVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, methodId: string) => Promise<FinalizedTxData>;
|
|
7
|
-
export declare const addSchnorrJubjubVerificationMethod: (didContract: DeployedMidnightDIDContract, verificationMethod: SchnorrJubjubVerificationMethod) => Promise<FinalizedTxData>;
|
|
8
|
-
export declare const updateSchnorrJubjubVerificationMethod: (didContract: DeployedMidnightDIDContract, verificationMethod: SchnorrJubjubVerificationMethod) => Promise<FinalizedTxData>;
|
|
7
|
+
export declare const addSchnorrJubjubVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, verificationMethod: SchnorrJubjubVerificationMethod) => Promise<FinalizedTxData>;
|
|
8
|
+
export declare const updateSchnorrJubjubVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, verificationMethod: SchnorrJubjubVerificationMethod) => Promise<FinalizedTxData>;
|
|
9
9
|
export declare const removeSchnorrJubjubVerificationMethod: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, methodId: string) => Promise<FinalizedTxData>;
|
|
10
10
|
/**
|
|
11
11
|
* Submits the ledger-bound SchnorrJubjub verification circuit.
|