Skip to content

Commit

Permalink
WAL-646: allow for config section CredentialSupplierConfig in Credent…
Browse files Browse the repository at this point in the history
…ialDataSupplierArgs
  • Loading branch information
sanderPostma committed Sep 28, 2023
1 parent 214e3c6 commit 9bde31c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"fix:lint": "eslint . --fix --ext .ts",
"fix:prettier": "prettier --write \"{packages,__tests__,!dist}/**/*.{ts,tsx,js,json,md,yml}\"",
"build": "pnpm -r --stream build",
"build:clean": "lerna clean -y && pnpm install && lerna run build:clean --concurrency 1",
"test:ci": "jest --config=jest.json",
"test": "jest --verbose --config=jest.json --coverage=true --detectOpenHandles",
"clean": "rimraf --glob **/dist **/coverage **/pnpm-lock.yaml packages/**/node_modules node_modules packages/**/tsconfig.tsbuildinfo",
Expand Down
3 changes: 2 additions & 1 deletion packages/callback-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@digitalcredentials/did-method-key": "^2.0.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/common/lib/types/Generic.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type MetadataDisplay = NameAndLocale &
name?: string; //OPTIONAL. String value of a display name for the Credential Issuer.
};

export interface CredentialSupplierConfig {
[key: string]: any; // This allows additional properties for credential suppliers
}

export interface CredentialIssuerMetadataOpts {
credential_endpoint?: string; // REQUIRED. URL of the Credential Issuer's Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components.
batch_credential_endpoint?: string; // OPTIONAL. URL of the Credential Issuer's Batch Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components. If omitted, the Credential Issuer does not support the Batch Credential Endpoint.
Expand All @@ -49,6 +53,7 @@ export interface CredentialIssuerMetadataOpts {
authorization_server?: string; // OPTIONAL. Identifier of the OAuth 2.0 Authorization Server (as defined in [RFC8414]) the Credential Issuer relies on for authorization. If this element is omitted, the entity providing the Credential Issuer is also acting as the AS, i.e. the Credential Issuer's identifier is used as the OAuth 2.0 Issuer value to obtain the Authorization Server metadata as per [RFC8414].
token_endpoint?: string;
display?: MetadataDisplay[]; // An array of objects, where each object contains display properties of a Credential Issuer for a certain language. Below is a non-exhaustive list of valid parameters that MAY be included:
credential_supplier_config?: CredentialSupplierConfig
}

// For now we extend the opts above. Only difference is that the credential endpoint is optional in the Opts, as it can come from other sources. The value is however required in the eventual Issuer Metadata
Expand Down
3 changes: 2 additions & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/ssi-types": "^0.15.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/issuer-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"types": "dist/index.d.ts",
"scripts": {
"start": "ts-node lib/OID4VCIServer.ts",
"build": "tsc"
"build": "tsc",
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "workspace:*",
Expand Down
12 changes: 7 additions & 5 deletions packages/issuer/lib/VcIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { v4 } from 'uuid'

import { assertValidPinNumber, createCredentialOfferObject, createCredentialOfferURIFromObject } from './functions'
import { LookupStateManager } from './state-manager'
import { CredentialDataSupplier, CredentialSignerCallback } from './types'
import { CredentialDataSupplier, CredentialDataSupplierArgs, CredentialSignerCallback } from './types'

const SECOND = 1000

Expand Down Expand Up @@ -275,12 +275,14 @@ export class VcIssuer<DIDDoc extends object> {
throw Error('Credential Offer missing')
}
const credentialDataSupplierInput = opts.credentialDataSupplierInput ?? session.credentialDataSupplierInput
const result = await credentialDataSupplier({

const result = await credentialDataSupplier({
...cNonceState,
credentialRequest: opts.credentialRequest,
credentialOffer /*todo: clientId: */,
credentialRequest: opts.credentialRequest,
credentialSupplierConfig: this._issuerMetadata.credential_supplier_config,
credentialOffer /*todo: clientId: */,
...(credentialDataSupplierInput && { credentialDataSupplierInput }),
})
} as CredentialDataSupplierArgs)
credential = result.credential
if (result.format) {
format = result.format
Expand Down
7 changes: 4 additions & 3 deletions packages/issuer/lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
AssertedUniformCredentialOffer,
CNonceState,
CredentialDataSupplierInput,
CredentialDataSupplierInput, CredentialSupplierConfig,
JwtVerifyResult,
OID4VCICredentialFormat,
UniformCredentialRequest,
UniformCredentialRequest
} from '@sphereon/oid4vci-common'
import { ICredential, W3CVerifiableCredential } from '@sphereon/ssi-types'

Expand All @@ -21,8 +21,9 @@ export type CredentialSignerCallback<T extends object> = (opts: {

export interface CredentialDataSupplierArgs extends CNonceState {
credentialRequest: UniformCredentialRequest
clientId?: string
credentialOffer: AssertedUniformCredentialOffer
clientId?: string
credentialSupplierConfig?: CredentialSupplierConfig
credentialDataSupplierInput?: CredentialDataSupplierInput
}

Expand Down
3 changes: 2 additions & 1 deletion packages/issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "workspace:*",
Expand Down

0 comments on commit 9bde31c

Please sign in to comment.