Skip to content

verifyAgainstProperties

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

Verifies a statement’s properties against provided parameters.

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?: did:cord:3${string}

(Optional) The DID URI 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.

Returns

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

isValid: boolean

message

message: string

Remarks

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.

Example

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);
});

Throws

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

Description

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.

Source

statement/src/Statement.ts:245