@getpara/core-sdk 2.0.0-alpha.53 → 2.0.0-alpha.54
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.
- package/dist/cjs/ParaCore.js +213 -60
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/shares/enclave.js +266 -0
- package/dist/cjs/shares/shareDistribution.js +16 -1
- package/dist/cjs/types/assets.js +15 -0
- package/dist/cjs/types/events.js +2 -0
- package/dist/cjs/utils/formatting.js +41 -0
- package/dist/esm/ParaCore.js +214 -61
- package/dist/esm/{chunk-7B52C2XE.js → chunk-W5CT3TVS.js} +2 -0
- package/dist/esm/constants.js +6 -2
- package/dist/esm/cryptography/utils.js +1 -1
- package/dist/esm/errors.js +1 -1
- package/dist/esm/external/mpcComputationClient.js +1 -1
- package/dist/esm/external/userManagementClient.js +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/shares/KeyContainer.js +1 -1
- package/dist/esm/shares/enclave.js +226 -0
- package/dist/esm/shares/recovery.js +1 -1
- package/dist/esm/shares/shareDistribution.js +17 -2
- package/dist/esm/transmission/transmissionUtils.js +1 -1
- package/dist/esm/types/assets.js +0 -0
- package/dist/esm/types/auth.js +1 -1
- package/dist/esm/types/config.js +1 -1
- package/dist/esm/types/coreApi.js +1 -1
- package/dist/esm/types/events.js +3 -1
- package/dist/esm/types/popup.js +1 -1
- package/dist/esm/types/wallet.js +1 -1
- package/dist/esm/utils/autobind.js +1 -1
- package/dist/esm/utils/events.js +1 -1
- package/dist/esm/utils/formatting.js +41 -1
- package/dist/esm/utils/json.js +1 -1
- package/dist/esm/utils/listeners.js +1 -1
- package/dist/esm/utils/onRamps.js +1 -1
- package/dist/esm/utils/phone.js +1 -1
- package/dist/esm/utils/polling.js +1 -1
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm/utils/url.js +1 -1
- package/dist/esm/utils/wallet.js +1 -1
- package/dist/types/ParaCore.d.ts +15 -2
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/shares/enclave.d.ts +81 -0
- package/dist/types/shares/shareDistribution.d.ts +4 -2
- package/dist/types/types/assets.d.ts +14 -0
- package/dist/types/types/config.d.ts +2 -0
- package/dist/types/types/coreApi.d.ts +1 -0
- package/dist/types/types/events.d.ts +7 -2
- package/dist/types/types/methods.d.ts +15 -7
- package/dist/types/utils/formatting.d.ts +10 -1
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -99,7 +99,8 @@ var import_recovery = require("./shares/recovery.js");
|
|
|
99
99
|
var import_utils2 = require("./utils/index.js");
|
|
100
100
|
var import_errors = require("./errors.js");
|
|
101
101
|
var constants = __toESM(require("./constants.js"));
|
|
102
|
-
var
|
|
102
|
+
var import_enclave = require("./shares/enclave.js");
|
|
103
|
+
var _authInfo, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareDoneState_fn, prepareVerificationState_fn, prepareLoginState_fn, prepareSignUpState_fn;
|
|
103
104
|
if (typeof global !== "undefined") {
|
|
104
105
|
global.Buffer = global.Buffer || import_buffer.Buffer;
|
|
105
106
|
} else if (typeof window !== "undefined") {
|
|
@@ -113,10 +114,12 @@ const { pki, jsbn } = import_node_forge.default;
|
|
|
113
114
|
const _ParaCore = class _ParaCore {
|
|
114
115
|
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
115
116
|
__privateAdd(this, _ParaCore_instances);
|
|
117
|
+
this.popupWindow = null;
|
|
116
118
|
__privateAdd(this, _authInfo);
|
|
117
119
|
this.isNativePasskey = false;
|
|
118
120
|
this.isReady = false;
|
|
119
121
|
this.accountLinkInProgress = void 0;
|
|
122
|
+
this.isEnclaveUser = false;
|
|
120
123
|
this.isAwaitingAccountCreation = false;
|
|
121
124
|
this.isAwaitingLogin = false;
|
|
122
125
|
this.isAwaitingFarcaster = false;
|
|
@@ -152,6 +155,12 @@ const _ParaCore = class _ParaCore {
|
|
|
152
155
|
this.retrieveSessionCookie = () => {
|
|
153
156
|
return this.sessionCookie;
|
|
154
157
|
};
|
|
158
|
+
this.retrieveEnclaveJwt = () => {
|
|
159
|
+
return this.enclaveJwt;
|
|
160
|
+
};
|
|
161
|
+
this.retrieveEnclaveRefreshJwt = () => {
|
|
162
|
+
return this.enclaveRefreshJwt;
|
|
163
|
+
};
|
|
155
164
|
/**
|
|
156
165
|
* Remove all local storage and prefixed session storage.
|
|
157
166
|
* @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
|
|
@@ -210,6 +219,7 @@ const _ParaCore = class _ParaCore {
|
|
|
210
219
|
this.updateWalletIdsFromStorage();
|
|
211
220
|
this.updateSessionCookieFromStorage();
|
|
212
221
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
222
|
+
this.updateEnclaveJwtFromStorage();
|
|
213
223
|
};
|
|
214
224
|
this.updateAuthInfoFromStorage = () => {
|
|
215
225
|
var _a;
|
|
@@ -229,6 +239,10 @@ const _ParaCore = class _ParaCore {
|
|
|
229
239
|
}
|
|
230
240
|
__privateSet(this, _authInfo, authInfo);
|
|
231
241
|
};
|
|
242
|
+
this.updateEnclaveJwtFromStorage = () => {
|
|
243
|
+
this.enclaveJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || void 0;
|
|
244
|
+
this.enclaveRefreshJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || void 0;
|
|
245
|
+
};
|
|
232
246
|
this.updateUserIdFromStorage = () => {
|
|
233
247
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
234
248
|
};
|
|
@@ -380,18 +394,41 @@ const _ParaCore = class _ParaCore {
|
|
|
380
394
|
cookie
|
|
381
395
|
);
|
|
382
396
|
};
|
|
397
|
+
this.persistEnclaveJwt = (jwt) => {
|
|
398
|
+
this.enclaveJwt = jwt;
|
|
399
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(
|
|
400
|
+
constants.LOCAL_STORAGE_ENCLAVE_JWT,
|
|
401
|
+
jwt
|
|
402
|
+
);
|
|
403
|
+
};
|
|
404
|
+
this.persistEnclaveRefreshJwt = (refreshJwt) => {
|
|
405
|
+
this.enclaveRefreshJwt = refreshJwt;
|
|
406
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(
|
|
407
|
+
constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
|
|
408
|
+
refreshJwt
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
const client = (0, import_userManagementClient.initClient)({
|
|
412
|
+
env,
|
|
413
|
+
version: _ParaCore.version,
|
|
414
|
+
apiKey,
|
|
415
|
+
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
416
|
+
useFetchAdapter: !!opts.disableWorkers,
|
|
417
|
+
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
418
|
+
persistSessionCookie: this.persistSessionCookie
|
|
419
|
+
});
|
|
420
|
+
const enclaveClient = new import_enclave.EnclaveClient({
|
|
421
|
+
userManagementClient: client,
|
|
422
|
+
retrieveJwt: this.retrieveEnclaveJwt,
|
|
423
|
+
persistJwt: this.persistEnclaveJwt,
|
|
424
|
+
retrieveRefreshJwt: this.retrieveEnclaveRefreshJwt,
|
|
425
|
+
persistRefreshJwt: this.persistEnclaveRefreshJwt
|
|
426
|
+
});
|
|
383
427
|
this.ctx = {
|
|
384
428
|
env,
|
|
385
429
|
apiKey,
|
|
386
|
-
client
|
|
387
|
-
|
|
388
|
-
version: _ParaCore.version,
|
|
389
|
-
apiKey,
|
|
390
|
-
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
391
|
-
useFetchAdapter: !!opts.disableWorkers,
|
|
392
|
-
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
393
|
-
persistSessionCookie: this.persistSessionCookie
|
|
394
|
-
}),
|
|
430
|
+
client,
|
|
431
|
+
enclaveClient,
|
|
395
432
|
disableWorkers: opts.disableWorkers,
|
|
396
433
|
offloadMPCComputationURL: opts.offloadMPCComputationURL,
|
|
397
434
|
useLocalFiles: opts.useLocalFiles,
|
|
@@ -713,23 +750,30 @@ const _ParaCore = class _ParaCore {
|
|
|
713
750
|
constructPortalUrl(_0) {
|
|
714
751
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
715
752
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
716
|
-
const [isCreate, isLogin, isOnRamp] = [
|
|
753
|
+
const [isCreate, isLogin, isOnRamp, isOAuth, isOAuthCallback, isTelegramLogin, isFarcasterLogin] = [
|
|
717
754
|
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
718
|
-
["loginAuth", "loginPassword", "loginPIN"].includes(type),
|
|
719
|
-
type === "onRamp"
|
|
755
|
+
["loginAuth", "loginPassword", "loginPIN", "loginOTP"].includes(type),
|
|
756
|
+
type === "onRamp",
|
|
757
|
+
type === "oAuth",
|
|
758
|
+
type === "oAuthCallback",
|
|
759
|
+
["telegramLogin", "telegramLoginVerify"].includes(type),
|
|
760
|
+
type === "loginFarcaster"
|
|
720
761
|
];
|
|
762
|
+
if (isOAuth && !opts.oAuthMethod) {
|
|
763
|
+
throw new Error("oAuthMethod is required for oAuth portal URLs");
|
|
764
|
+
}
|
|
721
765
|
if (isCreate || isLogin) {
|
|
722
766
|
this.assertIsAuthSet();
|
|
723
767
|
}
|
|
724
768
|
let sessionId = opts.sessionId;
|
|
725
|
-
if ((isLogin || isOnRamp) && !sessionId) {
|
|
769
|
+
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin) && !sessionId) {
|
|
726
770
|
const session = yield this.touchSession(true);
|
|
727
771
|
sessionId = session.sessionId;
|
|
728
772
|
}
|
|
729
773
|
if (!this.loginEncryptionKeyPair) {
|
|
730
774
|
yield this.setLoginEncryptionKeyPair();
|
|
731
775
|
}
|
|
732
|
-
const base = type === "onRamp" ||
|
|
776
|
+
const base = type === "onRamp" || isTelegramLogin ? (0, import_utils2.getPortalBaseURL)(this.ctx, isTelegramLogin) : yield this.getPortalURL();
|
|
733
777
|
let path;
|
|
734
778
|
switch (type) {
|
|
735
779
|
case "createPassword": {
|
|
@@ -764,10 +808,30 @@ const _ParaCore = class _ParaCore {
|
|
|
764
808
|
path = `/web/users/${this.userId}/on-ramp-transaction/v2/${opts.pathId}`;
|
|
765
809
|
break;
|
|
766
810
|
}
|
|
811
|
+
case "telegramLoginVerify": {
|
|
812
|
+
path = `/auth/telegram/verify`;
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
767
815
|
case "telegramLogin": {
|
|
768
816
|
path = `/auth/telegram`;
|
|
769
817
|
break;
|
|
770
818
|
}
|
|
819
|
+
case "oAuth": {
|
|
820
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}`;
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
case "oAuthCallback": {
|
|
824
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}/callback`;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
case "loginOTP": {
|
|
828
|
+
path = "/auth/otp";
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
case "loginFarcaster": {
|
|
832
|
+
path = "/auth/farcaster";
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
771
835
|
default: {
|
|
772
836
|
throw new Error(`invalid URL type ${type}`);
|
|
773
837
|
}
|
|
@@ -786,7 +850,7 @@ const _ParaCore = class _ParaCore {
|
|
|
786
850
|
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
787
851
|
sessionId
|
|
788
852
|
};
|
|
789
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
853
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
790
854
|
apiKey: this.ctx.apiKey,
|
|
791
855
|
partnerId: partner == null ? void 0 : partner.id,
|
|
792
856
|
portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
|
|
@@ -804,7 +868,7 @@ const _ParaCore = class _ParaCore {
|
|
|
804
868
|
}, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
805
869
|
pfpUrl: this.authInfo.pfpUrl,
|
|
806
870
|
displayName: this.authInfo.displayName
|
|
807
|
-
}) : {}), isOnRamp ? { origin: typeof window !== "undefined" ? window.location.origin : void 0, email: this.email } : {}), isLogin ? __spreadProps(__spreadValues({
|
|
871
|
+
}) : {}), isOnRamp ? { origin: typeof window !== "undefined" ? window.location.origin : void 0, email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin ? __spreadProps(__spreadValues({
|
|
808
872
|
sessionId: thisDevice.sessionId,
|
|
809
873
|
encryptionKey: thisDevice.encryptionKey
|
|
810
874
|
}, opts.newDevice ? {
|
|
@@ -812,7 +876,9 @@ const _ParaCore = class _ParaCore {
|
|
|
812
876
|
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
813
877
|
} : {}), {
|
|
814
878
|
pregenIds: JSON.stringify(this.pregenIds)
|
|
815
|
-
}) : {}),
|
|
879
|
+
}) : {}), isOAuth || isOAuthCallback || isFarcasterLogin ? {
|
|
880
|
+
appScheme: opts.appScheme
|
|
881
|
+
} : {}), isTelegramLogin ? { isEmbed: "true" } : {}), opts.params || {});
|
|
816
882
|
const url = (0, import_utils2.constructUrl)({ base, path, params });
|
|
817
883
|
if (opts.shorten) {
|
|
818
884
|
return (0, import_utils2.shortenUrl)(this.ctx, url);
|
|
@@ -1552,6 +1618,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1552
1618
|
return accounts;
|
|
1553
1619
|
});
|
|
1554
1620
|
}
|
|
1621
|
+
// TELEGRAM
|
|
1555
1622
|
/**
|
|
1556
1623
|
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
1557
1624
|
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
@@ -1561,19 +1628,28 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1561
1628
|
verifyTelegramProcess(_e) {
|
|
1562
1629
|
return __async(this, null, function* () {
|
|
1563
1630
|
var _f = _e, {
|
|
1631
|
+
serverAuthState: optsServerAuthState,
|
|
1564
1632
|
telegramAuthResponse,
|
|
1565
1633
|
isLinkAccount
|
|
1566
1634
|
} = _f, urlOptions = __objRest(_f, [
|
|
1635
|
+
"serverAuthState",
|
|
1567
1636
|
"telegramAuthResponse",
|
|
1568
1637
|
"isLinkAccount"
|
|
1569
1638
|
]);
|
|
1570
1639
|
try {
|
|
1571
1640
|
switch (isLinkAccount) {
|
|
1572
1641
|
case false: {
|
|
1573
|
-
|
|
1574
|
-
|
|
1642
|
+
if (!optsServerAuthState && !telegramAuthResponse) {
|
|
1643
|
+
throw new Error("one of serverAuthState or telegramAuthResponse are required for verifying telegram");
|
|
1644
|
+
}
|
|
1645
|
+
const serverAuthState = optsServerAuthState != null ? optsServerAuthState : yield this.ctx.client.verifyTelegram({ authObject: telegramAuthResponse });
|
|
1646
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
1647
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1575
1648
|
}
|
|
1576
1649
|
case true: {
|
|
1650
|
+
if (!telegramAuthResponse) {
|
|
1651
|
+
throw new Error("telegramAuthResponse is required for verifying telegram link");
|
|
1652
|
+
}
|
|
1577
1653
|
const accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "TELEGRAM");
|
|
1578
1654
|
const accounts = yield this.verifyLink({
|
|
1579
1655
|
accountLinkInProgress,
|
|
@@ -1583,7 +1659,8 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1583
1659
|
}
|
|
1584
1660
|
}
|
|
1585
1661
|
} catch (e) {
|
|
1586
|
-
|
|
1662
|
+
const errorMessage = e instanceof Error ? e.message : e ? String(e) : "Unknown error occurred";
|
|
1663
|
+
throw new Error(errorMessage);
|
|
1587
1664
|
}
|
|
1588
1665
|
});
|
|
1589
1666
|
}
|
|
@@ -1828,6 +1905,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1828
1905
|
return connectUri;
|
|
1829
1906
|
});
|
|
1830
1907
|
}
|
|
1908
|
+
// FARCASTER
|
|
1831
1909
|
/**
|
|
1832
1910
|
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
1833
1911
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
@@ -1840,14 +1918,20 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1840
1918
|
onConnectUri,
|
|
1841
1919
|
onCancel,
|
|
1842
1920
|
onPoll,
|
|
1843
|
-
isLinkAccount
|
|
1921
|
+
isLinkAccount,
|
|
1922
|
+
serverAuthState: optsServerAuthState
|
|
1844
1923
|
} = _h, urlOptions = __objRest(_h, [
|
|
1845
1924
|
"isCanceled",
|
|
1846
1925
|
"onConnectUri",
|
|
1847
1926
|
"onCancel",
|
|
1848
1927
|
"onPoll",
|
|
1849
|
-
"isLinkAccount"
|
|
1928
|
+
"isLinkAccount",
|
|
1929
|
+
"serverAuthState"
|
|
1850
1930
|
]);
|
|
1931
|
+
if (optsServerAuthState) {
|
|
1932
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, optsServerAuthState, urlOptions);
|
|
1933
|
+
return authState;
|
|
1934
|
+
}
|
|
1851
1935
|
let accountLinkInProgress;
|
|
1852
1936
|
if (isLinkAccount) {
|
|
1853
1937
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "FARCASTER");
|
|
@@ -1943,10 +2027,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1943
2027
|
"onOAuthPopup",
|
|
1944
2028
|
"isLinkAccount"
|
|
1945
2029
|
]);
|
|
1946
|
-
let popupWindow;
|
|
1947
2030
|
if (onOAuthPopup) {
|
|
1948
2031
|
try {
|
|
1949
|
-
popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.OAUTH });
|
|
2032
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.OAUTH });
|
|
1950
2033
|
} catch (error) {
|
|
1951
2034
|
throw new Error(`Failed to open OAuth popup: ${error}`);
|
|
1952
2035
|
}
|
|
@@ -1965,9 +2048,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
1965
2048
|
onOAuthUrl(oAuthUrl);
|
|
1966
2049
|
break;
|
|
1967
2050
|
}
|
|
1968
|
-
case (!!onOAuthPopup && !!popupWindow): {
|
|
1969
|
-
popupWindow.location.href = oAuthUrl;
|
|
1970
|
-
onOAuthPopup(popupWindow);
|
|
2051
|
+
case (!!onOAuthPopup && !!this.popupWindow): {
|
|
2052
|
+
this.popupWindow.location.href = oAuthUrl;
|
|
2053
|
+
onOAuthPopup(this.popupWindow);
|
|
1971
2054
|
break;
|
|
1972
2055
|
}
|
|
1973
2056
|
}
|
|
@@ -2197,7 +2280,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2197
2280
|
userId: this.userId,
|
|
2198
2281
|
walletId,
|
|
2199
2282
|
userShare: userSigner,
|
|
2200
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2283
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2284
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2285
|
+
walletScheme: this.wallets[walletId].scheme
|
|
2201
2286
|
});
|
|
2202
2287
|
return recoveryShare;
|
|
2203
2288
|
});
|
|
@@ -2325,7 +2410,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2325
2410
|
ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
|
|
2326
2411
|
emailProps: this.getBackupKitEmailProps(),
|
|
2327
2412
|
partnerId: newPartnerId,
|
|
2328
|
-
protocolId
|
|
2413
|
+
protocolId,
|
|
2414
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2415
|
+
walletScheme: this.wallets[walletId].scheme
|
|
2329
2416
|
});
|
|
2330
2417
|
return { signer, recoverySecret, protocolId };
|
|
2331
2418
|
});
|
|
@@ -2391,7 +2478,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2391
2478
|
userId: this.userId,
|
|
2392
2479
|
walletId: wallet.id,
|
|
2393
2480
|
userShare: signer,
|
|
2394
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2481
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2482
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2483
|
+
walletScheme: wallet.scheme
|
|
2395
2484
|
});
|
|
2396
2485
|
}
|
|
2397
2486
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
@@ -2472,7 +2561,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
2472
2561
|
walletId: wallet.id,
|
|
2473
2562
|
userShare: this.wallets[wallet.id].signer,
|
|
2474
2563
|
emailProps: this.getBackupKitEmailProps(),
|
|
2475
|
-
partnerId: wallet.partnerId
|
|
2564
|
+
partnerId: wallet.partnerId,
|
|
2565
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2566
|
+
walletScheme: wallet.scheme
|
|
2476
2567
|
});
|
|
2477
2568
|
if (distributeRes.length > 0) {
|
|
2478
2569
|
newRecoverySecret = distributeRes;
|
|
@@ -3112,7 +3203,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3112
3203
|
});
|
|
3113
3204
|
}
|
|
3114
3205
|
/**
|
|
3115
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey, password or
|
|
3206
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
|
|
3116
3207
|
* @param {Object} opts the options object
|
|
3117
3208
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
3118
3209
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
@@ -3141,6 +3232,9 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3141
3232
|
case "PIN":
|
|
3142
3233
|
urlType = "loginPIN";
|
|
3143
3234
|
break;
|
|
3235
|
+
case "BASIC_LOGIN":
|
|
3236
|
+
urlType = "loginOTP";
|
|
3237
|
+
break;
|
|
3144
3238
|
default:
|
|
3145
3239
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
3146
3240
|
}
|
|
@@ -3182,7 +3276,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3182
3276
|
yield this.setUserShare(userShare);
|
|
3183
3277
|
}
|
|
3184
3278
|
}
|
|
3185
|
-
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3279
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
|
|
3186
3280
|
});
|
|
3187
3281
|
}
|
|
3188
3282
|
verifyNewAccount(_m) {
|
|
@@ -3197,7 +3291,7 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3197
3291
|
const serverAuthState = yield this.ctx.client.verifyAccount(userId, {
|
|
3198
3292
|
verificationCode
|
|
3199
3293
|
});
|
|
3200
|
-
if (serverAuthState.stage === "login") {
|
|
3294
|
+
if (serverAuthState.stage === "login" || serverAuthState.stage === "done") {
|
|
3201
3295
|
throw new Error("Account already exists.");
|
|
3202
3296
|
}
|
|
3203
3297
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
@@ -3318,6 +3412,16 @@ Need help? Visit: https://docs.getpara.com or contact support
|
|
|
3318
3412
|
return accounts;
|
|
3319
3413
|
});
|
|
3320
3414
|
}
|
|
3415
|
+
getProfileBalance() {
|
|
3416
|
+
return __async(this, arguments, function* ({ config, refetch = false } = {}) {
|
|
3417
|
+
const { balance } = yield this.ctx.client.getProfileBalance({
|
|
3418
|
+
config,
|
|
3419
|
+
wallets: this.availableWallets.map(({ type, address }) => ({ type, address })),
|
|
3420
|
+
refetch
|
|
3421
|
+
});
|
|
3422
|
+
return balance;
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3321
3425
|
sendLoginCode() {
|
|
3322
3426
|
return __async(this, null, function* () {
|
|
3323
3427
|
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
@@ -3431,30 +3535,43 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
3431
3535
|
return yield this.linkAccount({ type });
|
|
3432
3536
|
});
|
|
3433
3537
|
};
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3538
|
+
getOAuthUrl_fn = function(_0) {
|
|
3539
|
+
return __async(this, arguments, function* ({
|
|
3540
|
+
method,
|
|
3541
|
+
appScheme,
|
|
3542
|
+
accountLinkInProgress,
|
|
3543
|
+
sessionLookupId,
|
|
3544
|
+
encryptionKey
|
|
3545
|
+
}) {
|
|
3546
|
+
if (!accountLinkInProgress && !this.isPortal()) {
|
|
3547
|
+
return yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
3548
|
+
}
|
|
3549
|
+
let portalSessionLookupId;
|
|
3550
|
+
if (this.isPortal()) {
|
|
3551
|
+
portalSessionLookupId = (yield this.touchSession(true)).sessionLookupId;
|
|
3552
|
+
}
|
|
3553
|
+
return (0, import_utils2.constructUrl)({
|
|
3554
|
+
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
3555
|
+
path: `/auth/${method.toLowerCase()}`,
|
|
3556
|
+
params: __spreadProps(__spreadValues({
|
|
3557
|
+
apiKey: this.ctx.apiKey,
|
|
3558
|
+
sessionLookupId,
|
|
3559
|
+
portalSessionLookupId,
|
|
3560
|
+
appScheme
|
|
3561
|
+
}, accountLinkInProgress ? {
|
|
3562
|
+
linkedAccountId: this.accountLinkInProgress.id
|
|
3563
|
+
} : {}), {
|
|
3564
|
+
callback: !accountLinkInProgress && (yield this.constructPortalUrl("oAuthCallback", {
|
|
3565
|
+
sessionId: sessionLookupId,
|
|
3566
|
+
oAuthMethod: method,
|
|
3567
|
+
appScheme,
|
|
3568
|
+
thisDevice: {
|
|
3569
|
+
sessionId: sessionLookupId,
|
|
3570
|
+
encryptionKey
|
|
3571
|
+
}
|
|
3572
|
+
}))
|
|
3573
|
+
})
|
|
3574
|
+
});
|
|
3458
3575
|
});
|
|
3459
3576
|
};
|
|
3460
3577
|
createPregenWallet_fn = function(opts) {
|
|
@@ -3530,8 +3647,14 @@ prepareAuthState_fn = function(_0) {
|
|
|
3530
3647
|
}
|
|
3531
3648
|
let authState;
|
|
3532
3649
|
switch (serverAuthState.stage) {
|
|
3650
|
+
case "done": {
|
|
3651
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareDoneState_fn).call(this, serverAuthState);
|
|
3652
|
+
break;
|
|
3653
|
+
}
|
|
3533
3654
|
case "verify":
|
|
3534
|
-
authState = serverAuthState
|
|
3655
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareVerificationState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), {
|
|
3656
|
+
sessionLookupId: opts.sessionLookupId
|
|
3657
|
+
}));
|
|
3535
3658
|
break;
|
|
3536
3659
|
case "login":
|
|
3537
3660
|
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
@@ -3551,6 +3674,36 @@ prepareAuthState_fn = function(_0) {
|
|
|
3551
3674
|
return authState;
|
|
3552
3675
|
});
|
|
3553
3676
|
};
|
|
3677
|
+
prepareDoneState_fn = function(doneState) {
|
|
3678
|
+
return __async(this, null, function* () {
|
|
3679
|
+
let isSLOPossible = doneState.authMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3680
|
+
this.isEnclaveUser = isSLOPossible;
|
|
3681
|
+
return doneState;
|
|
3682
|
+
});
|
|
3683
|
+
};
|
|
3684
|
+
prepareVerificationState_fn = function(_0, _1) {
|
|
3685
|
+
return __async(this, arguments, function* (verifyState, {
|
|
3686
|
+
useShortUrls: shorten = false,
|
|
3687
|
+
portalTheme,
|
|
3688
|
+
sessionLookupId
|
|
3689
|
+
}) {
|
|
3690
|
+
let isSLOPossible = false;
|
|
3691
|
+
if (verifyState.nextStage === "login") {
|
|
3692
|
+
isSLOPossible = verifyState.loginAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3693
|
+
} else if (verifyState.nextStage === "signup") {
|
|
3694
|
+
isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3695
|
+
}
|
|
3696
|
+
this.isEnclaveUser = isSLOPossible;
|
|
3697
|
+
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible ? {
|
|
3698
|
+
loginUrl: yield this.getLoginUrl({
|
|
3699
|
+
authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
|
|
3700
|
+
sessionId: sessionLookupId,
|
|
3701
|
+
shorten,
|
|
3702
|
+
portalTheme
|
|
3703
|
+
})
|
|
3704
|
+
} : {});
|
|
3705
|
+
});
|
|
3706
|
+
};
|
|
3554
3707
|
prepareLoginState_fn = function(_0, _1) {
|
|
3555
3708
|
return __async(this, arguments, function* (loginState, {
|
|
3556
3709
|
useShortUrls: shorten = false,
|
package/dist/cjs/constants.js
CHANGED
|
@@ -24,6 +24,8 @@ __export(constants_exports, {
|
|
|
24
24
|
LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
25
25
|
LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
|
|
26
26
|
LOCAL_STORAGE_EMAIL: () => LOCAL_STORAGE_EMAIL,
|
|
27
|
+
LOCAL_STORAGE_ENCLAVE_JWT: () => LOCAL_STORAGE_ENCLAVE_JWT,
|
|
28
|
+
LOCAL_STORAGE_ENCLAVE_REFRESH_JWT: () => LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
|
|
27
29
|
LOCAL_STORAGE_EXTERNAL_WALLETS: () => LOCAL_STORAGE_EXTERNAL_WALLETS,
|
|
28
30
|
LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: () => LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
|
|
29
31
|
LOCAL_STORAGE_FARCASTER_USERNAME: () => LOCAL_STORAGE_FARCASTER_USERNAME,
|
|
@@ -41,7 +43,7 @@ __export(constants_exports, {
|
|
|
41
43
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(constants_exports);
|
|
44
|
-
const PARA_CORE_VERSION = "2.0.0-alpha.
|
|
46
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.54";
|
|
45
47
|
const PREFIX = "@CAPSULE/";
|
|
46
48
|
const PARA_PREFIX = "@PARA/";
|
|
47
49
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -57,6 +59,8 @@ const LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
|
|
|
57
59
|
const LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
|
|
58
60
|
const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
|
|
59
61
|
const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
62
|
+
const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
|
|
63
|
+
const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
|
|
60
64
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
61
65
|
const POLLING_INTERVAL_MS = 2e3;
|
|
62
66
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
@@ -72,6 +76,8 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
|
|
72
76
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
73
77
|
LOCAL_STORAGE_ED25519_WALLETS,
|
|
74
78
|
LOCAL_STORAGE_EMAIL,
|
|
79
|
+
LOCAL_STORAGE_ENCLAVE_JWT,
|
|
80
|
+
LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
|
|
75
81
|
LOCAL_STORAGE_EXTERNAL_WALLETS,
|
|
76
82
|
LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
|
|
77
83
|
LOCAL_STORAGE_FARCASTER_USERNAME,
|
package/dist/cjs/index.js
CHANGED
|
@@ -65,6 +65,7 @@ __export(src_exports, {
|
|
|
65
65
|
decryptWithKeyPair: () => import_utils2.decryptWithKeyPair,
|
|
66
66
|
decryptWithPrivateKey: () => import_utils2.decryptWithPrivateKey,
|
|
67
67
|
default: () => src_default,
|
|
68
|
+
dispatchEvent: () => import_utils.dispatchEvent,
|
|
68
69
|
distributeNewShare: () => import_shareDistribution.distributeNewShare,
|
|
69
70
|
encodePrivateKeyToPemHex: () => import_utils2.encodePrivateKeyToPemHex,
|
|
70
71
|
encryptPrivateKey: () => import_utils2.encryptPrivateKey,
|
|
@@ -155,6 +156,7 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
155
156
|
decryptPrivateKeyWithPassword,
|
|
156
157
|
decryptWithKeyPair,
|
|
157
158
|
decryptWithPrivateKey,
|
|
159
|
+
dispatchEvent,
|
|
158
160
|
distributeNewShare,
|
|
159
161
|
encodePrivateKeyToPemHex,
|
|
160
162
|
encryptPrivateKey,
|