Issuing the credential
To issue a credential use the dynamic QR code functionality and the third party attribute extension:
x
const expiryDate = new Date();
expiryDate.setDate(expiryDate.getDate() + 1);
const thirdPartyAttributeExtension = new ThirdPartyAttributeExtensionBuilder()
.withDefinition('com.example.someAttribute')
.withExpiryDate(expiryDate)
.build();
const dynamicPolicy = (new DynamicPolicyBuilder())
.withWantedRememberMe(true)
.build();
const dynamicScenario = (new DynamicScenarioBuilder())
.withCallbackEndpoint('/issue-attribute')
.withPolicy(dynamicPolicy)
.withExtension(thirdPartyAttributeExtension)
.build();
const shareUrlResult = await yotiClient.createShareUrl(dynamicScenario);
Parameter | Description |
---|---|
withDefinition() | This value will be your credential name “com.example.someAttribute” |
withExpiryDate() | The expired date indicates by when the credential should be issued by. If the credential is not issued by that time, the issuance request will be automatically cancelled. It conforms to RFC3339 (e.g.: 2006-01-02T22:04:05.123Z) |
Dynamic policy | This is where you define all your Attributes explained you wish to retrieve from the user. You may set source constraints to ensure only an individual can only share data from a particular document. The soft preference set to 'false' will ensure this is enforced. Please head over to the Create button dynamic QR code section for more details on this. |
Dynamic scenario | Build the scenario with the third-party extension request and share policy request. |
Get credential issuance details
The credential issuance details will include an issuance token.
Note..
This should be stored as part of the customer record as this will be required for issuing the credential and revoking / updating the credential in the future.
const activityDetails = await yotiClient.getActivityDetails(token);
const attributeIssuanceDetails = activityDetails.getExtraData().getAttributeIssuanceDetails();
const issuingAttributes = attributeIssuanceDetails.getIssuingAttributes();
Request for credential to be issued
The credential value is now ready to be issued to the Yoti user which is the schema of the credential. You will need to provide the issuance token, the name and the payload below.
const payload = new Payload({
issuance_token: attributeIssuanceDetails.getToken(),
attributes: [
{
name: 'com.example.someAttribute',
value: 'some attribute value',
},
],
});
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/api/v1/attribute-registry')
.withEndpoint('/attributes')
.withPemString('PEM_CONTENT')
.withHeader('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
.withMethod('POST')
.withPayload(payload)
.build();
const response = await request.execute();
// Note:
// - Use RequestBuilder::withPemFilePath() to provide a file path
// (This may have performance implications)
The user will now have the credential.
Was this page helpful?