Skip to content

Commit

Permalink
fix: allow user to issue eip712 credentials from regular (non-schema)…
Browse files Browse the repository at this point in the history
… widget (#107)

* fix: allow user to issue eip712 credentials from regular (non-schema) widget

* fix: fix node version
  • Loading branch information
nickreynolds authored Oct 24, 2022
1 parent 7ea4772 commit b579c26
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"access": "public"
},
"engines": {
"node": "16.x"
"node": "> 16.0"
},
"license": "Apache-2.0",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/components/standard/IssueCredentialFromSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
placeholder="Proof type"
defaultActiveFirstOption={true}
>
<Option key={'jwt'} value="jwt">
<Option key="jwt" value="jwt">
jwt
</Option>
<Option key="lds" value="lds">
Expand Down
10 changes: 8 additions & 2 deletions src/components/widgets/IssueCredential.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,21 @@ const IssueCredential: React.FC<IssueCredentialProps> = ({
<Select
style={{ width: '60%' }}
onChange={(e) => setProofFormat(e as string)}
placeholder="jwt or lds"
placeholder="Proof type"
defaultActiveFirstOption={true}
>
<Option key={'jwt'} value="jwt">
<Option key="jwt" value="jwt">
jwt
</Option>
<Option key="lds" value="lds">
lds
</Option>
<Option
key="EthereumEip712Signature2021lds"
value="EthereumEip712Signature2021"
>
EthereumEip712Signature2021
</Option>
</Select>
</Form.Item>

Expand Down
19 changes: 14 additions & 5 deletions src/utils/signing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const issueCredential = async (
type?: string,
credentialSchemaId?: string,
) => {
return await agent?.createVerifiableCredential({
let credentialObj: any = {
credential: {
issuer: { id: iss },
issuanceDate: new Date().toISOString(),
Expand All @@ -26,13 +26,22 @@ const issueCredential = async (
: ['https://www.w3.org/2018/credentials/v1'],
type: type ? ['VerifiableCredential', type] : ['VerifiableCredential'],
credentialSubject: { id: sub, ...claimToObject(claims) },
credentialSchema: credentialSchemaId
? { id: credentialSchemaId, type: 'JsonSchemaValidator2018' }
: undefined,
},
proofFormat,
save: true,
})
}

// adding undefined field was breaking EIP-712 Issuance, so just don't add field at all if undefined
if (credentialSchemaId) {
credentialObj = {
...credentialObj,
credentialSchema: {
id: credentialSchemaId,
type: 'JsonSchemaValidator2018',
},
}
}
return await agent?.createVerifiableCredential(credentialObj)
}

const signVerifiablePresentation = async (
Expand Down

0 comments on commit b579c26

Please sign in to comment.