-
Notifications
You must be signed in to change notification settings - Fork 146
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
1 parent
b47fe6b
commit 59683e7
Showing
21 changed files
with
2,489 additions
and
192 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 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
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
44 changes: 44 additions & 0 deletions
44
src/app/pages/transaction-request/hooks/use-transaction-validator.ts
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,44 @@ | ||
import { useIsDomainPreApproved } from '@app/store/apps/apps.actions'; | ||
import { | ||
useTransactionRequestOrigin, | ||
useTransactionRequestValidation, | ||
} from '@app/store/transactions/requests.hooks'; | ||
|
||
interface SuccesfullTransactionValidationResult { | ||
isValid: true; | ||
validatedBy: 'jwt-payload' | 'preapproved-domain'; | ||
} | ||
|
||
interface FailedTransactionValidationResult { | ||
isValid: false; | ||
} | ||
|
||
type TransactionValidationResult = | ||
| SuccesfullTransactionValidationResult | ||
| FailedTransactionValidationResult; | ||
|
||
const invalidTxResult: FailedTransactionValidationResult = Object.seal({ | ||
isValid: false, | ||
}); | ||
|
||
const validatedBySignedJwtPayload: SuccesfullTransactionValidationResult = Object.seal({ | ||
isValid: true, | ||
validatedBy: 'jwt-payload', | ||
}); | ||
|
||
const validatedByPreapprovedDomain: SuccesfullTransactionValidationResult = Object.seal({ | ||
isValid: true, | ||
validatedBy: 'preapproved-domain', | ||
}); | ||
|
||
export function useTransactionValidator(): TransactionValidationResult { | ||
const isValidTransaction = useTransactionRequestValidation(); | ||
const origin = useTransactionRequestOrigin(); | ||
const isDomainApproved = useIsDomainPreApproved(); | ||
|
||
if (isValidTransaction) return validatedBySignedJwtPayload; | ||
|
||
if (isDomainApproved(origin || '')) return validatedByPreapprovedDomain; | ||
|
||
return invalidTxResult; | ||
} |
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
Empty file.
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.