-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support encrypted and signed in CheckoutSettingsProvider
- Loading branch information
1 parent
32aefe2
commit d3fe27f
Showing
3 changed files
with
66 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
import React from "react"; | ||
import { CheckoutSettings } from "./CheckoutSettings"; | ||
import { hasOwnPropertyOfType } from "./hasOwnProperty"; | ||
|
||
export const CheckoutSettingsContext = React.createContext<CheckoutSettings | undefined>(undefined); // the global contextual CheckoutSettings. See CheckoutSettingsProvider. WARNING this context must only be provided by CheckoutSettingsProvider and used by useCheckoutSettings, and not directly consumed by anything else | ||
// CheckoutSettingsRequiresPassword represents the global contextual | ||
// CheckoutSettings requiring a password to proceed. The client should | ||
// use setPassword to provide the password, upon which the checkout | ||
// settings will be decrypted and provided normally. | ||
export type CheckoutSettingsRequiresPassword = { | ||
requirementType: | ||
'needToDecrypt' // the global contextual CheckoutSettings is encrypted and needs a decryption password | ||
| 'needToVerifySignature'; // the global contextual CheckoutSettings is decrypted but needs a signature verification password | ||
setPassword: (password: string) => void; | ||
} | ||
|
||
export function isCheckoutSettingsRequiresPassword(c: CheckoutSettings | CheckoutSettingsRequiresPassword): c is CheckoutSettingsRequiresPassword { | ||
return hasOwnPropertyOfType(c, 'requirementType', 'string'); | ||
} | ||
|
||
export const CheckoutSettingsContext = React.createContext<CheckoutSettings | CheckoutSettingsRequiresPassword | undefined>(undefined); // the global contextual CheckoutSettings. See CheckoutSettingsProvider. WARNING this context must only be provided by CheckoutSettingsProvider and used by useCheckoutSettings, and not directly consumed by anything else |
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