This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix getting client_id from registration object if present. fixes #…
- Loading branch information
Showing
10 changed files
with
122 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { PassBy, ResponseType, RevocationVerification, RP, Scope, SigningAlgo, SubjectType, SupportedVersion } from '../../src'; | ||
|
||
const EXAMPLE_REDIRECT_URL = 'https://acme.com/hello'; | ||
// const EXAMPLE_REFERENCE_URL = 'https://rp.acme.com/siop/jwts'; | ||
const HEX_KEY = 'f857544a9d1097e242ff0b287a7e6e90f19cf973efe2317f2a4678739664420f'; | ||
const DID = 'did:ethr:0x0106a2e985b1E1De9B5ddb4aF6dC9e928F4e99D0'; | ||
const KID = 'did:ethr:0x0106a2e985b1E1De9B5ddb4aF6dC9e928F4e99D0#keys-1'; | ||
|
||
const rp = RP.builder() | ||
// .withClientId('test') | ||
.withRedirectUri(EXAMPLE_REDIRECT_URL) | ||
.withRequestByValue() | ||
.withRevocationVerification(RevocationVerification.NEVER) | ||
.withInternalSignature(HEX_KEY, DID, KID, SigningAlgo.ES256K) | ||
.addDidMethod('ethr') | ||
.addDidMethod('key') | ||
.withSupportedVersions([SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1]) | ||
.withClientMetadata({ | ||
idTokenSigningAlgValuesSupported: [SigningAlgo.EDDSA], | ||
passBy: PassBy.VALUE, | ||
requestObjectSigningAlgValuesSupported: [SigningAlgo.EDDSA, SigningAlgo.ES256], | ||
responseTypesSupported: [ResponseType.ID_TOKEN], | ||
vpFormatsSupported: { jwt_vc: { alg: [SigningAlgo.EDDSA] } }, | ||
scopesSupported: [Scope.OPENID_DIDAUTHN, Scope.OPENID], | ||
subjectTypesSupported: [SubjectType.PAIRWISE], | ||
subject_syntax_types_supported: ['did:ethr:', 'did:key:', 'did'], | ||
}) | ||
.withPresentationDefinition({ | ||
definition: { | ||
id: '1234-1234-1234-1234', | ||
input_descriptors: [ | ||
{ | ||
id: 'ExampleInputDescriptor', | ||
schema: [ | ||
{ | ||
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}) | ||
.build(); | ||
|
||
describe('Creating an AuthRequest with an RP from builder', () => { | ||
it('should have a client_id that is a string when not explicitly provided', async () => { | ||
// see: https://github.com/Sphereon-Opensource/SIOP-OID4VP/issues/54 | ||
// When not supplying a clientId to the builder, the request object creates an object of the clientId | ||
const authRequest = await rp.createAuthorizationRequest({ | ||
correlationId: '1', | ||
nonce: 'qBrR7mqnY3Qr49dAZycPF8FzgE83m6H0c2l0bzP4xSg', | ||
state: 'b32f0087fc9816eb813fd11f', | ||
}); | ||
|
||
const requestObjectPayload = await authRequest.requestObject.getPayload(); | ||
await expect(requestObjectPayload.client_id).toEqual(DID); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters