Skip to content

Commit

Permalink
chore: relax sendnotification options
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 10, 2024
1 parent 126f976 commit 2905b7d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ console.log(client.getAccessTokenEndpoint()); // https://auth.research.identipro
```

Using https scheme

```typescript
import { OpenID4VCIClient } from '@sphereon/oid4vci-client';

Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export class OpenID4VCIClient {
}

public async sendNotification(
credentialRequestOpts: CredentialRequestOpts,
credentialRequestOpts: Partial<CredentialRequestOpts>,
request: NotificationRequest,
accessToken?: string,
): Promise<NotificationResult> {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/lib/__tests__/IssuanceInitiation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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');
})
});
});
1 change: 1 addition & 0 deletions packages/client/lib/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './AuthorizationUtil';
export * from './notifications';
2 changes: 1 addition & 1 deletion packages/client/lib/functions/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CredentialRequestOpts } from '../CredentialRequestClient';
import { LOG } from '../types';

export async function sendNotification(
credentialRequestOpts: CredentialRequestOpts,
credentialRequestOpts: Partial<CredentialRequestOpts>,
request: NotificationRequest,
accessToken?: string,
): Promise<NotificationResult> {
Expand Down
9 changes: 1 addition & 8 deletions packages/common/lib/functions/Encoding.ts
Original file line number Diff line number Diff line change
@@ -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<never> | string | object, opts?: EncodeJsonAsURIOpts)} encodes a Json object into a URI
Expand Down
34 changes: 22 additions & 12 deletions packages/issuer/lib/__tests__/CredentialOfferUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
)
})
Expand All @@ -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`,
)
})
Expand Down

0 comments on commit 2905b7d

Please sign in to comment.