## Update Martin:
# Actual credential Obejct from:
`normalizeCredential(${data}.signature)` in `signJWT(...)`
```
{
"credentialSubject": {
"type": "SocialMediaPosting",
"author": {
"id": "did:ethr:0xf89b67B4FebbB1a6237232bd54611ED0fd17A1bd",
"image": "https://www.gravatar.com/avatar/4ad4a6c0979055233c763a1d5453e83e?s=200&d=retro",
"name": "did:ethr:0xf89b67B4FebbB1a6237232bd54611ED0fd17A1bd"
},
"headline": "",
"articleBody": "1234",
"id": "http://localhost:3332/posts/SdlC4EAGN"
},
"issuer": {
"id": "did:ethr:0xf89b67B4FebbB1a6237232bd54611ED0fd17A1bd"
},
"id": "http://localhost:3332/posts/SdlC4EAGN",
"type": [
"VerifiableCredential",
"VerifiableSocialPosting"
],
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3id.org/veramolabs/socialmedia/context/v1"
],
"issuanceDate": "2021-03-15T18:18:21.000Z",
"proof": {
"type": "JwtProof2020",
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJ2YyI6eyJjcmVkZW50aWFsU3ViamVjdCI6eyJ0eXBlIjoiU29jaWFsTWVkaWFQb3N0aW5nIiwiYXV0aG9yIjp7ImlkIjoiZGlkOmV0aHI6MHhmODliNjdCNEZlYmJCMWE2MjM3MjMyYmQ1NDYxMUVEMGZkMTdBMWJkIiwiaW1hZ2UiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzRhZDRhNmMwOTc5MDU1MjMzYzc2M2ExZDU0NTNlODNlP3M9MjAwJmQ9cmV0cm8iLCJuYW1lIjoiZGlkOmV0aHI6MHhmODliNjdCNEZlYmJCMWE2MjM3MjMyYmQ1NDYxMUVEMGZkMTdBMWJkIn0sImhlYWRsaW5lIjoiIiwiYXJ0aWNsZUJvZHkiOiIxMjM0In0sIkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly93d3cudzNpZC5vcmcvdmVyYW1vbGFicy9zb2NpYWxtZWRpYS9jb250ZXh0L3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJWZXJpZmlhYmxlU29jaWFsUG9zdGluZyJdfSwic3ViIjoiaHR0cDovL2xvY2FsaG9zdDozMzMyL3Bvc3RzL1NkbEM0RUFHTiIsImp0aSI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzMzMi9wb3N0cy9TZGxDNEVBR04iLCJuYmYiOjE2MTU4MzIzMDEsImlzcyI6ImRpZDpldGhyOjB4Zjg5YjY3QjRGZWJiQjFhNjIzNzIzMmJkNTQ2MTFFRDBmZDE3QTFiZCJ9.signature"
}
}
```
Differences:
- `proof` property is added by `normalizeCredential` from dummy `signature`
- `issuer.id` vs `issuer`
- Some fields from example missing (thumbnail e.g.)
````
const credential = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3id.org/veramolabs/socialmedia/context/v1"
],
"type": [
"VerifiableCredential",
"VerifableSocialMediaPosting"
],
"id": "https://example.org/post/1234",
"issuer": "did:example:aadsfewfweasdfsfad",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
// might contain reply tweet URL
"id": "https://example.org/post/1234",
"type": "SocialMediaPosting",
"author": {
"id": "did:nft:ebfeb1f712ebc6f1c276e12ec21",
"type": "Person",
"thumbnail": "https://google.com",
"image": "https://google.com",
"name": "cryptopunk"
},
"headline": "punks are aliens",
"articleBody": "waffles for zoomers"
},
"credentialSchema": {
"id": "https://www.w3id.org/veramolabs/socialmedia/context/v1/eip712.json",
"type": "Eip712SchemaValidator2021"
}
};
// TODO: normalize one should get eip712 schema from credentialSchema URI
const eip712Schema = {
VerifiableCredential: [
{ name: '@context', type: 'string[]' },
{ name: 'type', type: 'string[]' },
{ name: 'id', type: 'string' },
{ name: 'issuer', type: 'string' },
{ name: 'issuanceDate', type: 'string' },
{ name: 'credentialSubject', type: 'CredentialSubject' },
{ name: 'credentialSchema', type: 'CredentialSchema' }
],
CredentialSchema: [
{ name: 'id', type: 'string' },
{ name: 'type', type: 'string' },
],
CredentialSubject: [
{ name: 'type', type: 'string' },
{ name: 'id', type: 'string' },
{ name: 'headline', type: 'string' },
{ name: 'articleBody', type: 'string' },
{ name: 'author', type: 'Person' }
],
Person: [
{ name: 'type', type: 'string' },
{ name: 'id', type: 'string' },
{ name: 'thumbnail', type: 'string' },
{ name: 'image', type: 'string' },
{ name: 'name', type: 'string' }
]
};
// TODO: normalize credential using JCS
const data = JSON.stringify({
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'salt', type: 'bytes32' },
],
... eip712Schema
},
domain: {
name: 'Sign Tweet',
version: '2',
chainId: 4,
salt: '0xf2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a558',
},
primaryType: 'VerifiableCredential',
message: {
... credential
}
});
const signer = walletAddress;
const params = [signer, data];
web3.currentProvider.sendAsync(
{
method: 'eth_signTypedData_v4',
params,
from: signer,
jsonrpc: '2.0',
id: new Date().getTime(),
},
(error, response) => {
if (error) {
return setErrorMsg(error.message);
} else if (response && response.error) {
const errMsg = response.error.message.substring(0, 70).concat('...');
return setErrorMsg(errMsg);
} else {
const result = response && response.result;
const signature = result && result.substring(2);
const r = signature && '0x' + signature.substring(0, 64);
const s = signature && '0x' + signature.substring(64, 128);
const v = signature && parseInt(signature.substring(128, 130), 16);
const signatures = {
signature,
r,
s,
v,
};
setSuccessMsg(`Successfully signed data!! ${signature}`);
setData({ signatures, ...JSON.parse(data) });
}
}
);
};
```