diff --git a/.changeset/wise-boxes-drop.md b/.changeset/wise-boxes-drop.md new file mode 100644 index 0000000..87e6e7c --- /dev/null +++ b/.changeset/wise-boxes-drop.md @@ -0,0 +1,5 @@ +--- +"@joyid/common": minor +--- + +feat(common): support local config for `runPopup` diff --git a/packages/common/src/sdk/popup.ts b/packages/common/src/sdk/popup.ts index 6d9a6a0..935db82 100644 --- a/packages/common/src/sdk/popup.ts +++ b/packages/common/src/sdk/popup.ts @@ -1,6 +1,7 @@ /* eslint-disable prefer-const */ import type { AuthResponseData, + DappConfig, DappRequestType, SignCkbTxResponseData, SignCotaNFTResponseData, @@ -51,7 +52,7 @@ export const openPopup = (url: string = ''): Window | null => { ) } -interface PopupRerurnType { +export interface PopupRerurnType { [DappRequestType.Auth]: AuthResponseData [DappRequestType.SignMessage]: SignMessageResponseData [DappRequestType.SignEvm]: SignEvmTxResponseData @@ -72,7 +73,7 @@ interface PopupRerurnType { } export const runPopup = async ( - config: PopupConfigOptions + config: PopupConfigOptions & Partial ): Promise => new Promise((resolve, reject) => { if (isStandaloneBrowser()) { @@ -100,7 +101,7 @@ export const runPopup = async ( ) popupEventListener = (e: MessageEvent) => { - const { joyidAppURL } = getConfig() + const joyidAppURL = config.joyidAppURL ?? getConfig().joyidAppURL if (joyidAppURL == null) { throw new Error('joyidAppURL is not set in the config') }