-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
45 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface AnonCredsResourceResolutionResult { | ||
resource: Record<string, unknown> | null | ||
resourceMetadata: Record<string, unknown> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { TypedArrayEncoder, Hasher } from '@aries-framework/core' | ||
import canonicalize from 'canonicalize' | ||
|
||
export function calculateObjectId(objectValue: unknown) { | ||
const objectString = canonicalize(objectValue) | ||
export function calculateResourceId(resourceObjectValue: unknown) { | ||
const objectString = canonicalize(resourceObjectValue) | ||
|
||
if (!objectString) { | ||
throw new Error('Cannot canonicalize object') | ||
throw new Error('Cannot canonicalize resource object') | ||
} | ||
|
||
return TypedArrayEncoder.toBase58(Hasher.hash(TypedArrayEncoder.fromString(objectString), 'sha2-256')) | ||
} | ||
|
||
export function verifyObjectId(objectValue: unknown, objectId: string) { | ||
return calculateObjectId(objectValue) === objectId | ||
export function verifyResourceId(resourceObjectValue: unknown, resourceId: string) { | ||
return calculateResourceId(resourceObjectValue) === resourceId | ||
} |