-
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 /acs/credentials/read_card (#1109)
- Loading branch information
Showing
4 changed files
with
1,317 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { z } from 'zod' | ||
|
||
import { | ||
common_failed_action_attempt, | ||
common_pending_action_attempt, | ||
common_succeeded_action_attempt, | ||
} from './common.js' | ||
|
||
const action_type = z.literal('READ_CARD') | ||
|
||
const error = z.object({ | ||
type: z.string(), // TODO This should be typed properly with the possible errors | ||
message: z.string(), | ||
}) | ||
|
||
const result = z.object({ | ||
acs_credential_id: z | ||
.string() | ||
.uuid() | ||
.nullable() | ||
.describe('Matching acs_credential currently encoded on this card.'), | ||
card_number: z | ||
.string() | ||
.nullable() | ||
.describe('A number or sting that physically identifies this card.'), | ||
// TODO visionline_metadata: visionline_credential_metadata, | ||
}) | ||
|
||
export const read_card_action_attempt = z.discriminatedUnion('status', [ | ||
common_pending_action_attempt | ||
.extend({ | ||
action_type, | ||
}) | ||
.describe('Reading card data from physical encoder.'), | ||
common_succeeded_action_attempt | ||
.extend({ | ||
action_type, | ||
result, | ||
}) | ||
.describe('Reading card data from physical encoder succeeded.'), | ||
common_failed_action_attempt | ||
.extend({ action_type, error }) | ||
.describe('Reading card data from physical encoder failed.'), | ||
]) | ||
|
||
export type ReadCardActionAttempt = z.infer<typeof read_card_action_attempt> |
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
Oops, something went wrong.