@bringg/dashboard-sdk 9.92.0 → 9.94.0-pre.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.
@@ -3433,6 +3433,19 @@ var BringgDashboardSDK = /** @class */ (function () {
3433
3433
  });
3434
3434
  });
3435
3435
  };
3436
+ BringgDashboardSDK.prototype.getSamlSignOutUrl = function () {
3437
+ return this.session.getSamlSignOutUrl();
3438
+ };
3439
+ BringgDashboardSDK.prototype.samlSignOut = function () {
3440
+ return __awaiter(this, void 0, void 0, function () {
3441
+ return __generator(this, function (_a) {
3442
+ switch (_a.label) {
3443
+ case 0: return [4 /*yield*/, this.session.samlSignOut()];
3444
+ case 1: return [2 /*return*/, _a.sent()];
3445
+ }
3446
+ });
3447
+ });
3448
+ };
3436
3449
  BringgDashboardSDK.resendConfirmationEmail = function (params) {
3437
3450
  return __awaiter(this, void 0, void 0, function () {
3438
3451
  var authService, email, password, merchant_uuid, recaptchaToken, recaptcha_qa_token;
@@ -8903,10 +8916,16 @@ function innerDeepMerge(target, source, diff) {
8903
8916
  target[key] = targetItems;
8904
8917
  }
8905
8918
  else if (source[key] && typeof source[key] === 'object') {
8906
- target[key] = target[key] || {};
8919
+ var previousValue = target[key];
8920
+ var replacesPrimitive = previousValue && typeof previousValue !== 'object';
8921
+ target[key] = previousValue && !replacesPrimitive ? previousValue : {};
8907
8922
  var innerDiff = {};
8908
8923
  var anyInnerChange = innerDeepMerge(target[key], source[key], innerDiff);
8909
- if (anyInnerChange) {
8924
+ if (replacesPrimitive) {
8925
+ diff[key] = previousValue;
8926
+ anyChange = true;
8927
+ }
8928
+ else if (anyInnerChange) {
8910
8929
  diff[key] = innerDiff;
8911
8930
  anyChange = true;
8912
8931
  }
@@ -23384,7 +23403,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23384
23403
  return (mod && mod.__esModule) ? mod : { "default": mod };
23385
23404
  };
23386
23405
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23387
- exports.SEND_OTP_MAIL_ROUTE = exports.OTP_CREATE_TOKEN_ROUTE = exports.RESEND_CONFIRMATION_EMAIL_ROUTE = exports.UNWIND_ROUTE = exports.IMPERSONATE_BY_TEAM_ROUTE = exports.IMPERSONATE_ROUTE = exports.SWITCH_ROUTE = exports.LOGOUT_ROUTE = exports.GET_USER_ROUTE = exports.CREATE_TOKEN_ONE_TIME_CODE_ROUTE = exports.CREATE_TOKEN_ROUTE = void 0;
23406
+ exports.SAML_SIGN_OUT_ROUTE = exports.SEND_OTP_MAIL_ROUTE = exports.OTP_CREATE_TOKEN_ROUTE = exports.RESEND_CONFIRMATION_EMAIL_ROUTE = exports.UNWIND_ROUTE = exports.IMPERSONATE_BY_TEAM_ROUTE = exports.IMPERSONATE_ROUTE = exports.SWITCH_ROUTE = exports.LOGOUT_ROUTE = exports.GET_USER_ROUTE = exports.CREATE_TOKEN_ONE_TIME_CODE_ROUTE = exports.CREATE_TOKEN_ROUTE = void 0;
23388
23407
  var lodash_1 = __webpack_require__(96486);
23389
23408
  var sha1_1 = __importDefault(__webpack_require__(18738));
23390
23409
  var BringgDashboardSDK_1 = __webpack_require__(5655);
@@ -23406,6 +23425,7 @@ exports.UNWIND_ROUTE = new Route_1.Route('/tokens/unwind_impersonate', 1 /* Http
23406
23425
  exports.RESEND_CONFIRMATION_EMAIL_ROUTE = new Route_1.Route('/tokens/resend_confirmation_email', 1 /* HttpMethod.POST */);
23407
23426
  exports.OTP_CREATE_TOKEN_ROUTE = new Route_1.Route('/otp', 1 /* HttpMethod.POST */);
23408
23427
  exports.SEND_OTP_MAIL_ROUTE = new Route_1.Route('/otp/send', 1 /* HttpMethod.POST */);
23428
+ exports.SAML_SIGN_OUT_ROUTE = new Route_1.Route('/users/saml/idp_sign_out', 0 /* HttpMethod.GET */);
23409
23429
  var AuthService = /** @class */ (function () {
23410
23430
  function AuthService(clientId, endpoint) {
23411
23431
  this.clientId = clientId;
@@ -23572,6 +23592,32 @@ var AuthService = /** @class */ (function () {
23572
23592
  });
23573
23593
  });
23574
23594
  };
23595
+ AuthService.prototype.getSamlSignOutUrl = function (authToken, merchantUuid) {
23596
+ var query = new URLSearchParams({ merchant_uuid: merchantUuid, token: authToken });
23597
+ return "".concat(this.endpoint.encode()).concat(exports.SAML_SIGN_OUT_ROUTE.uri, "?").concat(query);
23598
+ };
23599
+ AuthService.prototype.samlSignOut = function (authToken, merchantUuid) {
23600
+ return __awaiter(this, void 0, void 0, function () {
23601
+ return __generator(this, function (_a) {
23602
+ switch (_a.label) {
23603
+ case 0: return [4 /*yield*/, new ServiceRequest_1.AnonymousServiceRequest(this.clientId)
23604
+ .invoke(this.endpoint, exports.SAML_SIGN_OUT_ROUTE, null, {
23605
+ merchant_uuid: merchantUuid,
23606
+ token: authToken
23607
+ })
23608
+ .handle(function (response) {
23609
+ var data = response.data, status = response.status;
23610
+ if (status !== Enums_1.HttpStatusCode.OK) {
23611
+ (0, ServiceRequest_1.logErrorResponse)(response);
23612
+ throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.fromHttpStatusCode(status), 'Unable to sign out of SAML');
23613
+ }
23614
+ return data === null || data === void 0 ? void 0 : data.redirect_url;
23615
+ })];
23616
+ case 1: return [2 /*return*/, _a.sent()];
23617
+ }
23618
+ });
23619
+ });
23620
+ };
23575
23621
  AuthService.prototype.switchAccounts = function (authToken) {
23576
23622
  return __awaiter(this, void 0, void 0, function () {
23577
23623
  return __generator(this, function (_a) {
@@ -24061,6 +24107,55 @@ var Session = /** @class */ (function () {
24061
24107
  });
24062
24108
  });
24063
24109
  };
24110
+ /**
24111
+ * Whether the user signed in through SAML, read from the `aut` claim of the authentication token.
24112
+ * @returns false when the token cannot be read
24113
+ */
24114
+ Session.prototype.isSamlUser = function () {
24115
+ try {
24116
+ var payload = this.user.authentication_token.split('.')[1];
24117
+ return JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/'))).aut === 'saml';
24118
+ }
24119
+ catch (_a) {
24120
+ return false;
24121
+ }
24122
+ };
24123
+ /**
24124
+ * Url that signs a SAML user out of the identity provider when the browser navigates to it.
24125
+ * @returns undefined for users who did not sign in through SAML, or before the merchant is loaded
24126
+ */
24127
+ Session.prototype.getSamlSignOutUrl = function () {
24128
+ if (!this.canSignOutOfSaml()) {
24129
+ return undefined;
24130
+ }
24131
+ return AuthService_1.default.init(this.user.region).getSamlSignOutUrl(this.user.authentication_token, this.merchant.uuid);
24132
+ };
24133
+ /**
24134
+ * Signs a SAML user out of the identity provider and returns where to send the browser next.
24135
+ * Only for users with `sso_logout_redirect_on_frontend`; without it the server answers with a redirect,
24136
+ * so navigate to `getSamlSignOutUrl()` instead.
24137
+ * @returns the url to send the browser to, or undefined when the server has none,
24138
+ * for users who did not sign in through SAML, or before the merchant is loaded
24139
+ * @throws {BringgException} When the server rejects the token
24140
+ */
24141
+ Session.prototype.samlSignOut = function () {
24142
+ return __awaiter(this, void 0, void 0, function () {
24143
+ return __generator(this, function (_a) {
24144
+ switch (_a.label) {
24145
+ case 0:
24146
+ if (!this.canSignOutOfSaml()) {
24147
+ return [2 /*return*/, undefined];
24148
+ }
24149
+ return [4 /*yield*/, AuthService_1.default.init(this.user.region).samlSignOut(this.user.authentication_token, this.merchant.uuid)];
24150
+ case 1: return [2 /*return*/, _a.sent()];
24151
+ }
24152
+ });
24153
+ });
24154
+ };
24155
+ Session.prototype.canSignOutOfSaml = function () {
24156
+ var _a;
24157
+ return this.isSamlUser() && !!((_a = this.merchant) === null || _a === void 0 ? void 0 : _a.uuid);
24158
+ };
24064
24159
  Session.prototype.switchAccounts = function () {
24065
24160
  return __awaiter(this, void 0, void 0, function () {
24066
24161
  var _a, _b;
@@ -24805,7 +24900,7 @@ var BringgException_1 = __webpack_require__(43605);
24805
24900
  var client_page_1 = __webpack_require__(16573);
24806
24901
  var Logger_1 = __importDefault(__webpack_require__(55860));
24807
24902
  var abort_1 = __webpack_require__(34179);
24808
- var version = '9.92.0';
24903
+ var version = '9.94.0-pre.0';
24809
24904
  function logErrorResponse(response) {
24810
24905
  var data = response.data, status = response.status;
24811
24906
  try {
@@ -32399,6 +32494,7 @@ exports.ROUTES = {
32399
32494
  DRIVER_COST: '/users/{:userId}/driver_cost',
32400
32495
  GET_USERS_WITH_USER_TYPE: '/user_types/{:userTypeId}/users',
32401
32496
  INVITE: '/users/{:userId}/reinvite',
32497
+ INVITE_VIA_EMAIL: '/users/{:userId}/reinvite_via_email',
32402
32498
  CLOSED_TASKS: '/users/{:userId}/tasks/closed_tasks',
32403
32499
  TOTAL_TASKS: '/users/{:userId}/tasks/count',
32404
32500
  GOT_HOME: "".concat(exports.baseRoute, "/{:userId}/got_home"),
@@ -33245,6 +33341,20 @@ var UsersApi = /** @class */ (function () {
33245
33341
  });
33246
33342
  });
33247
33343
  };
33344
+ UsersApi.prototype.inviteByEmail = function (userId) {
33345
+ return __awaiter(this, void 0, void 0, function () {
33346
+ var user;
33347
+ return __generator(this, function (_a) {
33348
+ switch (_a.label) {
33349
+ case 0: return [4 /*yield*/, this.usersService.inviteByEmail(userId)];
33350
+ case 1:
33351
+ user = _a.sent();
33352
+ this.storableDataService.updateInStores(user);
33353
+ return [2 /*return*/, user];
33354
+ }
33355
+ });
33356
+ });
33357
+ };
33248
33358
  UsersApi.prototype.closedTasks = function (userId, page) {
33249
33359
  return __awaiter(this, void 0, void 0, function () {
33250
33360
  return __generator(this, function (_a) {
@@ -33611,6 +33721,18 @@ var UsersService = /** @class */ (function () {
33611
33721
  });
33612
33722
  });
33613
33723
  };
33724
+ UsersService.prototype.inviteByEmail = function (userId) {
33725
+ return __awaiter(this, void 0, void 0, function () {
33726
+ return __generator(this, function (_a) {
33727
+ return [2 /*return*/, this.service.routeGenerator
33728
+ .post(User_consts_1.ROUTES.INVITE_VIA_EMAIL)
33729
+ .withRouteParams({ userId: userId })
33730
+ .withExtractor(function (response) { return response.user; })
33731
+ .setException("Could not invite user by email with id: ".concat(userId))
33732
+ .invoke()];
33733
+ });
33734
+ });
33735
+ };
33614
33736
  UsersService.prototype.gotHome = function (userId) {
33615
33737
  return __awaiter(this, void 0, void 0, function () {
33616
33738
  return __generator(this, function (_a) {