-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add presentation callback parameters
- Loading branch information
Showing
6 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Claim } from '@2060.io/service-agent-model' | ||
import fetch from 'node-fetch' | ||
|
||
import { TsLogger } from '../utils/logger' | ||
|
||
export enum PresentationStatus { | ||
OK = 'ok', | ||
REFUSED = 'refused', | ||
NO_COMPATIBLE_CREDENTIALS = 'no-compatible-credentials', | ||
VERIFICATION_ERROR = 'verification-error', | ||
UNSPECIFIED_ERROR = 'unspecified-error', | ||
} | ||
|
||
export const sendPresentationCallbackEvent = async (options: { | ||
callbackUrl: string | ||
status: PresentationStatus | ||
ref?: string | ||
claims?: Claim[] | ||
logger: TsLogger | ||
}) => { | ||
const { callbackUrl, ref, claims, logger } = options | ||
try { | ||
logger.debug(`sending presentation callback event to ${callbackUrl}: ${JSON.stringify(options)}`) | ||
await fetch(callbackUrl, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
ref, | ||
claims, | ||
}), | ||
headers: { 'Content-Type': 'application/json' }, | ||
}) | ||
} catch (error) { | ||
logger.error(`Error sending presentation callback event to ${callbackUrl}`, { | ||
cause: error, | ||
}) | ||
} | ||
} |
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