@getpara/core-sdk 2.0.0-alpha.34 → 2.0.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1785,9 +1785,6 @@ const _ParaCore = class _ParaCore {
1785
1785
  return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1786
1786
  });
1787
1787
  }
1788
- getOAuthUrlSync(opts) {
1789
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1790
- }
1791
1788
  /**
1792
1789
  * Awaits the response from a user's attempt to log in with OAuth.
1793
1790
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1805,6 +1802,7 @@ const _ParaCore = class _ParaCore {
1805
1802
  onCancel,
1806
1803
  onPoll,
1807
1804
  onOAuthUrl,
1805
+ onOAuthPopup,
1808
1806
  isLinkAccount
1809
1807
  } = _j, urlOptions = __objRest(_j, [
1810
1808
  "method",
@@ -1813,10 +1811,19 @@ const _ParaCore = class _ParaCore {
1813
1811
  "onCancel",
1814
1812
  "onPoll",
1815
1813
  "onOAuthUrl",
1814
+ "onOAuthPopup",
1816
1815
  "isLinkAccount"
1817
1816
  ]);
1817
+ let popupWindow;
1818
+ if (onOAuthPopup) {
1819
+ try {
1820
+ popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.OAUTH });
1821
+ } catch (error) {
1822
+ throw new Error(`Failed to open OAuth popup: ${error}`);
1823
+ }
1824
+ }
1818
1825
  let sessionLookupId, accountLinkInProgress;
1819
- if (onOAuthUrl) {
1826
+ if (onOAuthUrl || onOAuthPopup) {
1820
1827
  if (isLinkAccount) {
1821
1828
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1822
1829
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
@@ -1824,7 +1831,17 @@ const _ParaCore = class _ParaCore {
1824
1831
  sessionLookupId = yield this.prepareLogin();
1825
1832
  }
1826
1833
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1827
- onOAuthUrl(oAuthUrl);
1834
+ switch (true) {
1835
+ case !!onOAuthUrl: {
1836
+ onOAuthUrl(oAuthUrl);
1837
+ break;
1838
+ }
1839
+ case (!!onOAuthPopup && !!popupWindow): {
1840
+ popupWindow.location.href = oAuthUrl;
1841
+ onOAuthPopup(popupWindow);
1842
+ break;
1843
+ }
1844
+ }
1828
1845
  } else {
1829
1846
  ({ sessionLookupId } = yield this.touchSession());
1830
1847
  }
@@ -40,7 +40,7 @@ __export(constants_exports, {
40
40
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
41
41
  });
42
42
  module.exports = __toCommonJS(constants_exports);
43
- const PARA_CORE_VERSION = "2.0.0-alpha.34";
43
+ const PARA_CORE_VERSION = "2.0.0-alpha.35";
44
44
  const PREFIX = "@CAPSULE/";
45
45
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
46
46
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -1750,9 +1750,6 @@ const _ParaCore = class _ParaCore {
1750
1750
  return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1751
1751
  });
1752
1752
  }
1753
- getOAuthUrlSync(opts) {
1754
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1755
- }
1756
1753
  /**
1757
1754
  * Awaits the response from a user's attempt to log in with OAuth.
1758
1755
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1770,6 +1767,7 @@ const _ParaCore = class _ParaCore {
1770
1767
  onCancel,
1771
1768
  onPoll,
1772
1769
  onOAuthUrl,
1770
+ onOAuthPopup,
1773
1771
  isLinkAccount
1774
1772
  } = _j, urlOptions = __objRest(_j, [
1775
1773
  "method",
@@ -1778,10 +1776,19 @@ const _ParaCore = class _ParaCore {
1778
1776
  "onCancel",
1779
1777
  "onPoll",
1780
1778
  "onOAuthUrl",
1779
+ "onOAuthPopup",
1781
1780
  "isLinkAccount"
1782
1781
  ]);
1782
+ let popupWindow;
1783
+ if (onOAuthPopup) {
1784
+ try {
1785
+ popupWindow = yield this.platformUtils.openPopup("about:blank", { type: PopupType.OAUTH });
1786
+ } catch (error) {
1787
+ throw new Error(`Failed to open OAuth popup: ${error}`);
1788
+ }
1789
+ }
1783
1790
  let sessionLookupId, accountLinkInProgress;
1784
- if (onOAuthUrl) {
1791
+ if (onOAuthUrl || onOAuthPopup) {
1785
1792
  if (isLinkAccount) {
1786
1793
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1787
1794
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
@@ -1789,7 +1796,17 @@ const _ParaCore = class _ParaCore {
1789
1796
  sessionLookupId = yield this.prepareLogin();
1790
1797
  }
1791
1798
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1792
- onOAuthUrl(oAuthUrl);
1799
+ switch (true) {
1800
+ case !!onOAuthUrl: {
1801
+ onOAuthUrl(oAuthUrl);
1802
+ break;
1803
+ }
1804
+ case (!!onOAuthPopup && !!popupWindow): {
1805
+ popupWindow.location.href = oAuthUrl;
1806
+ onOAuthPopup(popupWindow);
1807
+ break;
1808
+ }
1809
+ }
1793
1810
  } else {
1794
1811
  ({ sessionLookupId } = yield this.touchSession());
1795
1812
  }
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.34";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.35";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
5
5
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -435,9 +435,6 @@ export declare abstract class ParaCore implements CoreInterface {
435
435
  verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
436
436
  protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
437
437
  getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
438
- getOAuthUrlSync(opts: Omit<CoreMethodParams<'getOAuthUrl'>, 'sessionLookupId'> & {
439
- sessionLookupId: string;
440
- }): Awaited<CoreMethodResponse<'getOAuthUrl'>>;
441
438
  protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
442
439
  isLinkAccount: true;
443
440
  }): InternalMethodResponse<'verifyOAuthLink'>;
@@ -110,8 +110,17 @@ export type OAuthParams = OAuthUrlParams & PollParams & {
110
110
  /**
111
111
  * A callback function that will be invoked with the OAuth URL when it is available.
112
112
  * For example, you can use this to open the URL in a new window or tab.
113
+ *
114
+ * You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
113
115
  */
114
116
  onOAuthUrl?: (url: string) => void;
117
+ /**
118
+ * A callback function that will be invoked with the OAuth popup window when it is available.
119
+ * If supplied, a window will automatically be opened for you if running on an applicable platform.
120
+ *
121
+ * You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
122
+ */
123
+ onOAuthPopup?: (popup: Window) => void;
115
124
  };
116
125
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
117
126
  export type AuthStateVerify = ServerAuthStateVerify;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.34",
3
+ "version": "2.0.0-alpha.35",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "2.0.0-alpha.34",
8
+ "@getpara/user-management-client": "2.0.0-alpha.35",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "base64url": "^3.0.1",
11
11
  "libphonenumber-js": "^1.11.7",
@@ -27,7 +27,7 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
- "gitHead": "cff5cb1fa7284a850e688b20a6596d435315a475",
30
+ "gitHead": "abfec8cf9931f7a8469b09b67b5d48eee6f4cfd5",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {