@startbahn/startrail-sdk-js 1.31.0-beta.2 → 1.31.0-beta.4

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.
@@ -131033,27 +131033,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
131033
131033
  });
131034
131034
  };
131035
131035
  Object.defineProperty(exports, "__esModule", { value: true });
131036
- exports.getCallabckUrl = void 0;
131037
131036
  /* eslint-disable no-unused-vars */
131038
131037
  const util_1 = __webpack_require__(/*! ./util */ "./src/configContext/util.ts");
131039
- const util_2 = __webpack_require__(/*! ../util */ "./src/util.ts");
131040
131038
  const constant_1 = __webpack_require__(/*! ../constant */ "./src/constant.ts");
131041
- const globalThis = __webpack_require__(/*! globalthis */ "./node_modules/globalthis/index.js")();
131039
+ const torusSocialLogin_1 = __webpack_require__(/*! ./torusSocialLogin */ "./src/configContext/torusSocialLogin.ts");
131042
131040
  /**
131043
131041
  * Config properties for torus-embed init()
131044
131042
  */
131045
131043
  const torusConfig = (config) => {
131046
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
131044
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
131047
131045
  return {
131048
131046
  buildEnv: config.network.torusEnv,
131049
131047
  skipTKey: true,
131050
- enabledVerifiers: {
131051
- facebook: false,
131052
- reddit: false,
131053
- twitch: false,
131054
- discord: false
131055
- },
131056
- enableLogging: false,
131048
+ // enabledVerifiers: {
131049
+ // facebook: false,
131050
+ // reddit: false,
131051
+ // twitch: false,
131052
+ // discord: false
131053
+ // },
131054
+ enableLogging: true,
131057
131055
  network: config.network.ethereumNetwork,
131058
131056
  showTorusButton: false,
131059
131057
  whiteLabel: {
@@ -131065,6 +131063,7 @@ const torusConfig = (config) => {
131065
131063
  }
131066
131064
  },
131067
131065
  defaultLanguage: config.lang,
131066
+ // FIXME: this is a bug on Torus. They set the logoLight for light background on passwordless email other way around.
131068
131067
  logoDark: ((_a = config === null || config === void 0 ? void 0 : config.customUi) === null || _a === void 0 ? void 0 : _a.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black,
131069
131068
  logoLight: ((_b = config === null || config === void 0 ? void 0 : config.customUi) === null || _b === void 0 ? void 0 : _b.logoWhiteUrl) || ((_c = config === null || config === void 0 ? void 0 : config.customUi) === null || _c === void 0 ? void 0 : _c.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).white,
131070
131069
  topupHide: true,
@@ -131080,119 +131079,48 @@ const torusConfig = (config) => {
131080
131079
  disclaimerHide: true,
131081
131080
  customTranslations: formatConfigForTorusUI(config) // Most properties for UI customization are here.
131082
131081
  },
131083
- loginConfig: {
131082
+ // showOnModal is set to show social login on modal
131083
+ loginConfig: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, torusSocialLogin_1.getModalConfigByLoginProviders('apple', config.loginProvider)[config.network.appEnv]), torusSocialLogin_1.getModalConfigByLoginProviders('facebook', config.loginProvider)[config.network.appEnv]), torusSocialLogin_1.getModalConfigByLoginProviders('google', config.loginProvider)[config.network.appEnv]), torusSocialLogin_1.getModalConfigByLoginProviders('twitter', config.loginProvider)[config.network.appEnv]), torusSocialLogin_1.getModalConfigByLoginProviders('email_passwordless', config.loginProvider)[config.network.appEnv]), torusSocialLogin_1.getCustomLoginConfig(config)), {
131084
+ // Deactivating default Social Login. or else it will show on modal
131084
131085
  discord: {
131085
131086
  showOnModal: false
131086
- },
131087
- 'discord-lrc': {
131088
- showOnModal: false
131089
- },
131090
- facebook: {
131091
- showOnModal: false
131092
- },
131093
- 'facebook-lrc': {
131094
- showOnModal: false
131095
- },
131096
- // Deactivate Google logo only for user coming from Auth0 signup mail verification to encourage Auth0 login under the name of better UX
131097
- google: {
131098
- showOnModal: config.loginProvider.google
131099
- },
131100
- 'google-lrc': {
131101
- showOnModal: config.loginProvider.google
131102
- },
131103
- reddit: {
131104
- showOnModal: false
131105
- },
131106
- 'reddit-lrc': {
131087
+ }, 'discord-lrc': {
131107
131088
  showOnModal: false
131108
- },
131109
- 'torus-auth0-apple': {
131089
+ }, reddit: {
131110
131090
  showOnModal: false
131111
- },
131112
- 'torus-auth0-apple-lrc': {
131091
+ }, 'reddit-lrc': {
131113
131092
  showOnModal: false
131114
- },
131115
- 'torus-auth0-email-passwordless': {
131093
+ },
131094
+ // Intentionally deactivate defatul Torus because we are using custom LINE to get user Email
131095
+ 'torus-auth0-line': {
131116
131096
  showOnModal: false
131117
- },
131118
- 'torus-auth0-email-passwordless-lrc': {
131097
+ }, 'torus-auth0-line-lrc': {
131119
131098
  showOnModal: false
131120
- },
131121
- 'torus-auth0-github': {
131099
+ }, 'torus-auth0-github': {
131122
131100
  showOnModal: false
131123
- },
131124
- 'torus-auth0-github-lrc': {
131101
+ }, 'torus-auth0-github-lrc': {
131125
131102
  showOnModal: false
131126
- },
131127
- 'torus-auth0-kakao': {
131103
+ }, 'torus-auth0-kakao': {
131128
131104
  showOnModal: false
131129
- },
131130
- 'torus-auth0-kakao-lrc': {
131105
+ }, 'torus-auth0-kakao-lrc': {
131131
131106
  showOnModal: false
131132
- },
131133
- 'torus-auth0-line': {
131107
+ }, 'torus-auth0-linkedin': {
131134
131108
  showOnModal: false
131135
- },
131136
- 'torus-auth0-line-lrc': {
131109
+ }, 'torus-auth0-linkedin-lrc': {
131137
131110
  showOnModal: false
131138
- },
131139
- 'torus-auth0-linkedin': {
131111
+ }, 'torus-auth0-weibo': {
131140
131112
  showOnModal: false
131141
- },
131142
- 'torus-auth0-linkedin-lrc': {
131113
+ }, 'torus-auth0-weibo-lrc': {
131143
131114
  showOnModal: false
131144
- },
131145
- 'torus-auth0-twitter': {
131115
+ }, twitch: {
131146
131116
  showOnModal: false
131147
- },
131148
- 'torus-auth0-twitter-lrc': {
131117
+ }, 'twitch-lrc': {
131149
131118
  showOnModal: false
131150
- },
131151
- 'torus-auth0-weibo': {
131119
+ }, 'torus-auth0-wechat': {
131152
131120
  showOnModal: false
131153
- },
131154
- 'torus-auth0-weibo-lrc': {
131121
+ }, 'torus-auth0-wechat-lrc': {
131155
131122
  showOnModal: false
131156
- },
131157
- twitch: {
131158
- showOnModal: false
131159
- },
131160
- 'twitch-lrc': {
131161
- showOnModal: false
131162
- },
131163
- 'torus-auth0-wechat': {
131164
- showOnModal: false
131165
- },
131166
- 'torus-auth0-wechat-lrc': {
131167
- showOnModal: false
131168
- },
131169
- [config.auth0TorusConfigKey]: {
131170
- name: 'email',
131171
- typeOfLogin: 'email_password',
131172
- description: 'login.buttonText',
131173
- clientId: config.auth0ClientId,
131174
- logoHover: ((_v = config === null || config === void 0 ? void 0 : config.customUi) === null || _v === void 0 ? void 0 : _v.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black,
131175
- logoLight: ((_w = config === null || config === void 0 ? void 0 : config.customUi) === null || _w === void 0 ? void 0 : _w.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).white,
131176
- logoDark: ((_x = config === null || config === void 0 ? void 0 : config.customUi) === null || _x === void 0 ? void 0 : _x.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black,
131177
- showOnModal: config.loginProvider.emailPassword,
131178
- priority: 1,
131179
- mainOption: false,
131180
- showOnMobile: true,
131181
- showOnDesktop: true,
131182
- jwtParameters: {
131183
- disable_signup: !config.authAction.signup,
131184
- disable_login: !config.authAction.login,
131185
- domain: config.auth0Domain,
131186
- callback_url: config.callbackUrl || exports.getCallabckUrl(),
131187
- contactUrl: ((_y = config === null || config === void 0 ? void 0 : config.customUi) === null || _y === void 0 ? void 0 : _y.contactUrl) || constant_1.CONTACT_EMAIL,
131188
- serviceName: ((_z = config === null || config === void 0 ? void 0 : config.customUi) === null || _z === void 0 ? void 0 : _z.serviceName) || constant_1.APP,
131189
- logoURL: ((_0 = config.customUi) === null || _0 === void 0 ? void 0 : _0.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black,
131190
- titleSignup: ((_4 = (_3 = (_2 = (_1 = config.customUi) === null || _1 === void 0 ? void 0 : _1.words) === null || _2 === void 0 ? void 0 : _2[config.lang]) === null || _3 === void 0 ? void 0 : _3.emailAuthPopup) === null || _4 === void 0 ? void 0 : _4['titleSignup']) || constant_1.EMAIL_PASSWORD_POPUP_LABEL.SIGNUP[config.lang],
131191
- titleLogin: ((_8 = (_7 = (_6 = (_5 = config.customUi) === null || _5 === void 0 ? void 0 : _5.words) === null || _6 === void 0 ? void 0 : _6[config.lang]) === null || _7 === void 0 ? void 0 : _7.emailAuthPopup) === null || _8 === void 0 ? void 0 : _8['titleLogin']) || constant_1.EMAIL_PASSWORD_POPUP_LABEL.LOGIN[config.lang],
131192
- ui_locales: config.lang
131193
- }
131194
- }
131195
- }
131123
+ } })
131196
131124
  };
131197
131125
  };
131198
131126
  const serviceName = (config) => {
@@ -131249,16 +131177,6 @@ const formatConfigForTorusUI = (config) => {
131249
131177
  }
131250
131178
  return customUi;
131251
131179
  };
131252
- /**
131253
- * For backward-compatibility
131254
- */
131255
- exports.getCallabckUrl = () => {
131256
- const url = new URL(globalThis.location.href);
131257
- const callback = url.searchParams.get('callback');
131258
- if (!callback)
131259
- return '';
131260
- return util_2.checkCallbackUrl(callback) ? callback : '';
131261
- };
131262
131180
  class TorusConfigContext {
131263
131181
  /**
131264
131182
  * Store preConfig so that data passed for overwriting is always through
@@ -131276,7 +131194,7 @@ class TorusConfigContext {
131276
131194
  // with rest of the data kept as it is.
131277
131195
  return Object.assign(Object.assign(Object.assign({}, this.torusContextConfig.preConfig), Object.assign(Object.assign({}, config), { lang: config.lang })), {
131278
131196
  network: this.network(this.torusContextConfig.config.buildEnv, config === null || config === void 0 ? void 0 : config.rpcEndpoint),
131279
- loginProvider: this.setLoginProvider(config),
131197
+ loginProvider: torusSocialLogin_1.restructureLoginConfig(config === null || config === void 0 ? void 0 : config.loginProvider),
131280
131198
  conditionalWords: this.convertWordsByAuthProvider(config)
131281
131199
  });
131282
131200
  };
@@ -131284,14 +131202,14 @@ class TorusConfigContext {
131284
131202
  return {
131285
131203
  apiPath: (config === null || config === void 0 ? void 0 : config.apiPath) || constant_1.STARTRAIL_API,
131286
131204
  authAction: (config === null || config === void 0 ? void 0 : config.authAction) || constant_1.AUTH0_DEFAULT_TAB,
131287
- auth0ClientId: (config === null || config === void 0 ? void 0 : config.auth0ClientId) || constant_1.AUTH0_CLIENT_ID,
131288
- auth0TorusConfigKey: (config === null || config === void 0 ? void 0 : config.auth0TorusConfigKey) || constant_1.AUTH0_TORUS_CONFIG_KEY,
131289
- auth0Domain: (config === null || config === void 0 ? void 0 : config.auth0Domain) || constant_1.AUTH0_DOMAIN,
131205
+ auth0ClientId: (config === null || config === void 0 ? void 0 : config.auth0ClientId) || constant_1.AUTH0_CLIENT_IDS[this.adaptTorusEnvToAppEnv(config === null || config === void 0 ? void 0 : config.env)],
131206
+ auth0TorusConfigKey: (config === null || config === void 0 ? void 0 : config.auth0TorusConfigKey) || constant_1.AUTH0_TORUS_CONFIG_KEYS[this.adaptTorusEnvToAppEnv(config === null || config === void 0 ? void 0 : config.env)],
131207
+ auth0Domain: (config === null || config === void 0 ? void 0 : config.auth0Domain) || constant_1.AUTH0_DOMAINS[this.adaptTorusEnvToAppEnv(config === null || config === void 0 ? void 0 : config.env)],
131290
131208
  lang: ((config === null || config === void 0 ? void 0 : config.lang) !== constant_1.LANG.JP ? constant_1.LANG.EN : constant_1.LANG.JP),
131291
- loginProvider: this.setLoginProvider(config),
131209
+ loginProvider: torusSocialLogin_1.restructureLoginConfig(config === null || config === void 0 ? void 0 : config.loginProvider),
131292
131210
  network: this.network(config === null || config === void 0 ? void 0 : config.env, config === null || config === void 0 ? void 0 : config.rpcEndpoint),
131293
131211
  callbackUrl: (config === null || config === void 0 ? void 0 : config.callbackUrl) || null,
131294
- withModal: (config === null || config === void 0 ? void 0 : config.withModal) || false,
131212
+ withModal: typeof (config === null || config === void 0 ? void 0 : config.withModal) === 'boolean' ? config === null || config === void 0 ? void 0 : config.withModal : true,
131295
131213
  conditionalWords: this.convertWordsByAuthProvider(config),
131296
131214
  customUi: config === null || config === void 0 ? void 0 : config.customUi
131297
131215
  };
@@ -131332,21 +131250,12 @@ class TorusConfigContext {
131332
131250
  return this.torusContextConfig.config;
131333
131251
  }
131334
131252
  /**
131335
- * Return LoginConfig to open modal or provider login directly
131253
+ * Set login config for direct login without modal
131336
131254
  */
131337
- getLoginConfig() {
131338
- if (this.torusContextConfig.preConfig.withModal)
131339
- return {};
131340
- let suffix = '';
131341
- const torusEnv = this.torusContextConfig.preConfig.network.torusEnv;
131342
- if (torusEnv && torusEnv !== 'production')
131343
- suffix = `-lrc`;
131344
- if (this.torusContextConfig.preConfig.loginProvider.google) {
131345
- return { verifier: `google${suffix}` };
131346
- }
131347
- else if (this.torusContextConfig.preConfig.loginProvider.emailPassword) {
131348
- return { verifier: this.torusContextConfig.preConfig.auth0TorusConfigKey };
131349
- }
131255
+ getDirectLoginConfig() {
131256
+ const preConfig = this.torusContextConfig.preConfig;
131257
+ const verifier = torusSocialLogin_1.getVerifierByLoginProvider(preConfig.network.appEnv, preConfig.withModal, preConfig.loginProvider, preConfig.auth0TorusConfigKey);
131258
+ return verifier ? { verifier } : {};
131350
131259
  }
131351
131260
  network(env, rpcEndpoint) {
131352
131261
  const blockchainNetwork = (envKey) => {
@@ -131359,53 +131268,47 @@ class TorusConfigContext {
131359
131268
  case 'staging':
131360
131269
  return {
131361
131270
  torusEnv: 'production',
131271
+ appEnv: this.adaptTorusEnvToAppEnv(env),
131362
131272
  ethereumNetwork: blockchainNetwork('DEV')
131363
131273
  };
131364
131274
  case 'lrc':
131365
131275
  return {
131366
131276
  torusEnv: 'lrc',
131277
+ appEnv: this.adaptTorusEnvToAppEnv(env),
131367
131278
  ethereumNetwork: blockchainNetwork('DEV')
131368
131279
  };
131369
131280
  case 'beta':
131370
131281
  return {
131371
131282
  torusEnv: 'beta',
131283
+ appEnv: this.adaptTorusEnvToAppEnv(env),
131372
131284
  ethereumNetwork: blockchainNetwork('DEV')
131373
131285
  };
131374
131286
  case 'local':
131375
131287
  return {
131376
131288
  torusEnv: 'beta',
131289
+ appEnv: this.adaptTorusEnvToAppEnv(env),
131377
131290
  ethereumNetwork: blockchainNetwork('LOCAL')
131378
131291
  };
131379
131292
  default:
131380
131293
  return {
131381
131294
  torusEnv: 'production',
131295
+ appEnv: this.adaptTorusEnvToAppEnv(),
131382
131296
  ethereumNetwork: blockchainNetwork('PROD')
131383
131297
  };
131384
131298
  }
131385
131299
  }
131386
- /**
131387
- * Bundle login provider status
131388
- */
131389
- setLoginProvider(config) {
131390
- if ((config === null || config === void 0 ? void 0 : config.loginProvider) === 'email_password') {
131391
- return { google: false, emailPassword: true };
131392
- }
131393
- else if ((config === null || config === void 0 ? void 0 : config.loginProvider) === 'google') {
131394
- return { google: true, emailPassword: false };
131395
- }
131396
- return { google: true, emailPassword: true };
131397
- }
131398
131300
  /**
131399
131301
  * Some wording is determined by users' action
131400
131302
  */
131401
131303
  convertWordsByAuthProvider(config) {
131304
+ var _a;
131402
131305
  /**
131403
131306
  * Application title should be prefixed only in English with Email login condition
131404
131307
  * (Google logo is automatially attached by torus-website with Gmail login)
131405
131308
  */
131406
131309
  const subtitle = {
131407
131310
  ja: `${serviceName(config)}${constant_1.DEFAULT_WORD.dappLogin.subtitle.ja}`,
131408
- en: `${constant_1.DEFAULT_WORD.dappLogin.subtitle.en}${(config === null || config === void 0 ? void 0 : config.loginProvider) === 'email_password' ? ' ' + serviceName(config) : ''}`
131311
+ en: `${constant_1.DEFAULT_WORD.dappLogin.subtitle.en}${((_a = config === null || config === void 0 ? void 0 : config.loginProvider) === null || _a === void 0 ? void 0 : _a.includes('email_password')) ? ' ' + serviceName(config) : ''}`
131409
131312
  };
131410
131313
  switch (true) {
131411
131314
  case isSignup(config): // Signup
@@ -131422,10 +131325,155 @@ class TorusConfigContext {
131422
131325
  };
131423
131326
  }
131424
131327
  }
131328
+ adaptTorusEnvToAppEnv(env) {
131329
+ switch (env) {
131330
+ case 'production':
131331
+ return 'PROD';
131332
+ case 'staging':
131333
+ return 'STG';
131334
+ case 'lrc':
131335
+ return 'DEV';
131336
+ case 'beta':
131337
+ return 'DEV';
131338
+ default:
131339
+ return 'PROD';
131340
+ }
131341
+ }
131425
131342
  }
131426
131343
  exports.default = TorusConfigContext;
131427
131344
 
131428
131345
 
131346
+ /***/ }),
131347
+
131348
+ /***/ "./src/configContext/torusSocialLogin.ts":
131349
+ /*!***********************************************!*\
131350
+ !*** ./src/configContext/torusSocialLogin.ts ***!
131351
+ \***********************************************/
131352
+ /*! no static exports found */
131353
+ /*! all exports used */
131354
+ /***/ (function(module, exports, __webpack_require__) {
131355
+
131356
+ "use strict";
131357
+
131358
+ Object.defineProperty(exports, "__esModule", { value: true });
131359
+ exports.getCallabckUrl = exports.restructureLoginConfig = exports.getVerifierByLoginProvider = exports.getCustomLoginConfig = exports.getModalConfigByLoginProviders = exports.allAllowedVerifiers = void 0;
131360
+ const constant_1 = __webpack_require__(/*! ../constant */ "./src/constant.ts");
131361
+ const error_1 = __webpack_require__(/*! ../error */ "./src/error.ts");
131362
+ const util_1 = __webpack_require__(/*! ../util */ "./src/util.ts");
131363
+ const globalThis = __webpack_require__(/*! globalthis */ "./node_modules/globalthis/index.js")();
131364
+ exports.allAllowedVerifiers = ['google', 'line', 'facebook', 'twitter', 'apple', 'email_passwordless', 'email_password'];
131365
+ const verifiersDisplayedAsSubmain = ['email_passwordless', 'email_password'];
131366
+ /**
131367
+ * When a specific social logins unselected, show all optioins on modal.
131368
+ * Else, show only selected social logins on modal.
131369
+ */
131370
+ exports.getModalConfigByLoginProviders = (verifier, configVerifiers) => {
131371
+ return {
131372
+ PROD: {
131373
+ [constant_1.TORUS_VERIFIERS[verifier].PROD]: configVerifiers[verifier]
131374
+ },
131375
+ STG: {
131376
+ [constant_1.TORUS_VERIFIERS[verifier].PROD]: configVerifiers[verifier]
131377
+ },
131378
+ DEV: {
131379
+ [constant_1.TORUS_VERIFIERS[verifier].DEV]: configVerifiers[verifier]
131380
+ }
131381
+ };
131382
+ };
131383
+ /**
131384
+ * Config in integration with custom Auth0.
131385
+ * User data is stored in your Auth0 DB.
131386
+ */
131387
+ exports.getCustomLoginConfig = (config) => {
131388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
131389
+ const baseConf = {
131390
+ line: Object.assign({ typeOfLogin: 'line', clientId: config.auth0ClientId, jwtParameters: {
131391
+ prompt: 'select_account',
131392
+ domain: config.auth0Domain
131393
+ } }, config.loginProvider.line),
131394
+ emailPassword: Object.assign(Object.assign({ name: 'email', typeOfLogin: 'email_password', description: 'login.buttonText', clientId: config.auth0ClientId, logoHover: ((_a = config === null || config === void 0 ? void 0 : config.customUi) === null || _a === void 0 ? void 0 : _a.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black, logoLight: ((_b = config === null || config === void 0 ? void 0 : config.customUi) === null || _b === void 0 ? void 0 : _b.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).white, logoDark: ((_c = config === null || config === void 0 ? void 0 : config.customUi) === null || _c === void 0 ? void 0 : _c.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black }, config.loginProvider.email_password), { jwtParameters: {
131395
+ disable_signup: !config.authAction.signup,
131396
+ disable_login: !config.authAction.login,
131397
+ domain: config.auth0Domain,
131398
+ callback_url: config.callbackUrl || exports.getCallabckUrl(),
131399
+ contactUrl: ((_d = config === null || config === void 0 ? void 0 : config.customUi) === null || _d === void 0 ? void 0 : _d.contactUrl) || constant_1.CONTACT_EMAIL,
131400
+ serviceName: ((_e = config === null || config === void 0 ? void 0 : config.customUi) === null || _e === void 0 ? void 0 : _e.serviceName) || constant_1.APP,
131401
+ logoURL: ((_f = config.customUi) === null || _f === void 0 ? void 0 : _f.logoUrl) || constant_1.LOGO_URL(constant_1.STARTRAIL_ENV.PROD).black,
131402
+ titleSignup: ((_k = (_j = (_h = (_g = config.customUi) === null || _g === void 0 ? void 0 : _g.words) === null || _h === void 0 ? void 0 : _h[config.lang]) === null || _j === void 0 ? void 0 : _j.emailAuthPopup) === null || _k === void 0 ? void 0 : _k['titleSignup']) || constant_1.EMAIL_PASSWORD_POPUP_LABEL.SIGNUP[config.lang],
131403
+ titleLogin: ((_p = (_o = (_m = (_l = config.customUi) === null || _l === void 0 ? void 0 : _l.words) === null || _m === void 0 ? void 0 : _m[config.lang]) === null || _o === void 0 ? void 0 : _o.emailAuthPopup) === null || _p === void 0 ? void 0 : _p['titleLogin']) || constant_1.EMAIL_PASSWORD_POPUP_LABEL.LOGIN[config.lang],
131404
+ ui_locales: config.lang
131405
+ } })
131406
+ };
131407
+ return {
131408
+ [constant_1.TORUS_AUTH0_CUSTOM_VERIFIERS.line[config.network.appEnv]]: baseConf.line,
131409
+ [config.auth0TorusConfigKey]: baseConf.emailPassword
131410
+ };
131411
+ };
131412
+ /**
131413
+ * Verifier that is used for direct login without modal.
131414
+ */
131415
+ exports.getVerifierByLoginProvider = (env, withModal, loginProvider, authConfigKey) => {
131416
+ if (withModal)
131417
+ return null;
131418
+ const verifiers = Object.entries(loginProvider)
131419
+ .filter(([_, value]) => value.showOnModal)
131420
+ .map(([key, _]) => key);
131421
+ // Alwasys Use first index of array when withModal is false
131422
+ const verifier = verifiers[0];
131423
+ switch (verifier) {
131424
+ // NOTE: email_passwordless always need modal
131425
+ case 'email_passwordless':
131426
+ return null;
131427
+ case 'email_password':
131428
+ if (env === 'DEV' && !authConfigKey)
131429
+ throw new error_1.CustomError(Error('authConfigKey should be assigned for email password')).sdk();
131430
+ return env === 'DEV' ? authConfigKey : constant_1.TORUS_VERIFIERS.email_password[env];
131431
+ case 'line':
131432
+ return constant_1.TORUS_AUTH0_CUSTOM_VERIFIERS.line[env];
131433
+ default:
131434
+ return constant_1.TORUS_VERIFIERS[verifier][env];
131435
+ }
131436
+ };
131437
+ /**
131438
+ * To absorb irregularity such as
131439
+ * verifiers is undefined or empty array, priority number
131440
+ * and isShowAsMainOption for some verifiers
131441
+ */
131442
+ exports.restructureLoginConfig = (verifiers) => {
131443
+ // default undefined should show everything in modal
131444
+ const hasVerifier = (verifiers) => Boolean(verifiers && verifiers.length > 0);
131445
+ // eg. [2,1] + [1,2,3] =>[2,1,3]
131446
+ const sortedVerifiers = !hasVerifier(verifiers) ? exports.allAllowedVerifiers : verifiers.concat(exports.allAllowedVerifiers.filter(item => !verifiers.includes(item)));
131447
+ const conf = {};
131448
+ for (let i = 0; i < sortedVerifiers.length; i++) {
131449
+ const isShow = !hasVerifier(verifiers) ? true : verifiers.includes(sortedVerifiers[i]);
131450
+ conf[sortedVerifiers[i]] = {
131451
+ // Modify the order of buttons. Should be greater than zero, where 1 is top priority.
131452
+ priority: i + 1,
131453
+ // Whether to show the login button on modal or not
131454
+ showOnModal: isShow,
131455
+ // Whether to show the login button on mobile
131456
+ showOnMobile: isShow,
131457
+ // Whether to show the login button on desktop
131458
+ showOnDesktop: isShow,
131459
+ // Show login button on the main list of the modal
131460
+ mainOption: !verifiersDisplayedAsSubmain.includes(sortedVerifiers[i])
131461
+ };
131462
+ }
131463
+ return conf;
131464
+ };
131465
+ /**
131466
+ * For backward-compatibility
131467
+ */
131468
+ exports.getCallabckUrl = () => {
131469
+ const url = new URL(globalThis.location.href);
131470
+ const callback = url.searchParams.get('callback');
131471
+ if (!callback)
131472
+ return '';
131473
+ return util_1.checkCallbackUrl(callback) ? callback : '';
131474
+ };
131475
+
131476
+
131429
131477
  /***/ }),
131430
131478
 
131431
131479
  /***/ "./src/configContext/util.ts":
@@ -131525,7 +131573,7 @@ exports.findEnvByChainId = (chainId) => {
131525
131573
  "use strict";
131526
131574
 
131527
131575
  Object.defineProperty(exports, "__esModule", { value: true });
131528
- exports.StartrailSdkErrorCodeEnum = exports.PRIVACY_POLICY_LINK = exports.TERMS_OF_CONDITION_LINK = exports.STARTRAIL_ENV = exports.STARTRAIL_API = exports.LOGO_URL = exports.LANG = exports.ETHEREUM_NETWORK = exports.RPC_URLS = exports.ERROR_STATUS_CODE = exports.ERROR_MESSAGE = exports.ERROR_FROM = exports.EMAIL_PASSWORD_POPUP_LABEL = exports.EMAIL_BUTTON = exports.DEFAULT_WORD = exports.CONTACT_EMAIL = exports.COMPRESSION_ALGORITHM = exports.AUTH0_TORUS_CONFIG_KEY = exports.AUTH0_DOMAIN = exports.AUTH0_DEFAULT_TAB = exports.AUTH0_CLIENT_ID = exports.AUTH_LABEL = exports.APP = void 0;
131576
+ exports.TORUS_AUTH0_CUSTOM_VERIFIERS = exports.TORUS_VERIFIERS = exports.StartrailSdkErrorCodeEnum = exports.PRIVACY_POLICY_LINK = exports.TERMS_OF_CONDITION_LINK = exports.STARTRAIL_ENV = exports.STARTRAIL_API = exports.LOGO_URL = exports.LANG = exports.ETHEREUM_NETWORK = exports.RPC_URLS = exports.ERROR_STATUS_CODE = exports.ERROR_MESSAGE = exports.ERROR_FROM = exports.EMAIL_PASSWORD_POPUP_LABEL = exports.EMAIL_BUTTON = exports.DEFAULT_WORD = exports.CONTACT_EMAIL = exports.COMPRESSION_ALGORITHM = exports.AUTH0_DEFAULT_TAB = exports.AUTH0_TORUS_CONFIG_KEYS = exports.AUTH0_DOMAINS = exports.AUTH0_CLIENT_IDS = exports.AUTH_LABEL = exports.APP = void 0;
131529
131577
  exports.APP = 'Startrail';
131530
131578
  exports.AUTH_LABEL = {
131531
131579
  SIGNUP: {
@@ -131537,10 +131585,22 @@ exports.AUTH_LABEL = {
131537
131585
  EN: 'Login'
131538
131586
  }
131539
131587
  };
131540
- exports.AUTH0_CLIENT_ID = 'o2GR8rwXJ0ni4cifcPrkO2olJG5Kafis';
131588
+ exports.AUTH0_CLIENT_IDS = {
131589
+ PROD: 'o2GR8rwXJ0ni4cifcPrkO2olJG5Kafis',
131590
+ STG: 'bjLPkbje34kWs4p5jM58q0kIW21KnuiH',
131591
+ DEV: 'F1NCHy8cV6UfZPTHUwELJZWU2zPsI7Gt'
131592
+ };
131593
+ exports.AUTH0_DOMAINS = {
131594
+ PROD: 'https://auth0.startrail.io',
131595
+ STG: 'https://startrail-staging.jp.auth0.com',
131596
+ DEV: 'https://torusstartrail.au.auth0.com'
131597
+ };
131598
+ exports.AUTH0_TORUS_CONFIG_KEYS = {
131599
+ PROD: 'startrail-auth0-email-password',
131600
+ STG: 'startrail-auth0-staging',
131601
+ DEV: 'startrail-auth0-email-password-qa'
131602
+ };
131541
131603
  exports.AUTH0_DEFAULT_TAB = { login: true, signup: true };
131542
- exports.AUTH0_DOMAIN = 'https://auth0.startrail.io';
131543
- exports.AUTH0_TORUS_CONFIG_KEY = 'startrail-auth0-email-password';
131544
131604
  exports.COMPRESSION_ALGORITHM = 'gzip';
131545
131605
  exports.CONTACT_EMAIL = 'contact@startrail.io';
131546
131606
  exports.DEFAULT_WORD = {
@@ -131705,6 +131765,45 @@ var StartrailSdkErrorCodeEnum;
131705
131765
  StartrailSdkErrorCodeEnum["WALLET_USER_REJECT_WALLET_REQUEST"] = "WALLET_USER_REJECT_WALLET_REQUEST";
131706
131766
  StartrailSdkErrorCodeEnum["METADATA_VALIDATION_FAILED"] = "METADATA_VALIDATION_FAILED";
131707
131767
  })(StartrailSdkErrorCodeEnum = exports.StartrailSdkErrorCodeEnum || (exports.StartrailSdkErrorCodeEnum = {}));
131768
+ exports.TORUS_VERIFIERS = {
131769
+ google: {
131770
+ PROD: 'google',
131771
+ STG: 'google',
131772
+ DEV: 'google-lrc'
131773
+ },
131774
+ facebook: {
131775
+ PROD: 'facebook',
131776
+ STG: 'facebook',
131777
+ DEV: 'facebook-lrc'
131778
+ },
131779
+ apple: {
131780
+ PROD: 'torus-auth0-apple',
131781
+ STG: 'torus-auth0-apple',
131782
+ DEV: 'torus-auth0-apple-lrc'
131783
+ },
131784
+ twitter: {
131785
+ PROD: 'torus-auth0-twitter',
131786
+ STG: 'torus-auth0-twitter',
131787
+ DEV: 'torus-auth0-twitter-lrc'
131788
+ },
131789
+ email_passwordless: {
131790
+ PROD: 'torus-auth0-email-passwordless',
131791
+ STG: 'torus-auth0-email-passwordless',
131792
+ DEV: 'torus-auth0-email-passwordless-lrc'
131793
+ },
131794
+ email_password: {
131795
+ PROD: exports.AUTH0_TORUS_CONFIG_KEYS.PROD,
131796
+ STG: exports.AUTH0_TORUS_CONFIG_KEYS.STG,
131797
+ DEV: '' // Should be passed from the caller
131798
+ }
131799
+ };
131800
+ exports.TORUS_AUTH0_CUSTOM_VERIFIERS = {
131801
+ line: {
131802
+ PROD: 'startrail-auth0-line',
131803
+ STG: 'startrail-auth0-line-staging',
131804
+ DEV: 'startrail-auth0-line-qa'
131805
+ }
131806
+ };
131708
131807
 
131709
131808
 
131710
131809
  /***/ }),
@@ -133438,7 +133537,7 @@ class Torus extends base_1.default {
133438
133537
  }
133439
133538
  this.provider = this.torusSDK.provider;
133440
133539
  try {
133441
- return yield this.torusSDK.login(this.configContext.getLoginConfig());
133540
+ return yield this.torusSDK.login(this.configContext.getDirectLoginConfig());
133442
133541
  }
133443
133542
  catch (e) {
133444
133543
  throw new error_1.CustomError(e).torus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startbahn/startrail-sdk-js",
3
- "version": "1.31.0-beta.2",
3
+ "version": "1.31.0-beta.4",
4
4
  "description": "Startrail Api for JS SDK",
5
5
  "main": "dist/startrail-sdk.js",
6
6
  "unpkg": "dist/startrail-sdk.js",
@@ -253,6 +253,16 @@ declare module '@startbahn/startrail-sdk-js/types' {
253
253
  }
254
254
  export type Language = 'ja' | 'en';
255
255
  export type LoginProvider = 'google' | 'email_password' | 'facebook' | 'twitter' | 'line' | 'apple' | 'email_passwordless';
256
+ export type TLoginProviders = LoginProvider[];
257
+ export type TConfByLoginProviders = {
258
+ [K in LoginProvider]: {
259
+ showOnMobile: boolean;
260
+ showOnDesktop: boolean;
261
+ showOnModal: boolean;
262
+ mainOption: boolean;
263
+ priority: number;
264
+ };
265
+ };
256
266
  export type TTorusNativeVerifier = Exclude<LoginProvider, 'line'>;
257
267
  export type TTorusAuth0CustomVerifier = Extract<LoginProvider, 'line'>;
258
268
  export type TAppEnv = 'PROD' | 'STG' | 'DEV';
@@ -277,7 +287,7 @@ declare module '@startbahn/startrail-sdk-js/types' {
277
287
  export interface OverwriteStartrailSDKConfig {
278
288
  authAction?: AuthAction;
279
289
  lang?: string;
280
- loginProvider?: LoginProvider;
290
+ loginProvider?: TLoginProviders;
281
291
  }
282
292
  export interface PreTorusConfig {
283
293
  apiPath: string;
@@ -286,7 +296,7 @@ declare module '@startbahn/startrail-sdk-js/types' {
286
296
  auth0Domain: string;
287
297
  auth0TorusConfigKey: string;
288
298
  lang: Language;
289
- loginProvider: LoginProvider | undefined;
299
+ loginProvider: TConfByLoginProviders;
290
300
  conditionalWords: WordsDeterminedByCondition;
291
301
  customUi: CustomUi | undefined;
292
302
  network: {
@@ -341,7 +351,7 @@ declare module '@startbahn/startrail-sdk-js/types' {
341
351
  auth0TorusConfigKey?: string;
342
352
  customUi?: CustomUi;
343
353
  lang?: string;
344
- loginProvider?: LoginProvider;
354
+ loginProvider?: TLoginProviders;
345
355
  callbackUrl?: string;
346
356
  withModal?: boolean;
347
357
  }
@@ -886,13 +896,25 @@ declare module '@startbahn/startrail-sdk-js/constant' {
886
896
  EN: string;
887
897
  };
888
898
  };
889
- export const AUTH0_CLIENT_ID = "o2GR8rwXJ0ni4cifcPrkO2olJG5Kafis";
899
+ export const AUTH0_CLIENT_IDS: {
900
+ PROD: string;
901
+ STG: string;
902
+ DEV: string;
903
+ };
904
+ export const AUTH0_DOMAINS: {
905
+ PROD: string;
906
+ STG: string;
907
+ DEV: string;
908
+ };
909
+ export const AUTH0_TORUS_CONFIG_KEYS: {
910
+ PROD: string;
911
+ STG: string;
912
+ DEV: string;
913
+ };
890
914
  export const AUTH0_DEFAULT_TAB: {
891
915
  login: boolean;
892
916
  signup: boolean;
893
917
  };
894
- export const AUTH0_DOMAIN = "https://auth0.startrail.io";
895
- export const AUTH0_TORUS_CONFIG_KEY = "startrail-auth0-email-password";
896
918
  export const COMPRESSION_ALGORITHM = "gzip";
897
919
  export const CONTACT_EMAIL = "contact@startrail.io";
898
920
  export const DEFAULT_WORD: {