Skip to content

fetchAuthorizationFromChain

fetchAuthorizationFromChain(authorizationUri): Promise<ISpaceAuthorizationAccountType | null>

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

authorizationUri: `auth:cord:${string}`

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

Promise<ISpaceAuthorizationAccountType | 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.

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.

  • Thrown when no authorization is found with the provided ID.
  • Thrown when an error occurs during the fetching process, such as issues with network connectivity or problems querying the blockchain.
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);
}
});

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