@europeum-ebsi/cli 0.0.0 → 1.0.0-rc.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/LICENSE.txt +289 -289
- package/LICENSES.txt +538 -0
- package/README.md +1140 -98
- package/dist/api/client.d.ts +4 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +14 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/fetch.d.ts +13 -0
- package/dist/api/fetch.d.ts.map +1 -0
- package/dist/api/fetch.js +30 -0
- package/dist/api/fetch.js.map +1 -0
- package/dist/api/params.d.ts +4 -0
- package/dist/api/params.d.ts.map +1 -0
- package/dist/api/params.js +9 -0
- package/dist/api/params.js.map +1 -0
- package/dist/auth/dcql.d.ts +5 -0
- package/dist/auth/dcql.d.ts.map +1 -0
- package/dist/auth/dcql.js +41 -0
- package/dist/auth/dcql.js.map +1 -0
- package/dist/auth/presentation.d.ts +30 -0
- package/dist/auth/presentation.d.ts.map +1 -0
- package/dist/auth/presentation.js +99 -0
- package/dist/auth/presentation.js.map +1 -0
- package/dist/auth/token.d.ts +11 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +116 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +96 -10
- package/dist/cli.js.map +1 -1
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +99 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +3 -0
- package/dist/commands/config-cmd.d.ts.map +1 -0
- package/dist/commands/config-cmd.js +86 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/contracts-registry.d.ts +3 -0
- package/dist/commands/contracts-registry.d.ts.map +1 -0
- package/dist/commands/contracts-registry.js +132 -0
- package/dist/commands/contracts-registry.js.map +1 -0
- package/dist/commands/did-registry.d.ts +3 -0
- package/dist/commands/did-registry.d.ts.map +1 -0
- package/dist/commands/did-registry.js +110 -0
- package/dist/commands/did-registry.js.map +1 -0
- package/dist/commands/faucet.d.ts +3 -0
- package/dist/commands/faucet.d.ts.map +1 -0
- package/dist/commands/faucet.js +78 -0
- package/dist/commands/faucet.js.map +1 -0
- package/dist/commands/health.d.ts +3 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +20 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/issuers-registry.d.ts +3 -0
- package/dist/commands/issuers-registry.d.ts.map +1 -0
- package/dist/commands/issuers-registry.js +340 -0
- package/dist/commands/issuers-registry.js.map +1 -0
- package/dist/commands/ledger.d.ts +3 -0
- package/dist/commands/ledger.d.ts.map +1 -0
- package/dist/commands/ledger.js +549 -372
- package/dist/commands/ledger.js.map +1 -1
- package/dist/commands/onboarding.d.ts +3 -0
- package/dist/commands/onboarding.d.ts.map +1 -0
- package/dist/commands/onboarding.js +301 -0
- package/dist/commands/onboarding.js.map +1 -0
- package/dist/commands/openapi.d.ts +3 -0
- package/dist/commands/openapi.d.ts.map +1 -0
- package/dist/commands/openapi.js +37 -0
- package/dist/commands/openapi.js.map +1 -0
- package/dist/commands/policies-registry.d.ts +3 -0
- package/dist/commands/policies-registry.d.ts.map +1 -0
- package/dist/commands/policies-registry.js +198 -0
- package/dist/commands/policies-registry.js.map +1 -0
- package/dist/commands/registry.d.ts +27 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +62 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/schemas-registry.d.ts +3 -0
- package/dist/commands/schemas-registry.d.ts.map +1 -0
- package/dist/commands/schemas-registry.js +231 -0
- package/dist/commands/schemas-registry.js.map +1 -0
- package/dist/commands/shared/args.d.ts +2 -0
- package/dist/commands/shared/args.d.ts.map +1 -0
- package/dist/commands/shared/args.js +4 -0
- package/dist/commands/shared/args.js.map +1 -0
- package/dist/commands/shared/wallet-opts.d.ts +9 -0
- package/dist/commands/shared/wallet-opts.d.ts.map +1 -0
- package/dist/commands/shared/wallet-opts.js +44 -0
- package/dist/commands/shared/wallet-opts.js.map +1 -0
- package/dist/commands/timestamp.d.ts +3 -0
- package/dist/commands/timestamp.d.ts.map +1 -0
- package/dist/commands/timestamp.js +250 -0
- package/dist/commands/timestamp.js.map +1 -0
- package/dist/commands/track-and-trace.d.ts +3 -0
- package/dist/commands/track-and-trace.d.ts.map +1 -0
- package/dist/commands/track-and-trace.js +235 -0
- package/dist/commands/track-and-trace.js.map +1 -0
- package/dist/commands/wallet.d.ts +3 -0
- package/dist/commands/wallet.d.ts.map +1 -0
- package/dist/commands/wallet.js +123 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/config/config.d.ts +45 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +111 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/ebsi-env.d.ts +4 -0
- package/dist/config/ebsi-env.d.ts.map +1 -0
- package/dist/config/ebsi-env.js +37 -0
- package/dist/config/ebsi-env.js.map +1 -0
- package/dist/crypto/wallet.d.ts +34 -0
- package/dist/crypto/wallet.d.ts.map +1 -0
- package/dist/crypto/wallet.js +100 -0
- package/dist/crypto/wallet.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/ledger/read.d.ts +11 -0
- package/dist/ledger/read.d.ts.map +1 -0
- package/dist/ledger/read.js +24 -0
- package/dist/ledger/read.js.map +1 -0
- package/dist/ledger/registries.d.ts +25 -0
- package/dist/ledger/registries.d.ts.map +1 -0
- package/dist/ledger/registries.js +111 -0
- package/dist/ledger/registries.js.map +1 -0
- package/dist/ledger/write.d.ts +43 -0
- package/dist/ledger/write.d.ts.map +1 -0
- package/dist/ledger/write.js +119 -0
- package/dist/ledger/write.js.map +1 -0
- package/dist/onboarding/vc.d.ts +18 -0
- package/dist/onboarding/vc.d.ts.map +1 -0
- package/dist/onboarding/vc.js +72 -0
- package/dist/onboarding/vc.js.map +1 -0
- package/dist/output/format.d.ts +7 -0
- package/dist/output/format.d.ts.map +1 -0
- package/dist/output/format.js +94 -0
- package/dist/output/format.js.map +1 -0
- package/dist/tui/App.d.ts +3 -0
- package/dist/tui/App.d.ts.map +1 -0
- package/dist/tui/App.js +99 -0
- package/dist/tui/App.js.map +1 -0
- package/dist/tui/CommandPalette.d.ts +8 -0
- package/dist/tui/CommandPalette.d.ts.map +1 -0
- package/dist/tui/CommandPalette.js +105 -0
- package/dist/tui/CommandPalette.js.map +1 -0
- package/package.json +66 -108
- package/src/api/client.ts +26 -0
- package/src/api/fetch.ts +53 -0
- package/src/api/params.ts +17 -0
- package/src/auth/dcql.ts +84 -0
- package/src/auth/presentation.ts +255 -0
- package/src/auth/token.ts +244 -0
- package/src/cli.ts +164 -0
- package/src/commands/auth.ts +119 -0
- package/src/commands/config-cmd.ts +122 -0
- package/src/commands/contracts-registry.ts +156 -0
- package/src/commands/did-registry.ts +126 -0
- package/src/commands/faucet.ts +112 -0
- package/src/commands/health.ts +21 -0
- package/src/commands/issuers-registry.ts +385 -0
- package/src/commands/ledger.ts +777 -0
- package/src/commands/onboarding.ts +411 -0
- package/src/commands/openapi.ts +42 -0
- package/src/commands/policies-registry.ts +218 -0
- package/src/commands/registry.ts +152 -0
- package/src/commands/schemas-registry.ts +255 -0
- package/src/commands/shared/args.ts +14 -0
- package/src/commands/shared/wallet-opts.ts +85 -0
- package/src/commands/timestamp.ts +272 -0
- package/src/commands/track-and-trace.ts +263 -0
- package/src/commands/wallet.ts +175 -0
- package/src/config/config.ts +275 -0
- package/src/config/ebsi-env.ts +67 -0
- package/src/crypto/wallet.ts +291 -0
- package/src/index.ts +24 -0
- package/src/ledger/read.ts +70 -0
- package/src/ledger/registries.ts +285 -0
- package/src/ledger/write.ts +381 -0
- package/src/onboarding/vc.ts +205 -0
- package/src/output/format.ts +157 -0
- package/src/tui/App.tsx +282 -0
- package/src/tui/CommandPalette.tsx +223 -0
- package/bin/cli.js +0 -13
- package/dist/abi/pilot/DidRegistry.js +0 -568
- package/dist/abi/pilot/DidRegistry.js.map +0 -1
- package/dist/abi/pilot/Ptr.js +0 -666
- package/dist/abi/pilot/Ptr.js.map +0 -1
- package/dist/abi/pilot/SchemaSCRegistry.js +0 -264
- package/dist/abi/pilot/SchemaSCRegistry.js.map +0 -1
- package/dist/abi/pilot/Tcr.js +0 -715
- package/dist/abi/pilot/Tcr.js.map +0 -1
- package/dist/abi/pilot/Timestamp.js +0 -658
- package/dist/abi/pilot/Timestamp.js.map +0 -1
- package/dist/abi/pilot/Tir.js +0 -428
- package/dist/abi/pilot/Tir.js.map +0 -1
- package/dist/abi/pilot/TnT.js +0 -842
- package/dist/abi/pilot/TnT.js.map +0 -1
- package/dist/abi/pilot/Tpr.js +0 -492
- package/dist/abi/pilot/Tpr.js.map +0 -1
- package/dist/abi/test/DidRegistry.js +0 -568
- package/dist/abi/test/DidRegistry.js.map +0 -1
- package/dist/abi/test/Ptr.js +0 -666
- package/dist/abi/test/Ptr.js.map +0 -1
- package/dist/abi/test/SchemaSCRegistry.js +0 -300
- package/dist/abi/test/SchemaSCRegistry.js.map +0 -1
- package/dist/abi/test/Tcr.js +0 -715
- package/dist/abi/test/Tcr.js.map +0 -1
- package/dist/abi/test/Timestamp.js +0 -658
- package/dist/abi/test/Timestamp.js.map +0 -1
- package/dist/abi/test/Tir.js +0 -428
- package/dist/abi/test/Tir.js.map +0 -1
- package/dist/abi/test/TnT.js +0 -842
- package/dist/abi/test/TnT.js.map +0 -1
- package/dist/abi/test/Tpr.js +0 -492
- package/dist/abi/test/Tpr.js.map +0 -1
- package/dist/app.js +0 -659
- package/dist/app.js.map +0 -1
- package/dist/buildParam/didr.js +0 -374
- package/dist/buildParam/didr.js.map +0 -1
- package/dist/buildParam/index.js +0 -53
- package/dist/buildParam/index.js.map +0 -1
- package/dist/buildParam/ptr.js +0 -80
- package/dist/buildParam/ptr.js.map +0 -1
- package/dist/buildParam/tcr.js +0 -36
- package/dist/buildParam/tcr.js.map +0 -1
- package/dist/buildParam/timestamp.js +0 -350
- package/dist/buildParam/timestamp.js.map +0 -1
- package/dist/buildParam/tir.js +0 -110
- package/dist/buildParam/tir.js.map +0 -1
- package/dist/buildParam/tnt.js +0 -214
- package/dist/buildParam/tnt.js.map +0 -1
- package/dist/buildParam/tpr.js +0 -91
- package/dist/buildParam/tpr.js.map +0 -1
- package/dist/buildParam/tsr.js +0 -115
- package/dist/buildParam/tsr.js.map +0 -1
- package/dist/commands/authorisation.js +0 -144
- package/dist/commands/authorisation.js.map +0 -1
- package/dist/commands/compute.js +0 -680
- package/dist/commands/compute.js.map +0 -1
- package/dist/commands/conformance.js +0 -813
- package/dist/commands/conformance.js.map +0 -1
- package/dist/commands/hardwarewallet.js +0 -41
- package/dist/commands/hardwarewallet.js.map +0 -1
- package/dist/commands/index.js +0 -8
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/ptr.js +0 -54
- package/dist/commands/ptr.js.map +0 -1
- package/dist/commands/tcr.js +0 -50
- package/dist/commands/tcr.js.map +0 -1
- package/dist/commands/tir.js +0 -64
- package/dist/commands/tir.js.map +0 -1
- package/dist/commands/tnl.js +0 -81
- package/dist/commands/tnl.js.map +0 -1
- package/dist/commands/tsr.js +0 -45
- package/dist/commands/tsr.js.map +0 -1
- package/dist/commands/view.js +0 -53
- package/dist/commands/view.js.map +0 -1
- package/dist/config.js +0 -497
- package/dist/config.js.map +0 -1
- package/dist/interfaces/context.js +0 -2
- package/dist/interfaces/context.js.map +0 -1
- package/dist/interfaces/contracts/ProxyFactory.js +0 -2
- package/dist/interfaces/contracts/ProxyFactory.js.map +0 -1
- package/dist/interfaces/contracts/ProxyTemplateRegistry.js +0 -2
- package/dist/interfaces/contracts/ProxyTemplateRegistry.js.map +0 -1
- package/dist/interfaces/contracts/SchemaSCRegistry.js +0 -2
- package/dist/interfaces/contracts/SchemaSCRegistry.js.map +0 -1
- package/dist/interfaces/contracts/common.js +0 -2
- package/dist/interfaces/contracts/common.js.map +0 -1
- package/dist/interfaces/index.js +0 -5
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/jsonrpc.interface.js +0 -2
- package/dist/interfaces/jsonrpc.interface.js.map +0 -1
- package/dist/interfaces/paginated-list.interface.js +0 -2
- package/dist/interfaces/paginated-list.interface.js.map +0 -1
- package/dist/interfaces/unsigned-transaction.interface.js +0 -2
- package/dist/interfaces/unsigned-transaction.interface.js.map +0 -1
- package/dist/interfaces/utils.interface.js +0 -2
- package/dist/interfaces/utils.interface.js.map +0 -1
- package/dist/programs/migrateDid.js +0 -159
- package/dist/programs/migrateDid.js.map +0 -1
- package/dist/programs/migrateDids.js +0 -232
- package/dist/programs/migrateDids.js.map +0 -1
- package/dist/programs/migrateTsr.js +0 -201
- package/dist/programs/migrateTsr.js.map +0 -1
- package/dist/scripts/accreditAndAuthorize/conformance/step1 +0 -34
- package/dist/scripts/accreditAndAuthorize/conformance/step2 +0 -18
- package/dist/scripts/accreditAndAuthorize/conformance/step3 +0 -9
- package/dist/scripts/accreditAndAuthorize/conformance/step4 +0 -27
- package/dist/scripts/accreditAndAuthorize/conformance/step5 +0 -13
- package/dist/scripts/accreditAndAuthorize/conformance/step6 +0 -14
- package/dist/scripts/accreditAndAuthorize/conformance/step7 +0 -7
- package/dist/scripts/accreditAndAuthorize/test/step1 +0 -34
- package/dist/scripts/accreditAndAuthorize/test/step2 +0 -18
- package/dist/scripts/accreditAndAuthorize/test/step3 +0 -9
- package/dist/scripts/accreditAndAuthorize/test/step4 +0 -27
- package/dist/scripts/accreditAndAuthorize/test/step5 +0 -13
- package/dist/scripts/accreditAndAuthorize/test/step6 +0 -14
- package/dist/scripts/accreditAndAuthorize/test/step7 +0 -7
- package/dist/scripts/accreditTI +0 -21
- package/dist/scripts/assets/Nodes.json +0 -27
- package/dist/scripts/assets/vcdm1.1/CTRevocableCredential.json +0 -30
- package/dist/scripts/assets/vcdm1.1/CredentialToAttestVerifiableAuthorisationForTrustChain.json +0 -29
- package/dist/scripts/assets/vcdm1.1/Nodes.json +0 -27
- package/dist/scripts/assets/vcdm1.1/TrustedNodesList.json +0 -35
- package/dist/scripts/assets/vcdm1.1/VerifiableAccreditationToAccredit.json +0 -35
- package/dist/scripts/assets/vcdm1.1/VerifiableAccreditationToAttest.json +0 -33
- package/dist/scripts/assets/vcdm1.1/VerifiableAuthorisationForTrustChain.json +0 -22
- package/dist/scripts/assets/vcdm1.1/VerifiableAuthorisationToInvoke.json +0 -24
- package/dist/scripts/assets/vcdm1.1/VerifiableAuthorisationToOnboard.json +0 -24
- package/dist/scripts/assets/vcdm2.0/CredentialToAttestVerifiableAuthorisationForTrustChain.json +0 -29
- package/dist/scripts/assets/vcdm2.0/TrustedNodesList.json +0 -36
- package/dist/scripts/assets/vcdm2.0/VerifiableAccreditationToAccredit.json +0 -40
- package/dist/scripts/assets/vcdm2.0/VerifiableAccreditationToAttest.json +0 -38
- package/dist/scripts/assets/vcdm2.0/VerifiableAuthorisationForTrustChain.json +0 -30
- package/dist/scripts/assets/vcdm2.0/VerifiableAuthorisationToInvoke.json +0 -24
- package/dist/scripts/assets/vcdm2.0/VerifiableAuthorisationToOnboard.json +0 -23
- package/dist/scripts/bootstrap/0a-loadTPROperator +0 -5
- package/dist/scripts/bootstrap/0b-loadAdmin +0 -8
- package/dist/scripts/bootstrap/1-populateTPR +0 -92
- package/dist/scripts/bootstrap/2-populateDID +0 -6
- package/dist/scripts/bootstrap/3-populateTimestamp +0 -9
- package/dist/scripts/bootstrap/4-populateTIR +0 -8
- package/dist/scripts/bootstrap/5-populateTSR +0 -85
- package/dist/scripts/bootstrap/6-setupConformanceIssuer +0 -35
- package/dist/scripts/bootstrap/README.md +0 -218
- package/dist/scripts/issueVcInvoke +0 -10
- package/dist/scripts/issueVcOnboard +0 -9
- package/dist/scripts/issueVcRootTAO +0 -11
- package/dist/scripts/issueVcTAO +0 -12
- package/dist/scripts/issueVcTI +0 -12
- package/dist/scripts/issueVcTnl +0 -32
- package/dist/scripts/issue_CTRevocableCredential +0 -12
- package/dist/scripts/issue_SelfAttestationSupportOffice +0 -10
- package/dist/scripts/issue_VerifiableAccreditationToAccredit +0 -11
- package/dist/scripts/issue_VerifiableAccreditationToAttest +0 -11
- package/dist/scripts/issue_VerifiableAuthorisationForTrustChain +0 -10
- package/dist/scripts/issue_VerifiableAuthorisationToOnboard +0 -9
- package/dist/scripts/preregisterIssuer +0 -6
- package/dist/scripts/registerDidDocument +0 -15
- package/dist/scripts/registerIssuer +0 -6
- package/dist/scripts/updateVcRootTAO +0 -10
- package/dist/scripts/updateVcTAO +0 -11
- package/dist/scripts/updateVcTI +0 -11
- package/dist/scripts/vcdm2.0/issueSelfAttestationSupportOffice +0 -10
- package/dist/scripts/vcdm2.0/issueVcInvoke +0 -12
- package/dist/scripts/vcdm2.0/issueVcOnboard +0 -11
- package/dist/scripts/vcdm2.0/issueVcRootTAO +0 -14
- package/dist/scripts/vcdm2.0/issueVcTAO +0 -15
- package/dist/scripts/vcdm2.0/issueVcTI +0 -15
- package/dist/scripts/vcdm2.0/issueVcTnl +0 -34
- package/dist/scripts/vcdm2.0/registerDidDocument +0 -15
- package/dist/scripts/vcdm2.0/updateVcRootTAO +0 -13
- package/dist/scripts/vcdm2.0/updateVcTAO +0 -14
- package/dist/scripts/vcdm2.0/updateVcTI +0 -14
- package/dist/scripts/vcdm2.0/verifyVcTnl +0 -10
- package/dist/scripts/verifyVcTnl +0 -10
- package/dist/scripts/wct/accreditAndAuthorize +0 -133
- package/dist/scripts/wct/accreditAndAuthorize2 +0 -89
- package/dist/scripts/wct/holderWallet +0 -39
- package/dist/scripts/wct/holderWallet2 +0 -39
- package/dist/scripts/wct/issueToHolder +0 -38
- package/dist/scripts/wct/issueToHolder2 +0 -38
- package/dist/scripts/wct/pda1 +0 -3
- package/dist/scripts/wct/verifier +0 -8
- package/dist/scripts/wct/verifier2 +0 -7
- package/dist/utils/Client.js +0 -155
- package/dist/utils/Client.js.map +0 -1
- package/dist/utils/HardwareWallet.js +0 -326
- package/dist/utils/HardwareWallet.js.map +0 -1
- package/dist/utils/http.js +0 -132
- package/dist/utils/http.js.map +0 -1
- package/dist/utils/index.js +0 -8
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/jsonrpc.js +0 -38
- package/dist/utils/jsonrpc.js.map +0 -1
- package/dist/utils/print.js +0 -56
- package/dist/utils/print.js.map +0 -1
- package/dist/utils/utils.js +0 -427
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/vcdm.js +0 -47
- package/dist/utils/vcdm.js.map +0 -1
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import type { CliConfig } from "../config/config.ts";
|
|
4
|
+
import type { WalletDetails } from "../crypto/wallet.ts";
|
|
5
|
+
import type { WriteReceipt } from "../ledger/write.ts";
|
|
6
|
+
import type { CommandDescriptor } from "./registry.ts";
|
|
7
|
+
|
|
8
|
+
import { getAccessToken } from "../auth/token.ts";
|
|
9
|
+
import { REGISTRIES } from "../ledger/registries.ts";
|
|
10
|
+
import { writeToRegistry } from "../ledger/write.ts";
|
|
11
|
+
import { buildOnboardingVc } from "../onboarding/vc.ts";
|
|
12
|
+
import { printWarning } from "../output/format.ts";
|
|
13
|
+
import { resolveWallet, WALLET_KEY_OPTIONS } from "./shared/wallet-opts.ts";
|
|
14
|
+
|
|
15
|
+
const DID_REGISTRY = REGISTRIES["did-registry"];
|
|
16
|
+
/* v8 ignore next 3 -- REGISTRIES["did-registry"] is always defined; defensive per its Record<string, RegistryEntry | undefined> typing */
|
|
17
|
+
if (!DID_REGISTRY) {
|
|
18
|
+
throw new Error('Unknown registry "did-registry"');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const RTAO_OPTIONS = [
|
|
22
|
+
{
|
|
23
|
+
description:
|
|
24
|
+
"The RTAO's DID (must already be registered as RootTAO in the Issuers Registry, " +
|
|
25
|
+
"e.g. via `hardhat bootstrap` or `setup-rtao.ts`). Also read from EBSI_RTAO_DID.",
|
|
26
|
+
flags: "--rtao-did <did>",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
description:
|
|
30
|
+
"The RTAO's secp256k1 private key (0x-prefixed hex), used to sign the VC ES256K. " +
|
|
31
|
+
"Optional when --rtao-es256-key is given. Also read from EBSI_RTAO_ES256K_PRIVATE_KEY.",
|
|
32
|
+
flags: "--rtao-es256k-key <hex>",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
description:
|
|
36
|
+
"The RTAO's P-256 private key (hex), used to sign the VC ES256 instead of ES256K. " +
|
|
37
|
+
"Required against deployments that restrict the did-registry:invite credential format to " +
|
|
38
|
+
"ES256. Also read from EBSI_RTAO_ES256_PRIVATE_KEY.",
|
|
39
|
+
flags: "--rtao-es256-key <hex>",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description:
|
|
43
|
+
"The RTAO's Issuers Registry attribute id carrying its RootTAO self-attestation " +
|
|
44
|
+
"(0x-prefixed hex, from `ebsi issuers-registry issuers attributes list <rtaoDid>`). " +
|
|
45
|
+
"Also read from EBSI_RTAO_ATTRIBUTE_ID.",
|
|
46
|
+
flags: "--rtao-attribute-id <hex>",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const MISSING_RTAO_MESSAGE =
|
|
51
|
+
"Missing RTAO credentials. Provide --rtao-did, --rtao-attribute-id, and " +
|
|
52
|
+
"one of --rtao-es256-key (ES256) or --rtao-es256k-key (ES256K), or set " +
|
|
53
|
+
"EBSI_RTAO_DID/EBSI_RTAO_ATTRIBUTE_ID plus " +
|
|
54
|
+
"EBSI_RTAO_ES256_PRIVATE_KEY/EBSI_RTAO_ES256K_PRIVATE_KEY.";
|
|
55
|
+
|
|
56
|
+
interface RtaoCredentials {
|
|
57
|
+
rtaoAttributeId: string;
|
|
58
|
+
rtaoDid: string;
|
|
59
|
+
rtaoEs256kPrivateKey?: string;
|
|
60
|
+
rtaoEs256PrivateKey?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The JSON-serialised-JWK public key encoding the DID Registry contract
|
|
65
|
+
* expects for a non-secp256k1 verification method (e.g. P-256) — see
|
|
66
|
+
* `generateDidParams.ts`'s `publicKeyHex` for ES256 in
|
|
67
|
+
* `contracts/deploy-toolkit`, which this must match exactly or the DID
|
|
68
|
+
* document's verification method won't resolve.
|
|
69
|
+
*/
|
|
70
|
+
function jwkToContractPublicKeyHex(jwk: unknown): string {
|
|
71
|
+
return `0x${Buffer.from(JSON.stringify(jwk)).toString("hex")}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolves RTAO credentials from flags or their EBSI_RTAO_* env var
|
|
76
|
+
* fallbacks. Returns `undefined` (rather than throwing) when the DID, the
|
|
77
|
+
* attribute id, or both signing keys are missing, so callers that also accept
|
|
78
|
+
* a pre-obtained `--vc <file>` can fall through.
|
|
79
|
+
*/
|
|
80
|
+
function resolveRtaoCredentials(
|
|
81
|
+
opts: Record<string, string>,
|
|
82
|
+
): RtaoCredentials | undefined {
|
|
83
|
+
const rtaoDid = opts["rtaoDid"] ?? process.env["EBSI_RTAO_DID"];
|
|
84
|
+
const rtaoEs256kPrivateKey =
|
|
85
|
+
opts["rtaoEs256kKey"] ?? process.env["EBSI_RTAO_ES256K_PRIVATE_KEY"];
|
|
86
|
+
const rtaoEs256PrivateKey =
|
|
87
|
+
opts["rtaoEs256Key"] ?? process.env["EBSI_RTAO_ES256_PRIVATE_KEY"];
|
|
88
|
+
const rtaoAttributeId =
|
|
89
|
+
opts["rtaoAttributeId"] ?? process.env["EBSI_RTAO_ATTRIBUTE_ID"];
|
|
90
|
+
// Either key can sign the VC, so only their absence together is fatal.
|
|
91
|
+
if (
|
|
92
|
+
!rtaoDid ||
|
|
93
|
+
!rtaoAttributeId ||
|
|
94
|
+
(!rtaoEs256kPrivateKey && !rtaoEs256PrivateKey)
|
|
95
|
+
) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
rtaoAttributeId,
|
|
100
|
+
rtaoDid,
|
|
101
|
+
...(rtaoEs256PrivateKey !== undefined && { rtaoEs256PrivateKey }),
|
|
102
|
+
...(rtaoEs256kPrivateKey !== undefined && { rtaoEs256kPrivateKey }),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Registers `wallet.es256`'s public key as an additional verification method
|
|
108
|
+
* on `did`'s DID document — an `authentication` and `assertionMethod`
|
|
109
|
+
* relationship, both usable for VC/VP signing (`onboarding onboard
|
|
110
|
+
* --register-es256-key`).
|
|
111
|
+
*
|
|
112
|
+
* Mints its own `did-registry:write` access token signed with the ES256K key
|
|
113
|
+
* specifically — regardless of `--sign-alg` — since the P-256 verification
|
|
114
|
+
* method doesn't exist in the DID document yet, so an ES256-signed VP
|
|
115
|
+
* wouldn't resolve against it.
|
|
116
|
+
*/
|
|
117
|
+
const registerEs256VerificationMethod = async (
|
|
118
|
+
config: CliConfig,
|
|
119
|
+
wallet: WalletDetails,
|
|
120
|
+
contractAddress: string,
|
|
121
|
+
): Promise<{
|
|
122
|
+
addVerificationMethod: WriteReceipt;
|
|
123
|
+
addVerificationRelationship: WriteReceipt[];
|
|
124
|
+
}> => {
|
|
125
|
+
const { es256, es256k } = wallet;
|
|
126
|
+
/* v8 ignore next 3 -- callers only invoke this once `es256` is confirmed present */
|
|
127
|
+
if (!es256) {
|
|
128
|
+
throw new Error("No P-256 key configured. Pass --es256-key <hex>.");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Forces ES256K regardless of --sign-alg -- see doc comment above.
|
|
132
|
+
const es256kOnlyWallet: WalletDetails = {
|
|
133
|
+
...wallet,
|
|
134
|
+
signingKey: () => es256k,
|
|
135
|
+
};
|
|
136
|
+
const token = await getAccessToken({
|
|
137
|
+
config,
|
|
138
|
+
scope: `did-registry:write:${contractAddress}`,
|
|
139
|
+
wallet: es256kOnlyWallet,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const publicKeyHex = jwkToContractPublicKeyHex(es256.publicKeyJwk);
|
|
143
|
+
const notBefore = 0;
|
|
144
|
+
const notAfter = 9_999_999_999;
|
|
145
|
+
|
|
146
|
+
const addVerificationMethod = await writeToRegistry({
|
|
147
|
+
config,
|
|
148
|
+
contractAddress,
|
|
149
|
+
functionArgs: [wallet.did, es256.thumbprint, publicKeyHex, false],
|
|
150
|
+
functionName: "addVerificationMethod",
|
|
151
|
+
registry: DID_REGISTRY,
|
|
152
|
+
token,
|
|
153
|
+
wallet,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const addVerificationRelationship: WriteReceipt[] = await Array.fromAsync(
|
|
157
|
+
["authentication", "assertionMethod"],
|
|
158
|
+
(relationship) =>
|
|
159
|
+
writeToRegistry({
|
|
160
|
+
config,
|
|
161
|
+
contractAddress,
|
|
162
|
+
functionArgs: [
|
|
163
|
+
wallet.did,
|
|
164
|
+
relationship,
|
|
165
|
+
es256.thumbprint,
|
|
166
|
+
notBefore,
|
|
167
|
+
notAfter,
|
|
168
|
+
],
|
|
169
|
+
functionName: "addVerificationRelationship",
|
|
170
|
+
registry: DID_REGISTRY,
|
|
171
|
+
token,
|
|
172
|
+
wallet,
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
return { addVerificationMethod, addVerificationRelationship };
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const onboardingCommands: CommandDescriptor[] = [
|
|
180
|
+
{
|
|
181
|
+
args: [],
|
|
182
|
+
group: "Onboarding",
|
|
183
|
+
async handler(_args, opts, config) {
|
|
184
|
+
let holderDid = opts["holderDid"];
|
|
185
|
+
let holderThumbprint = opts["holderThumbprint"];
|
|
186
|
+
if (holderDid === undefined || holderThumbprint === undefined) {
|
|
187
|
+
const wallet = await resolveWallet(opts, config);
|
|
188
|
+
holderDid ??= wallet.did;
|
|
189
|
+
holderThumbprint ??= wallet.signingKey().thumbprint;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const rtao = resolveRtaoCredentials(opts);
|
|
193
|
+
if (!rtao) {
|
|
194
|
+
throw new Error(MISSING_RTAO_MESSAGE);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const { alg, rtaoKid, vcJwt } = await buildOnboardingVc({
|
|
198
|
+
config,
|
|
199
|
+
holderDid,
|
|
200
|
+
holderThumbprint,
|
|
201
|
+
...rtao,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const outFile = opts["out"];
|
|
205
|
+
if (outFile) {
|
|
206
|
+
writeFileSync(outFile, vcJwt + "\n", "utf8");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
alg,
|
|
211
|
+
holderDid,
|
|
212
|
+
holderThumbprint,
|
|
213
|
+
...(outFile !== undefined && { outFile }),
|
|
214
|
+
rtaoDid: rtao.rtaoDid,
|
|
215
|
+
rtaoKid,
|
|
216
|
+
vcJwt,
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
id: "onboarding.issue-vc",
|
|
220
|
+
options: [
|
|
221
|
+
{
|
|
222
|
+
description:
|
|
223
|
+
"DID to embed as credentialSubject.id. Defaults to the DID derived from " +
|
|
224
|
+
"the configured wallet (--es256k-key/--did, EBSI_ES256K_PRIVATE_KEY, or persisted config).",
|
|
225
|
+
flags: "--holder-did <did>",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
description:
|
|
229
|
+
"JWK thumbprint to embed as credentialSubject.jwkThumbprint (binds the VC " +
|
|
230
|
+
"to a specific key). Defaults to the configured wallet's signing key thumbprint " +
|
|
231
|
+
"(see --sign-alg).",
|
|
232
|
+
flags: "--holder-thumbprint <thumbprint>",
|
|
233
|
+
},
|
|
234
|
+
...RTAO_OPTIONS,
|
|
235
|
+
...WALLET_KEY_OPTIONS,
|
|
236
|
+
{
|
|
237
|
+
description: "Also write the signed VC JWT to this file.",
|
|
238
|
+
flags: "--out <file>",
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
segments: ["onboarding", "issue-vc"],
|
|
242
|
+
summary:
|
|
243
|
+
"Mint a VerifiableAuthorisationToOnboard VC for a holder DID/key, signed by an " +
|
|
244
|
+
"RTAO already registered as RootTAO on chain. Signs ES256 when --rtao-es256-key " +
|
|
245
|
+
"is given, otherwise ES256K. There is no CLI/API endpoint for this otherwise — " +
|
|
246
|
+
"it's a local signing operation, not a network call.",
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
{
|
|
250
|
+
args: [],
|
|
251
|
+
group: "Onboarding",
|
|
252
|
+
async handler(_args, opts, config) {
|
|
253
|
+
const wallet = await resolveWallet(opts, config);
|
|
254
|
+
|
|
255
|
+
const registerEs256Key = Boolean(opts["registerEs256Key"]);
|
|
256
|
+
if (registerEs256Key && !wallet.es256) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
"--register-es256-key requires a P-256 key. Provide --es256-key <hex>, set " +
|
|
259
|
+
"EBSI_ES256_PRIVATE_KEY, or run `ebsi config set es256PrivateKey <hex>`.",
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// The onboarding VC authorises whichever key insertDidDocument is about
|
|
264
|
+
// to register — always the ES256K key (see doc comment on --sign-alg
|
|
265
|
+
// below). A VC signed ES256 here would authorise a key that never gets
|
|
266
|
+
// registered by this command.
|
|
267
|
+
if (wallet.es256 && config.signAlg === "ES256") {
|
|
268
|
+
printWarning(
|
|
269
|
+
"--sign-alg ES256 is set, but `onboarding onboard` always registers " +
|
|
270
|
+
"the ES256K key via insertDidDocument. Signing the onboarding VP with " +
|
|
271
|
+
"the ES256 key here would authorise a different key than the one " +
|
|
272
|
+
"being registered. Proceeding with the ES256K key for this VC/VP.",
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
const es256kOnlyWallet: WalletDetails = {
|
|
276
|
+
...wallet,
|
|
277
|
+
signingKey: () => wallet.es256k,
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const vcFile = opts["vc"];
|
|
281
|
+
let vcJwt: string;
|
|
282
|
+
if (vcFile) {
|
|
283
|
+
vcJwt = readFileSync(vcFile, "utf8").trim();
|
|
284
|
+
} else {
|
|
285
|
+
const rtao = resolveRtaoCredentials(opts);
|
|
286
|
+
if (!rtao) {
|
|
287
|
+
throw new Error(
|
|
288
|
+
"Provide --vc <file> with a pre-obtained onboarding VC, or the " +
|
|
289
|
+
"RTAO credentials to mint one inline. " +
|
|
290
|
+
MISSING_RTAO_MESSAGE,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
({ vcJwt } = await buildOnboardingVc({
|
|
294
|
+
config,
|
|
295
|
+
holderDid: wallet.did,
|
|
296
|
+
holderThumbprint: wallet.es256k.thumbprint,
|
|
297
|
+
...rtao,
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const specOpt = opts["spec"];
|
|
302
|
+
if (specOpt !== undefined && specOpt !== "draft14" && specOpt !== "1.0") {
|
|
303
|
+
throw new Error('Invalid --spec value. Must be "draft14" or "1.0".');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const token = await getAccessToken({
|
|
307
|
+
config,
|
|
308
|
+
scope: "did-registry:invite",
|
|
309
|
+
vcJwt,
|
|
310
|
+
wallet: es256kOnlyWallet,
|
|
311
|
+
...(specOpt !== undefined && { spec: specOpt }),
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const contractAddress =
|
|
315
|
+
opts["to"] ?? process.env[DID_REGISTRY.addressEnvKey];
|
|
316
|
+
if (!contractAddress) {
|
|
317
|
+
throw new Error(
|
|
318
|
+
`No contract address for "did-registry". Provide --to <address> or ` +
|
|
319
|
+
`set ${DID_REGISTRY.addressEnvKey}.`,
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const baseDocument = JSON.stringify({
|
|
324
|
+
"@context": [
|
|
325
|
+
"https://www.w3.org/ns/did/v1",
|
|
326
|
+
"https://w3id.org/security/suites/jws-2020/v1",
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
const notBefore = Number(opts["notBefore"] ?? "0");
|
|
330
|
+
const notAfter = Number(opts["notAfter"] ?? "9999999999");
|
|
331
|
+
const publicKey = wallet.wallet.signingKey.publicKey;
|
|
332
|
+
|
|
333
|
+
const receipt = await writeToRegistry({
|
|
334
|
+
config,
|
|
335
|
+
contractAddress,
|
|
336
|
+
functionArgs: [
|
|
337
|
+
wallet.did,
|
|
338
|
+
baseDocument,
|
|
339
|
+
wallet.es256k.thumbprint,
|
|
340
|
+
publicKey,
|
|
341
|
+
true,
|
|
342
|
+
notBefore,
|
|
343
|
+
notAfter,
|
|
344
|
+
],
|
|
345
|
+
functionName: "insertDidDocument",
|
|
346
|
+
registry: DID_REGISTRY,
|
|
347
|
+
token,
|
|
348
|
+
wallet,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
const es256Registration = registerEs256Key
|
|
352
|
+
? await registerEs256VerificationMethod(config, wallet, contractAddress)
|
|
353
|
+
: undefined;
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
did: wallet.did,
|
|
357
|
+
...receipt,
|
|
358
|
+
...(es256Registration !== undefined && { es256Registration }),
|
|
359
|
+
};
|
|
360
|
+
},
|
|
361
|
+
id: "onboarding.onboard",
|
|
362
|
+
options: [
|
|
363
|
+
{
|
|
364
|
+
description:
|
|
365
|
+
"Path to a pre-obtained onboarding VC JWT file. If omitted, one is minted " +
|
|
366
|
+
"inline from the --rtao-* flags.",
|
|
367
|
+
flags: "--vc <file>",
|
|
368
|
+
},
|
|
369
|
+
...RTAO_OPTIONS,
|
|
370
|
+
...WALLET_KEY_OPTIONS,
|
|
371
|
+
{
|
|
372
|
+
description:
|
|
373
|
+
"Contract address (0x-prefixed). If omitted, read from DID_REGISTRY_CONTRACT_ADDRESS.",
|
|
374
|
+
flags: "--to <address>",
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
description:
|
|
378
|
+
'Which OpenID4VP grant to speak: "draft14" (default) or "1.0" (DCQL).',
|
|
379
|
+
flags: "--spec <draft14|1.0>",
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
defaultValue: "0",
|
|
383
|
+
description: "Unix timestamp the DID document becomes valid from.",
|
|
384
|
+
flags: "--not-before <epoch>",
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
defaultValue: "9999999999",
|
|
388
|
+
description: "Unix timestamp the DID document expires at.",
|
|
389
|
+
flags: "--not-after <epoch>",
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
description:
|
|
393
|
+
"After registering the DID document, also register the configured P-256 key " +
|
|
394
|
+
"(--es256-key) as an additional verification method (authentication + " +
|
|
395
|
+
"assertionMethod), so it can be used to sign VCs/VPs afterwards. Requires a " +
|
|
396
|
+
"P-256 key to be configured. Mints a separate did-registry:write token, " +
|
|
397
|
+
"always signed with the ES256K key.",
|
|
398
|
+
flags: "--register-es256-key",
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
segments: ["onboarding", "onboard"],
|
|
402
|
+
summary:
|
|
403
|
+
"One-shot: mint (or load) a VerifiableAuthorisationToOnboard VC, exchange it for " +
|
|
404
|
+
"a did-registry:invite access token, and insert the DID document for the configured " +
|
|
405
|
+
"wallet — auto-deriving the base document, verification method id, and raw " +
|
|
406
|
+
"public key, so you don't have to build insertDidDocument's args by hand. Always " +
|
|
407
|
+
"signs with the ES256K key, regardless of --sign-alg — the P-256 key isn't " +
|
|
408
|
+
"registered in the DID document yet at this point. Pass --register-es256-key to " +
|
|
409
|
+
"also register a configured P-256 key right after.",
|
|
410
|
+
},
|
|
411
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CommandDescriptor } from "./registry.ts";
|
|
2
|
+
|
|
3
|
+
export const openapiCommands: CommandDescriptor[] = [
|
|
4
|
+
{
|
|
5
|
+
args: [],
|
|
6
|
+
group: "OpenAPI",
|
|
7
|
+
async handler(_args, _opts, config) {
|
|
8
|
+
const response = await fetch(`${config.baseUrl}/openapi.json`, {
|
|
9
|
+
headers: { Accept: "application/openapi+json" },
|
|
10
|
+
});
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Failed to fetch OpenAPI JSON: HTTP ${String(response.status)}`,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return response.json();
|
|
17
|
+
},
|
|
18
|
+
id: "openapi.json",
|
|
19
|
+
options: [],
|
|
20
|
+
segments: ["openapi", "json"],
|
|
21
|
+
summary: "Fetch the OpenAPI 3.1 spec in JSON format",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: [],
|
|
25
|
+
group: "OpenAPI",
|
|
26
|
+
async handler(_args, _opts, config) {
|
|
27
|
+
const response = await fetch(`${config.baseUrl}/openapi.yaml`, {
|
|
28
|
+
headers: { Accept: "application/openapi+yaml" },
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Failed to fetch OpenAPI YAML: HTTP ${String(response.status)}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return response.text();
|
|
36
|
+
},
|
|
37
|
+
id: "openapi.yaml",
|
|
38
|
+
options: [],
|
|
39
|
+
segments: ["openapi", "yaml"],
|
|
40
|
+
summary: "Fetch the OpenAPI 3.1 spec in YAML format",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { CommandDescriptor } from "./registry.ts";
|
|
2
|
+
|
|
3
|
+
import { getClient, unwrap } from "../api/fetch.ts";
|
|
4
|
+
import { q } from "../api/params.ts";
|
|
5
|
+
import { contractAddressOptionFor } from "../ledger/registries.ts";
|
|
6
|
+
import { requiredArg } from "./shared/args.ts";
|
|
7
|
+
|
|
8
|
+
const PAGINATION_OPTIONS = [
|
|
9
|
+
{
|
|
10
|
+
description: "Cursor for pagination (page[after])",
|
|
11
|
+
flags: "--page-after <cursor>",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: "Maximum number of items per page (page[size])",
|
|
15
|
+
flags: "--page-size <n>",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const { option: CONTRACT_ADDRESS_OPTION, resolve: contractAddress } =
|
|
20
|
+
contractAddressOptionFor("policies-registry");
|
|
21
|
+
|
|
22
|
+
export const policiesRegistryCommands: CommandDescriptor[] = [
|
|
23
|
+
{
|
|
24
|
+
args: [],
|
|
25
|
+
group: "Policies Registry",
|
|
26
|
+
async handler(_args, opts, config) {
|
|
27
|
+
const client = getClient(config);
|
|
28
|
+
const result = await client.GET("/policies-registry/policies", {
|
|
29
|
+
params: {
|
|
30
|
+
query: q({
|
|
31
|
+
contractAddress: contractAddress(opts),
|
|
32
|
+
"page[after]": opts["pageAfter"]
|
|
33
|
+
? Number(opts["pageAfter"])
|
|
34
|
+
: undefined,
|
|
35
|
+
"page[size]": opts["pageSize"]
|
|
36
|
+
? Number(opts["pageSize"])
|
|
37
|
+
: undefined,
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return unwrap(result);
|
|
42
|
+
},
|
|
43
|
+
id: "policies-registry.policies.list",
|
|
44
|
+
options: [...PAGINATION_OPTIONS, CONTRACT_ADDRESS_OPTION],
|
|
45
|
+
segments: ["policies-registry", "policies", "list"],
|
|
46
|
+
summary: "List all policies registered on the EBSI ledger",
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
args: [
|
|
51
|
+
{
|
|
52
|
+
description: "Policy name",
|
|
53
|
+
example: "VerifiableAuthorisationForTrustChain",
|
|
54
|
+
name: "policyName",
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
group: "Policies Registry",
|
|
59
|
+
async handler(args, opts, config) {
|
|
60
|
+
const client = getClient(config);
|
|
61
|
+
const result = await client.GET(
|
|
62
|
+
"/policies-registry/policies/{policyName}",
|
|
63
|
+
{
|
|
64
|
+
params: {
|
|
65
|
+
path: { policyName: requiredArg(args, "policyName") },
|
|
66
|
+
query: q({ contractAddress: contractAddress(opts) }),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
return unwrap(result);
|
|
71
|
+
},
|
|
72
|
+
id: "policies-registry.policies.get",
|
|
73
|
+
options: [CONTRACT_ADDRESS_OPTION],
|
|
74
|
+
segments: ["policies-registry", "policies", "get"],
|
|
75
|
+
summary: "Get a policy by name",
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
{
|
|
79
|
+
args: [],
|
|
80
|
+
group: "Policies Registry",
|
|
81
|
+
async handler(_args, opts, config) {
|
|
82
|
+
const client = getClient(config);
|
|
83
|
+
const result = await client.GET("/policies-registry/subjects", {
|
|
84
|
+
params: {
|
|
85
|
+
query: q({
|
|
86
|
+
contractAddress: contractAddress(opts),
|
|
87
|
+
"page[after]": opts["pageAfter"]
|
|
88
|
+
? Number(opts["pageAfter"])
|
|
89
|
+
: undefined,
|
|
90
|
+
"page[size]": opts["pageSize"]
|
|
91
|
+
? Number(opts["pageSize"])
|
|
92
|
+
: undefined,
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return unwrap(result);
|
|
97
|
+
},
|
|
98
|
+
id: "policies-registry.subjects.list",
|
|
99
|
+
options: [...PAGINATION_OPTIONS, CONTRACT_ADDRESS_OPTION],
|
|
100
|
+
segments: ["policies-registry", "subjects", "list"],
|
|
101
|
+
summary: "List all subjects with assigned policies",
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
args: [
|
|
106
|
+
{
|
|
107
|
+
description: "Subject DID",
|
|
108
|
+
example: "did:ebsi:ziDnioxYYLW1a3FDD",
|
|
109
|
+
name: "subject",
|
|
110
|
+
required: true,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
group: "Policies Registry",
|
|
114
|
+
async handler(args, opts, config) {
|
|
115
|
+
const client = getClient(config);
|
|
116
|
+
const result = await client.GET("/policies-registry/subjects/{subject}", {
|
|
117
|
+
params: {
|
|
118
|
+
path: { subject: requiredArg(args, "subject") },
|
|
119
|
+
query: q({ contractAddress: contractAddress(opts) }),
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
return unwrap(result);
|
|
123
|
+
},
|
|
124
|
+
id: "policies-registry.subjects.get",
|
|
125
|
+
options: [CONTRACT_ADDRESS_OPTION],
|
|
126
|
+
segments: ["policies-registry", "subjects", "get"],
|
|
127
|
+
summary: "Get a subject by DID",
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
{
|
|
131
|
+
args: [
|
|
132
|
+
{
|
|
133
|
+
description: "Subject DID",
|
|
134
|
+
example: "did:ebsi:ziDnioxYYLW1a3FDD",
|
|
135
|
+
name: "subject",
|
|
136
|
+
required: true,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
group: "Policies Registry",
|
|
140
|
+
async handler(args, opts, config) {
|
|
141
|
+
const client = getClient(config);
|
|
142
|
+
const result = await client.GET(
|
|
143
|
+
"/policies-registry/subjects/{subject}/policies",
|
|
144
|
+
{
|
|
145
|
+
params: {
|
|
146
|
+
path: { subject: requiredArg(args, "subject") },
|
|
147
|
+
query: q({
|
|
148
|
+
contractAddress: contractAddress(opts),
|
|
149
|
+
"page[after]": opts["pageAfter"]
|
|
150
|
+
? Number(opts["pageAfter"])
|
|
151
|
+
: undefined,
|
|
152
|
+
"page[size]": opts["pageSize"]
|
|
153
|
+
? Number(opts["pageSize"])
|
|
154
|
+
: undefined,
|
|
155
|
+
}),
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
return unwrap(result);
|
|
160
|
+
},
|
|
161
|
+
id: "policies-registry.subjects.policies",
|
|
162
|
+
options: [...PAGINATION_OPTIONS, CONTRACT_ADDRESS_OPTION],
|
|
163
|
+
segments: ["policies-registry", "subjects", "policies"],
|
|
164
|
+
summary: "List all policies assigned to a subject",
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
{
|
|
168
|
+
args: [
|
|
169
|
+
{
|
|
170
|
+
description: "Subject DID",
|
|
171
|
+
example: "did:ebsi:ziDnioxYYLW1a3FDD",
|
|
172
|
+
name: "subject",
|
|
173
|
+
required: true,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
description: "Policy name",
|
|
177
|
+
example: "VerifiableAuthorisationForTrustChain",
|
|
178
|
+
name: "policyName",
|
|
179
|
+
required: true,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
group: "Policies Registry",
|
|
183
|
+
async handler(args, opts, config) {
|
|
184
|
+
const client = getClient(config);
|
|
185
|
+
const result = await client.GET(
|
|
186
|
+
"/policies-registry/subjects/{subject}/policies/{policyName}",
|
|
187
|
+
{
|
|
188
|
+
params: {
|
|
189
|
+
path: {
|
|
190
|
+
policyName: requiredArg(args, "policyName"),
|
|
191
|
+
subject: requiredArg(args, "subject"),
|
|
192
|
+
},
|
|
193
|
+
query: q({ contractAddress: contractAddress(opts) }),
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
return unwrap(result);
|
|
198
|
+
},
|
|
199
|
+
id: "policies-registry.subjects.policy",
|
|
200
|
+
options: [CONTRACT_ADDRESS_OPTION],
|
|
201
|
+
segments: ["policies-registry", "subjects", "policy"],
|
|
202
|
+
summary: "Get a specific policy assigned to a subject",
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
{
|
|
206
|
+
args: [],
|
|
207
|
+
group: "Policies Registry",
|
|
208
|
+
async handler(_args, _opts, config) {
|
|
209
|
+
const client = getClient(config);
|
|
210
|
+
const result = await client.GET("/policies-registry/abi");
|
|
211
|
+
return unwrap(result);
|
|
212
|
+
},
|
|
213
|
+
id: "policies-registry.abi",
|
|
214
|
+
options: [],
|
|
215
|
+
segments: ["policies-registry", "abi"],
|
|
216
|
+
summary: "Get the ABI of the Policies Registry smart contract",
|
|
217
|
+
},
|
|
218
|
+
];
|