Skip to content
LogoLogo

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:

OptionTypePurpose
tokenSourceWalletApi2TokenSourceRequired. An AccessKeyTokenSource with the scope read_credentials, or another token source (a Hanko session token).
walletIdstringThe wallet to list. Defaults to the token's wallet. Required for a token source that names none.
walletApistringDefaults to the token source's gateway. Required for a token source that names none.
allowInsecureTransport, timeoutMs, fetchImplAs for WalletApi2HttpClient.

listCredentials

listCredentials(signal?) answers WalletApi2CredentialMetadata[]:

FieldTypeContent
idstringThe wallet's id of the credential, as in check()'s credentialIds.
formatstringFor example jwt_vc_json, dc+sd-jwt, mso_mdoc.
issuerstring?The issuer's DID or URL, when the credential names one.
addedAtstring?When the credential was added to the wallet (ISO 8601).
storestring?org (the organisation's store) or wallet (the wallet's own).
subject, labelstring?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) or scope_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 the tokenSource you passed to the constructor does not ask for read_credentials (its scopes lack it). It has no status. Use withAccessKey, or an AccessKeyTokenSource with that scope.
  • wallet_not_in_scope, wallet_required: the key has no wallet for the address or walletId you pinned, or has several and you pinned none.
  • Every other code of the error table.