diff --git a/packages/client/README.md b/packages/client/README.md index 0ddf6df4..79c27184 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -69,6 +69,7 @@ console.log(client.getAccessTokenEndpoint()); // https://auth.research.identipro ``` Using https scheme + ```typescript import { OpenID4VCIClient } from '@sphereon/oid4vci-client'; diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index 9162da0d..fcc75e2a 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -473,7 +473,7 @@ export class OpenID4VCIClient { } public async sendNotification( - credentialRequestOpts: CredentialRequestOpts, + credentialRequestOpts: Partial, request: NotificationRequest, accessToken?: string, ): Promise { diff --git a/packages/client/lib/__tests__/IssuanceInitiation.spec.ts b/packages/client/lib/__tests__/IssuanceInitiation.spec.ts index 1c6635a5..e9676f98 100644 --- a/packages/client/lib/__tests__/IssuanceInitiation.spec.ts +++ b/packages/client/lib/__tests__/IssuanceInitiation.spec.ts @@ -68,7 +68,7 @@ describe('Issuance Initiation', () => { expect(client.scheme).toEqual('https'); expect(client.credential_offer.credential_issuer).toEqual('https://launchpad.vii.electron.mattrlabs.io'); expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X'); - }) + }); it('Should take an http url as input and return a Credential Offer', async () => { const client = await CredentialOfferClient.fromURI( @@ -79,5 +79,5 @@ describe('Issuance Initiation', () => { expect(client.scheme).toEqual('http'); expect(client.credential_offer.credential_issuer).toEqual('http://launchpad.vii.electron.mattrlabs.io'); expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X'); - }) + }); }); diff --git a/packages/client/lib/functions/index.ts b/packages/client/lib/functions/index.ts index a0df3769..217c462c 100644 --- a/packages/client/lib/functions/index.ts +++ b/packages/client/lib/functions/index.ts @@ -1 +1,2 @@ export * from './AuthorizationUtil'; +export * from './notifications'; diff --git a/packages/client/lib/functions/notifications.ts b/packages/client/lib/functions/notifications.ts index ce226890..c89e2939 100644 --- a/packages/client/lib/functions/notifications.ts +++ b/packages/client/lib/functions/notifications.ts @@ -4,7 +4,7 @@ import { CredentialRequestOpts } from '../CredentialRequestClient'; import { LOG } from '../types'; export async function sendNotification( - credentialRequestOpts: CredentialRequestOpts, + credentialRequestOpts: Partial, request: NotificationRequest, accessToken?: string, ): Promise { diff --git a/packages/common/lib/functions/Encoding.ts b/packages/common/lib/functions/Encoding.ts index ace4c949..bab52bdd 100644 --- a/packages/common/lib/functions/Encoding.ts +++ b/packages/common/lib/functions/Encoding.ts @@ -1,11 +1,4 @@ -import { - BAD_PARAMS, - DecodeURIAsJsonOpts, - EncodeJsonAsURIOpts, - JsonURIMode, - OpenId4VCIVersion, - SearchValue -} from '../types' +import { BAD_PARAMS, DecodeURIAsJsonOpts, EncodeJsonAsURIOpts, JsonURIMode, OpenId4VCIVersion, SearchValue } from '../types'; /** * @type {(json: {[s:string]: never} | ArrayLike | string | object, opts?: EncodeJsonAsURIOpts)} encodes a Json object into a URI diff --git a/packages/issuer/lib/__tests__/CredentialOfferUtils.spec.ts b/packages/issuer/lib/__tests__/CredentialOfferUtils.spec.ts index b4a741b7..5ca137ba 100644 --- a/packages/issuer/lib/__tests__/CredentialOfferUtils.spec.ts +++ b/packages/issuer/lib/__tests__/CredentialOfferUtils.spec.ts @@ -43,12 +43,17 @@ describe('CredentialOfferUtils should', () => { }, } as CredentialOfferPayloadV1_0_11 - expect(createCredentialOfferURI({ - credential_issuer: credentialOffer.credential_issuer, - credential_endpoint: 'test_issuer', - issuer: 'test_issuer', - credentials_supported: [] - }, { credentialOffer, state: 'eyJhbGciOiJSU0Et...FYUaBy', scheme: 'https' })).toEqual( + expect( + createCredentialOfferURI( + { + credential_issuer: credentialOffer.credential_issuer, + credential_endpoint: 'test_issuer', + issuer: 'test_issuer', + credentials_supported: [], + }, + { credentialOffer, state: 'eyJhbGciOiJSU0Et...FYUaBy', scheme: 'https' }, + ), + ).toEqual( `${credentialOffer.credential_issuer}?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fcredential-issuer.example.com%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc_json%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22authorization_code%22%3A%7B%22issuer_state%22%3A%22eyJhbGciOiJSU0Et...FYUaBy%22%7D%7D%7D`, ) }) @@ -71,12 +76,17 @@ describe('CredentialOfferUtils should', () => { }, } as CredentialOfferPayloadV1_0_11 - expect(createCredentialOfferURI({ - credential_issuer: credentialOffer.credential_issuer, - credential_endpoint: 'test_issuer', - issuer: 'test_issuer', - credentials_supported: [] - }, { credentialOffer, state: 'eyJhbGciOiJSU0Et...FYUaBy', scheme: 'http' })).toEqual( + expect( + createCredentialOfferURI( + { + credential_issuer: credentialOffer.credential_issuer, + credential_endpoint: 'test_issuer', + issuer: 'test_issuer', + credentials_supported: [], + }, + { credentialOffer, state: 'eyJhbGciOiJSU0Et...FYUaBy', scheme: 'http' }, + ), + ).toEqual( `${credentialOffer.credential_issuer}?credential_offer=%7B%22credential_issuer%22%3A%22http%3A%2F%2Fcredential-issuer.example.com%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22jwt_vc_json%22%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22authorization_code%22%3A%7B%22issuer_state%22%3A%22eyJhbGciOiJSU0Et...FYUaBy%22%7D%7D%7D`, ) })