WalletApi2CredentialReader
WalletApi2CredentialReader lists the credentials of a walt.id wallet-api2 wallet
(GET /wallet/{walletId}/credentials) as metadata. With an
access key the key's admin must have allowed read credential
list on it, and the list holds only the credentials in the key's scope.
Usage
const = .({
: 'https://wallet.example.org/api/gateway',
: .. as string
// Optional: address or walletId (a key with several wallets), organization, actor,
// accessKeyFile, timeoutMs, dpopSigner, allowInsecureTransport
})
const = await .()
await ..()WalletApi2CredentialReader.fromEnv(options?) does the same with PONTUSX_ACCESS_KEY (or
PONTUSX_ACCESS_KEY_FILE) and PONTUSX_WALLET_URL.
The reader makes its own AccessKeyTokenSource with
the scope read_credentials only (reader.tokenSource), so the presenting and DDO signing
tokens never carry it. withAccessKey takes the options of AccessKeyTokenSource except
scopes.
Options of the constructor
withAccessKey and fromEnv cover the access key. The constructor takes any token source:
| Option | Type | Purpose |
|---|---|---|
tokenSource | WalletApi2TokenSource | Required. An AccessKeyTokenSource with the scope read_credentials, or another token source (a Hanko session token). |
walletId | string | The wallet to list. Defaults to the token's wallet. Required for a token source that names none. |
walletApi | string | Defaults to the token source's gateway. Required for a token source that names none. |
allowInsecureTransport, timeoutMs, fetchImpl | As for WalletApi2HttpClient. |
listCredentials
listCredentials(signal?) answers WalletApi2CredentialMetadata[]:
| Field | Type | Content |
|---|---|---|
id | string | The wallet's id of the credential, as in check()'s credentialIds. |
format | string | For example jwt_vc_json, dc+sd-jwt, mso_mdoc. |
issuer | string? | The issuer's DID or URL, when the credential names one. |
addedAt | string? | When the credential was added to the wallet (ISO 8601). |
store | string? | org (the organisation's store) or wallet (the wallet's own). |
subject, label | string? | Never sent for an access token. A Hanko session token gets them. |
The list never holds the credential itself or its claims. nautilus leaves out entries
without a string id and format, and refuses an answer that is not a list
(wrong_endpoint).
Errors
The reader throws WaltIdWalletError with code and hint:
invalid_scope(at the token request) orscope_not_enabled(at the list): the key may not read the credential list. The hint asks the admin to turn on "Read credential list".scope_not_requested: nautilus's own, thrown before any request when thetokenSourceyou passed to the constructor does not ask forread_credentials(itsscopeslack it). It has nostatus. UsewithAccessKey, or anAccessKeyTokenSourcewith that scope.wallet_not_in_scope,wallet_required: the key has no wallet for theaddressorwalletIdyou pinned, or has several and you pinned none.- Every other code of the error table.