@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
|
@@ -1,813 +0,0 @@
|
|
|
1
|
-
import Joi from "joi";
|
|
2
|
-
import { base64url } from "multiformats/bases/base64";
|
|
3
|
-
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
4
|
-
import { URLSearchParams } from "node:url";
|
|
5
|
-
import { parse as qsParse, stringify as qsStringify } from "qs";
|
|
6
|
-
import { estimateVcdmVersion, httpCall, red } from "../utils/index.js";
|
|
7
|
-
import { compute, getUserPin } from "./compute.js";
|
|
8
|
-
export async function authMockAuthorize(inputs, context) {
|
|
9
|
-
const [openIdCredentialIssuer, openIdConfiguration, requestedTypes, inputAlg, codeVerifier, issuerState,] = inputs;
|
|
10
|
-
const alg = inputAlg || "ES256";
|
|
11
|
-
Joi.assert(requestedTypes, Joi.array());
|
|
12
|
-
Joi.assert(alg, Joi.string().valid("ES256K", "ES256", "EdDSA", "RS256"));
|
|
13
|
-
const isPKCEChallenge = !!codeVerifier;
|
|
14
|
-
const authorizationServer = openIdCredentialIssuer.authorization_server ??
|
|
15
|
-
openIdCredentialIssuer.credential_issuer;
|
|
16
|
-
const clientId = context.client.didVersion === 1
|
|
17
|
-
? context.client.clientId
|
|
18
|
-
: context.client.did;
|
|
19
|
-
let codeChallenge = "";
|
|
20
|
-
if (isPKCEChallenge) {
|
|
21
|
-
codeChallenge = base64url.baseEncode(createHash("sha256").update(codeVerifier).digest());
|
|
22
|
-
}
|
|
23
|
-
const clientMetadata = isPKCEChallenge
|
|
24
|
-
? {
|
|
25
|
-
authorization_endpoint: "openid:",
|
|
26
|
-
}
|
|
27
|
-
: {
|
|
28
|
-
authorization_endpoint: `${context.client.clientId}/authorize`,
|
|
29
|
-
jwks_uri: `${context.client.clientId}/jwks`,
|
|
30
|
-
redirect_uris: [`${context.client.clientId}/code-cb`],
|
|
31
|
-
};
|
|
32
|
-
const authorizationDetails = [
|
|
33
|
-
{
|
|
34
|
-
format: "jwt_vc",
|
|
35
|
-
locations: [openIdCredentialIssuer.credential_issuer],
|
|
36
|
-
type: "openid_credential",
|
|
37
|
-
types: requestedTypes,
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
const queryParams = {
|
|
41
|
-
client_id: clientId,
|
|
42
|
-
client_metadata: JSON.stringify(clientMetadata),
|
|
43
|
-
redirect_uri: isPKCEChallenge
|
|
44
|
-
? "openid://callback"
|
|
45
|
-
: `${context.client.clientId}/code-cb`,
|
|
46
|
-
response_type: "code",
|
|
47
|
-
scope: "openid",
|
|
48
|
-
state: randomUUID(),
|
|
49
|
-
...(isPKCEChallenge && {
|
|
50
|
-
code_challenge: codeChallenge,
|
|
51
|
-
code_challenge_method: "S256",
|
|
52
|
-
}),
|
|
53
|
-
...(issuerState && { issuer_state: issuerState }),
|
|
54
|
-
authorization_details: JSON.stringify(authorizationDetails),
|
|
55
|
-
};
|
|
56
|
-
const jwtPayload = {
|
|
57
|
-
...queryParams,
|
|
58
|
-
aud: authorizationServer,
|
|
59
|
-
authorization_details: authorizationDetails,
|
|
60
|
-
client_metadata: clientMetadata,
|
|
61
|
-
iss: clientId,
|
|
62
|
-
};
|
|
63
|
-
const requestParam = await context.client.signJWT(jwtPayload, {}, alg);
|
|
64
|
-
const responseAuthorize = await httpCall.get(`${openIdConfiguration.authorization_endpoint}?${new URLSearchParams({
|
|
65
|
-
...queryParams,
|
|
66
|
-
request: requestParam,
|
|
67
|
-
}).toString()}`);
|
|
68
|
-
const { location } = responseAuthorize.headers;
|
|
69
|
-
const locationUrl = new URL(location);
|
|
70
|
-
if (locationUrl.searchParams.get("error"))
|
|
71
|
-
throw new Error(locationUrl.searchParams.toString());
|
|
72
|
-
const responseQueryParams = qsParse(locationUrl.search.slice(1));
|
|
73
|
-
return responseQueryParams;
|
|
74
|
-
}
|
|
75
|
-
export async function authMockDirectPostIdToken(inputs, context) {
|
|
76
|
-
const [openIdCredentialIssuer, issuerRequest, inputAlg, vcdmVersion] = inputs;
|
|
77
|
-
const alg = inputAlg || "ES256";
|
|
78
|
-
Joi.assert(alg, Joi.string().valid("ES256K", "ES256", "EdDSA", "RS256"));
|
|
79
|
-
const authorizationServer = openIdCredentialIssuer.authorization_server ??
|
|
80
|
-
openIdCredentialIssuer.credential_issuer;
|
|
81
|
-
const { nonce, state } = issuerRequest;
|
|
82
|
-
const iat = Math.floor(Date.now() / 1000);
|
|
83
|
-
const exp = iat + 5 * 60;
|
|
84
|
-
const idTokenDirectPost = await context.client.signJWT({
|
|
85
|
-
aud: authorizationServer,
|
|
86
|
-
exp,
|
|
87
|
-
iat,
|
|
88
|
-
iss: context.client.did,
|
|
89
|
-
nonce,
|
|
90
|
-
sub: context.client.did,
|
|
91
|
-
}, { typ: vcdmVersion === "1.1" ? "JWT" : "vp+jwt" }, alg);
|
|
92
|
-
const responseDirectPost = await httpCall.post(issuerRequest.redirect_uri, new URLSearchParams({
|
|
93
|
-
id_token: idTokenDirectPost,
|
|
94
|
-
state,
|
|
95
|
-
vcdm_version: vcdmVersion,
|
|
96
|
-
}).toString(), {
|
|
97
|
-
headers: {
|
|
98
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
const { location } = responseDirectPost.headers;
|
|
102
|
-
const locationUrl = new URL(location);
|
|
103
|
-
if (locationUrl.searchParams.get("error"))
|
|
104
|
-
throw new Error(locationUrl.searchParams.toString());
|
|
105
|
-
const responseQueryParams = qsParse(locationUrl.search.slice(1));
|
|
106
|
-
return responseQueryParams;
|
|
107
|
-
}
|
|
108
|
-
export async function authMockDirectPostVpToken(inputs) {
|
|
109
|
-
const [issuerRequest, vpJwt, type, vcdmVersion] = inputs;
|
|
110
|
-
const { state } = issuerRequest;
|
|
111
|
-
const presentationSubmission = type === "holder"
|
|
112
|
-
? {
|
|
113
|
-
definition_id: "holder-wallet-qualification-presentation",
|
|
114
|
-
descriptor_map: [
|
|
115
|
-
{
|
|
116
|
-
format: "jwt_vp",
|
|
117
|
-
id: "same-device-authorised-in-time-credential",
|
|
118
|
-
path: "$",
|
|
119
|
-
path_nested: {
|
|
120
|
-
format: "jwt_vc",
|
|
121
|
-
id: "same-device-authorised-in-time-credential",
|
|
122
|
-
path: "$.vp.verifiableCredential[0]",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
format: "jwt_vp",
|
|
127
|
-
id: "cross-device-authorised-in-time-credential",
|
|
128
|
-
path: "$",
|
|
129
|
-
path_nested: {
|
|
130
|
-
format: "jwt_vc",
|
|
131
|
-
id: "cross-device-authorised-in-time-credential",
|
|
132
|
-
path: "$.vp.verifiableCredential[1]",
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
format: "jwt_vp",
|
|
137
|
-
id: "same-device-authorised-deferred-credential",
|
|
138
|
-
path: "$",
|
|
139
|
-
path_nested: {
|
|
140
|
-
format: "jwt_vc",
|
|
141
|
-
id: "same-device-authorised-deferred-credential",
|
|
142
|
-
path: "$.vp.verifiableCredential[2]",
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
format: "jwt_vp",
|
|
147
|
-
id: "cross-device-authorised-deferred-credential",
|
|
148
|
-
path: "$",
|
|
149
|
-
path_nested: {
|
|
150
|
-
format: "jwt_vc",
|
|
151
|
-
id: "cross-device-authorised-deferred-credential",
|
|
152
|
-
path: "$.vp.verifiableCredential[3]",
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
format: "jwt_vp",
|
|
157
|
-
id: "same-device-pre-authorised-in-time-credential",
|
|
158
|
-
path: "$",
|
|
159
|
-
path_nested: {
|
|
160
|
-
format: "jwt_vc",
|
|
161
|
-
id: "same-device-pre-authorised-in-time-credential",
|
|
162
|
-
path: "$.vp.verifiableCredential[4]",
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
format: "jwt_vp",
|
|
167
|
-
id: "cross-device-pre-authorised-in-time-credential",
|
|
168
|
-
path: "$",
|
|
169
|
-
path_nested: {
|
|
170
|
-
format: "jwt_vc",
|
|
171
|
-
id: "cross-device-pre-authorised-in-time-credential",
|
|
172
|
-
path: "$.vp.verifiableCredential[5]",
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
format: "jwt_vp",
|
|
177
|
-
id: "same-device-pre-authorised-deferred-credential",
|
|
178
|
-
path: "$",
|
|
179
|
-
path_nested: {
|
|
180
|
-
format: "jwt_vc",
|
|
181
|
-
id: "same-device-pre-authorised-deferred-credential",
|
|
182
|
-
path: "$.vp.verifiableCredential[6]",
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
format: "jwt_vp",
|
|
187
|
-
id: "cross-device-pre-authorised-deferred-credential",
|
|
188
|
-
path: "$",
|
|
189
|
-
path_nested: {
|
|
190
|
-
format: "jwt_vc",
|
|
191
|
-
id: "cross-device-pre-authorised-deferred-credential",
|
|
192
|
-
path: "$.vp.verifiableCredential[7]",
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
id: randomUUID(),
|
|
197
|
-
}
|
|
198
|
-
: {
|
|
199
|
-
definition_id: "va-to-onboard-presentation",
|
|
200
|
-
descriptor_map: [
|
|
201
|
-
{
|
|
202
|
-
format: "jwt_vp",
|
|
203
|
-
id: "verifiable-authorisation-to-onboard",
|
|
204
|
-
path: "$",
|
|
205
|
-
path_nested: {
|
|
206
|
-
format: "jwt_vc",
|
|
207
|
-
id: "verifiable-authorisation-to-onboard",
|
|
208
|
-
path: "$.vp.verifiableCredential[0]",
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
id: randomUUID(),
|
|
213
|
-
};
|
|
214
|
-
const responseDirectPost = await httpCall.post(issuerRequest.redirect_uri, new URLSearchParams({
|
|
215
|
-
presentation_submission: JSON.stringify(presentationSubmission),
|
|
216
|
-
state,
|
|
217
|
-
vcdm_version: vcdmVersion,
|
|
218
|
-
vp_token: vpJwt,
|
|
219
|
-
}).toString(), {
|
|
220
|
-
headers: {
|
|
221
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
const { location } = responseDirectPost.headers;
|
|
225
|
-
const locationUrl = new URL(location);
|
|
226
|
-
if (locationUrl.searchParams.get("error"))
|
|
227
|
-
throw new Error(locationUrl.searchParams.toString());
|
|
228
|
-
const responseQueryParams = qsParse(locationUrl.search.slice(1));
|
|
229
|
-
return responseQueryParams;
|
|
230
|
-
}
|
|
231
|
-
export async function authMockToken(inputs, context) {
|
|
232
|
-
const [openIdCredentialIssuer, openIdConfiguration, code, inputAlg, codeVerifier, type,] = inputs;
|
|
233
|
-
const alg = inputAlg || "ES256";
|
|
234
|
-
const isPKCEChallenge = !!codeVerifier;
|
|
235
|
-
const authorizationServer = openIdCredentialIssuer.authorization_server ??
|
|
236
|
-
openIdCredentialIssuer.credential_issuer;
|
|
237
|
-
const queryParams = type === "preAuthorised"
|
|
238
|
-
? {
|
|
239
|
-
grant_type: "urn:ietf:params:oauth:grant-type:pre-authorized_code",
|
|
240
|
-
"pre-authorized_code": code,
|
|
241
|
-
user_pin: getUserPin(context.client.did),
|
|
242
|
-
}
|
|
243
|
-
: {
|
|
244
|
-
code,
|
|
245
|
-
grant_type: "authorization_code",
|
|
246
|
-
...(!isPKCEChallenge && {
|
|
247
|
-
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
248
|
-
client_id: context.client.clientId,
|
|
249
|
-
redirect_uri: `${context.client.clientId}/code-cb`,
|
|
250
|
-
}),
|
|
251
|
-
...(isPKCEChallenge && {
|
|
252
|
-
client_id: context.client.did,
|
|
253
|
-
code_verifier: codeVerifier,
|
|
254
|
-
redirect_uri: "openid://callback",
|
|
255
|
-
}),
|
|
256
|
-
};
|
|
257
|
-
const iat = Math.floor(Date.now() / 1000);
|
|
258
|
-
const exp = iat + 5 * 60;
|
|
259
|
-
const jwtPayload = {
|
|
260
|
-
...queryParams,
|
|
261
|
-
aud: authorizationServer,
|
|
262
|
-
exp,
|
|
263
|
-
iat,
|
|
264
|
-
iss: context.client.clientId,
|
|
265
|
-
sub: context.client.clientId,
|
|
266
|
-
};
|
|
267
|
-
const clientAssertion = await context.client.signJWT(jwtPayload, {}, alg);
|
|
268
|
-
const responseToken = await httpCall.post(openIdConfiguration.token_endpoint, new URLSearchParams({
|
|
269
|
-
...queryParams,
|
|
270
|
-
client_assertion: clientAssertion,
|
|
271
|
-
}).toString(), {
|
|
272
|
-
headers: {
|
|
273
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
return responseToken.data;
|
|
277
|
-
}
|
|
278
|
-
export async function check(inputs, context) {
|
|
279
|
-
const [intent, inputVcdmVersion, preAuthorizedCode, userPin] = inputs;
|
|
280
|
-
const apiUrl = context.config.api.conformance.url;
|
|
281
|
-
const vcdmVersion = inputVcdmVersion
|
|
282
|
-
? Number(inputVcdmVersion).toFixed(1)
|
|
283
|
-
: "1.1";
|
|
284
|
-
const response = await httpCall.post(`${apiUrl}/check`, {
|
|
285
|
-
data: {
|
|
286
|
-
clientId: context.client.clientId,
|
|
287
|
-
credentialIssuer: context.client.clientId,
|
|
288
|
-
credentialIssuerDid: context.client.did,
|
|
289
|
-
did: context.client.did,
|
|
290
|
-
issuerState: context.client.issuerState,
|
|
291
|
-
...(preAuthorizedCode && {
|
|
292
|
-
preAuthorizedCode,
|
|
293
|
-
userPin,
|
|
294
|
-
}),
|
|
295
|
-
vcdmVersion,
|
|
296
|
-
},
|
|
297
|
-
intent,
|
|
298
|
-
});
|
|
299
|
-
if (!response.data.success) {
|
|
300
|
-
red(response.data.errors);
|
|
301
|
-
throw new Error(`check ${intent} failed: ${response.data.errors
|
|
302
|
-
? JSON.stringify(response.data.errors)
|
|
303
|
-
: "unknown error"}`);
|
|
304
|
-
}
|
|
305
|
-
return response.data;
|
|
306
|
-
}
|
|
307
|
-
export async function clientMockInitiate(context) {
|
|
308
|
-
const apiUrl = context.config.api.conformance.url;
|
|
309
|
-
const { accreditationUrl, issuerState, proxyId } = context.rtVars["user"];
|
|
310
|
-
const response = await httpCall.post(`${apiUrl}/client-mock/initiate`, {
|
|
311
|
-
did: context.client.did,
|
|
312
|
-
keys: Object.keys(context.client.keys).map((keyName) => {
|
|
313
|
-
const key = context.client.keys[keyName];
|
|
314
|
-
return {
|
|
315
|
-
...key.privateKeyJwk,
|
|
316
|
-
kid: key.kid,
|
|
317
|
-
};
|
|
318
|
-
}),
|
|
319
|
-
...(accreditationUrl && { attributeUrl: accreditationUrl }),
|
|
320
|
-
...(proxyId && { proxyId }),
|
|
321
|
-
...(issuerState && { issuerState }),
|
|
322
|
-
});
|
|
323
|
-
context.client.clientId = `${apiUrl}/client-mock/${context.client.did}`;
|
|
324
|
-
context.rtVars["user"].clientId =
|
|
325
|
-
context.client.clientId;
|
|
326
|
-
return response.data;
|
|
327
|
-
}
|
|
328
|
-
export async function clientMockUpdateBitstringList(inputs, context) {
|
|
329
|
-
const [statusIndex, statusListIndex, value] = inputs;
|
|
330
|
-
const apiUrl = context.config.api.conformance.url;
|
|
331
|
-
const response = await httpCall.post(`${apiUrl}/client-mock/updateBitstringStatusList`, {
|
|
332
|
-
did: context.client.did,
|
|
333
|
-
id: statusIndex.toString(),
|
|
334
|
-
position: Number(statusListIndex),
|
|
335
|
-
value: Number(value),
|
|
336
|
-
});
|
|
337
|
-
return response.data;
|
|
338
|
-
}
|
|
339
|
-
export async function clientMockUpdateList(inputs, context) {
|
|
340
|
-
const [statusIndex, statusListIndex, value] = inputs;
|
|
341
|
-
const apiUrl = context.config.api.conformance.url;
|
|
342
|
-
const response = await httpCall.post(`${apiUrl}/client-mock/updateList`, {
|
|
343
|
-
did: context.client.did,
|
|
344
|
-
id: statusIndex.toString(),
|
|
345
|
-
position: Number(statusListIndex),
|
|
346
|
-
value: Number(value),
|
|
347
|
-
});
|
|
348
|
-
return response.data;
|
|
349
|
-
}
|
|
350
|
-
export async function conformance(method, inputs, context) {
|
|
351
|
-
switch (method) {
|
|
352
|
-
case "authMockAuthorize": {
|
|
353
|
-
return authMockAuthorize(inputs, context);
|
|
354
|
-
}
|
|
355
|
-
case "authMockDirectPostIdToken": {
|
|
356
|
-
return authMockDirectPostIdToken(inputs, context);
|
|
357
|
-
}
|
|
358
|
-
case "authMockDirectPostVpToken": {
|
|
359
|
-
return authMockDirectPostVpToken(inputs);
|
|
360
|
-
}
|
|
361
|
-
case "authMockToken": {
|
|
362
|
-
return authMockToken(inputs, context);
|
|
363
|
-
}
|
|
364
|
-
case "check": {
|
|
365
|
-
return check(inputs, context);
|
|
366
|
-
}
|
|
367
|
-
case "clientMockInitiate": {
|
|
368
|
-
return clientMockInitiate(context);
|
|
369
|
-
}
|
|
370
|
-
case "clientMockUpdateBitstringList": {
|
|
371
|
-
return clientMockUpdateBitstringList(inputs, context);
|
|
372
|
-
}
|
|
373
|
-
case "clientMockUpdateList": {
|
|
374
|
-
return clientMockUpdateList(inputs, context);
|
|
375
|
-
}
|
|
376
|
-
case "get": {
|
|
377
|
-
return conformanceGet(inputs, context);
|
|
378
|
-
}
|
|
379
|
-
case "getCredential": {
|
|
380
|
-
return getCredential(inputs, context);
|
|
381
|
-
}
|
|
382
|
-
case "holder": {
|
|
383
|
-
return holder(inputs, context);
|
|
384
|
-
}
|
|
385
|
-
case "issuerMockCredential": {
|
|
386
|
-
return issuerMockCredential(inputs, context);
|
|
387
|
-
}
|
|
388
|
-
case "issuerMockDeferred": {
|
|
389
|
-
return issuerMockDeferred(inputs);
|
|
390
|
-
}
|
|
391
|
-
case "issuerMockInitiateCredentialOffer": {
|
|
392
|
-
return issuerMockInitiateCredentialOffer(inputs, context);
|
|
393
|
-
}
|
|
394
|
-
default: {
|
|
395
|
-
throw new Error(`Invalid method '${method}'`);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
export async function conformanceGet(inputs, context) {
|
|
400
|
-
const apiUrl = context.config.api.conformance.url;
|
|
401
|
-
const urlPath = inputs.join("");
|
|
402
|
-
const url = urlPath.startsWith("http") ? urlPath : `${apiUrl}${urlPath}`;
|
|
403
|
-
const response = await httpCall.get(url, context.httpOpts);
|
|
404
|
-
return response.data;
|
|
405
|
-
}
|
|
406
|
-
export async function getCredential(inputs, context) {
|
|
407
|
-
const [type, inputAlg, inputVcdmVersion, inputVc, inputIssuer] = inputs;
|
|
408
|
-
const alg = inputAlg || "ES256";
|
|
409
|
-
const vcdmVersion = inputVcdmVersion
|
|
410
|
-
? Number(inputVcdmVersion).toFixed(1)
|
|
411
|
-
: estimateVcdmVersion(inputVc);
|
|
412
|
-
const vc = inputVc ?? [];
|
|
413
|
-
const vcString = typeof vc === "string" ? vc : JSON.stringify(vc);
|
|
414
|
-
let openIdCredentialIssuerUrl;
|
|
415
|
-
if (inputIssuer) {
|
|
416
|
-
openIdCredentialIssuerUrl = inputIssuer.startsWith("http")
|
|
417
|
-
? `${inputIssuer}/.well-known/openid-credential-issuer`
|
|
418
|
-
: `/client-mock/${inputIssuer}/.well-known/openid-credential-issuer`;
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
openIdCredentialIssuerUrl =
|
|
422
|
-
"/issuer-mock/.well-known/openid-credential-issuer";
|
|
423
|
-
}
|
|
424
|
-
let requestedTypes;
|
|
425
|
-
switch (type) {
|
|
426
|
-
case "ctrevocable": {
|
|
427
|
-
requestedTypes = [
|
|
428
|
-
"VerifiableCredential",
|
|
429
|
-
"VerifiableAttestation",
|
|
430
|
-
"CTRevocable",
|
|
431
|
-
];
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
case "onboard": {
|
|
435
|
-
requestedTypes = [
|
|
436
|
-
"VerifiableCredential",
|
|
437
|
-
"VerifiableAttestation",
|
|
438
|
-
"VerifiableAuthorisationToOnboard",
|
|
439
|
-
];
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
case "qualification": {
|
|
443
|
-
requestedTypes = [
|
|
444
|
-
"VerifiableCredential",
|
|
445
|
-
"VerifiableAttestation",
|
|
446
|
-
"CTAAQualificationCredential",
|
|
447
|
-
];
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case "roottao": {
|
|
451
|
-
requestedTypes =
|
|
452
|
-
vcdmVersion === "1.1"
|
|
453
|
-
? [
|
|
454
|
-
"VerifiableCredential",
|
|
455
|
-
"VerifiableAttestation",
|
|
456
|
-
"VerifiableAuthorisationForTrustChain",
|
|
457
|
-
]
|
|
458
|
-
: [
|
|
459
|
-
"VerifiableCredential",
|
|
460
|
-
"VerifiableAttestation",
|
|
461
|
-
// "VerifiableTrustModel",
|
|
462
|
-
"VerifiableAuthorisationForTrustChain",
|
|
463
|
-
];
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
case "tao": {
|
|
467
|
-
requestedTypes =
|
|
468
|
-
vcdmVersion === "1.1"
|
|
469
|
-
? [
|
|
470
|
-
"VerifiableCredential",
|
|
471
|
-
"VerifiableAttestation",
|
|
472
|
-
"VerifiableAccreditation",
|
|
473
|
-
"VerifiableAccreditationToAccredit",
|
|
474
|
-
]
|
|
475
|
-
: [
|
|
476
|
-
"VerifiableCredential",
|
|
477
|
-
"VerifiableAttestation",
|
|
478
|
-
"VerifiableTrustModel",
|
|
479
|
-
"VerifiableAccreditationToAccredit",
|
|
480
|
-
];
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
case "ti": {
|
|
484
|
-
requestedTypes =
|
|
485
|
-
vcdmVersion === "1.1"
|
|
486
|
-
? [
|
|
487
|
-
"VerifiableCredential",
|
|
488
|
-
"VerifiableAttestation",
|
|
489
|
-
"VerifiableAccreditation",
|
|
490
|
-
"VerifiableAccreditationToAttest",
|
|
491
|
-
]
|
|
492
|
-
: [
|
|
493
|
-
"VerifiableCredential",
|
|
494
|
-
"VerifiableAttestation",
|
|
495
|
-
"VerifiableTrustModel",
|
|
496
|
-
"VerifiableAccreditationToAttest",
|
|
497
|
-
];
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
default: {
|
|
501
|
-
throw new Error(`type ${type} is not supported`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
// conformance clientMockInitiate
|
|
505
|
-
console.log("==> conformance clientMockInitiate");
|
|
506
|
-
await clientMockInitiate(context);
|
|
507
|
-
// opIssuer: conformance get /issuer-mock/.well-known/openid-credential-issuer
|
|
508
|
-
console.log(`==> conformance get ${openIdCredentialIssuerUrl}`);
|
|
509
|
-
const opIssuer = (await conformanceGet([openIdCredentialIssuerUrl], context));
|
|
510
|
-
const authorizationServer = opIssuer.authorization_server ?? opIssuer.credential_issuer;
|
|
511
|
-
// opConf: conformance get opIssuer.authorization_server /.well-known/openid-configuration
|
|
512
|
-
console.log(`==> conformance get ${authorizationServer}/.well-known/openid-configuration`);
|
|
513
|
-
const opConf = (await conformanceGet([authorizationServer, "/.well-known/openid-configuration"], context));
|
|
514
|
-
// respAuthorize: conformance authMockAuthorize opIssuer opConf requestedTypes ES256
|
|
515
|
-
console.log(`==> conformance authMockAuthorize ${stringify(opIssuer, [
|
|
516
|
-
"authorization_server",
|
|
517
|
-
"credential_issuer",
|
|
518
|
-
])} ${stringify(opConf, ["authorization_endpoint"])} ${JSON.stringify(requestedTypes)} ${alg}`);
|
|
519
|
-
const respAuthorize = await authMockAuthorize([opIssuer, opConf, requestedTypes, alg], context);
|
|
520
|
-
let code;
|
|
521
|
-
if (type === "roottao") {
|
|
522
|
-
const payloadJwt = { aud: opConf.issuer };
|
|
523
|
-
// vpJwt: compute createVpJwt vc {} {aud:opConf.issuer} alg vcdmVersion
|
|
524
|
-
console.log(`==> compute createVpJwt ${vcString} {} ${JSON.stringify(payloadJwt)} ${alg} ${vcdmVersion}`);
|
|
525
|
-
const vpJwt = (await compute("createVpJwt", [vc, {}, payloadJwt, alg, vcdmVersion], context));
|
|
526
|
-
// respDirectPost: conformance authMockDirectPostVpToken respAuthorize ES256
|
|
527
|
-
console.log(`==> conformance authMockDirectPostVpToken ${JSON.stringify(respAuthorize)} ${vpJwt} onboard ${vcdmVersion}`);
|
|
528
|
-
const respDirectPost = (await authMockDirectPostVpToken([
|
|
529
|
-
respAuthorize,
|
|
530
|
-
vpJwt,
|
|
531
|
-
"onboard",
|
|
532
|
-
vcdmVersion,
|
|
533
|
-
]));
|
|
534
|
-
code = respDirectPost.code;
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
// respDirectPost: conformance authMockDirectPostIdToken opIssuer respAuthorize ES256
|
|
538
|
-
console.log(`==> conformance authMockDirectPostIdToken ${stringify(opIssuer, [
|
|
539
|
-
"authorization_server",
|
|
540
|
-
"credential_issuer",
|
|
541
|
-
])} ${JSON.stringify(respAuthorize)} ${alg} ${vcdmVersion}`);
|
|
542
|
-
const respDirectPost = (await authMockDirectPostIdToken([opIssuer, respAuthorize, alg, vcdmVersion], context));
|
|
543
|
-
code = respDirectPost.code;
|
|
544
|
-
}
|
|
545
|
-
// resToken: conformance authMockToken opIssuer opConf respDirectPost.code ES256
|
|
546
|
-
console.log(`==> conformance authMockToken ${stringify(opIssuer, [
|
|
547
|
-
"authorization_server",
|
|
548
|
-
"credential_issuer",
|
|
549
|
-
])} ${stringify(opConf, ["token_endpoint"])} ${code} ${alg}`);
|
|
550
|
-
const respToken = (await authMockToken([opIssuer, opConf, code, alg], context));
|
|
551
|
-
// using token resToken.access_token
|
|
552
|
-
console.log(`==> using token ${respToken.access_token}`);
|
|
553
|
-
context.httpOpts = {
|
|
554
|
-
headers: {
|
|
555
|
-
authorization: `Bearer ${respToken.access_token}`,
|
|
556
|
-
},
|
|
557
|
-
};
|
|
558
|
-
// resCredential: conformance issuerMockCredential opIssuer resToken.c_nonce requestedTypes ES256
|
|
559
|
-
console.log(`==> conformance issuerMockCredential ${stringify(opIssuer, [
|
|
560
|
-
"credential_issuer",
|
|
561
|
-
])} ${respToken.c_nonce} ${JSON.stringify(requestedTypes)} ${alg} ${vcdmVersion}`);
|
|
562
|
-
const respCredential = (await issuerMockCredential([opIssuer, respToken.c_nonce, requestedTypes, alg, vcdmVersion], context));
|
|
563
|
-
let credential;
|
|
564
|
-
if (type === "roottao") {
|
|
565
|
-
console.log(`waiting 5.5 seconds...`);
|
|
566
|
-
await new Promise((r) => {
|
|
567
|
-
setTimeout(r, 5500);
|
|
568
|
-
});
|
|
569
|
-
// respDeferred: conformance issuerMockDeferred respDirectPost.acceptance_token
|
|
570
|
-
console.log(`==> conformance issuerMockDeferred ${stringify(opIssuer, [
|
|
571
|
-
"deferred_credential_endpoint",
|
|
572
|
-
])} ${respCredential.acceptance_token}`);
|
|
573
|
-
const respDeferred = (await issuerMockDeferred([
|
|
574
|
-
opIssuer,
|
|
575
|
-
respCredential.acceptance_token,
|
|
576
|
-
]));
|
|
577
|
-
credential = respDeferred.credential;
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
credential = respCredential.credential;
|
|
581
|
-
}
|
|
582
|
-
// decodedCredential: compute decodeJWT resCredential.credential
|
|
583
|
-
console.log(`==> compute decodeJWT ${credential}`);
|
|
584
|
-
const decodedCredential = (await compute("decodeJWT", [credential], context));
|
|
585
|
-
let reservedAttributeId = "";
|
|
586
|
-
if (decodedCredential.payload.vc?.credentialSubject?.reservedAttributeId) {
|
|
587
|
-
reservedAttributeId =
|
|
588
|
-
decodedCredential.payload.vc.credentialSubject.reservedAttributeId;
|
|
589
|
-
}
|
|
590
|
-
return {
|
|
591
|
-
reservedAttributeId,
|
|
592
|
-
vc: credential,
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
export async function holder(inputs, context) {
|
|
596
|
-
const apiUrl = context.config.api.conformance.url;
|
|
597
|
-
const [credentialType, communicationType, inputAlg, inputVcdmVersion, inputVc, typeCredentialOffer, inputIssuer,] = inputs;
|
|
598
|
-
const alg = inputAlg || "ES256";
|
|
599
|
-
const vcdmVersion = inputVcdmVersion
|
|
600
|
-
? Number(inputVcdmVersion).toFixed(1)
|
|
601
|
-
: estimateVcdmVersion(inputVc);
|
|
602
|
-
const vc = inputVc ?? [];
|
|
603
|
-
const vcString = typeof vc === "string" ? vc : JSON.stringify(vc);
|
|
604
|
-
const codeVerifier = randomBytes(50).toString("base64url");
|
|
605
|
-
const requestedTypes = [
|
|
606
|
-
"VerifiableCredential",
|
|
607
|
-
"VerifiableAttestation",
|
|
608
|
-
credentialType,
|
|
609
|
-
];
|
|
610
|
-
let openIdCredentialIssuerUrl;
|
|
611
|
-
let initiateCredentialOfferEndpoint;
|
|
612
|
-
if (inputIssuer) {
|
|
613
|
-
if (inputIssuer.startsWith("http")) {
|
|
614
|
-
openIdCredentialIssuerUrl = `${inputIssuer}/.well-known/openid-credential-issuer`;
|
|
615
|
-
initiateCredentialOfferEndpoint = `${inputIssuer}/initiate-credential-offer`;
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
openIdCredentialIssuerUrl = `/client-mock/${inputIssuer}/.well-known/openid-credential-issuer`;
|
|
619
|
-
initiateCredentialOfferEndpoint = `${apiUrl}/client-mock/${inputIssuer}/initiate-credential-offer`;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
openIdCredentialIssuerUrl =
|
|
624
|
-
"/issuer-mock/.well-known/openid-credential-issuer";
|
|
625
|
-
initiateCredentialOfferEndpoint = `${apiUrl}/issuer-mock/initiate-credential-offer`;
|
|
626
|
-
}
|
|
627
|
-
// credentialOffer: conformance issuerMockInitiateCredentialOffer initiateCredentialOfferEndpoint
|
|
628
|
-
console.log(`==> conformance issuerMockInitiateCredentialOffer ${initiateCredentialOfferEndpoint} ${credentialType}`);
|
|
629
|
-
let credentialOffer;
|
|
630
|
-
const validTypesIssuerState = [
|
|
631
|
-
"use-credential-offer",
|
|
632
|
-
"skip-credential-offer",
|
|
633
|
-
];
|
|
634
|
-
if (typeCredentialOffer &&
|
|
635
|
-
!validTypesIssuerState.includes(typeCredentialOffer)) {
|
|
636
|
-
throw new Error(`invalid command for typeCredentialOffer. valid types: ${validTypesIssuerState.join(", ")}`);
|
|
637
|
-
}
|
|
638
|
-
const useCredentialOffer = typeCredentialOffer !== "skip-credential-offer";
|
|
639
|
-
const isPreauthorised = communicationType
|
|
640
|
-
.toLowerCase()
|
|
641
|
-
.startsWith("preauthorised");
|
|
642
|
-
if (useCredentialOffer) {
|
|
643
|
-
credentialOffer = await issuerMockInitiateCredentialOffer([initiateCredentialOfferEndpoint, credentialType], context);
|
|
644
|
-
}
|
|
645
|
-
else {
|
|
646
|
-
if (isPreauthorised)
|
|
647
|
-
throw new Error("For preauthorised credentials set use-credential-offer");
|
|
648
|
-
}
|
|
649
|
-
// opIssuer: conformance get /issuer-mock/.well-known/openid-credential-issuer
|
|
650
|
-
console.log(`==> conformance get ${openIdCredentialIssuerUrl}`);
|
|
651
|
-
const opIssuer = (await conformanceGet([openIdCredentialIssuerUrl], context));
|
|
652
|
-
const authorizationServer = opIssuer.authorization_server ?? opIssuer.credential_issuer;
|
|
653
|
-
// opConf: conformance get opIssuer.authorization_server /.well-known/openid-configuration
|
|
654
|
-
console.log(`==> conformance get ${authorizationServer}/.well-known/openid-configuration`);
|
|
655
|
-
const opConf = (await conformanceGet([authorizationServer, "/.well-known/openid-configuration"], context));
|
|
656
|
-
let code;
|
|
657
|
-
if (isPreauthorised) {
|
|
658
|
-
code =
|
|
659
|
-
credentialOffer.grants["urn:ietf:params:oauth:grant-type:pre-authorized_code"]?.["pre-authorized_code"];
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
// respAuthorize: conformance authMockAuthorize opIssuer opConf requestedTypes ES256
|
|
663
|
-
let issuerState = "";
|
|
664
|
-
if (useCredentialOffer)
|
|
665
|
-
issuerState = credentialOffer.grants.authorization_code
|
|
666
|
-
? credentialOffer.grants.authorization_code.issuer_state
|
|
667
|
-
: "";
|
|
668
|
-
console.log(`==> conformance authMockAuthorize ${stringify(opIssuer, [
|
|
669
|
-
"authorization_server",
|
|
670
|
-
"credential_issuer",
|
|
671
|
-
])} ${stringify(opConf, ["authorization_endpoint"])} ${JSON.stringify(requestedTypes)} ${alg} ${codeVerifier} ${issuerState}`);
|
|
672
|
-
const respAuthorize = await authMockAuthorize([opIssuer, opConf, requestedTypes, alg, codeVerifier, issuerState], context);
|
|
673
|
-
if (credentialType === "CTWalletQualificationCredential") {
|
|
674
|
-
const payloadJwt = { aud: opConf.issuer };
|
|
675
|
-
// vpJwt: compute createVpJwt vc {} {aud:opConf.issuer} alg vcdmVersion
|
|
676
|
-
console.log(`==> compute createVpJwt ${vcString} {} ${JSON.stringify(payloadJwt)} ${alg} ${vcdmVersion ?? "1.1"}`);
|
|
677
|
-
const vpJwt = (await compute("createVpJwt", [vc, {}, payloadJwt, alg, vcdmVersion ?? "1.1"], context));
|
|
678
|
-
// respDirectPost: conformance authMockDirectPostVpToken respAuthorize ES256
|
|
679
|
-
console.log(`==> conformance authMockDirectPostVpToken ${JSON.stringify(respAuthorize)} ${vpJwt} holder ${vcdmVersion}`);
|
|
680
|
-
const respDirectPost = (await authMockDirectPostVpToken([
|
|
681
|
-
respAuthorize,
|
|
682
|
-
vpJwt,
|
|
683
|
-
"holder",
|
|
684
|
-
vcdmVersion,
|
|
685
|
-
]));
|
|
686
|
-
code = respDirectPost.code;
|
|
687
|
-
}
|
|
688
|
-
else {
|
|
689
|
-
// respDirectPost: conformance authMockDirectPostIdToken opIssuer respAuthorize ES256
|
|
690
|
-
console.log(`==> conformance authMockDirectPostIdToken ${stringify(opIssuer, [
|
|
691
|
-
"authorization_server",
|
|
692
|
-
"credential_issuer",
|
|
693
|
-
])} ${JSON.stringify(respAuthorize)} ${alg} ${vcdmVersion}`);
|
|
694
|
-
const respDirectPost = (await authMockDirectPostIdToken([opIssuer, respAuthorize, alg, vcdmVersion], context));
|
|
695
|
-
code = respDirectPost.code;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
// resToken: conformance authMockToken opIssuer opConf respDirectPost.code ES256
|
|
699
|
-
console.log(`==> conformance authMockToken ${stringify(opIssuer, [
|
|
700
|
-
"authorization_server",
|
|
701
|
-
"credential_issuer",
|
|
702
|
-
])} ${stringify(opConf, [
|
|
703
|
-
"token_endpoint",
|
|
704
|
-
])} ${code} ${alg} ${codeVerifier}`);
|
|
705
|
-
const respToken = (await authMockToken([
|
|
706
|
-
opIssuer,
|
|
707
|
-
opConf,
|
|
708
|
-
code,
|
|
709
|
-
alg,
|
|
710
|
-
codeVerifier,
|
|
711
|
-
isPreauthorised ? "preAuthorised" : "",
|
|
712
|
-
], context));
|
|
713
|
-
// using token resToken.access_token
|
|
714
|
-
console.log(`==> using token ${respToken.access_token}`);
|
|
715
|
-
context.httpOpts = {
|
|
716
|
-
headers: {
|
|
717
|
-
authorization: `Bearer ${respToken.access_token}`,
|
|
718
|
-
},
|
|
719
|
-
};
|
|
720
|
-
// resCredential: conformance issuerMockCredential opIssuer resToken.c_nonce requestedTypes ES256
|
|
721
|
-
console.log(`==> conformance issuerMockCredential ${stringify(opIssuer, [
|
|
722
|
-
"credential_issuer",
|
|
723
|
-
])} ${respToken.c_nonce} ${JSON.stringify(requestedTypes)} ${alg} ${vcdmVersion}`);
|
|
724
|
-
const respCredential = (await issuerMockCredential([opIssuer, respToken.c_nonce, requestedTypes, alg, vcdmVersion], context));
|
|
725
|
-
let credential;
|
|
726
|
-
const isDeferred = communicationType.toLowerCase().endsWith("deferred");
|
|
727
|
-
if (isDeferred) {
|
|
728
|
-
console.log(`waiting 5.5 seconds...`);
|
|
729
|
-
await new Promise((r) => {
|
|
730
|
-
setTimeout(r, 5500);
|
|
731
|
-
});
|
|
732
|
-
// respDeferred: conformance issuerMockDeferred respDirectPost.acceptance_token
|
|
733
|
-
console.log(`==> conformance issuerMockDeferred ${stringify(opIssuer, [
|
|
734
|
-
"deferred_credential_endpoint",
|
|
735
|
-
])} ${respCredential.acceptance_token}`);
|
|
736
|
-
const respDeferred = (await issuerMockDeferred([
|
|
737
|
-
opIssuer,
|
|
738
|
-
respCredential.acceptance_token,
|
|
739
|
-
]));
|
|
740
|
-
credential = respDeferred.credential;
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
credential = respCredential.credential;
|
|
744
|
-
}
|
|
745
|
-
return credential;
|
|
746
|
-
}
|
|
747
|
-
export async function issuerMockCredential(inputs, context) {
|
|
748
|
-
const [openIdCredentialIssuer, nonce, requestedTypes, inputAlg, inputVcdmVersion,] = inputs;
|
|
749
|
-
const alg = inputAlg || "ES256";
|
|
750
|
-
const vcdmVersion = Number(inputVcdmVersion || "1.1").toFixed(1);
|
|
751
|
-
const clientId = context.client.didVersion === 1
|
|
752
|
-
? context.client.clientId
|
|
753
|
-
: context.client.did;
|
|
754
|
-
const iat = Math.floor(Date.now() / 1000);
|
|
755
|
-
const exp = iat + 5 * 60;
|
|
756
|
-
const jwtPayload = {
|
|
757
|
-
aud: openIdCredentialIssuer.credential_issuer,
|
|
758
|
-
exp,
|
|
759
|
-
iat,
|
|
760
|
-
iss: clientId,
|
|
761
|
-
nonce,
|
|
762
|
-
};
|
|
763
|
-
const proofJwt = await context.client.signJWT(jwtPayload, {
|
|
764
|
-
typ: "openid4vci-proof+jwt",
|
|
765
|
-
}, alg);
|
|
766
|
-
const responseCredential = await httpCall.post(`${openIdCredentialIssuer.credential_issuer}/credential?vcdm_version=${vcdmVersion}`, {
|
|
767
|
-
format: "jwt_vc",
|
|
768
|
-
proof: {
|
|
769
|
-
jwt: proofJwt,
|
|
770
|
-
proof_type: "jwt",
|
|
771
|
-
},
|
|
772
|
-
types: requestedTypes,
|
|
773
|
-
}, context.httpOpts);
|
|
774
|
-
return responseCredential.data;
|
|
775
|
-
}
|
|
776
|
-
export async function issuerMockDeferred(inputs) {
|
|
777
|
-
const [openIdCredentialIssuer, acceptanceToken] = inputs;
|
|
778
|
-
const response = await httpCall.post(openIdCredentialIssuer.deferred_credential_endpoint, undefined, {
|
|
779
|
-
headers: {
|
|
780
|
-
authorization: `Bearer ${acceptanceToken}`,
|
|
781
|
-
},
|
|
782
|
-
});
|
|
783
|
-
return response.data;
|
|
784
|
-
}
|
|
785
|
-
export async function issuerMockInitiateCredentialOffer(inputs, context) {
|
|
786
|
-
const [initiateCredentialOfferEndpoint, credentialType] = inputs;
|
|
787
|
-
const requestParams = {
|
|
788
|
-
client_id: context.client.did,
|
|
789
|
-
credential_offer_endpoint: "openid-credential-offer://",
|
|
790
|
-
credential_type: credentialType,
|
|
791
|
-
};
|
|
792
|
-
let response = await httpCall.get(`${initiateCredentialOfferEndpoint}?${qsStringify(requestParams)}`);
|
|
793
|
-
const search = credentialType.startsWith("CTWalletSame")
|
|
794
|
-
? new URL(response.headers.location).search
|
|
795
|
-
: new URL(response.data).search;
|
|
796
|
-
const parsedCredentialOffer = qsParse(search.slice(1));
|
|
797
|
-
if (parsedCredentialOffer.credential_offer_uri) {
|
|
798
|
-
response = await httpCall.get(parsedCredentialOffer.credential_offer_uri);
|
|
799
|
-
return response.data;
|
|
800
|
-
}
|
|
801
|
-
return qsParse(parsedCredentialOffer.credential_offer);
|
|
802
|
-
}
|
|
803
|
-
function stringify(obj, fields) {
|
|
804
|
-
if (typeof obj !== "object" || !obj)
|
|
805
|
-
throw new Error("not an object");
|
|
806
|
-
const newObj = {};
|
|
807
|
-
for (const f of fields) {
|
|
808
|
-
if (f in obj && obj[f])
|
|
809
|
-
newObj[f] = obj[f];
|
|
810
|
-
}
|
|
811
|
-
return JSON.stringify(newObj);
|
|
812
|
-
}
|
|
813
|
-
//# sourceMappingURL=conformance.js.map
|