Skip to content

Commit

Permalink
feat: did etr
Browse files Browse the repository at this point in the history
  • Loading branch information
osslgtm committed Dec 1, 2023
1 parent 1279340 commit d217a15
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/4.0/tt/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@
},
"credentialStatusType": {
"type": "string",
"enum": ["REVOCATION_STORE", "OCSP_RESPONDER"]
"enum": ["REVOCATION_STORE", "OCSP_RESPONDER", "TOKEN_REGISTRY"]
},
"location": {
"type": "string",
"format": "uri",
"examples": ["https://ocsp-responder.example.com"]
"examples": ["https://ocsp-responder.example.com", "0x0000000000000000000000000000000000000000"]
}
},
"required": ["credentialStatusType", "location"],
Expand Down
9 changes: 5 additions & 4 deletions src/shared/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export function getIssuerAddress(document: any): any {
return document.openAttestationMetadata.proof.value;
}
// TODO: OA v4 proof schema not updated to support document store issuance yet
// else if (isWrappedV4Document(document)) {
// return document.proof.?
// }
else if (isWrappedTTV4Document(document)) {
return document.credentialStatus.location;
}
throw new Error(
"Unsupported document type: Only can retrieve issuer address from wrapped OpenAttestation v2 & v3 documents."
);
Expand Down Expand Up @@ -166,7 +166,8 @@ export const getDocumentData = (document: WrappedDocument<OpenAttestationDocumen
export const isTransferableAsset = (document: any): boolean => {
return (
!!getData(document)?.issuers[0]?.tokenRegistry ||
document?.openAttestationMetadata?.proof?.method === "TOKEN_REGISTRY"
document?.openAttestationMetadata?.proof?.method === "TOKEN_REGISTRY" ||
document?.credentialStatus?.credentialStatusType === "TOKEN_REGISTRY"
);
};

Expand Down
113 changes: 113 additions & 0 deletions test/fixtures/v4/etr/etr-did-idvc-raw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://schemata.tradetrust.io/io/tradetrust/4.0/alpha-schema.json"
],
"type": ["VerifiableCredential", "TradeTrustCredential"],
"validFrom": "2021-03-08T12:00:00+08:00",
"network": { "chain": "MATIC", "chainId": "80001" },
"issuer": {
"id": "did:ethr:0xE94E4f16ad40ADc90C29Dc85b42F1213E034947C",
"type": "TradeTrustIssuer",
"name": "My Own Company Pte Ltd",
"identityProof": {
"identityProofType": "IDVC",
"identifier": "My Own Company Pte Ltd",
"identityVC": {
"type": "TradeTrustIdentityVC",
"data": {
"@context": [
"https://w3id.org/security/bbs/v1",
"https://www.w3.org/2018/credentials/v1",
"https://stg.issuer.myinfo.gov.sg/myinfobusiness/schema/corporatebasicdetails/v1",
"https://w3id.org/vc/status-list/2021/v1"
],
"id": "https://sbl.alwaysdata.net/oa/credentials/123456789",
"type": ["VerifiableCredential"],
"issuer": "did:web:sbl.alwaysdata.net:oa",
"credentialSubject": {
"uen": "198801234E",
"companyname": "My Own Company Pte Ltd",
"type": ["CorporateBasicDetails"],
"id": "did:ethr:0xE94E4f16ad40ADc90C29Dc85b42F1213E034947C"
},
"expirationDate": "2023-11-01T06:45:43Z",
"credentialStatus": {
"id": "https://sbl.alwaysdata.net/oa/status/1#325",
"type": "StatusList2021Entry",
"statusListIndex": 325,
"statusListCredential": "https://sbl.alwaysdata.net/oa/status/1/325"
},
"issuanceDate": "2023-22-13T01:35:08Z",
"proof": {
"type": "BbsBlsSignature2020",
"created": "2023-10-18T07:14:46Z",
"proofPurpose": "assertionMethod",
"proofValue": "tqvUVZOPaY/A+7Wu47HZIYbboPU/MPGhb1EPLUKKPRwmRe8QJ/dzjRviQ5fAbR88TjSalqLbaBeopNocjrl7TmzCOlLQxGeNC4El1TCICu5tiX0HxGSNAPY4t5CglTLMTsdu5kg4f0a5MGQTnFgwyw==",
"verificationMethod": "did:web:sbl.alwaysdata.net:oa#didkey"
}
}
}
}
},
"credentialStatus": {
"type": "TradeTrustCredentialStatus",
"credentialStatusType": "TOKEN_REGISTRY",
"location": "0xE0a94770B8e969B5D9179d6dA8730B01e19279e2"
},
"renderMethod": {
"type": "TradeTrustRenderMethod",
"renderMethodType": "EMBEDDED_RENDERER",
"name": "INVOICE",
"url": "https://generic-templates.tradetrust.io"
},
"credentialSubject": {
"name": "TradeTrust Invoice",
"id": "urn:uuid:a013fb9d-bb03-4056-b696-05575eceaf42",
"date": "2018-02-21",
"customerId": "564",
"terms": "Due Upon Receipt",
"billFrom": {
"name": "ABC Company",
"streetAddress": "Level 1, Industry Offices",
"city": "Singapore",
"postalCode": "123456",
"phoneNumber": "60305029"
},
"billTo": {
"company": {
"name": "DEF Company",
"streetAddress": "Level 2, Industry Offices",
"city": "Singapore",
"postalCode": "612345",
"phoneNumber": "61204028"
},
"name": "James Lee",
"email": "def@company.com"
},
"billableItems": [
{
"description": "Service Fee",
"quantity": "1",
"unitPrice": "200",
"amount": "200"
},
{
"description": "Labor: 5 hours at $75/hr",
"quantity": "5",
"unitPrice": "75",
"amount": "375"
},
{
"description": "New client discount",
"quantity": "1",
"unitPrice": "50",
"amount": "50"
}
],
"subtotal": "625",
"tax": "0",
"taxTotal": "0",
"total": "625"
}
}

0 comments on commit d217a15

Please sign in to comment.