@getpara/core-sdk 2.0.0-alpha.32 → 2.0.0-alpha.33
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 +107 -54
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/types/coreApi.js +2 -1
- package/dist/esm/ParaCore.js +107 -54
- package/dist/esm/constants.js +1 -1
- package/dist/esm/types/coreApi.js +2 -1
- package/dist/types/ParaCore.d.ts +11 -1
- package/dist/types/types/coreApi.d.ts +5 -1
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -99,7 +99,7 @@ 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 _authInfo, _partner, _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,
|
|
102
|
+
var _authInfo, _partner, _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, prepareLoginState_fn, prepareSignUpState_fn;
|
|
103
103
|
if (typeof global !== "undefined") {
|
|
104
104
|
global.Buffer = global.Buffer || import_buffer.Buffer;
|
|
105
105
|
} else if (typeof window !== "undefined") {
|
|
@@ -935,11 +935,59 @@ const _ParaCore = class _ParaCore {
|
|
|
935
935
|
*/
|
|
936
936
|
setExternalWallet(externalWallet) {
|
|
937
937
|
return __async(this, null, function* () {
|
|
938
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
938
939
|
this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
|
|
940
|
+
(acc, {
|
|
941
|
+
partnerId: wPartnerId,
|
|
942
|
+
address,
|
|
943
|
+
type,
|
|
944
|
+
provider,
|
|
945
|
+
providerId,
|
|
946
|
+
addressBech32,
|
|
947
|
+
withFullParaAuth,
|
|
948
|
+
isConnectionOnly,
|
|
949
|
+
withVerification
|
|
950
|
+
}) => {
|
|
951
|
+
if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
|
|
952
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
953
|
+
[address]: {
|
|
954
|
+
id: address,
|
|
955
|
+
partnerId,
|
|
956
|
+
address: addressBech32 != null ? addressBech32 : address,
|
|
957
|
+
type,
|
|
958
|
+
name: provider,
|
|
959
|
+
isExternal: true,
|
|
960
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
961
|
+
externalProviderId: providerId,
|
|
962
|
+
signer: "",
|
|
963
|
+
isExternalConnectionOnly: isConnectionOnly,
|
|
964
|
+
isExternalWithVerification: withVerification
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
return acc;
|
|
969
|
+
},
|
|
970
|
+
{}
|
|
971
|
+
), this.setExternalWallets(this.externalWallets);
|
|
972
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
addExternalWallets(externalWallets) {
|
|
976
|
+
return __async(this, null, function* () {
|
|
977
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
978
|
+
this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
|
|
979
|
+
if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
|
|
980
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
981
|
+
[address]: wallet
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
return acc;
|
|
985
|
+
}, {})), externalWallets.reduce(
|
|
939
986
|
(acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
|
|
940
987
|
return __spreadProps(__spreadValues({}, acc), {
|
|
941
988
|
[address]: {
|
|
942
989
|
id: address,
|
|
990
|
+
partnerId,
|
|
943
991
|
address: addressBech32 != null ? addressBech32 : address,
|
|
944
992
|
type,
|
|
945
993
|
name: provider,
|
|
@@ -953,7 +1001,7 @@ const _ParaCore = class _ParaCore {
|
|
|
953
1001
|
});
|
|
954
1002
|
},
|
|
955
1003
|
{}
|
|
956
|
-
);
|
|
1004
|
+
));
|
|
957
1005
|
this.setExternalWallets(this.externalWallets);
|
|
958
1006
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
959
1007
|
});
|
|
@@ -1307,7 +1355,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1307
1355
|
]);
|
|
1308
1356
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1309
1357
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
1310
|
-
yield this.
|
|
1358
|
+
yield this.addExternalWallets(
|
|
1311
1359
|
externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
1312
1360
|
withFullParaAuth: false
|
|
1313
1361
|
}))
|
|
@@ -1717,9 +1765,14 @@ const _ParaCore = class _ParaCore {
|
|
|
1717
1765
|
}
|
|
1718
1766
|
getOAuthUrl(opts) {
|
|
1719
1767
|
return __async(this, null, function* () {
|
|
1720
|
-
|
|
1768
|
+
var _a;
|
|
1769
|
+
const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
|
|
1770
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
|
|
1721
1771
|
});
|
|
1722
1772
|
}
|
|
1773
|
+
getOAuthUrlSync(opts) {
|
|
1774
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
|
|
1775
|
+
}
|
|
1723
1776
|
/**
|
|
1724
1777
|
* Awaits the response from a user's attempt to log in with OAuth.
|
|
1725
1778
|
* If successful, this returns the user's email address and indicates whether the user already exists.
|
|
@@ -1728,9 +1781,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1728
1781
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1729
1782
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1730
1783
|
*/
|
|
1731
|
-
verifyOAuthProcess(
|
|
1784
|
+
verifyOAuthProcess(_i) {
|
|
1732
1785
|
return __async(this, null, function* () {
|
|
1733
|
-
var
|
|
1786
|
+
var _j = _i, {
|
|
1734
1787
|
method,
|
|
1735
1788
|
appScheme,
|
|
1736
1789
|
isCanceled = () => false,
|
|
@@ -1738,7 +1791,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1738
1791
|
onPoll,
|
|
1739
1792
|
onOAuthUrl,
|
|
1740
1793
|
isLinkAccount
|
|
1741
|
-
} =
|
|
1794
|
+
} = _j, urlOptions = __objRest(_j, [
|
|
1742
1795
|
"method",
|
|
1743
1796
|
"appScheme",
|
|
1744
1797
|
"isCanceled",
|
|
@@ -1753,7 +1806,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1753
1806
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
|
|
1754
1807
|
sessionLookupId = (yield this.touchSession()).sessionLookupId;
|
|
1755
1808
|
} else {
|
|
1756
|
-
sessionLookupId = yield
|
|
1809
|
+
sessionLookupId = yield this.prepareLogin();
|
|
1757
1810
|
}
|
|
1758
1811
|
const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
|
|
1759
1812
|
onOAuthUrl(oAuthUrl);
|
|
@@ -2436,12 +2489,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2436
2489
|
});
|
|
2437
2490
|
});
|
|
2438
2491
|
}
|
|
2439
|
-
getOnRampTransactionUrl(
|
|
2492
|
+
getOnRampTransactionUrl(_k) {
|
|
2440
2493
|
return __async(this, null, function* () {
|
|
2441
|
-
var
|
|
2494
|
+
var _l = _k, {
|
|
2442
2495
|
purchaseId,
|
|
2443
2496
|
providerKey
|
|
2444
|
-
} =
|
|
2497
|
+
} = _l, walletParams = __objRest(_l, [
|
|
2445
2498
|
"purchaseId",
|
|
2446
2499
|
"providerKey"
|
|
2447
2500
|
]);
|
|
@@ -2927,9 +2980,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2927
2980
|
});
|
|
2928
2981
|
});
|
|
2929
2982
|
}
|
|
2930
|
-
|
|
2983
|
+
prepareLogin() {
|
|
2931
2984
|
return __async(this, null, function* () {
|
|
2932
|
-
|
|
2985
|
+
yield this.logout();
|
|
2986
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
2987
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2988
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2989
|
+
}
|
|
2990
|
+
return sessionLookupId;
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
signUpOrLogIn(_m) {
|
|
2994
|
+
return __async(this, null, function* () {
|
|
2995
|
+
var _n = _m, { auth } = _n, urlOptions = __objRest(_n, ["auth"]);
|
|
2933
2996
|
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
2934
2997
|
const authInfo = serverAuthState.auth;
|
|
2935
2998
|
if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
|
|
@@ -2941,11 +3004,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2941
3004
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2942
3005
|
});
|
|
2943
3006
|
}
|
|
2944
|
-
verifyNewAccount(
|
|
3007
|
+
verifyNewAccount(_o) {
|
|
2945
3008
|
return __async(this, null, function* () {
|
|
2946
|
-
var
|
|
3009
|
+
var _p = _o, {
|
|
2947
3010
|
verificationCode
|
|
2948
|
-
} =
|
|
3011
|
+
} = _p, urlOptions = __objRest(_p, [
|
|
2949
3012
|
"verificationCode"
|
|
2950
3013
|
]);
|
|
2951
3014
|
this.assertIsAuthSet(["email", "phone"]);
|
|
@@ -3039,10 +3102,10 @@ const _ParaCore = class _ParaCore {
|
|
|
3039
3102
|
});
|
|
3040
3103
|
}
|
|
3041
3104
|
verifyLink() {
|
|
3042
|
-
return __async(this, arguments, function* (
|
|
3043
|
-
var
|
|
3105
|
+
return __async(this, arguments, function* (_q = {}) {
|
|
3106
|
+
var _r = _q, {
|
|
3044
3107
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3045
|
-
} =
|
|
3108
|
+
} = _r, opts = __objRest(_r, [
|
|
3046
3109
|
"accountLinkInProgress"
|
|
3047
3110
|
]);
|
|
3048
3111
|
try {
|
|
@@ -3179,30 +3242,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
3179
3242
|
return yield this.linkAccount({ type });
|
|
3180
3243
|
});
|
|
3181
3244
|
};
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
})
|
|
3245
|
+
/**
|
|
3246
|
+
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
3247
|
+
*
|
|
3248
|
+
* @param {Object} opts the options object
|
|
3249
|
+
* @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
|
|
3250
|
+
* @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
|
|
3251
|
+
* @returns {string} the URL for the user to log in with OAuth.
|
|
3252
|
+
*/
|
|
3253
|
+
getOAuthUrl_fn = function({
|
|
3254
|
+
method,
|
|
3255
|
+
appScheme,
|
|
3256
|
+
accountLinkInProgress,
|
|
3257
|
+
sessionLookupId
|
|
3258
|
+
}) {
|
|
3259
|
+
return (0, import_utils2.constructUrl)({
|
|
3260
|
+
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
3261
|
+
path: `/auth/${method}`,
|
|
3262
|
+
params: __spreadValues({
|
|
3263
|
+
apiKey: this.ctx.apiKey,
|
|
3264
|
+
sessionLookupId,
|
|
3265
|
+
appScheme
|
|
3266
|
+
}, accountLinkInProgress ? {
|
|
3267
|
+
linkedAccountId: this.accountLinkInProgress.id
|
|
3268
|
+
} : {})
|
|
3206
3269
|
});
|
|
3207
3270
|
};
|
|
3208
3271
|
createPregenWallet_fn = function(opts) {
|
|
@@ -3256,7 +3319,7 @@ _isCreateGuestWalletsPending = new WeakMap();
|
|
|
3256
3319
|
prepareAuthState_fn = function(_0) {
|
|
3257
3320
|
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
3258
3321
|
if (!opts.sessionLookupId && serverAuthState.stage === "login") {
|
|
3259
|
-
opts.sessionLookupId = yield
|
|
3322
|
+
opts.sessionLookupId = yield this.prepareLogin();
|
|
3260
3323
|
}
|
|
3261
3324
|
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
3262
3325
|
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
|
|
@@ -3298,16 +3361,6 @@ prepareAuthState_fn = function(_0) {
|
|
|
3298
3361
|
return authState;
|
|
3299
3362
|
});
|
|
3300
3363
|
};
|
|
3301
|
-
prepareLogin_fn = function() {
|
|
3302
|
-
return __async(this, null, function* () {
|
|
3303
|
-
yield this.logout();
|
|
3304
|
-
const { sessionLookupId } = yield this.touchSession(true);
|
|
3305
|
-
if (!this.loginEncryptionKeyPair) {
|
|
3306
|
-
yield this.setLoginEncryptionKeyPair();
|
|
3307
|
-
}
|
|
3308
|
-
return sessionLookupId;
|
|
3309
|
-
});
|
|
3310
|
-
};
|
|
3311
3364
|
prepareLoginState_fn = function(_0, _1) {
|
|
3312
3365
|
return __async(this, arguments, function* (loginState, {
|
|
3313
3366
|
useShortUrls: shorten = false,
|
package/dist/cjs/constants.js
CHANGED
|
@@ -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.
|
|
43
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.33";
|
|
44
44
|
const PREFIX = "@CAPSULE/";
|
|
45
45
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
46
46
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
@@ -80,7 +80,8 @@ const PARA_INTERNAL_METHODS = [
|
|
|
80
80
|
"verifyFarcasterLink",
|
|
81
81
|
"verifyTelegramLink",
|
|
82
82
|
"verifyExternalWalletLink",
|
|
83
|
-
"accountLinkInProgress"
|
|
83
|
+
"accountLinkInProgress",
|
|
84
|
+
"prepareLogin"
|
|
84
85
|
];
|
|
85
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
87
|
0 && (module.exports = {
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__spreadProps,
|
|
9
9
|
__spreadValues
|
|
10
10
|
} from "./chunk-7B52C2XE.js";
|
|
11
|
-
var _authInfo, _partner, _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,
|
|
11
|
+
var _authInfo, _partner, _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, prepareLoginState_fn, prepareSignUpState_fn;
|
|
12
12
|
import { Buffer as NodeBuffer } from "buffer";
|
|
13
13
|
if (typeof global !== "undefined") {
|
|
14
14
|
global.Buffer = global.Buffer || NodeBuffer;
|
|
@@ -901,11 +901,59 @@ const _ParaCore = class _ParaCore {
|
|
|
901
901
|
*/
|
|
902
902
|
setExternalWallet(externalWallet) {
|
|
903
903
|
return __async(this, null, function* () {
|
|
904
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
904
905
|
this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
|
|
906
|
+
(acc, {
|
|
907
|
+
partnerId: wPartnerId,
|
|
908
|
+
address,
|
|
909
|
+
type,
|
|
910
|
+
provider,
|
|
911
|
+
providerId,
|
|
912
|
+
addressBech32,
|
|
913
|
+
withFullParaAuth,
|
|
914
|
+
isConnectionOnly,
|
|
915
|
+
withVerification
|
|
916
|
+
}) => {
|
|
917
|
+
if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
|
|
918
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
919
|
+
[address]: {
|
|
920
|
+
id: address,
|
|
921
|
+
partnerId,
|
|
922
|
+
address: addressBech32 != null ? addressBech32 : address,
|
|
923
|
+
type,
|
|
924
|
+
name: provider,
|
|
925
|
+
isExternal: true,
|
|
926
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
927
|
+
externalProviderId: providerId,
|
|
928
|
+
signer: "",
|
|
929
|
+
isExternalConnectionOnly: isConnectionOnly,
|
|
930
|
+
isExternalWithVerification: withVerification
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
return acc;
|
|
935
|
+
},
|
|
936
|
+
{}
|
|
937
|
+
), this.setExternalWallets(this.externalWallets);
|
|
938
|
+
dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
addExternalWallets(externalWallets) {
|
|
942
|
+
return __async(this, null, function* () {
|
|
943
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
944
|
+
this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
|
|
945
|
+
if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
|
|
946
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
947
|
+
[address]: wallet
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
return acc;
|
|
951
|
+
}, {})), externalWallets.reduce(
|
|
905
952
|
(acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
|
|
906
953
|
return __spreadProps(__spreadValues({}, acc), {
|
|
907
954
|
[address]: {
|
|
908
955
|
id: address,
|
|
956
|
+
partnerId,
|
|
909
957
|
address: addressBech32 != null ? addressBech32 : address,
|
|
910
958
|
type,
|
|
911
959
|
name: provider,
|
|
@@ -919,7 +967,7 @@ const _ParaCore = class _ParaCore {
|
|
|
919
967
|
});
|
|
920
968
|
},
|
|
921
969
|
{}
|
|
922
|
-
);
|
|
970
|
+
));
|
|
923
971
|
this.setExternalWallets(this.externalWallets);
|
|
924
972
|
dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
925
973
|
});
|
|
@@ -1273,7 +1321,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1273
1321
|
]);
|
|
1274
1322
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1275
1323
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
1276
|
-
yield this.
|
|
1324
|
+
yield this.addExternalWallets(
|
|
1277
1325
|
externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
1278
1326
|
withFullParaAuth: false
|
|
1279
1327
|
}))
|
|
@@ -1683,9 +1731,14 @@ const _ParaCore = class _ParaCore {
|
|
|
1683
1731
|
}
|
|
1684
1732
|
getOAuthUrl(opts) {
|
|
1685
1733
|
return __async(this, null, function* () {
|
|
1686
|
-
|
|
1734
|
+
var _a;
|
|
1735
|
+
const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
|
|
1736
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
|
|
1687
1737
|
});
|
|
1688
1738
|
}
|
|
1739
|
+
getOAuthUrlSync(opts) {
|
|
1740
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
|
|
1741
|
+
}
|
|
1689
1742
|
/**
|
|
1690
1743
|
* Awaits the response from a user's attempt to log in with OAuth.
|
|
1691
1744
|
* If successful, this returns the user's email address and indicates whether the user already exists.
|
|
@@ -1694,9 +1747,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1694
1747
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1695
1748
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1696
1749
|
*/
|
|
1697
|
-
verifyOAuthProcess(
|
|
1750
|
+
verifyOAuthProcess(_i) {
|
|
1698
1751
|
return __async(this, null, function* () {
|
|
1699
|
-
var
|
|
1752
|
+
var _j = _i, {
|
|
1700
1753
|
method,
|
|
1701
1754
|
appScheme,
|
|
1702
1755
|
isCanceled = () => false,
|
|
@@ -1704,7 +1757,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1704
1757
|
onPoll,
|
|
1705
1758
|
onOAuthUrl,
|
|
1706
1759
|
isLinkAccount
|
|
1707
|
-
} =
|
|
1760
|
+
} = _j, urlOptions = __objRest(_j, [
|
|
1708
1761
|
"method",
|
|
1709
1762
|
"appScheme",
|
|
1710
1763
|
"isCanceled",
|
|
@@ -1719,7 +1772,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1719
1772
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
|
|
1720
1773
|
sessionLookupId = (yield this.touchSession()).sessionLookupId;
|
|
1721
1774
|
} else {
|
|
1722
|
-
sessionLookupId = yield
|
|
1775
|
+
sessionLookupId = yield this.prepareLogin();
|
|
1723
1776
|
}
|
|
1724
1777
|
const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
|
|
1725
1778
|
onOAuthUrl(oAuthUrl);
|
|
@@ -2402,12 +2455,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2402
2455
|
});
|
|
2403
2456
|
});
|
|
2404
2457
|
}
|
|
2405
|
-
getOnRampTransactionUrl(
|
|
2458
|
+
getOnRampTransactionUrl(_k) {
|
|
2406
2459
|
return __async(this, null, function* () {
|
|
2407
|
-
var
|
|
2460
|
+
var _l = _k, {
|
|
2408
2461
|
purchaseId,
|
|
2409
2462
|
providerKey
|
|
2410
|
-
} =
|
|
2463
|
+
} = _l, walletParams = __objRest(_l, [
|
|
2411
2464
|
"purchaseId",
|
|
2412
2465
|
"providerKey"
|
|
2413
2466
|
]);
|
|
@@ -2893,9 +2946,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2893
2946
|
});
|
|
2894
2947
|
});
|
|
2895
2948
|
}
|
|
2896
|
-
|
|
2949
|
+
prepareLogin() {
|
|
2897
2950
|
return __async(this, null, function* () {
|
|
2898
|
-
|
|
2951
|
+
yield this.logout();
|
|
2952
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
2953
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2954
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2955
|
+
}
|
|
2956
|
+
return sessionLookupId;
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
signUpOrLogIn(_m) {
|
|
2960
|
+
return __async(this, null, function* () {
|
|
2961
|
+
var _n = _m, { auth } = _n, urlOptions = __objRest(_n, ["auth"]);
|
|
2899
2962
|
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
2900
2963
|
const authInfo = serverAuthState.auth;
|
|
2901
2964
|
if (this.fetchPregenWalletsOverride && isPregenAuth(authInfo)) {
|
|
@@ -2907,11 +2970,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2907
2970
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2908
2971
|
});
|
|
2909
2972
|
}
|
|
2910
|
-
verifyNewAccount(
|
|
2973
|
+
verifyNewAccount(_o) {
|
|
2911
2974
|
return __async(this, null, function* () {
|
|
2912
|
-
var
|
|
2975
|
+
var _p = _o, {
|
|
2913
2976
|
verificationCode
|
|
2914
|
-
} =
|
|
2977
|
+
} = _p, urlOptions = __objRest(_p, [
|
|
2915
2978
|
"verificationCode"
|
|
2916
2979
|
]);
|
|
2917
2980
|
this.assertIsAuthSet(["email", "phone"]);
|
|
@@ -3005,10 +3068,10 @@ const _ParaCore = class _ParaCore {
|
|
|
3005
3068
|
});
|
|
3006
3069
|
}
|
|
3007
3070
|
verifyLink() {
|
|
3008
|
-
return __async(this, arguments, function* (
|
|
3009
|
-
var
|
|
3071
|
+
return __async(this, arguments, function* (_q = {}) {
|
|
3072
|
+
var _r = _q, {
|
|
3010
3073
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3011
|
-
} =
|
|
3074
|
+
} = _r, opts = __objRest(_r, [
|
|
3012
3075
|
"accountLinkInProgress"
|
|
3013
3076
|
]);
|
|
3014
3077
|
try {
|
|
@@ -3145,30 +3208,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
3145
3208
|
return yield this.linkAccount({ type });
|
|
3146
3209
|
});
|
|
3147
3210
|
};
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
})
|
|
3211
|
+
/**
|
|
3212
|
+
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
3213
|
+
*
|
|
3214
|
+
* @param {Object} opts the options object
|
|
3215
|
+
* @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
|
|
3216
|
+
* @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
|
|
3217
|
+
* @returns {string} the URL for the user to log in with OAuth.
|
|
3218
|
+
*/
|
|
3219
|
+
getOAuthUrl_fn = function({
|
|
3220
|
+
method,
|
|
3221
|
+
appScheme,
|
|
3222
|
+
accountLinkInProgress,
|
|
3223
|
+
sessionLookupId
|
|
3224
|
+
}) {
|
|
3225
|
+
return constructUrl({
|
|
3226
|
+
base: getBaseOAuthUrl(this.ctx.env),
|
|
3227
|
+
path: `/auth/${method}`,
|
|
3228
|
+
params: __spreadValues({
|
|
3229
|
+
apiKey: this.ctx.apiKey,
|
|
3230
|
+
sessionLookupId,
|
|
3231
|
+
appScheme
|
|
3232
|
+
}, accountLinkInProgress ? {
|
|
3233
|
+
linkedAccountId: this.accountLinkInProgress.id
|
|
3234
|
+
} : {})
|
|
3172
3235
|
});
|
|
3173
3236
|
};
|
|
3174
3237
|
createPregenWallet_fn = function(opts) {
|
|
@@ -3222,7 +3285,7 @@ _isCreateGuestWalletsPending = new WeakMap();
|
|
|
3222
3285
|
prepareAuthState_fn = function(_0) {
|
|
3223
3286
|
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
3224
3287
|
if (!opts.sessionLookupId && serverAuthState.stage === "login") {
|
|
3225
|
-
opts.sessionLookupId = yield
|
|
3288
|
+
opts.sessionLookupId = yield this.prepareLogin();
|
|
3226
3289
|
}
|
|
3227
3290
|
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
3228
3291
|
const authInfo = __spreadValues(__spreadValues({}, extractAuthInfo(auth, { isRequired: true })), Object.fromEntries(
|
|
@@ -3264,16 +3327,6 @@ prepareAuthState_fn = function(_0) {
|
|
|
3264
3327
|
return authState;
|
|
3265
3328
|
});
|
|
3266
3329
|
};
|
|
3267
|
-
prepareLogin_fn = function() {
|
|
3268
|
-
return __async(this, null, function* () {
|
|
3269
|
-
yield this.logout();
|
|
3270
|
-
const { sessionLookupId } = yield this.touchSession(true);
|
|
3271
|
-
if (!this.loginEncryptionKeyPair) {
|
|
3272
|
-
yield this.setLoginEncryptionKeyPair();
|
|
3273
|
-
}
|
|
3274
|
-
return sessionLookupId;
|
|
3275
|
-
});
|
|
3276
|
-
};
|
|
3277
3330
|
prepareLoginState_fn = function(_0, _1) {
|
|
3278
3331
|
return __async(this, arguments, function* (loginState, {
|
|
3279
3332
|
useShortUrls: shorten = false,
|
package/dist/esm/constants.js
CHANGED
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -206,7 +206,12 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
206
206
|
* Init only needs to be called for storage that is async.
|
|
207
207
|
*/
|
|
208
208
|
init(): Promise<void>;
|
|
209
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Call this method to perform initial setup for the `ParaCore` instance.
|
|
211
|
+
*
|
|
212
|
+
* This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
|
|
213
|
+
*/
|
|
214
|
+
abstract ready(): Promise<void>;
|
|
210
215
|
protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
|
|
211
216
|
extras?: AuthExtras;
|
|
212
217
|
userId?: string;
|
|
@@ -240,6 +245,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
240
245
|
* @param externalType - Type of external wallet to set.
|
|
241
246
|
*/
|
|
242
247
|
setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
|
|
248
|
+
protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
|
|
243
249
|
/**
|
|
244
250
|
* Sets the user id associated with the `ParaCore` instance.
|
|
245
251
|
* @param userId - User id to set.
|
|
@@ -423,6 +429,9 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
423
429
|
verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
|
|
424
430
|
protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
|
|
425
431
|
getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
|
|
432
|
+
getOAuthUrlSync(opts: Omit<CoreMethodParams<'getOAuthUrl'>, 'sessionLookupId'> & {
|
|
433
|
+
sessionLookupId: string;
|
|
434
|
+
}): Awaited<CoreMethodResponse<'getOAuthUrl'>>;
|
|
426
435
|
protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
|
|
427
436
|
isLinkAccount: true;
|
|
428
437
|
}): InternalMethodResponse<'verifyOAuthLink'>;
|
|
@@ -676,6 +685,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
676
685
|
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
677
686
|
*/
|
|
678
687
|
protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
|
|
688
|
+
protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
|
|
679
689
|
signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
|
|
680
690
|
verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
|
|
681
691
|
getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
|
|
@@ -4,7 +4,7 @@ import { ParaCore } from '../ParaCore.js';
|
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './auth.js';
|
|
6
6
|
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
|
|
7
|
-
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress"];
|
|
7
|
+
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin"];
|
|
8
8
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
9
9
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
10
10
|
params: infer P;
|
|
@@ -522,6 +522,10 @@ export type InternalMethods = {
|
|
|
522
522
|
params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
|
|
523
523
|
response: LinkedAccounts;
|
|
524
524
|
};
|
|
525
|
+
prepareLogin: {
|
|
526
|
+
params: void;
|
|
527
|
+
response: string;
|
|
528
|
+
};
|
|
525
529
|
};
|
|
526
530
|
export type CoreInterface = {
|
|
527
531
|
[key in keyof CoreMethods]: Partial<CoreMethod<key>>;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.33",
|
|
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.
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.33",
|
|
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": "
|
|
30
|
+
"gitHead": "f338306fa30497d2190f8da2ff72ddd8d9d9032f",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|