@midnight-ntwrk/midnight-did-api 0.4.0-snapshot.51.a3d433c5e196
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/LICENSE +201 -0
- package/README.md +218 -0
- package/dist/api-logger.d.ts +3 -0
- package/dist/api-logger.js +8 -0
- package/dist/api-logger.js.map +1 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +6 -0
- package/dist/browser.js.map +1 -0
- package/dist/config-profiles.d.ts +75 -0
- package/dist/config-profiles.js +75 -0
- package/dist/config-profiles.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/contract-instance.d.ts +7 -0
- package/dist/contract-instance.js +6 -0
- package/dist/contract-instance.js.map +1 -0
- package/dist/contract-lifecycle-operations.d.ts +4 -0
- package/dist/contract-lifecycle-operations.js +40 -0
- package/dist/contract-lifecycle-operations.js.map +1 -0
- package/dist/contract-lifecycle.d.ts +6 -0
- package/dist/contract-lifecycle.js +7 -0
- package/dist/contract-lifecycle.js.map +1 -0
- package/dist/controller-operations.d.ts +9 -0
- package/dist/controller-operations.js +49 -0
- package/dist/controller-operations.js.map +1 -0
- package/dist/deploy.d.ts +6 -0
- package/dist/deploy.js +7 -0
- package/dist/deploy.js.map +1 -0
- package/dist/did-operations.d.ts +6 -0
- package/dist/did-operations.js +7 -0
- package/dist/did-operations.js.map +1 -0
- package/dist/did-subject.d.ts +6 -0
- package/dist/did-subject.js +11 -0
- package/dist/did-subject.js.map +1 -0
- package/dist/document-operations.d.ts +5 -0
- package/dist/document-operations.js +17 -0
- package/dist/document-operations.js.map +1 -0
- package/dist/domain-to-runtime.d.ts +4 -0
- package/dist/domain-to-runtime.js +7 -0
- package/dist/domain-to-runtime.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger-mappers.d.ts +15 -0
- package/dist/ledger-mappers.js +137 -0
- package/dist/ledger-mappers.js.map +1 -0
- package/dist/ledger-state.d.ts +6 -0
- package/dist/ledger-state.js +24 -0
- package/dist/ledger-state.js.map +1 -0
- package/dist/lib.d.ts +15 -0
- package/dist/lib.js +16 -0
- package/dist/lib.js.map +1 -0
- package/dist/lightweight.d.ts +1 -0
- package/dist/lightweight.js +9 -0
- package/dist/lightweight.js.map +1 -0
- package/dist/logger-utils.d.ts +3 -0
- package/dist/logger-utils.js +26 -0
- package/dist/logger-utils.js.map +1 -0
- package/dist/network-mapping.d.ts +6 -0
- package/dist/network-mapping.js +20 -0
- package/dist/network-mapping.js.map +1 -0
- package/dist/package-paths.d.ts +10 -0
- package/dist/package-paths.js +31 -0
- package/dist/package-paths.js.map +1 -0
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +7 -0
- package/dist/polyfills.js.map +1 -0
- package/dist/private-state-storage.d.ts +8 -0
- package/dist/private-state-storage.js +18 -0
- package/dist/private-state-storage.js.map +1 -0
- package/dist/private-state.d.ts +13 -0
- package/dist/private-state.js +75 -0
- package/dist/private-state.js.map +1 -0
- package/dist/providers.d.ts +13 -0
- package/dist/providers.js +32 -0
- package/dist/providers.js.map +1 -0
- package/dist/release-artifacts.d.ts +41 -0
- package/dist/release-artifacts.js +60 -0
- package/dist/release-artifacts.js.map +1 -0
- package/dist/resolution.d.ts +15 -0
- package/dist/resolution.js +46 -0
- package/dist/resolution.js.map +1 -0
- package/dist/runtime-to-domain.d.ts +4 -0
- package/dist/runtime-to-domain.js +7 -0
- package/dist/runtime-to-domain.js.map +1 -0
- package/dist/seed.d.ts +1 -0
- package/dist/seed.js +13 -0
- package/dist/seed.js.map +1 -0
- package/dist/service-operations.d.ts +6 -0
- package/dist/service-operations.js +17 -0
- package/dist/service-operations.js.map +1 -0
- package/dist/transaction-intents.d.ts +9 -0
- package/dist/transaction-intents.js +27 -0
- package/dist/transaction-intents.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/update.d.ts +7 -0
- package/dist/update.js +8 -0
- package/dist/update.js.map +1 -0
- package/dist/verification-method-operations.d.ts +19 -0
- package/dist/verification-method-operations.js +60 -0
- package/dist/verification-method-operations.js.map +1 -0
- package/dist/verification-method-relations.d.ts +13 -0
- package/dist/verification-method-relations.js +40 -0
- package/dist/verification-method-relations.js.map +1 -0
- package/dist/wallet-context.d.ts +3 -0
- package/dist/wallet-context.js +55 -0
- package/dist/wallet-context.js.map +1 -0
- package/dist/wallet-dust.d.ts +10 -0
- package/dist/wallet-dust.js +28 -0
- package/dist/wallet-dust.js.map +1 -0
- package/dist/wallet-keys.d.ts +5 -0
- package/dist/wallet-keys.js +27 -0
- package/dist/wallet-keys.js.map +1 -0
- package/dist/wallet-provider.d.ts +3 -0
- package/dist/wallet-provider.js +29 -0
- package/dist/wallet-provider.js.map +1 -0
- package/dist/wallet-sdk-config.d.ts +32 -0
- package/dist/wallet-sdk-config.js +23 -0
- package/dist/wallet-sdk-config.js.map +1 -0
- package/dist/wallet-state.d.ts +6 -0
- package/dist/wallet-state.js +32 -0
- package/dist/wallet-state.js.map +1 -0
- package/dist/wallet.d.ts +9 -0
- package/dist/wallet.js +17 -0
- package/dist/wallet.js.map +1 -0
- package/examples/README.md +60 -0
- package/examples/bootstrap-issuer-did.ts +313 -0
- package/examples/deploy-did.ts +40 -0
- package/examples/update-did.ts +84 -0
- package/package.json +88 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +23 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { applyMidnightNetworkProfile, resolveMidnightNetworkConfig, } from "./config-profiles.js";
|
|
2
|
+
import { contractConfig, currentDir } from "./package-paths.js";
|
|
3
|
+
export { applyMidnightNetworkProfile, getMidnightNetworkProfile, isMidnightNetworkProfileName, MIDNIGHT_NETWORK_PROFILE_NAMES, MIDNIGHT_NETWORK_PROFILES, resolveMidnightNetworkConfig, } from "./config-profiles.js";
|
|
4
|
+
export { contractConfig, currentDir };
|
|
5
|
+
export class ProfileConfig {
|
|
6
|
+
profileName;
|
|
7
|
+
logDir;
|
|
8
|
+
indexer;
|
|
9
|
+
indexerWS;
|
|
10
|
+
node;
|
|
11
|
+
proofServer;
|
|
12
|
+
midnightDbName;
|
|
13
|
+
constructor(profileName, endpointOverrides = {}) {
|
|
14
|
+
this.profileName = profileName;
|
|
15
|
+
const values = resolveMidnightNetworkConfig(currentDir, profileName, endpointOverrides);
|
|
16
|
+
this.logDir = values.logDir;
|
|
17
|
+
this.indexer = values.indexer;
|
|
18
|
+
this.indexerWS = values.indexerWS;
|
|
19
|
+
this.node = values.node;
|
|
20
|
+
this.proofServer = values.proofServer;
|
|
21
|
+
this.midnightDbName = values.midnightDbName;
|
|
22
|
+
applyMidnightNetworkProfile(profileName);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class TestnetLocalConfig extends ProfileConfig {
|
|
26
|
+
constructor() {
|
|
27
|
+
super("testnet-local");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class StandaloneConfig extends ProfileConfig {
|
|
31
|
+
constructor() {
|
|
32
|
+
super("standalone");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class TestnetRemoteConfig extends ProfileConfig {
|
|
36
|
+
constructor() {
|
|
37
|
+
super("testnet-remote");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class PreprodConfig extends ProfileConfig {
|
|
41
|
+
constructor() {
|
|
42
|
+
super("preprod");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class MainnetConfig extends ProfileConfig {
|
|
46
|
+
constructor(input = {}) {
|
|
47
|
+
super("mainnet", input);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO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AAgB,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAY,QAAmC,EAAE;QAC/C,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CompiledContract } from "@midnight-ntwrk/compact-js";
|
|
2
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
3
|
+
import { type MidnightDIDContract } from "./types.js";
|
|
4
|
+
export declare const midnightDIDCompiledContract: CompiledContract.CompiledContract<DIDContract.Contract<import("@midnight-ntwrk/midnight-did-contract").DIDPrivateState, DIDContract.Witnesses<import("@midnight-ntwrk/midnight-did-contract").DIDPrivateState>> & {
|
|
5
|
+
provableCircuits: DIDContract.ImpureCircuits<import("./types.js").MidnightDIDPrivateState>;
|
|
6
|
+
}, import("@midnight-ntwrk/midnight-did-contract").DIDPrivateState, never>;
|
|
7
|
+
export declare const midnightDIDContractInstance: MidnightDIDContract;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CompiledContract } from "@midnight-ntwrk/compact-js";
|
|
2
|
+
import { DIDContract, witnesses } from "@midnight-ntwrk/midnight-did-contract";
|
|
3
|
+
import { contractConfig } from "./config.js";
|
|
4
|
+
export const midnightDIDCompiledContract = CompiledContract.make("did", DIDContract.Contract).pipe(CompiledContract.withWitnesses(witnesses), CompiledContract.withCompiledFileAssets(contractConfig.zkConfigPath));
|
|
5
|
+
export const midnightDIDContractInstance = new DIDContract.Contract(witnesses);
|
|
6
|
+
//# sourceMappingURL=contract-instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-instance.js","sourceRoot":"","sources":["../src/contract-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,gBAAgB,CAAC,IAAI,CAC9D,KAAK,EACL,WAAW,CAAC,QAEY,CACzB,CAAC,IAAI,CACJ,gBAAgB,CAAC,aAAa,CAAC,SAAkB,CAAC,EAClD,gBAAgB,CAAC,sBAAsB,CAAC,cAAc,CAAC,YAAY,CAAC,CACrE,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GACtC,IAAK,WAAW,CAAC,QAEQ,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDPrivateState, type MidnightDIDProviders } from "./types.js";
|
|
2
|
+
export declare const joinContract: (providers: MidnightDIDProviders, contractAddress: string) => Promise<DeployedMidnightDIDContract>;
|
|
3
|
+
export declare const deploy: (providers: MidnightDIDProviders, privateState: MidnightDIDPrivateState) => Promise<DeployedMidnightDIDContract>;
|
|
4
|
+
export declare const createDID: (providers: MidnightDIDProviders, privateState: MidnightDIDPrivateState) => Promise<DeployedMidnightDIDContract>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { deployContract, findDeployedContract, } from "@midnight-ntwrk/midnight-js-contracts";
|
|
2
|
+
import { getLogger } from "./api-logger.js";
|
|
3
|
+
import { midnightDIDCompiledContract } from "./contract-instance.js";
|
|
4
|
+
import { bindPrivateStateProvider, requirePrivateState, savePrivateState, } from "./private-state.js";
|
|
5
|
+
import { MidnightDIDPrivateStateId, } from "./types.js";
|
|
6
|
+
export const joinContract = async (providers, contractAddress) => {
|
|
7
|
+
// Private state is scoped by contract address; bind before reading so join
|
|
8
|
+
// cannot create or load controller state from the wrong DID namespace.
|
|
9
|
+
bindPrivateStateProvider(providers, contractAddress);
|
|
10
|
+
const initialPrivateState = await requirePrivateState(providers);
|
|
11
|
+
const didContract = await findDeployedContract(providers, {
|
|
12
|
+
contractAddress,
|
|
13
|
+
compiledContract: midnightDIDCompiledContract,
|
|
14
|
+
privateStateId: MidnightDIDPrivateStateId,
|
|
15
|
+
initialPrivateState: initialPrivateState,
|
|
16
|
+
});
|
|
17
|
+
getLogger().info(`Joined contract at address: ${didContract.deployTxData.public.contractAddress}`);
|
|
18
|
+
return didContract;
|
|
19
|
+
};
|
|
20
|
+
export const deploy = async (providers, privateState) => {
|
|
21
|
+
getLogger().info("Deploying Midnight DID contract...");
|
|
22
|
+
const didContract = await deployContract(providers, {
|
|
23
|
+
compiledContract: midnightDIDCompiledContract,
|
|
24
|
+
privateStateId: MidnightDIDPrivateStateId,
|
|
25
|
+
initialPrivateState: privateState,
|
|
26
|
+
});
|
|
27
|
+
bindPrivateStateProvider(providers, didContract.deployTxData.public.contractAddress);
|
|
28
|
+
// `deployContract` receives the initial state for proving; this explicit
|
|
29
|
+
// post-bind save makes the controller key durable for subsequent sessions.
|
|
30
|
+
await savePrivateState(providers, privateState);
|
|
31
|
+
getLogger().info(`Deployed contract at address: ${didContract.deployTxData.public.contractAddress}`);
|
|
32
|
+
return didContract;
|
|
33
|
+
};
|
|
34
|
+
export const createDID = async (providers, privateState) => {
|
|
35
|
+
getLogger().info("Creating DID...");
|
|
36
|
+
const didContract = await deploy(providers, privateState);
|
|
37
|
+
getLogger().info(`Created DID at contract address: ${didContract.deployTxData.public.contractAddress}`);
|
|
38
|
+
return didContract;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=contract-lifecycle-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-lifecycle-operations.js","sourceRoot":"","sources":["../src/contract-lifecycle-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,SAAS,EA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E,CAAC,IAAI,CACd,iCAAiC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,EAAE,CACnF,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,SAA+B,EAC/B,YAAqC,EACC,EAAE;IACxC,SAAS,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1D,SAAS,EAAE,CAAC,IAAI,CACd,oCAAoC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,EAAE,CACtF,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-lifecycle.js","sourceRoot":"","sources":["../src/contract-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FinalizedTxData } from "@midnight-ntwrk/midnight-js-types";
|
|
2
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDProviders } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Rotates the DID controller key to a freshly derived controller public key.
|
|
5
|
+
*
|
|
6
|
+
* The replacement secret is first written to a pending recovery slot, then
|
|
7
|
+
* promoted to active private state after the transaction finalizes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const rotateControllerKey: (didContract: DeployedMidnightDIDContract, providers: MidnightDIDProviders, newSecretKey?: Uint8Array) => Promise<FinalizedTxData>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { deriveControllerPublicKey } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { getLogger } from "./api-logger.js";
|
|
3
|
+
import { randomBytes } from "./lightweight.js";
|
|
4
|
+
import { clearPendingControllerPrivateState, savePendingControllerPrivateState, savePrivateState, } from "./private-state.js";
|
|
5
|
+
const privateStateFromSecret = (secretKey) => {
|
|
6
|
+
if (!(secretKey instanceof Uint8Array) || secretKey.length !== 32) {
|
|
7
|
+
throw new Error("DID controller secret key must be 32 bytes");
|
|
8
|
+
}
|
|
9
|
+
return { secretKey: new Uint8Array(secretKey) };
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Rotates the DID controller key to a freshly derived controller public key.
|
|
13
|
+
*
|
|
14
|
+
* The replacement secret is first written to a pending recovery slot, then
|
|
15
|
+
* promoted to active private state after the transaction finalizes.
|
|
16
|
+
*/
|
|
17
|
+
export const rotateControllerKey = async (didContract, providers, newSecretKey = randomBytes(32)) => {
|
|
18
|
+
const nextPrivateState = privateStateFromSecret(newSecretKey);
|
|
19
|
+
const nextControllerPublicKey = deriveControllerPublicKey(nextPrivateState.secretKey);
|
|
20
|
+
await savePendingControllerPrivateState(providers, nextPrivateState);
|
|
21
|
+
let finalized = false;
|
|
22
|
+
try {
|
|
23
|
+
const result = await didContract.callTx.rotateControllerKey(nextControllerPublicKey);
|
|
24
|
+
finalized = true;
|
|
25
|
+
await savePrivateState(providers, nextPrivateState);
|
|
26
|
+
try {
|
|
27
|
+
await clearPendingControllerPrivateState(providers);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
getLogger().warn({ error }, "Controller key rotation finalized, but pending private state cleanup failed.");
|
|
31
|
+
}
|
|
32
|
+
return result.public;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (!finalized) {
|
|
36
|
+
try {
|
|
37
|
+
await clearPendingControllerPrivateState(providers);
|
|
38
|
+
}
|
|
39
|
+
catch (cleanupError) {
|
|
40
|
+
getLogger().warn({ error: cleanupError }, "Controller key rotation failed before finalization, and pending private state cleanup failed.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
getLogger().error({ error }, "Controller key rotation finalized, but active private state promotion failed. Use recoverPendingControllerPrivateState() before submitting further controller operations.");
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=controller-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-operations.js","sourceRoot":"","sources":["../src/controller-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAO5B,MAAM,sBAAsB,GAAG,CAC7B,SAAqB,EACI,EAAE;IAC3B,IAAI,CAAC,CAAC,SAAS,YAAY,UAAU,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;AAClD,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,WAAwC,EACxC,SAA+B,EAC/B,eAA2B,WAAW,CAAC,EAAE,CAAC,EAChB,EAAE;IAC5B,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAC9D,MAAM,uBAAuB,GAAG,yBAAyB,CACvD,gBAAgB,CAAC,SAAS,CAC3B,CAAC;IAEF,MAAM,iCAAiC,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAErE,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,mBAAmB,CACzD,uBAAuB,CACxB,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"}
|
package/dist/deploy.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "./polyfills.js";
|
|
2
|
+
export { midnightDIDContractInstance } from "./contract-instance.js";
|
|
3
|
+
export { createDID, deploy, joinContract, } from "./contract-lifecycle-operations.js";
|
|
4
|
+
export { rotateControllerKey } from "./controller-operations.js";
|
|
5
|
+
export { getMidnightDIDLedgerState, requireDeployedMidnightDIDLedgerState, requireMidnightDIDLedgerState, } from "./ledger-state.js";
|
|
6
|
+
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
package/dist/deploy.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./polyfills.js";
|
|
2
|
+
export { midnightDIDContractInstance } from "./contract-instance.js";
|
|
3
|
+
export { createDID, deploy, joinContract, } from "./contract-lifecycle-operations.js";
|
|
4
|
+
export { rotateControllerKey } from "./controller-operations.js";
|
|
5
|
+
export { getMidnightDIDLedgerState, requireDeployedMidnightDIDLedgerState, requireMidnightDIDLedgerState, } from "./ledger-state.js";
|
|
6
|
+
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
|
7
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,SAAS,EACT,MAAM,EACN,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,yBAAyB,EACzB,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,oCAAoC,EACpC,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-operations.js","sourceRoot":"","sources":["../src/did-operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MidnightNetwork } from "@midnight-ntwrk/midnight-did/midnight";
|
|
2
|
+
import { type BoundIdField } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
+
import { type DeployedMidnightDIDContract } from "./types.js";
|
|
4
|
+
export declare const getMidnightNetwork: () => MidnightNetwork;
|
|
5
|
+
export declare const getDidSubject: (didContract: DeployedMidnightDIDContract) => string;
|
|
6
|
+
export declare const normalizeBoundFragmentId: (didContract: DeployedMidnightDIDContract, value: string, field: BoundIdField) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createMidnightDIDString, parseContractAddress, } from "@midnight-ntwrk/midnight-did/midnight";
|
|
2
|
+
import { normalizeBoundFragmentId as normalizeBoundFragmentIdWithSubject, } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
+
import { getNetworkId } from "@midnight-ntwrk/midnight-js-network-id";
|
|
4
|
+
import { RuntimeToDomain } from "./runtime-to-domain.js";
|
|
5
|
+
export const getMidnightNetwork = () => RuntimeToDomain.NetworkMap[getNetworkId()];
|
|
6
|
+
export const getDidSubject = (didContract) => {
|
|
7
|
+
const contractAddress = parseContractAddress(didContract.deployTxData.public.contractAddress);
|
|
8
|
+
return createMidnightDIDString(contractAddress, getMidnightNetwork());
|
|
9
|
+
};
|
|
10
|
+
export const normalizeBoundFragmentId = (didContract, value, field) => normalizeBoundFragmentIdWithSubject(value, field, getDidSubject(didContract));
|
|
11
|
+
//# sourceMappingURL=did-subject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-subject.js","sourceRoot":"","sources":["../src/did-subject.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAEvB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,wBAAwB,IAAI,mCAAmC,GAChE,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAoB,EAAE,CACtD,eAAe,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,WAAwC,EAChC,EAAE;IACV,MAAM,eAAe,GAAG,oBAAoB,CAC1C,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,CAChD,CAAC;IACF,OAAO,uBAAuB,CAAC,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,WAAwC,EACxC,KAAa,EACb,KAAmB,EACX,EAAE,CACV,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { assertAbsoluteUri } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
+
export const addAlsoKnownAs = async (didContract, aliasUri) => {
|
|
4
|
+
const alias = assertAbsoluteUri(aliasUri, "aliasUri");
|
|
5
|
+
const result = await didContract.callTx.setAlsoKnownAs(alias, DIDContract.SetMutation.Insert);
|
|
6
|
+
return result.public;
|
|
7
|
+
};
|
|
8
|
+
export const removeAlsoKnownAs = async (didContract, aliasUri) => {
|
|
9
|
+
const alias = assertAbsoluteUri(aliasUri, "aliasUri");
|
|
10
|
+
const result = await didContract.callTx.setAlsoKnownAs(alias, DIDContract.SetMutation.Remove);
|
|
11
|
+
return result.public;
|
|
12
|
+
};
|
|
13
|
+
export const deactivate = async (didContract) => {
|
|
14
|
+
const result = await didContract.callTx.deactivate();
|
|
15
|
+
return result.public;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=document-operations.js.map
|
|
@@ -0,0 +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;AAKxE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,WAAwC,EACxC,QAAgB,EACU,EAAE;IAC5B,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,CACpD,KAAK,EACL,WAAW,CAAC,WAAW,CAAC,MAAM,CAC/B,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,WAAwC,EACxC,QAAgB,EACU,EAAE;IAC5B,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,CACpD,KAAK,EACL,WAAW,CAAC,WAAW,CAAC,MAAM,CAC/B,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,WAAwC,EACd,EAAE;IAC5B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-to-runtime.js","sourceRoot":"","sources":["../src/domain-to-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,OAAO,eAAe;IAC1B,MAAM,KAAK,UAAU;QACnB,OAAO,6BAA6B,CAAC;IACvC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./domain-to-runtime.js";
|
|
3
|
+
export * from "./lib.js";
|
|
4
|
+
export * from "./logger-utils.js";
|
|
5
|
+
export type { DomainToRuntimeNetworkMap, RuntimeToDomainNetworkMap, } from "./network-mapping.js";
|
|
6
|
+
export * from "./release-artifacts.js";
|
|
7
|
+
export * from "./runtime-to-domain.js";
|
|
8
|
+
export * from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./domain-to-runtime.js";
|
|
3
|
+
export * from "./lib.js";
|
|
4
|
+
export * from "./logger-utils.js";
|
|
5
|
+
export * from "./release-artifacts.js";
|
|
6
|
+
export * from "./runtime-to-domain.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { Service, VerificationMethod, VerificationMethodRelationType } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
+
import { type DeployedMidnightDIDContract, type SchnorrJubjubVerificationMethod } from "./types.js";
|
|
4
|
+
declare const LedgerVerificationMethodRelation: typeof DIDContract.VerificationMethodRelation;
|
|
5
|
+
export declare const LedgerVerificationMethodRelationMap: Record<VerificationMethodRelationType, (typeof LedgerVerificationMethodRelation)[keyof typeof LedgerVerificationMethodRelation]>;
|
|
6
|
+
export declare const verificationMethodToLedger: (didContract: DeployedMidnightDIDContract, method: VerificationMethod) => DIDContract.VerificationMethod;
|
|
7
|
+
export declare const schnorrJubjubVerificationMethodToLedger: (didContract: DeployedMidnightDIDContract, method: SchnorrJubjubVerificationMethod) => DIDContract.SchnorrJubjubVerificationMethod;
|
|
8
|
+
export declare const serviceToLedger: (didContract: DeployedMidnightDIDContract, service: Service) => DIDContract.Service;
|
|
9
|
+
export declare const relationSetFromState: (didState: DIDContract.Ledger, relation: VerificationMethodRelationType) => {
|
|
10
|
+
isEmpty(): boolean;
|
|
11
|
+
size(): bigint;
|
|
12
|
+
member(elem_0: string): boolean;
|
|
13
|
+
[Symbol.iterator](): Iterator<string>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
2
|
+
import { CurveType, decodeBase64UrlBytes, KeyType, publicKeyJwkCoordinateByteLength, serviceEndpointToLedger as serviceEndpointToLedgerValue, serviceTypeToLedger as serviceTypeToLedgerValue, VerificationMethodRelationType, VerificationMethodType, } from "@midnight-ntwrk/midnight-did-domain";
|
|
3
|
+
import { getDidSubject, normalizeBoundFragmentId } from "./did-subject.js";
|
|
4
|
+
const LedgerKeyType = DIDContract.KeyType;
|
|
5
|
+
const LedgerCurveType = DIDContract.CurveType;
|
|
6
|
+
const LedgerVerificationMethodType = DIDContract.VerificationMethodType;
|
|
7
|
+
const LedgerVerificationMethodRelation = DIDContract.VerificationMethodRelation;
|
|
8
|
+
const LedgerKeyTypeMap = {
|
|
9
|
+
[KeyType.EC]: LedgerKeyType.EC,
|
|
10
|
+
[KeyType.RSA]: LedgerKeyType.RSA,
|
|
11
|
+
[KeyType.oct]: LedgerKeyType.oct,
|
|
12
|
+
[KeyType.OKP]: LedgerKeyType.OKP,
|
|
13
|
+
};
|
|
14
|
+
const LedgerCurveTypeMap = {
|
|
15
|
+
[CurveType.Ed25519]: LedgerCurveType.Ed25519,
|
|
16
|
+
[CurveType.X25519]: LedgerCurveType.X25519,
|
|
17
|
+
[CurveType.Jubjub]: LedgerCurveType.Jubjub,
|
|
18
|
+
[CurveType.P256]: LedgerCurveType.P256,
|
|
19
|
+
[CurveType.Secp256k1]: LedgerCurveType.Secp256k1,
|
|
20
|
+
[CurveType.BLS12381G1]: LedgerCurveType.BLS12381G1,
|
|
21
|
+
[CurveType.BLS12381G2]: LedgerCurveType.BLS12381G2,
|
|
22
|
+
};
|
|
23
|
+
const LedgerVerificationMethodTypeMap = {
|
|
24
|
+
[VerificationMethodType.Undefined]: LedgerVerificationMethodType.Undefined,
|
|
25
|
+
[VerificationMethodType.JsonWebKey]: LedgerVerificationMethodType.JsonWebKey,
|
|
26
|
+
};
|
|
27
|
+
export const LedgerVerificationMethodRelationMap = {
|
|
28
|
+
[VerificationMethodRelationType.Undefined]: LedgerVerificationMethodRelation.Undefined,
|
|
29
|
+
[VerificationMethodRelationType.Authentication]: LedgerVerificationMethodRelation.Authentication,
|
|
30
|
+
[VerificationMethodRelationType.AssertionMethod]: LedgerVerificationMethodRelation.AssertionMethod,
|
|
31
|
+
[VerificationMethodRelationType.KeyAgreement]: LedgerVerificationMethodRelation.KeyAgreement,
|
|
32
|
+
[VerificationMethodRelationType.CapabilityInvocation]: LedgerVerificationMethodRelation.CapabilityInvocation,
|
|
33
|
+
[VerificationMethodRelationType.CapabilityDelegation]: LedgerVerificationMethodRelation.CapabilityDelegation,
|
|
34
|
+
};
|
|
35
|
+
const publicKeyJwkToLedger = (publicKeyJwk) => {
|
|
36
|
+
if ("d" in publicKeyJwk) {
|
|
37
|
+
throw new Error("publicKeyJwk must not include private key material");
|
|
38
|
+
}
|
|
39
|
+
const kty = LedgerKeyTypeMap[publicKeyJwk.kty];
|
|
40
|
+
const crv = LedgerCurveTypeMap[publicKeyJwk.crv];
|
|
41
|
+
const xLength = publicKeyJwkCoordinateByteLength(publicKeyJwk, "x");
|
|
42
|
+
if (xLength === undefined) {
|
|
43
|
+
throw new Error(`Unsupported publicKeyJwk.x profile ${publicKeyJwk.kty}/${publicKeyJwk.crv}`);
|
|
44
|
+
}
|
|
45
|
+
decodeBase64UrlBytes(publicKeyJwk.x, xLength, "publicKeyJwk.x");
|
|
46
|
+
if (publicKeyJwk.y !== undefined) {
|
|
47
|
+
const yLength = publicKeyJwkCoordinateByteLength(publicKeyJwk, "y");
|
|
48
|
+
if (yLength === undefined) {
|
|
49
|
+
throw new Error(`Unsupported publicKeyJwk.y profile ${publicKeyJwk.kty}/${publicKeyJwk.crv}`);
|
|
50
|
+
}
|
|
51
|
+
decodeBase64UrlBytes(publicKeyJwk.y, yLength, "publicKeyJwk.y");
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
kty,
|
|
55
|
+
crv,
|
|
56
|
+
x: publicKeyJwk.x,
|
|
57
|
+
y: publicKeyJwk.y ?? "",
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const assertMidnightKeyProfile = (publicKeyJwk) => {
|
|
61
|
+
if (publicKeyJwk.kty === KeyType.OKP) {
|
|
62
|
+
if (publicKeyJwk.crv !== CurveType.Ed25519 &&
|
|
63
|
+
publicKeyJwk.crv !== CurveType.X25519 &&
|
|
64
|
+
publicKeyJwk.crv !== CurveType.BLS12381G1 &&
|
|
65
|
+
publicKeyJwk.crv !== CurveType.BLS12381G2) {
|
|
66
|
+
throw new Error("OKP keys must use Ed25519, X25519, BLS12381G1, or BLS12381G2");
|
|
67
|
+
}
|
|
68
|
+
if (publicKeyJwk.y !== undefined) {
|
|
69
|
+
throw new Error("OKP keys must not include a y coordinate");
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (publicKeyJwk.kty === KeyType.EC) {
|
|
74
|
+
if (publicKeyJwk.crv === CurveType.Jubjub) {
|
|
75
|
+
throw new Error("Jubjub keys must use addSchnorrJubjubVerificationMethod");
|
|
76
|
+
}
|
|
77
|
+
if (publicKeyJwk.crv !== CurveType.P256 &&
|
|
78
|
+
publicKeyJwk.crv !== CurveType.Secp256k1) {
|
|
79
|
+
throw new Error("EC keys must use P-256 or secp256k1; use SchnorrJubjub methods for Jubjub");
|
|
80
|
+
}
|
|
81
|
+
if (publicKeyJwk.y === undefined) {
|
|
82
|
+
throw new Error("EC keys must include a y coordinate");
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
throw new Error("Only OKP (Ed25519/X25519/BLS12381G1/BLS12381G2) and EC (P-256/secp256k1) keys are supported");
|
|
87
|
+
};
|
|
88
|
+
export const verificationMethodToLedger = (didContract, method) => {
|
|
89
|
+
if (method.type !== VerificationMethodType.JsonWebKey) {
|
|
90
|
+
throw new Error("verificationMethod.type must be JsonWebKey");
|
|
91
|
+
}
|
|
92
|
+
assertMidnightKeyProfile(method.publicKeyJwk);
|
|
93
|
+
const didSubject = getDidSubject(didContract);
|
|
94
|
+
if (method.controller !== didSubject) {
|
|
95
|
+
throw new Error(`verificationMethod.controller must equal DID subject (${didSubject})`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
id: normalizeBoundFragmentId(didContract, method.id, "verificationMethod.id"),
|
|
99
|
+
typ: LedgerVerificationMethodTypeMap[method.type],
|
|
100
|
+
publicKeyJwk: publicKeyJwkToLedger(method.publicKeyJwk),
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export const schnorrJubjubVerificationMethodToLedger = (didContract, method) => ({
|
|
104
|
+
id: normalizeBoundFragmentId(didContract, method.id, "schnorrJubjubVerificationMethod.id"),
|
|
105
|
+
publicKey: method.publicKey,
|
|
106
|
+
});
|
|
107
|
+
export const serviceToLedger = (didContract, service) => {
|
|
108
|
+
let endpoint;
|
|
109
|
+
try {
|
|
110
|
+
endpoint = serviceEndpointToLedgerValue(service.serviceEndpoint);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new Error("Invalid serviceEndpoint: could not serialize to JSON");
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
id: normalizeBoundFragmentId(didContract, service.id, "service.id"),
|
|
117
|
+
typ: serviceTypeToLedgerValue(service.type),
|
|
118
|
+
serviceEndpoint: endpoint,
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export const relationSetFromState = (didState, relation) => {
|
|
122
|
+
switch (relation) {
|
|
123
|
+
case VerificationMethodRelationType.Authentication:
|
|
124
|
+
return didState.authenticationRelation;
|
|
125
|
+
case VerificationMethodRelationType.AssertionMethod:
|
|
126
|
+
return didState.assertionMethodRelation;
|
|
127
|
+
case VerificationMethodRelationType.KeyAgreement:
|
|
128
|
+
return didState.keyAgreementRelation;
|
|
129
|
+
case VerificationMethodRelationType.CapabilityInvocation:
|
|
130
|
+
return didState.capabilityInvocationRelation;
|
|
131
|
+
case VerificationMethodRelationType.CapabilityDelegation:
|
|
132
|
+
return didState.capabilityDelegationRelation;
|
|
133
|
+
case VerificationMethodRelationType.Undefined:
|
|
134
|
+
throw new Error("relation must be defined");
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=ledger-mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-mappers.js","sourceRoot":"","sources":["../src/ledger-mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,OAAO,EAEP,gCAAgC,EAEhC,uBAAuB,IAAI,4BAA4B,EACvD,mBAAmB,IAAI,wBAAwB,EAE/C,8BAA8B,EAC9B,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAA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,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,EAAE,EAAE,wBAAwB,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC;QACnE,GAAG,EAAE,wBAAwB,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3C,eAAe,EAAE,QAAQ;KAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,QAA4B,EAC5B,QAAwC,EACxC,EAAE;IACF,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,8BAA8B,CAAC,cAAc;YAChD,OAAO,QAAQ,CAAC,sBAAsB,CAAC;QACzC,KAAK,8BAA8B,CAAC,eAAe;YACjD,OAAO,QAAQ,CAAC,uBAAuB,CAAC;QAC1C,KAAK,8BAA8B,CAAC,YAAY;YAC9C,OAAO,QAAQ,CAAC,oBAAoB,CAAC;QACvC,KAAK,8BAA8B,CAAC,oBAAoB;YACtD,OAAO,QAAQ,CAAC,4BAA4B,CAAC;QAC/C,KAAK,8BAA8B,CAAC,oBAAoB;YACtD,OAAO,QAAQ,CAAC,4BAA4B,CAAC;QAC/C,KAAK,8BAA8B,CAAC,SAAS;YAC3C,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ContractAddress } from "@midnight-ntwrk/midnight-did/midnight";
|
|
2
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
3
|
+
import { type DeployedMidnightDIDContract, type MidnightDIDProviders } from "./types.js";
|
|
4
|
+
export declare const getMidnightDIDLedgerState: (providers: MidnightDIDProviders, contractAddress: ContractAddress) => Promise<DIDContract.Ledger | null>;
|
|
5
|
+
export declare const requireMidnightDIDLedgerState: (providers: MidnightDIDProviders, contractAddress: ContractAddress) => Promise<DIDContract.Ledger>;
|
|
6
|
+
export declare const requireDeployedMidnightDIDLedgerState: (providers: MidnightDIDProviders, didContract: DeployedMidnightDIDContract) => Promise<DIDContract.Ledger>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LedgerToDomain } from "@midnight-ntwrk/midnight-did";
|
|
2
|
+
import { parseContractAddress, } from "@midnight-ntwrk/midnight-did/midnight";
|
|
3
|
+
import { DIDContract } from "@midnight-ntwrk/midnight-did-contract";
|
|
4
|
+
import { assertIsContractAddress } from "@midnight-ntwrk/midnight-js-utils";
|
|
5
|
+
import { getLogger } from "./api-logger.js";
|
|
6
|
+
export const getMidnightDIDLedgerState = async (providers, contractAddress) => {
|
|
7
|
+
assertIsContractAddress(contractAddress);
|
|
8
|
+
getLogger().info("Checking MidnightDID contract ledger state...");
|
|
9
|
+
const state = await providers.publicDataProvider
|
|
10
|
+
.queryContractState(contractAddress)
|
|
11
|
+
.then((contractState) => contractState != null ? DIDContract.ledger(contractState.data) : null);
|
|
12
|
+
if (state != null)
|
|
13
|
+
getLogger().info(LedgerToDomain.toJSON(state));
|
|
14
|
+
return state;
|
|
15
|
+
};
|
|
16
|
+
export const requireMidnightDIDLedgerState = async (providers, contractAddress) => {
|
|
17
|
+
const didState = await getMidnightDIDLedgerState(providers, contractAddress);
|
|
18
|
+
if (!didState) {
|
|
19
|
+
throw new Error("Cannot query DID state");
|
|
20
|
+
}
|
|
21
|
+
return didState;
|
|
22
|
+
};
|
|
23
|
+
export const requireDeployedMidnightDIDLedgerState = async (providers, didContract) => await requireMidnightDIDLedgerState(providers, parseContractAddress(didContract.deployTxData.public.contractAddress));
|
|
24
|
+
//# sourceMappingURL=ledger-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-state.js","sourceRoot":"","sources":["../src/ledger-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAEL,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,WAAW,EAA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ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./polyfills.js";
|
|
2
|
+
export { setLogger } from "./api-logger.js";
|
|
3
|
+
export { midnightDIDContractInstance } from "./contract-instance.js";
|
|
4
|
+
export { createDID, deploy, joinContract, } from "./contract-lifecycle-operations.js";
|
|
5
|
+
export { rotateControllerKey } from "./controller-operations.js";
|
|
6
|
+
export { getMidnightNetwork } from "./did-subject.js";
|
|
7
|
+
export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-operations.js";
|
|
8
|
+
export { getMidnightDIDLedgerState } from "./ledger-state.js";
|
|
9
|
+
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
|
10
|
+
export { configureProviders, createWalletAndMidnightProvider, } from "./providers.js";
|
|
11
|
+
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
12
|
+
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
13
|
+
export { addSchnorrJubjubVerificationMethod, addVerificationMethod, addVerificationMethodRelation, removeSchnorrJubjubVerificationMethod, removeVerificationMethod, removeVerificationMethodRelation, updateSchnorrJubjubVerificationMethod, updateVerificationMethod, verifySchnorrJubjubDigestSignature, } from "./verification-method-operations.js";
|
|
14
|
+
export { buildFreshWallet, buildWallet, buildWalletAndWaitForFunds, getWalletBalances, registerForDustGeneration, restoreWalletFromState, serializeWalletState, waitForWalletFunds, waitForWalletSync, } from "./wallet.js";
|
|
15
|
+
export { deriveUnshieldedAddressFromSeed } from "./wallet-keys.js";
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./polyfills.js";
|
|
2
|
+
export { setLogger } from "./api-logger.js";
|
|
3
|
+
export { midnightDIDContractInstance } from "./contract-instance.js";
|
|
4
|
+
export { createDID, deploy, joinContract, } from "./contract-lifecycle-operations.js";
|
|
5
|
+
export { rotateControllerKey } from "./controller-operations.js";
|
|
6
|
+
export { getMidnightNetwork } from "./did-subject.js";
|
|
7
|
+
export { addAlsoKnownAs, deactivate, removeAlsoKnownAs, } from "./document-operations.js";
|
|
8
|
+
export { getMidnightDIDLedgerState } from "./ledger-state.js";
|
|
9
|
+
export { initPrivateState, recoverPendingControllerPrivateState, requirePrivateState, restorePrivateState, } from "./private-state.js";
|
|
10
|
+
export { configureProviders, createWalletAndMidnightProvider, } from "./providers.js";
|
|
11
|
+
export { resolve, resolveDIDResolutionResult } from "./resolution.js";
|
|
12
|
+
export { addService, removeService, updateService, } from "./service-operations.js";
|
|
13
|
+
export { addSchnorrJubjubVerificationMethod, addVerificationMethod, addVerificationMethodRelation, removeSchnorrJubjubVerificationMethod, removeVerificationMethod, removeVerificationMethodRelation, updateSchnorrJubjubVerificationMethod, updateVerificationMethod, verifySchnorrJubjubDigestSignature, } from "./verification-method-operations.js";
|
|
14
|
+
export { buildFreshWallet, buildWallet, buildWalletAndWaitForFunds, getWalletBalances, registerForDustGeneration, restoreWalletFromState, serializeWalletState, waitForWalletFunds, waitForWalletSync, } from "./wallet.js";
|
|
15
|
+
export { deriveUnshieldedAddressFromSeed } from "./wallet-keys.js";
|
|
16
|
+
//# sourceMappingURL=lib.js.map
|
package/dist/lib.js.map
ADDED
|
@@ -0,0 +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,EACL,SAAS,EACT,MAAM,EACN,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,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,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,oCAAoC,EACpC,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const randomBytes: (length: number) => Uint8Array;
|