WalletApi2CredentialProvider
Answers the OpenID4VP 1.0 (DCQL) request of a node with the native SSI module
(pontusx-node, ssiInitiate) from walt.id wallet-api2, the wallet of the pontusx identity
stack. nautilus opens the session before and polls ssiStatus after
(PolicySessionResolver), so this is only needed
for assets with an SSIpolicyV2 (or deprecated SSIpolicy) entry.
For a node with a policy server, use WaltIdCredentialProvider.
Usage
const = await .(, {
,
: new ({
: 'https://wallet-api.example.org',
:
})
})
// Unchanged at the call site: the exchange happens inside.
const { } = await .({ : 'did:ope:1234abcd...' })token is the account's session token (a Hanko session JWT on the pontusx platform): pass the
token, or a function that returns a current one; it is asked for on every request and never
logged. Scripts and CI jobs sign in with the key of an organisation address instead:
withAddressSignIn.
withAddressSignIn
const = .({
: 'https://wallet.example.org/api/address-gateway',
// chainId?: from signer.provider.getNetwork()
// smartAccount?: 'auto' (default) | true | false
// scopes?: ['present'] (default) | ['present', 'sign-ddo']
})
.(await ..()) // what the address may do
const = await .(, { , })Builds an AddressSignIn for the wallet UI's address
gateway and a provider bound to the same gateway; credentials.signIn is the sign-in (for
check(), signOut() and WalletApi2VcSigner). Takes
the options of AddressSignIn and of the provider (walletId, holderDid,
expectedVerifierHost, onSelectCredentials, allowInsecureTransport). With it:
- the provider presents from the address's own wallet (the token is for that wallet only), and lists no wallets;
prepare()signs in, checks that the address signed in is the consumer ("Signed in as 0xA, but the order is for 0xB",signer_mismatch) and that a pinnedwalletIdis its wallet (wallet_mismatch), and runscheck(): no verifier, a missing grant for the node's announced verifier (orexpectedVerifierHostwhen unannounced; case-insensitive host,:443implied), or nothing it may present (no_presentable_credentials) fails before any node session is opened. The answer is reused for the same token for at most a minute, and dropped whenprepare()fails, so an admin's fix takes effect at the next call;- a preview evicted by newer previews of the same token (
handle_evicted) is made again once. That is a new preview:onSelectCredentialsis asked again.
Setup and CI guidance: Sign in from scripts and CI.
Options
| Option | Type | Purpose |
|---|---|---|
walletApi | string | wallet-api2 base URL. Required unless wallet is given. |
token | string | () => string | Promise<string> | WalletApi2TokenSource | The account's session token, or a token source (an AddressSignIn). Required with walletApi. |
wallet | WalletApi2 | Supply your own client instead (a backend-for-frontend, tests). |
walletId | string | Pin a wallet. By default the organisation's wallet of the consumer's address (GET /org/wallets). |
holderDid | string | The DID to sign as. By default wallet-api2's choice for the request. |
expectedVerifierHost | string | The verifier host to require when the node does not announce one. |
onSelectCredentials | (matches, preview) => Promise<Record<string, string[]>> | Choose credentials (ids by DCQL query id) from a UI. |
allowInsecureTransport | boolean | Accept plain http:// wallet and request URLs on a non-loopback host. Default false. |
What it does
prepare(), before nautilus opens the node session: finds the consumer's wallet (GET /org/wallets), so a missing wallet or a rejected token fails withwallet-setupand leaves no pending session at the node.- Checks the request: an
openid4vp://URL whoserequest_uriishttps://(orhttp://on a loopback host) and on the node's announced verifier host (status.ssi.verifierPublicHost). POST /wallet/{walletId}/credentials/present/preview-handle: wallet-api2 resolves the request once and keeps it behind a single-use handle.- Checks the preview, and declines it (
reject-handle) when the presentation would be posted off the verifier host, the wallet offers credentials for a DCQL query the node did not ask for, ortransaction_datais not the node'sorg.oceanenterprise.transaction-data.asset-accessitem for this consumer, asset and service. POST …/present/submit-handlewith the chosen credentials: exactly the request that was previewed is signed and sent.
Errors
A CredentialPresentationError with reason:
request-invalid: a check above failed, or the wallet found the request invalid; also a policy-server challenge (protocol: 'policy-server');wallet-setup: no wallet for the consumer's address, or wallet-api2 refused the token (401/403);no-matching-credential: a required combination cannot be met (details.missing);none-selected:onSelectCredentialschose nothing, or something not offered;wallet-failed: wallet-api2 failed;verifier-rejected: the verifier refused the presentation. nautilus then readsssiStatusand throws aPolicyDeniedErrornaming the failed checks, with this error ascause;sign-in: the address could not sign in, its token was refused, or a Hanko token was sent to the address gateway;not-permitted(address sign-in only): the address may not do this; an organisation admin changes its settings.
With an address token, details.code carries wallet-api2's or the gateway's code (with
details.hint, status, retryAfter), also for wallet-failed (e.g. rate_limited), and
no-matching-credential adds that organisation credentials appear only once an admin put the
address on their access list. Every code, its cause and who fixes it:
AddressSignIn errors. A Hanko token keeps the
reasons above (wallet-setup for a 401/403, except the gateway's hanko_token_not_accepted).