@getpara/core-sdk 2.0.0-alpha.18 → 2.0.0-alpha.20

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.
@@ -326,6 +326,7 @@ const _ParaCore = class _ParaCore {
326
326
  this.portalTheme = opts.portalTheme;
327
327
  this.platformUtils = this.getPlatformUtils();
328
328
  this.disableProviderModal = this.platformUtils.disableProviderModal;
329
+ this.fetchPregenWalletsOverride = opts.fetchPregenWalletsOverride;
329
330
  if (opts.useStorageOverrides) {
330
331
  this.localStorageGetItem = opts.localStorageGetItemOverride;
331
332
  this.localStorageSetItem = opts.localStorageSetItemOverride;
@@ -2786,6 +2787,13 @@ const _ParaCore = class _ParaCore {
2786
2787
  return __async(this, null, function* () {
2787
2788
  var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2788
2789
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2790
+ const authInfo = serverAuthState.auth;
2791
+ if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
2792
+ const { userShare } = yield this.fetchPregenWalletsOverride({ pregenId: authInfo });
2793
+ if (userShare) {
2794
+ yield this.setUserShare(userShare);
2795
+ }
2796
+ }
2789
2797
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2790
2798
  });
2791
2799
  }
@@ -3018,7 +3026,8 @@ prepareLoginState_fn = function(_0, _1) {
3018
3026
  passwordUrl: yield this.constructPortalUrl("loginPassword", {
3019
3027
  sessionId: sessionLookupId,
3020
3028
  shorten,
3021
- portalTheme
3029
+ portalTheme,
3030
+ params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
3022
3031
  })
3023
3032
  } : {});
3024
3033
  });
@@ -39,7 +39,7 @@ __export(constants_exports, {
39
39
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
40
40
  });
41
41
  module.exports = __toCommonJS(constants_exports);
42
- const PARA_CORE_VERSION = "2.0.0-alpha.18";
42
+ const PARA_CORE_VERSION = "2.0.0-alpha.20";
43
43
  const PREFIX = "@CAPSULE/";
44
44
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
45
45
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -27,12 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var formatting_exports = {};
29
29
  __export(formatting_exports, {
30
+ compressPubkey: () => compressPubkey,
30
31
  decimalToHex: () => decimalToHex,
31
32
  getCosmosAddress: () => getCosmosAddress,
32
33
  hexStringToBase64: () => hexStringToBase64,
33
34
  hexToDecimal: () => hexToDecimal,
34
35
  hexToSignature: () => hexToSignature,
35
36
  hexToUint8Array: () => hexToUint8Array,
37
+ rawSecp256k1PubkeyToRawAddress: () => rawSecp256k1PubkeyToRawAddress,
36
38
  truncateAddress: () => truncateAddress
37
39
  });
38
40
  module.exports = __toCommonJS(formatting_exports);
@@ -102,11 +104,13 @@ function truncateAddress(str, addressType, {
102
104
  }
103
105
  // Annotate the CommonJS export names for ESM import in node:
104
106
  0 && (module.exports = {
107
+ compressPubkey,
105
108
  decimalToHex,
106
109
  getCosmosAddress,
107
110
  hexStringToBase64,
108
111
  hexToDecimal,
109
112
  hexToSignature,
110
113
  hexToUint8Array,
114
+ rawSecp256k1PubkeyToRawAddress,
111
115
  truncateAddress
112
116
  });
@@ -33,7 +33,8 @@ import {
33
33
  toPregenTypeAndId,
34
34
  toPregenIds,
35
35
  isExternalWallet,
36
- WALLET_TYPES
36
+ WALLET_TYPES,
37
+ isPregenAuth
37
38
  } from "@getpara/user-management-client";
38
39
  import forge from "node-forge";
39
40
  const { pki, jsbn } = forge;
@@ -289,6 +290,7 @@ const _ParaCore = class _ParaCore {
289
290
  this.portalTheme = opts.portalTheme;
290
291
  this.platformUtils = this.getPlatformUtils();
291
292
  this.disableProviderModal = this.platformUtils.disableProviderModal;
293
+ this.fetchPregenWalletsOverride = opts.fetchPregenWalletsOverride;
292
294
  if (opts.useStorageOverrides) {
293
295
  this.localStorageGetItem = opts.localStorageGetItemOverride;
294
296
  this.localStorageSetItem = opts.localStorageSetItemOverride;
@@ -2749,6 +2751,13 @@ const _ParaCore = class _ParaCore {
2749
2751
  return __async(this, null, function* () {
2750
2752
  var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2751
2753
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2754
+ const authInfo = serverAuthState.auth;
2755
+ if (this.fetchPregenWalletsOverride && isPregenAuth(authInfo)) {
2756
+ const { userShare } = yield this.fetchPregenWalletsOverride({ pregenId: authInfo });
2757
+ if (userShare) {
2758
+ yield this.setUserShare(userShare);
2759
+ }
2760
+ }
2752
2761
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2753
2762
  });
2754
2763
  }
@@ -2981,7 +2990,8 @@ prepareLoginState_fn = function(_0, _1) {
2981
2990
  passwordUrl: yield this.constructPortalUrl("loginPassword", {
2982
2991
  sessionId: sessionLookupId,
2983
2992
  shorten,
2984
- portalTheme
2993
+ portalTheme,
2994
+ params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
2985
2995
  })
2986
2996
  } : {});
2987
2997
  });
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.18";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.20";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
5
5
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -64,11 +64,13 @@ function truncateAddress(str, addressType, {
64
64
  return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
65
65
  }
66
66
  export {
67
+ compressPubkey,
67
68
  decimalToHex,
68
69
  getCosmosAddress,
69
70
  hexStringToBase64,
70
71
  hexToDecimal,
71
72
  hexToSignature,
72
73
  hexToUint8Array,
74
+ rawSecp256k1PubkeyToRawAddress,
73
75
  truncateAddress
74
76
  };
@@ -120,6 +120,7 @@ export declare abstract class ParaCore implements CoreInterface {
120
120
  */
121
121
  externalWalletConnectionOnly?: boolean;
122
122
  private disableProviderModal?;
123
+ private fetchPregenWalletsOverride?;
123
124
  get isNoWalletConfig(): boolean;
124
125
  get supportedWalletTypes(): SupportedWalletTypes;
125
126
  get cosmosPrefix(): string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { ParaCore } from './ParaCore.js';
2
- export { type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TOAuthMethod, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, } from '@getpara/user-management-client';
2
+ export { type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TOAuthMethod, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type PregenAuth, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, } from '@getpara/user-management-client';
3
3
  export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, } from './types/index.js';
4
4
  export * from './types/coreApi.js';
5
5
  export * from './types/events.js';
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, TWalletScheme, TWalletType } from '@getpara/user-management-client';
2
+ import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType } from '@getpara/user-management-client';
3
3
  import { Theme } from './theme.js';
4
4
  export declare enum Environment {
5
5
  DEV = "DEV",
@@ -140,4 +140,12 @@ export interface ConstructorOpts {
140
140
  * Partner ID set in the Para Portal to track analytics for legacy SDK versions. This variable is unused outside of the Para Portal.
141
141
  */
142
142
  portalPartnerId?: string;
143
+ /**
144
+ * An optional function that fetches the pregenerated wallets for a given identifier so a user can claim them on account creation.
145
+ */
146
+ fetchPregenWalletsOverride?: (opts: {
147
+ pregenId: PregenAuth;
148
+ }) => Promise<{
149
+ userShare?: string;
150
+ }>;
143
151
  }
@@ -24,6 +24,7 @@ export type PortalUrlOptions = {
24
24
  portalTheme?: Theme;
25
25
  pathId?: string;
26
26
  shorten?: boolean;
27
+ isEmbedded?: boolean;
27
28
  };
28
29
  export type WithAuthMethod = {
29
30
  /**
@@ -10,6 +10,8 @@ export declare function hexToSignature(hexSig: string): Signature;
10
10
  export declare function hexToUint8Array(hex: string): Uint8Array;
11
11
  export declare function hexToDecimal(hex: string): string;
12
12
  export declare function decimalToHex(decimal: string): Hex;
13
+ export declare function compressPubkey(pubkey: Uint8Array): Uint8Array;
14
+ export declare function rawSecp256k1PubkeyToRawAddress(pubkeyData: Uint8Array): Uint8Array;
13
15
  export declare function getCosmosAddress(publicKey: string, prefix: string): string;
14
16
  export declare function truncateAddress(str: string, addressType: TWalletType, { prefix, targetLength, }?: {
15
17
  prefix?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.18",
3
+ "version": "2.0.0-alpha.20",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@celo/utils": "^8.0.2",
11
11
  "@cosmjs/encoding": "^0.32.4",
12
12
  "@ethereumjs/util": "^9.1.0",
13
- "@getpara/user-management-client": "2.0.0-alpha.18",
13
+ "@getpara/user-management-client": "2.0.0-alpha.20",
14
14
  "@noble/hashes": "^1.5.0",
15
15
  "base64url": "^3.0.1",
16
16
  "libphonenumber-js": "1.11.2",
@@ -41,5 +41,5 @@
41
41
  "require": "./dist/cjs/index.js"
42
42
  }
43
43
  },
44
- "gitHead": "2333bc727fe61593821d448ee12facaee230c4b0"
44
+ "gitHead": "4c8d918b9fc387476968bfc08524fe1a8b6ec83b"
45
45
  }