-
-
Save sublimator/0520f70fa7dab9d7d373759fdd60aa3e to your computer and use it in GitHub Desktop.
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
export interface MonetizationAmount { | |
value: string | |
assetScale: number | |
assetCode: string | |
} | |
export interface SPSPResponse { | |
destinationAccount: string | |
sharedSecret: string | |
receiptsEnabled: boolean | |
} | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
type Callback = (...args: any[]) => void | |
interface WebExtEvt<C extends Callback = Callback> { | |
addListener(listener: C): void | |
removeListener(listener: C): void | |
hasListener(listener: C): boolean | |
} | |
export interface ExtensionMonetization { | |
onStart: WebExtEvt<(sessionId: string, spspResponse: SPSPResponse) => void> | |
onStop: WebExtEvt<(sessionId: string) => void> | |
onPause: WebExtEvt<(sessionId: string) => void> | |
onResume: WebExtEvt<(sessionId: string) => void> | |
/** | |
* - Returns a Promise of a new sessionId | |
* - may be rejected | |
* - Causes an onStop with old sessionId, then onStart with new one | |
* This should all happen AFTER the return promise resolve handlers have | |
* run ? | |
*/ | |
refresh(/*SPSP*/ sessionId: string): Promise<string> | |
completePayment( | |
sessionId: string, | |
amount: MonetizationAmount, | |
receipt?: string | |
): void | |
} | |
export interface PageMonetization extends EventTarget { | |
onprogress: EventHandlerNonNull | |
} | |
declare global { | |
interface Navigator { | |
monetization: PageMonetization | |
} | |
// eslint-disable-next-line @typescript-eslint/no-namespace,@typescript-eslint/no-unused-vars | |
namespace browser { | |
const monetization: ExtensionMonetization | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment