@startbahn/startrail-sdk-js 1.28.0 → 1.28.1

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.
@@ -165158,7 +165158,6 @@ class Service {
165158
165158
  this.wallet.start(new torus_1.default(Object.assign(Object.assign({}, this.patchedConfig), { wallet: 'startrail' })));
165159
165159
  }
165160
165160
  // Intentionally sync to avoid init and login at the same action which causes pop-up blocking alert
165161
- this.wallet.init();
165162
165161
  this.tx = new transaction_1.default((config === null || config === void 0 ? void 0 : config.apiPath) || constant_1.STARTRAIL_API);
165163
165162
  }
165164
165163
  /**
@@ -165167,14 +165166,10 @@ class Service {
165167
165166
  */
165168
165167
  login(overwriteConfig) {
165169
165168
  return __awaiter(this, void 0, void 0, function* () {
165170
- // Case that initiated with torusEmbed at mount but change wallet with metamask at login timing
165171
- // TODO: To be more strucured when more wallets are introduced
165172
- if ((overwriteConfig === null || overwriteConfig === void 0 ? void 0 : overwriteConfig.wallet) && (overwriteConfig === null || overwriteConfig === void 0 ? void 0 : overwriteConfig.wallet) !== 'startrail' && this.wallet.wallet instanceof torus_1.default) {
165173
- this.wallet.clearInit();
165174
- this.wallet.start(new metamask_1.default(Object.assign(Object.assign({}, this.patchedConfig), { wallet: 'metamask' })));
165175
- }
165169
+ if (overwriteConfig)
165170
+ this.wallet.overwriteConfig(overwriteConfig);
165176
165171
  try {
165177
- return yield this.wallet.login(overwriteConfig);
165172
+ return yield this.wallet.login();
165178
165173
  }
165179
165174
  catch (error) {
165180
165175
  yield this.wallet.logout();
@@ -165986,23 +165981,6 @@ class WalletBuilder {
165986
165981
  yield this.wallet.overwriteConfig(partialConfig);
165987
165982
  });
165988
165983
  }
165989
- /**
165990
- * initialise wallet instance
165991
- */
165992
- init() {
165993
- return __awaiter(this, void 0, void 0, function* () {
165994
- if (this.wallet === undefined)
165995
- throw new error_1.CustomError(Error(constant_1.StartrailSdkErrorCodeEnum.WALLET_NOT_INITIALIZED)).sdk();
165996
- try {
165997
- yield this.wallet.init();
165998
- }
165999
- catch (e) {
166000
- if (e.errorCode !== constant_1.StartrailSdkErrorCodeEnum.WALLET_NOT_SUPPORT_FUNCTION) {
166001
- throw e;
166002
- }
166003
- }
166004
- });
166005
- }
166006
165984
  /**
166007
165985
  * Set your wallet and return EOA
166008
165986
  */
@@ -166166,11 +166144,6 @@ class Wallet {
166166
166144
  }))();
166167
166145
  });
166168
166146
  }
166169
- init() {
166170
- return __awaiter(this, void 0, void 0, function* () {
166171
- throw new error_1.CustomError(Error(constant_1.StartrailSdkErrorCodeEnum.WALLET_NOT_SUPPORT_FUNCTION)).sdk();
166172
- });
166173
- }
166174
166147
  logout() {
166175
166148
  return __awaiter(this, void 0, void 0, function* () {
166176
166149
  throw new error_1.CustomError(Error(constant_1.StartrailSdkErrorCodeEnum.WALLET_NOT_SUPPORT_FUNCTION)).sdk();
@@ -166377,7 +166350,7 @@ class Torus extends base_1.default {
166377
166350
  this.torusSDK = new torus_embed_1.default({});
166378
166351
  this.configContext = new torus_1.default(config);
166379
166352
  }
166380
- init() {
166353
+ login() {
166381
166354
  return __awaiter(this, void 0, void 0, function* () {
166382
166355
  yield this.configContext.updateRpcEndpoint();
166383
166356
  try {
@@ -166388,45 +166361,12 @@ class Torus extends base_1.default {
166388
166361
  throw error;
166389
166362
  }
166390
166363
  this.provider = this.torusSDK.provider;
166391
- });
166392
- }
166393
- /**
166394
- * torusEmbed.init() is called in service constructor without promise/async to
166395
- * initiate login() immediately after user action, which enables removing pop-up block.
166396
- */
166397
- login(partialConfig) {
166398
- return __awaiter(this, void 0, void 0, function* () {
166399
- if (partialConfig)
166400
- yield this.overwriteConfig(partialConfig); // this opens popup as async makes time gap between user action and login
166401
- const login = () => __awaiter(this, void 0, void 0, function* () {
166364
+ try {
166402
166365
  return yield this.torusSDK.login(this.configContext.getLoginConfig());
166403
- });
166404
- // Wait until torusSDK is initialized for the case that new Startrail-sdk() and login() is initiated
166405
- // by the same user action in clients' application
166406
- let cnt = 0;
166407
- return new Promise((resolve, reject) => {
166408
- const intervalId = setInterval(() => {
166409
- if (cnt > 30) {
166410
- clearInterval(intervalId);
166411
- reject(new Error(constant_1.ERROR_MESSAGE.TORUS_FAILS_INIT));
166412
- }
166413
- if (this.torusSDK.isInitialized) {
166414
- clearInterval(intervalId);
166415
- try {
166416
- const res = login();
166417
- resolve(res);
166418
- }
166419
- catch (e) {
166420
- reject(e);
166421
- }
166422
- }
166423
- cnt++;
166424
- }, 1000);
166425
- }).catch((e) => {
166366
+ }
166367
+ catch (e) {
166426
166368
  throw new error_1.CustomError(e).torus();
166427
- }).then((eoas) => {
166428
- return eoas;
166429
- });
166369
+ }
166430
166370
  });
166431
166371
  }
166432
166372
  /**
@@ -166434,11 +166374,7 @@ class Torus extends base_1.default {
166434
166374
  */
166435
166375
  overwriteConfig(partialConfig) {
166436
166376
  return __awaiter(this, void 0, void 0, function* () {
166437
- const { isOverwrite } = this.configContext.overwriteConfig(partialConfig);
166438
- if (!isOverwrite)
166439
- return;
166440
- this.clearInit();
166441
- yield this._reInit();
166377
+ this.configContext.overwriteConfig(partialConfig);
166442
166378
  });
166443
166379
  }
166444
166380
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startbahn/startrail-sdk-js",
3
- "version": "1.28.0",
3
+ "version": "1.28.1",
4
4
  "description": "Startrail Api for JS SDK",
5
5
  "main": "dist/startrail-sdk.js",
6
6
  "unpkg": "dist/startrail-sdk.js",
@@ -259,7 +259,6 @@ declare module '@startbahn/startrail-sdk-js/types' {
259
259
  authAction?: AuthAction;
260
260
  lang?: string;
261
261
  loginProvider?: LoginProvider;
262
- wallet?: WalletType;
263
262
  }
264
263
  export interface PreTorusConfig {
265
264
  apiPath: string;
@@ -826,10 +825,6 @@ declare module '@startbahn/startrail-sdk-js/walletBuilder' {
826
825
  * Overwrite config that has persistency such as Torus
827
826
  */
828
827
  overwriteConfig(partialConfig: OverwriteStartrailSDKConfig): Promise<void>;
829
- /**
830
- * initialise wallet instance
831
- */
832
- init(): Promise<void>;
833
828
  /**
834
829
  * Set your wallet and return EOA
835
830
  */
@@ -1065,7 +1060,6 @@ declare module '@startbahn/startrail-sdk-js/wallets/base' {
1065
1060
  abstract getUserInfo(): Promise<UserInfo>;
1066
1061
  signMessage(params: MessageToBeSigned, signMethod?: SignMethod): Promise<string>;
1067
1062
  signTypedDataMessage(eoa: string, typedData: EIP712TypedData): Promise<string>;
1068
- init(): Promise<void>;
1069
1063
  logout(): Promise<void>;
1070
1064
  switchLanguage(): Promise<void | boolean>;
1071
1065
  overwriteConfig(partialConfig: OverwriteStartrailSDKConfig): Promise<void>;