@getpara/core-sdk 2.24.0 → 3.0.0-alpha.0

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.
Files changed (43) hide show
  1. package/dist/cjs/ParaCore.js +28 -9
  2. package/dist/cjs/constants.js +1 -1
  3. package/dist/cjs/services/AuthService.js +2 -2
  4. package/dist/cjs/services/ExternalWalletService.js +0 -3
  5. package/dist/cjs/services/LoginFlowService.js +24 -13
  6. package/dist/cjs/services/PollingService.js +3 -3
  7. package/dist/cjs/services/PortalUrlService.js +50 -43
  8. package/dist/cjs/services/SessionManagementService.js +3 -3
  9. package/dist/cjs/services/SignupFlowService.js +18 -3
  10. package/dist/cjs/services/VerificationFlowService.js +9 -4
  11. package/dist/cjs/services/WalletService.js +8 -1
  12. package/dist/cjs/state/CoreStateManager.js +37 -17
  13. package/dist/cjs/state/machines/authStateMachine.js +12 -0
  14. package/dist/cjs/types/coreApi.js +1 -0
  15. package/dist/esm/ParaCore.js +28 -9
  16. package/dist/esm/constants.js +1 -1
  17. package/dist/esm/services/AuthService.js +2 -2
  18. package/dist/esm/services/ExternalWalletService.js +0 -3
  19. package/dist/esm/services/LoginFlowService.js +24 -13
  20. package/dist/esm/services/PollingService.js +3 -3
  21. package/dist/esm/services/PortalUrlService.js +50 -43
  22. package/dist/esm/services/SessionManagementService.js +3 -3
  23. package/dist/esm/services/SignupFlowService.js +18 -3
  24. package/dist/esm/services/VerificationFlowService.js +9 -4
  25. package/dist/esm/services/WalletService.js +8 -1
  26. package/dist/esm/state/CoreStateManager.js +37 -17
  27. package/dist/esm/state/machines/authStateMachine.js +12 -0
  28. package/dist/esm/types/coreApi.js +1 -0
  29. package/dist/types/ParaCore.d.ts +17 -7
  30. package/dist/types/services/WalletService.d.ts +2 -1
  31. package/dist/types/services/types/AuthServiceTypes.d.ts +4 -1
  32. package/dist/types/services/types/PortalUrlServiceTypes.d.ts +9 -5
  33. package/dist/types/services/types/WalletServiceTypes.d.ts +12 -0
  34. package/dist/types/state/machines/authStateMachine.d.ts +112 -1
  35. package/dist/types/state/machines/coreStateMachine.d.ts +682 -16
  36. package/dist/types/state/types/auth.d.ts +4 -1
  37. package/dist/types/state/types/core.d.ts +11 -1
  38. package/dist/types/types/authState.d.ts +25 -0
  39. package/dist/types/types/config.d.ts +3 -2
  40. package/dist/types/types/coreApi.d.ts +9 -3
  41. package/dist/types/types/serviceInterfaces.d.ts +3 -3
  42. package/dist/types/types/util.d.ts +14 -1
  43. package/package.json +3 -3
@@ -31,29 +31,44 @@ class SignupFlowService extends BaseAuthFlowService {
31
31
  signupAuthMethods
32
32
  });
33
33
  if (isPasskey) {
34
- const { url: passkeyUrl, credentialId: passkeyId } = yield this.services.authService.getNewCredentialAndUrl({
34
+ const {
35
+ url: passkeyUrl,
36
+ fullUrl: passkeyFullUrl,
37
+ credentialId: passkeyId
38
+ } = yield this.services.authService.getNewCredentialAndUrl({
35
39
  authMethod: "PASSKEY",
36
40
  shorten
37
41
  });
38
42
  if (passkeyUrl) signupState.passkeyUrl = passkeyUrl;
43
+ if (passkeyFullUrl) signupState.passkeyFullUrl = passkeyFullUrl;
39
44
  signupState.passkeyId = passkeyId;
40
45
  }
41
46
  if (isPassword) {
42
- const { url: passwordUrl, credentialId: passwordId } = yield this.services.authService.getNewCredentialAndUrl({
47
+ const {
48
+ url: passwordUrl,
49
+ fullUrl: passwordFullUrl,
50
+ credentialId: passwordId
51
+ } = yield this.services.authService.getNewCredentialAndUrl({
43
52
  authMethod: "PASSWORD",
44
53
  portalTheme,
45
54
  shorten
46
55
  });
47
56
  signupState.passwordUrl = passwordUrl;
57
+ if (passwordFullUrl) signupState.passwordFullUrl = passwordFullUrl;
48
58
  signupState.passwordId = passwordId;
49
59
  }
50
60
  if (isPIN) {
51
- const { url: pinUrl, credentialId: pinId } = yield this.services.authService.getNewCredentialAndUrl({
61
+ const {
62
+ url: pinUrl,
63
+ fullUrl: pinFullUrl,
64
+ credentialId: pinId
65
+ } = yield this.services.authService.getNewCredentialAndUrl({
52
66
  authMethod: "PIN",
53
67
  portalTheme,
54
68
  shorten
55
69
  });
56
70
  signupState.pinUrl = pinUrl;
71
+ if (pinFullUrl) signupState.pinFullUrl = pinFullUrl;
57
72
  signupState.pinId = pinId;
58
73
  }
59
74
  return signupState;
@@ -23,14 +23,19 @@ class VerificationFlowService extends BaseAuthFlowService {
23
23
  this.services.authService.isEnclaveUser = isSLOPossible;
24
24
  yield this.paraCoreInterface.localStorageSetItem(LOCAL_STORAGE_IS_ENCLAVE_USER, JSON.stringify(isSLOPossible));
25
25
  const isExternalWalletFullAuth = (_a = serverAuthState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
26
- return __spreadValues(__spreadValues({}, serverAuthState), isSLOPossible || isExternalWalletFullAuth ? {
27
- loginUrl: yield this.services.portalUrlService.getLoginUrl({
26
+ let loginUrl;
27
+ let loginFullUrl;
28
+ if (isSLOPossible || isExternalWalletFullAuth) {
29
+ const result = yield this.services.portalUrlService.getLoginUrl({
28
30
  authMethod: AuthMethod.BASIC_LOGIN,
29
31
  sessionId: sessionLookupId,
30
32
  shorten,
31
33
  portalTheme
32
- })
33
- } : {});
34
+ });
35
+ loginUrl = result.url;
36
+ loginFullUrl = result.fullUrl;
37
+ }
38
+ return __spreadValues(__spreadValues({}, serverAuthState), loginUrl ? { loginUrl, loginFullUrl } : {});
34
39
  });
35
40
  this.performVerifyNewAccount = (params) => __async(this, null, function* () {
36
41
  this.services.authService.assertIsAuthSet(["email", "phone"]);
@@ -127,6 +127,8 @@ class WalletService {
127
127
  yield this.setCurrentWalletIds(updatedWalletIds, options);
128
128
  });
129
129
  this.setCurrentWalletIds = (_0, ..._1) => __async(this, [_0, ..._1], function* (currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId } = {}) {
130
+ var _a;
131
+ const hasChanged = JSON.stringify((_a = this.currentWalletIds) != null ? _a : {}) !== JSON.stringify(currentWalletIds != null ? currentWalletIds : {});
130
132
  this.currentWalletIds = currentWalletIds;
131
133
  yield __privateGet(this, _paraCoreInterface).localStorageSetItem(
132
134
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
@@ -141,7 +143,9 @@ class WalletService {
141
143
  newDeviceSessionLookupId
142
144
  );
143
145
  }
144
- dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
146
+ if (hasChanged) {
147
+ dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
148
+ }
145
149
  });
146
150
  this.createWallet = (..._0) => __async(this, [..._0], function* ({ type: _type, skipDistribute = false } = {}) {
147
151
  var _a, _b;
@@ -393,6 +397,9 @@ class WalletService {
393
397
  this.getWalletBalance = (_0) => __async(this, [_0], function* ({ walletId, rpcUrl }) {
394
398
  return (yield __privateGet(this, _paraCoreInterface).ctx.client.getWalletBalance({ walletId, rpcUrl })).balance;
395
399
  });
400
+ this.requestFaucet = (_0) => __async(this, [_0], function* ({ walletId, chain }) {
401
+ return yield __privateGet(this, _paraCoreInterface).ctx.client.requestFaucet({ walletId, chain });
402
+ });
396
403
  __privateAdd(this, _encodeWalletBase64, (wallet) => {
397
404
  const walletJson = JSON.stringify(wallet);
398
405
  const base64Wallet = Buffer.from(walletJson).toString("base64");
@@ -80,7 +80,7 @@ const _CoreStateManager = class _CoreStateManager {
80
80
  * Extracts all data needed by UI consumers from authStateResult.
81
81
  */
82
82
  computeAuthStateInfo(authContext, walletContext) {
83
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
83
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
84
84
  const defaultAuthStateInfo = {
85
85
  userId: null,
86
86
  isPasskeySupported: false,
@@ -89,11 +89,15 @@ const _CoreStateManager = class _CoreStateManager {
89
89
  hasPassword: false,
90
90
  hasPin: false,
91
91
  passkeyUrl: null,
92
+ passkeyFullUrl: null,
92
93
  passkeyKnownDeviceUrl: null,
93
94
  passwordUrl: null,
94
95
  pinUrl: null,
96
+ passwordFullUrl: null,
97
+ pinFullUrl: null,
95
98
  passkeyId: null,
96
99
  verificationUrl: null,
100
+ verificationFullUrl: null,
97
101
  externalWalletVerification: null,
98
102
  recoverySecret: null,
99
103
  isNewUser: false
@@ -123,10 +127,14 @@ const _CoreStateManager = class _CoreStateManager {
123
127
  let hasPin = false;
124
128
  let isPasskeySupported = false;
125
129
  let passkeyUrl = null;
130
+ let passkeyFullUrl = null;
126
131
  let passkeyKnownDeviceUrl = null;
127
132
  let passwordUrl = null;
128
133
  let pinUrl = null;
134
+ let passwordFullUrl = null;
135
+ let pinFullUrl = null;
129
136
  let verificationUrl = null;
137
+ let verificationFullUrl = null;
130
138
  let passkeyHints = null;
131
139
  let passkeyId = null;
132
140
  if (stage === "login") {
@@ -137,24 +145,31 @@ const _CoreStateManager = class _CoreStateManager {
137
145
  hasPin = authMethods.includes("PIN");
138
146
  isPasskeySupported = (_k = loginState.isPasskeySupported) != null ? _k : false;
139
147
  passkeyUrl = (_l = loginState.passkeyUrl) != null ? _l : null;
140
- passkeyKnownDeviceUrl = (_m = loginState.passkeyKnownDeviceUrl) != null ? _m : null;
141
- passwordUrl = (_n = loginState.passwordUrl) != null ? _n : null;
142
- pinUrl = (_o = loginState.pinUrl) != null ? _o : null;
143
- passkeyHints = (_p = loginState.biometricHints) != null ? _p : null;
148
+ passkeyFullUrl = (_m = loginState.passkeyFullUrl) != null ? _m : null;
149
+ passkeyKnownDeviceUrl = (_n = loginState.passkeyKnownDeviceUrl) != null ? _n : null;
150
+ passwordUrl = (_o = loginState.passwordUrl) != null ? _o : null;
151
+ pinUrl = (_p = loginState.pinUrl) != null ? _p : null;
152
+ passwordFullUrl = (_q = loginState.passwordFullUrl) != null ? _q : null;
153
+ pinFullUrl = (_r = loginState.pinFullUrl) != null ? _r : null;
154
+ passkeyHints = (_s = loginState.biometricHints) != null ? _s : null;
144
155
  } else if (stage === "signup") {
145
156
  const signupState = authStateResult;
146
- const authMethods = (_q = signupState.signupAuthMethods) != null ? _q : [];
157
+ const authMethods = (_t = signupState.signupAuthMethods) != null ? _t : [];
147
158
  hasPasskey = authMethods.includes("PASSKEY");
148
159
  hasPassword = authMethods.includes("PASSWORD");
149
160
  hasPin = authMethods.includes("PIN");
150
- isPasskeySupported = (_r = signupState.isPasskeySupported) != null ? _r : false;
151
- passkeyUrl = (_s = signupState.passkeyUrl) != null ? _s : null;
152
- passwordUrl = (_t = signupState.passwordUrl) != null ? _t : null;
153
- pinUrl = (_u = signupState.pinUrl) != null ? _u : null;
154
- passkeyId = (_v = signupState.passkeyId) != null ? _v : null;
161
+ isPasskeySupported = (_u = signupState.isPasskeySupported) != null ? _u : false;
162
+ passkeyUrl = (_v = signupState.passkeyUrl) != null ? _v : null;
163
+ passkeyFullUrl = (_w = signupState.passkeyFullUrl) != null ? _w : null;
164
+ passwordUrl = (_x = signupState.passwordUrl) != null ? _x : null;
165
+ pinUrl = (_y = signupState.pinUrl) != null ? _y : null;
166
+ passwordFullUrl = (_z = signupState.passwordFullUrl) != null ? _z : null;
167
+ pinFullUrl = (_A = signupState.pinFullUrl) != null ? _A : null;
168
+ passkeyId = (_B = signupState.passkeyId) != null ? _B : null;
155
169
  } else if (stage === "verify") {
156
170
  const verifyState = authStateResult;
157
- verificationUrl = (_w = verifyState.loginUrl) != null ? _w : null;
171
+ verificationUrl = (_C = verifyState.loginUrl) != null ? _C : null;
172
+ verificationFullUrl = (_D = verifyState.loginFullUrl) != null ? _D : null;
158
173
  }
159
174
  return {
160
175
  userId,
@@ -164,15 +179,19 @@ const _CoreStateManager = class _CoreStateManager {
164
179
  hasPassword,
165
180
  hasPin,
166
181
  passkeyUrl,
182
+ passkeyFullUrl,
167
183
  passkeyKnownDeviceUrl,
168
184
  passwordUrl,
169
185
  pinUrl,
186
+ passwordFullUrl,
187
+ pinFullUrl,
170
188
  passkeyId,
171
189
  verificationUrl,
190
+ verificationFullUrl,
172
191
  externalWalletVerification: externalWalletVerification ? {
173
- signatureVerificationMessage: (_x = externalWalletVerification.signatureVerificationMessage) != null ? _x : "",
174
- walletAddress: (_z = (_y = externalWalletVerification.externalWallet) == null ? void 0 : _y.address) != null ? _z : "",
175
- walletType: (_B = (_A = externalWalletVerification.externalWallet) == null ? void 0 : _A.type) != null ? _B : ""
192
+ signatureVerificationMessage: (_E = externalWalletVerification.signatureVerificationMessage) != null ? _E : "",
193
+ walletAddress: (_G = (_F = externalWalletVerification.externalWallet) == null ? void 0 : _F.address) != null ? _G : "",
194
+ walletType: (_I = (_H = externalWalletVerification.externalWallet) == null ? void 0 : _H.type) != null ? _I : ""
176
195
  } : null,
177
196
  recoverySecret,
178
197
  isNewUser
@@ -202,6 +221,7 @@ const _CoreStateManager = class _CoreStateManager {
202
221
  newWalletsResult: (walletMachineState == null ? void 0 : walletMachineState.context.newWalletsResult) || null,
203
222
  externalWalletSignVerification: (authMachineState == null ? void 0 : authMachineState.context.externalWalletSignVerification) || null,
204
223
  isNewUser: (authMachineState == null ? void 0 : authMachineState.context.isNewUser) || false,
224
+ selectedOAuthMethod: (authMachineState == null ? void 0 : authMachineState.context.selectedOAuthMethod) || null,
205
225
  // Wallet process
206
226
  guestWallets: (walletMachineState == null ? void 0 : walletMachineState.context.guestWallets) || null
207
227
  };
@@ -229,11 +249,11 @@ const _CoreStateManager = class _CoreStateManager {
229
249
  }
230
250
  statesEqual(state1, state2) {
231
251
  var _a, _b;
232
- return state1.phase === state2.phase && state1.authStatePhase === state2.authStatePhase && state1.walletStatePhase === state2.walletStatePhase && state1.isLoading === state2.isLoading && state1.isReady === state2.isReady && state1.isNewUser === state2.isNewUser && state1.needsWallet === state2.needsWallet && ((_a = state1.error) == null ? void 0 : _a.message) === ((_b = state2.error) == null ? void 0 : _b.message) && state1.authStateResult === state2.authStateResult && state1.newWalletsResult === state2.newWalletsResult && state1.guestWallets === state2.guestWallets && state1.externalWalletSignVerification === state2.externalWalletSignVerification && this.authStateInfoEqual(state1.authStateInfo, state2.authStateInfo);
252
+ return state1.phase === state2.phase && state1.authStatePhase === state2.authStatePhase && state1.walletStatePhase === state2.walletStatePhase && state1.isLoading === state2.isLoading && state1.isReady === state2.isReady && state1.isNewUser === state2.isNewUser && state1.needsWallet === state2.needsWallet && ((_a = state1.error) == null ? void 0 : _a.message) === ((_b = state2.error) == null ? void 0 : _b.message) && state1.authStateResult === state2.authStateResult && state1.newWalletsResult === state2.newWalletsResult && state1.guestWallets === state2.guestWallets && state1.externalWalletSignVerification === state2.externalWalletSignVerification && state1.selectedOAuthMethod === state2.selectedOAuthMethod && this.authStateInfoEqual(state1.authStateInfo, state2.authStateInfo);
233
253
  }
234
254
  authStateInfoEqual(a, b) {
235
255
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
236
- return a.userId === b.userId && a.isPasskeySupported === b.isPasskeySupported && a.hasPasskey === b.hasPasskey && a.hasPassword === b.hasPassword && a.hasPin === b.hasPin && a.passkeyUrl === b.passkeyUrl && a.passkeyKnownDeviceUrl === b.passkeyKnownDeviceUrl && a.passwordUrl === b.passwordUrl && a.pinUrl === b.pinUrl && a.passkeyId === b.passkeyId && a.verificationUrl === b.verificationUrl && a.recoverySecret === b.recoverySecret && a.isNewUser === b.isNewUser && ((_a = a.externalWalletVerification) == null ? void 0 : _a.signatureVerificationMessage) === ((_b = b.externalWalletVerification) == null ? void 0 : _b.signatureVerificationMessage) && ((_c = a.externalWalletVerification) == null ? void 0 : _c.walletAddress) === ((_d = b.externalWalletVerification) == null ? void 0 : _d.walletAddress) && ((_e = a.externalWalletVerification) == null ? void 0 : _e.walletType) === ((_f = b.externalWalletVerification) == null ? void 0 : _f.walletType) && ((_g = a.passkeyHints) == null ? void 0 : _g.length) === ((_h = b.passkeyHints) == null ? void 0 : _h.length) && ((_i = a.passkeyHints) != null ? _i : []).every(
256
+ return a.userId === b.userId && a.isPasskeySupported === b.isPasskeySupported && a.hasPasskey === b.hasPasskey && a.hasPassword === b.hasPassword && a.hasPin === b.hasPin && a.passkeyUrl === b.passkeyUrl && a.passkeyFullUrl === b.passkeyFullUrl && a.passkeyKnownDeviceUrl === b.passkeyKnownDeviceUrl && a.passwordUrl === b.passwordUrl && a.passwordFullUrl === b.passwordFullUrl && a.pinUrl === b.pinUrl && a.pinFullUrl === b.pinFullUrl && a.passkeyId === b.passkeyId && a.verificationUrl === b.verificationUrl && a.verificationFullUrl === b.verificationFullUrl && a.recoverySecret === b.recoverySecret && a.isNewUser === b.isNewUser && ((_a = a.externalWalletVerification) == null ? void 0 : _a.signatureVerificationMessage) === ((_b = b.externalWalletVerification) == null ? void 0 : _b.signatureVerificationMessage) && ((_c = a.externalWalletVerification) == null ? void 0 : _c.walletAddress) === ((_d = b.externalWalletVerification) == null ? void 0 : _d.walletAddress) && ((_e = a.externalWalletVerification) == null ? void 0 : _e.walletType) === ((_f = b.externalWalletVerification) == null ? void 0 : _f.walletType) && ((_g = a.passkeyHints) == null ? void 0 : _g.length) === ((_h = b.passkeyHints) == null ? void 0 : _h.length) && ((_i = a.passkeyHints) != null ? _i : []).every(
237
257
  (hint, i) => hint.useragent === b.passkeyHints[i].useragent && hint.aaguid === b.passkeyHints[i].aaguid
238
258
  );
239
259
  }
@@ -114,6 +114,7 @@ function createAuthStateMachine(paraCoreInterface) {
114
114
  shouldAutoCreateWallets: false,
115
115
  skipSessionRefreshOnSetup: false,
116
116
  isLegacy: false,
117
+ selectedOAuthMethod: null,
117
118
  retryAttempts: {},
118
119
  externalWalletInfo: void 0,
119
120
  externalWalletSignVerification: void 0
@@ -175,8 +176,12 @@ function createAuthStateMachine(paraCoreInterface) {
175
176
  shouldAutoCreateWallets: false,
176
177
  skipSessionRefreshOnSetup: false,
177
178
  isLegacy: false,
179
+ selectedOAuthMethod: null,
178
180
  retryAttempts: {}
179
181
  }),
182
+ on: {
183
+ LOGOUT: { target: ".unauthenticated", actions: ["resetState"] }
184
+ },
180
185
  states: {
181
186
  checking_state: {
182
187
  invoke: {
@@ -212,6 +217,7 @@ function createAuthStateMachine(paraCoreInterface) {
212
217
  }
213
218
  },
214
219
  unauthenticated: {
220
+ entry: [assign({ selectedOAuthMethod: null })],
215
221
  on: __spreadProps(__spreadValues({}, AUTH_RESTART_TRANSITIONS), {
216
222
  INITIALIZE_GUEST_MODE: "guest_mode",
217
223
  SESSION_IMPORTED: "authenticated"
@@ -335,6 +341,12 @@ function createAuthStateMachine(paraCoreInterface) {
335
341
  };
336
342
  }
337
343
  return null;
344
+ },
345
+ selectedOAuthMethod: ({ event }) => {
346
+ if (event.type === "AUTHENTICATE_OAUTH") {
347
+ return event.data.method;
348
+ }
349
+ return null;
338
350
  }
339
351
  }),
340
352
  "setIsLegacy"
@@ -47,6 +47,7 @@ const PARA_CORE_METHODS = [
47
47
  "signTransaction",
48
48
  "initiateOnRampTransaction",
49
49
  "getWalletBalance",
50
+ "requestFaucet",
50
51
  "issueJwt",
51
52
  "getLinkedAccounts",
52
53
  "accountLinkInProgress",
@@ -1,9 +1,9 @@
1
- import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams as VerifyExternalWalletParamsServer, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme, IssueJwtParams, TWalletScheme } from '@getpara/user-management-client';
1
+ import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams as VerifyExternalWalletParamsServer, SupportedAccountLinks, OnRampPurchase, BalancesConfig, IssueJwtParams, TWalletScheme } from '@getpara/user-management-client';
2
2
  import type { pki as pkiType } from 'node-forge';
3
- import { Ctx, Environment, Wallet, ConstructorOpts, CoreAuthInfo, CoreMethodParams, CoreMethodResponse, CoreInterface, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, OAuthResponse, AvailableWallet } from './types/index.js';
3
+ import { Ctx, Environment, Wallet, ConstructorOpts, CoreAuthInfo, CoreMethodParams, CoreMethodResponse, CoreInterface, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, OAuthResponse, AvailableWallet, PortalTheme } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
5
5
  import { AuthServiceInterface, ExternalWalletServiceInterface, PollingServiceInterface, PortalUrlServiceInterface, PregenWalletServiceInterface, SessionManagementServiceInterface, StateMachineInterface, WalletServiceInterface } from './types/serviceInterfaces.js';
6
- import type { WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, VerifyFarcasterParams, VerifyFarcasterResponse, VerifyNewAccountParams, VerifyTelegramParams, AddCredentialParams, GetNewCredentialAndUrlParams, GetNewCredentialAndUrlResponse, LoginExternalWalletParams, ResendVerificationCodeParams, SignUpOrLogInParams, VerifyOAuthProcessParams, VerifyOAuthProcessResponse, GetLoginUrlParams, GetOAuthUrlParams, PortalUrlOptions, PortalUrlType, ClaimPregenWalletsParams, CreatePregenWalletParams, CreatePregenWalletPerTypeParams, GetPregenWalletsParams, HasPregenWalletParams, UpdatePregenWalletIdentifierParams, CreateWalletParams, CreateWalletPerTypeParams, DistributeNewWalletShareParams, FindWalletByAddressParams, FindWalletIdParams, FindWalletParams, GetDisplayAddressParams, GetIdenticonHashParams, GetWalletBalanceParams, GetWalletsByTypeParams, RefreshShareParams, SetCurrentWalletIdsParams, SetWalletsParams, RefreshSessionParams, VerifyExternalWalletParams, InitExternalWalletProviderParams, ConnectExternalWalletParams, ExternalSignMessageParams, AuthenticateWithEmailOrPhoneParams, AuthenticateWithOAuthParams } from './services/types';
6
+ import type { WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, VerifyFarcasterParams, VerifyFarcasterResponse, VerifyNewAccountParams, VerifyTelegramParams, AddCredentialParams, GetNewCredentialAndUrlParams, GetNewCredentialAndUrlResponse, LoginExternalWalletParams, ResendVerificationCodeParams, SignUpOrLogInParams, VerifyOAuthProcessParams, VerifyOAuthProcessResponse, GetLoginUrlParams, GetOAuthUrlParams, PortalUrlOptions, PortalUrlType, ClaimPregenWalletsParams, CreatePregenWalletParams, CreatePregenWalletPerTypeParams, GetPregenWalletsParams, HasPregenWalletParams, UpdatePregenWalletIdentifierParams, CreateWalletParams, CreateWalletPerTypeParams, DistributeNewWalletShareParams, FindWalletByAddressParams, FindWalletIdParams, FindWalletParams, GetDisplayAddressParams, GetIdenticonHashParams, GetWalletBalanceParams, GetWalletsByTypeParams, RequestFaucetParams, RequestFaucetResponse, RefreshShareParams, SetCurrentWalletIdsParams, SetWalletsParams, RefreshSessionParams, VerifyExternalWalletParams, InitExternalWalletProviderParams, ConnectExternalWalletParams, ExternalSignMessageParams, AuthenticateWithEmailOrPhoneParams, AuthenticateWithOAuthParams } from './services/types';
7
7
  import { CorePhase, StateSnapshot } from './state/types/core.js';
8
8
  import { AuthPhase } from './state/types/auth.js';
9
9
  import { WalletPhase } from './state/types/wallet.js';
@@ -198,7 +198,7 @@ export declare abstract class ParaCore implements CoreInterface {
198
198
  * Theme to use for the portal
199
199
  * WARNING: This theme will override portal options set within the developer portal.
200
200
  */
201
- portalTheme?: Theme;
201
+ portalTheme?: PortalTheme;
202
202
  /**
203
203
  * Whether or not to treat external wallets as connections only, skipping all Para functionality.
204
204
  */
@@ -258,7 +258,7 @@ export declare abstract class ParaCore implements CoreInterface {
258
258
  getAddress(walletId?: string): string | undefined;
259
259
  protected abstract getPlatformUtils(): PlatformUtils;
260
260
  abstract isPasskeySupported(): Promise<boolean>;
261
- protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<string>;
261
+ protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<import("./services/types").ConstructPortalUrlResult>;
262
262
  static resolveEnvironment(env: Environment | undefined, apiKey: string | undefined): Environment;
263
263
  /**
264
264
  * Constructs a new `ParaCore` instance.
@@ -746,6 +746,14 @@ export declare abstract class ParaCore implements CoreInterface {
746
746
  private getTransactionReviewUrl;
747
747
  private getOnRampTransactionUrl;
748
748
  getWalletBalance(params: GetWalletBalanceParams): Promise<string>;
749
+ /**
750
+ * Requests testnet funds from the faucet for the specified wallet.
751
+ * @param {RequestFaucetParams} params the options object.
752
+ * @param {string} params.walletId the id of the wallet to fund.
753
+ * @param {string} [params.chain] optional chain identifier to target a specific testnet.
754
+ * @returns the faucet transaction details, including the transaction hash and amount sent.
755
+ */
756
+ requestFaucet(params: RequestFaucetParams): Promise<RequestFaucetResponse>;
749
757
  /**
750
758
  * Signs a message using one of the current wallets.
751
759
  *
@@ -838,7 +846,7 @@ export declare abstract class ParaCore implements CoreInterface {
838
846
  * @param {Object} opts the options object
839
847
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
840
848
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
841
- * @param {Theme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
849
+ * @param {PortalTheme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
842
850
  * @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
843
851
  */
844
852
  protected getLoginUrl(params: GetLoginUrlParams): Promise<string>;
@@ -858,6 +866,8 @@ export declare abstract class ParaCore implements CoreInterface {
858
866
  config?: BalancesConfig;
859
867
  refetch?: boolean;
860
868
  }): Promise<import("@getpara/user-management-client").ProfileBalance>;
861
- protected sendLoginCode(): Promise<void>;
869
+ protected sendLoginCode(): Promise<{
870
+ userId: string;
871
+ }>;
862
872
  exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
863
873
  }
@@ -5,7 +5,7 @@ import { AuthService } from './AuthService.js';
5
5
  import { PollingService } from './PollingService.js';
6
6
  import { PregenWalletService } from './PregenWalletService.js';
7
7
  import { ExternalWalletService } from './ExternalWalletService.js';
8
- import type { AssertIsValidWalletIdMethod, AssertIsValidWalletTypeMethod, CreateWalletMethod, CreateWalletPerTypeMethod, DistributeNewWalletShareMethod, FetchWalletsMethod, FindWalletByAddressMethod, FindWalletIdMethod, FindWalletMethod, GetDisplayAddressMethod, GetIdenticonHashMethod, GetTypesToCreateMethod, GetUserShareMethod, GetWalletBalanceMethod, GetWalletsByTypeMethod, IsWalletOwnedMethod, IsWalletSupportedMethod, IsWalletUsableMethod, RefreshShareMethod, SetCurrentWalletIdsMethod, SetUserShareMethod, SetWalletsMethod } from './types/WalletServiceTypes.js';
8
+ import type { AssertIsValidWalletIdMethod, AssertIsValidWalletTypeMethod, CreateWalletMethod, CreateWalletPerTypeMethod, DistributeNewWalletShareMethod, FetchWalletsMethod, FindWalletByAddressMethod, FindWalletIdMethod, FindWalletMethod, GetDisplayAddressMethod, GetIdenticonHashMethod, GetTypesToCreateMethod, GetUserShareMethod, GetWalletBalanceMethod, GetWalletsByTypeMethod, RequestFaucetMethod, IsWalletOwnedMethod, IsWalletSupportedMethod, IsWalletUsableMethod, RefreshShareMethod, SetCurrentWalletIdsMethod, SetUserShareMethod, SetWalletsMethod } from './types/WalletServiceTypes.js';
9
9
  export declare class WalletService {
10
10
  #private;
11
11
  get wallets(): Record<string, Wallet>;
@@ -48,6 +48,7 @@ export declare class WalletService {
48
48
  assertIsValidWalletType: AssertIsValidWalletTypeMethod;
49
49
  fetchWallets: FetchWalletsMethod;
50
50
  getWalletBalance: GetWalletBalanceMethod;
51
+ requestFaucet: RequestFaucetMethod;
51
52
  getUserShare: GetUserShareMethod;
52
53
  setUserShare: SetUserShareMethod;
53
54
  distributeNewWalletShare: DistributeNewWalletShareMethod;
@@ -18,8 +18,10 @@ export interface OAuthRedirectCallbacks {
18
18
  /**
19
19
  * Called when an OAuth URL is generated for redirect.
20
20
  * If this is provided onOAuthPopup will not be called.
21
+ * @param url - The (possibly shortened) URL
22
+ * @param fullUrl - The full unshortened URL, for preloaded iframe navigation
21
23
  */
22
- onOAuthUrl?: (url: string) => void;
24
+ onOAuthUrl?: (url: string, fullUrl?: string) => void;
23
25
  }
24
26
  export type SetAuthMethod = (_: PrimaryAuth, __?: {
25
27
  extras?: AuthExtras;
@@ -133,6 +135,7 @@ export interface GetNewCredentialAndUrlParams extends WithCustomTheme, WithShort
133
135
  export interface GetNewCredentialAndUrlResponse {
134
136
  credentialId: string;
135
137
  url?: string;
138
+ fullUrl?: string;
136
139
  }
137
140
  export type GetNewCredentialAndUrlMethod = (_?: GetNewCredentialAndUrlParams) => Promise<GetNewCredentialAndUrlResponse>;
138
141
  export interface AddCredentialParams {
@@ -1,5 +1,5 @@
1
- import type { TAuthMethod, Theme, TOAuthMethod } from '@getpara/user-management-client';
2
- import type { AccountLinkInProgress, WithAuthMethod, WithCustomTheme, WithSessionId, WithShorten } from '../../types/index.js';
1
+ import type { TAuthMethod, TOAuthMethod } from '@getpara/user-management-client';
2
+ import type { AccountLinkInProgress, PortalTheme, WithAuthMethod, WithCustomTheme, WithSessionId, WithShorten } from '../../types/index.js';
3
3
  type Device = {
4
4
  sessionId: string;
5
5
  encryptionKey: string;
@@ -11,7 +11,7 @@ export type PortalUrlOptions = {
11
11
  thisDevice?: Device;
12
12
  newDevice?: Device;
13
13
  sessionId?: string;
14
- portalTheme?: Theme;
14
+ portalTheme?: PortalTheme;
15
15
  pathId?: string;
16
16
  shorten?: boolean;
17
17
  isEmbedded?: boolean;
@@ -23,9 +23,13 @@ export type PortalUrlOptions = {
23
23
  addNewCredentialPasskeyId?: string;
24
24
  useLegacyUrl?: boolean;
25
25
  };
26
- export type ConstructPortalUrlMethod = (type: PortalUrlType, opts?: PortalUrlOptions) => Promise<string>;
26
+ export type ConstructPortalUrlResult = {
27
+ url: string;
28
+ fullUrl: string;
29
+ };
30
+ export type ConstructPortalUrlMethod = (type: PortalUrlType, opts?: PortalUrlOptions) => Promise<ConstructPortalUrlResult>;
27
31
  export type GetLoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & WithSessionId;
28
- export type GetLoginUrlMethod = (_: GetLoginUrlParams) => Promise<string>;
32
+ export type GetLoginUrlMethod = (_: GetLoginUrlParams) => Promise<ConstructPortalUrlResult>;
29
33
  export type BaseOAuthUrlParams = {
30
34
  /**
31
35
  * The third-party OAuth service.
@@ -106,4 +106,16 @@ export interface DistributeNewWalletShareParams {
106
106
  forceRefresh?: boolean;
107
107
  }
108
108
  export type DistributeNewWalletShareMethod = (_: DistributeNewWalletShareParams) => Promise<string>;
109
+ export interface RequestFaucetParams {
110
+ walletId: string;
111
+ chain?: string;
112
+ }
113
+ export interface RequestFaucetResponse {
114
+ transactionHash: string;
115
+ amount: string;
116
+ chain: string;
117
+ walletId: string;
118
+ address: string;
119
+ }
120
+ export type RequestFaucetMethod = (_: RequestFaucetParams) => Promise<RequestFaucetResponse>;
109
121
  export {};
@@ -623,8 +623,15 @@ export declare function createAuthStateMachine(paraCoreInterface: StateMachineIn
623
623
  shouldAutoCreateWallets: false;
624
624
  skipSessionRefreshOnSetup: false;
625
625
  isLegacy: false;
626
+ selectedOAuthMethod: any;
626
627
  retryAttempts: {};
627
628
  };
629
+ readonly on: {
630
+ readonly LOGOUT: {
631
+ readonly target: ".unauthenticated";
632
+ readonly actions: readonly ["resetState"];
633
+ };
634
+ };
628
635
  readonly states: {
629
636
  readonly checking_state: {
630
637
  readonly invoke: {
@@ -660,6 +667,110 @@ export declare function createAuthStateMachine(paraCoreInterface: StateMachineIn
660
667
  };
661
668
  };
662
669
  readonly unauthenticated: {
670
+ readonly entry: readonly [import("xstate").ActionFunction<AuthContext, AuthEvents, AuthEvents, undefined, import("xstate").Values<{
671
+ connectExternalWallet: {
672
+ src: "connectExternalWallet";
673
+ logic: import("xstate").PromiseActorLogic<import("../../index.js").PerformConnectExternalWalletResponse, import("../../index.js").ConnectExternalWalletParams, import("xstate").EventObject>;
674
+ id: string;
675
+ };
676
+ verifyNewAccount: {
677
+ src: "verifyNewAccount";
678
+ logic: import("xstate").PromiseActorLogic<{
679
+ authState: ServerAuthState;
680
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls;
681
+ }, import("../../services/types/VerificationFlowServiceTypes.js").PerformVerifyNewAccountParams, import("xstate").EventObject>;
682
+ id: string;
683
+ };
684
+ verifyExternalWallet: {
685
+ src: "verifyExternalWallet";
686
+ logic: import("xstate").PromiseActorLogic<{
687
+ authState: ServerAuthState;
688
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls;
689
+ }, import("../../services/types/VerificationFlowServiceTypes.js").VerifyExternalWalletParams, import("xstate").EventObject>;
690
+ id: string;
691
+ };
692
+ authenticateWithEmailOrPhone: {
693
+ src: "authenticateWithEmailOrPhone";
694
+ logic: import("xstate").PromiseActorLogic<{
695
+ authState: ServerAuthState;
696
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls;
697
+ }, import("../../index.js").SignUpOrLogInParams, import("xstate").EventObject>;
698
+ id: string;
699
+ };
700
+ polling: {
701
+ src: "polling";
702
+ logic: import("xstate").CallbackActorLogic<any, import("../../index.js").PollingConfig<any>, import("xstate").EventObject>;
703
+ id: string;
704
+ };
705
+ checkUserState: {
706
+ src: "checkUserState";
707
+ logic: import("xstate").PromiseActorLogic<{
708
+ isAuthenticated: boolean;
709
+ isFullyLoggedIn: boolean;
710
+ isGuestMode: boolean;
711
+ }, {}, import("xstate").EventObject>;
712
+ id: string;
713
+ };
714
+ authenticateWithExternalWallet: {
715
+ src: "authenticateWithExternalWallet";
716
+ logic: import("xstate").PromiseActorLogic<{
717
+ authState: ServerAuthState;
718
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls;
719
+ }, import("../../index.js").LoginExternalWalletParams, import("xstate").EventObject>;
720
+ id: string;
721
+ };
722
+ authenticateWithTelegram: {
723
+ src: "authenticateWithTelegram";
724
+ logic: import("xstate").PromiseActorLogic<AuthenticationOutput, import("../../index.js").WaitForTelegramEventParams, import("xstate").EventObject>;
725
+ id: string;
726
+ };
727
+ authenticateWithTelegramLegacy: {
728
+ src: "authenticateWithTelegramLegacy";
729
+ logic: import("xstate").PromiseActorLogic<{
730
+ authState: ServerAuthState;
731
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls;
732
+ }, import("../../services/types/VerificationFlowServiceTypes.js").VerifyTelegramParams, import("xstate").EventObject>;
733
+ id: string;
734
+ };
735
+ authenticateWithFarcaster: {
736
+ src: "authenticateWithFarcaster";
737
+ logic: import("xstate").PromiseActorLogic<AuthenticationOutput, import("../../index.js").WaitForFarcasterEventParams, import("xstate").EventObject>;
738
+ id: string;
739
+ };
740
+ authenticateWithFarcasterLegacy: {
741
+ src: "authenticateWithFarcasterLegacy";
742
+ logic: import("xstate").PromiseActorLogic<import("../../services/types/VerificationFlowServiceTypes.js").PerformVerifyFarcasterResponse, import("../../services/types/VerificationFlowServiceTypes.js").VerifyFarcasterParams, import("xstate").EventObject>;
743
+ id: string;
744
+ };
745
+ processAuthentication: {
746
+ src: "processAuthentication";
747
+ logic: import("xstate").PromiseActorLogic<AuthState, {
748
+ authState: ServerAuthState;
749
+ opts: import("../../types/util.js").WithCustomTheme & import("../../types/util.js").WithUseShortUrls & {
750
+ sessionLookupId?: string;
751
+ isFromExternalWallet?: boolean;
752
+ };
753
+ }, import("xstate").EventObject>;
754
+ id: string;
755
+ };
756
+ signExternalWalletVerification: {
757
+ src: "signExternalWalletVerification";
758
+ logic: import("xstate").PromiseActorLogic<BaseVerifyExternalWalletParams, import("../../index.js").ExternalSignMessageParams & {
759
+ externalWallet: import("@getpara/user-management-client").ExternalWalletInfo;
760
+ }, import("xstate").EventObject>;
761
+ id: string;
762
+ };
763
+ switchExternalWallet: {
764
+ src: "switchExternalWallet";
765
+ logic: import("xstate").PromiseActorLogic<import("../../index.js").PerformSwitchExternalWalletResponse, import("../../index.js").WatchWalletChangeCallbackParams, import("xstate").EventObject>;
766
+ id: string;
767
+ };
768
+ logoutActor: {
769
+ src: "logoutActor";
770
+ logic: import("xstate").PromiseActorLogic<void, {}, import("xstate").EventObject>;
771
+ id: string;
772
+ };
773
+ }>, never, never, never, never>];
663
774
  readonly on: {
664
775
  readonly INITIALIZE_GUEST_MODE: "guest_mode";
665
776
  readonly SESSION_IMPORTED: "authenticated";
@@ -731,7 +842,7 @@ export declare function createAuthStateMachine(paraCoreInterface: StateMachineIn
731
842
  data: {
732
843
  authState: ServerAuthState;
733
844
  sessionLookupId: string;
734
- portalTheme: import("@getpara/user-management-client").Theme;
845
+ portalTheme: import("../../types/util.js").PortalTheme;
735
846
  useShortUrls: boolean;
736
847
  };
737
848
  finished: boolean;