Skip to content

verifyAgainstProperties

verifyAgainstProperties(stmtUri, digest, creator?, spaceuri?, schemaUri?): Promise<object>

Verifies a statement’s properties against provided parameters.

stmtUri: `stmt:cord:${string}`

The URI of the statement to be verified.

digest: HexString

The hexadecimal string representing the digest of the statement.

creator?: string

(Optional) The account address of the statement’s creator for verification.

spaceuri?: `space:cord:${string}`

(Optional) The URI of the ChainSpace associated with the statement for verification.

schemaUri?: `schema:cord:${string}`

(Optional) The URI of the schema linked to the statement for verification.

Promise<object>

A promise that resolves to an object with isValid flag and message. The isValid flag indicates whether the verification was successful, and the message provides details or error information.

isValid: boolean

message: string

This asynchronous function checks if the provided statement URI, digest, and other optional properties match the corresponding entry in the blockchain. It’s used to validate the integrity and accuracy of statement entries.

const stmtUri = 'stmt:cord:example_uri';
const digest = '0x123...';
const creatorUri = 'did:cord:creator_uri';
const spaceUri = 'space:cord:example_uri';
const schemaUri = 'schema:cord:schema_uri';
verifyAgainstProperties(stmtUri, digest, creatorUri, spaceUri, schemaUri)
.then(result => {
console.log('Verification result:', result);
})
.catch(error => {
console.error('Error in verification:', error);
});

Various errors if there’s a problem fetching the statement status from the blockchain or if an unexpected error occurs.

The function begins by fetching the statement status from the blockchain using the provided stmtUri. It then compares the digest, creator, spaceuri, and schemaUri with the fetched statement details. If any of these properties do not match or if the statement is revoked, the function returns an object indicating the verification failure with an appropriate message. If all properties match and the statement is not revoked, it returns an object indicating successful verification.

statement/src/Statement.ts:248