Skip to content

fetchAuthorizationFromChain

fetchAuthorizationFromChain(authorizationUri): Promise<ISpaceAuthorization | null>

Fetches authorization details from the CORD chain based on a given authorization ID.

Parameters

authorizationUri: auth:cord:${string}

The unique identifier (URI) of the authorization to be fetched.

Returns

Promise<ISpaceAuthorization | null>

A promise that resolves to the authorization details if found. These details are represented as an ISpaceAuthorization object, which includes information such as the space ID, delegate DID, permissions, authorization ID, and delegator DID. The function returns null if the authorization details are not found or cannot be decoded.

Remarks

This function queries the CORD blockchain to retrieve details about a specific authorization, using the provided authorization URI. It is designed to fetch and decode the authorization details stored on the blockchain. If the authorization details are not found or cannot be decoded, the function throws an error.

Throws

  • Thrown when no authorization is found with the provided ID.

Throws

  • Thrown when an error occurs during the fetching process, such as issues with network connectivity or problems querying the blockchain.

Example

const authorizationUri = 'auth:cord:example_id';
fetchAuthorizationFromChain(authorizationUri)
.then(authorizationDetails => {
console.log('Authorization Details:', authorizationDetails);
})
.catch(error => {
if (error instanceof SDKErrors.AuthorizationMissingError) {
console.error('Authorization not found:', authorizationUri);
} else {
console.error('Error fetching authorization:', error);
}
});

Source

chain-space/src/ChainSpace.chain.ts:757