@salesforcedevs/dw-components 1.3.195 → 1.3.196-canary.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.195",
3
+ "version": "1.3.196-canary.10",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -23,6 +23,5 @@
23
23
  "@types/lodash.uniqby": "^4.7.7",
24
24
  "@types/setimmediate": "^1.0.2",
25
25
  "setimmediate": "^1.0.5"
26
- },
27
- "gitHead": "340bec89716f643664e18b660ed169bb8cb25ee3"
26
+ }
28
27
  }
@@ -79,8 +79,8 @@ export default class J2sCardSequence extends LightningElement {
79
79
  _recaptchaResetTimeoutId: number | null = null;
80
80
  _stepsData: StepDatum[] = [];
81
81
  @api drmDomain: string = "https://drm.my.salesforce-sites.com";
82
- @api formHandler: string =
83
- "https://formhandlermule-1s9xrb.5sc6y6-4.usa-e2.cloudhub.io/form_handler";
82
+ @api drmHandlerBaseUrl: string =
83
+ "https://dev-sapi-th-ms-infra-form-handler-proxy.us-w2.cloudhub.io";
84
84
  @api tbidApiBaseUrl: string | undefined;
85
85
  @api useHistory: boolean = false;
86
86
 
@@ -128,6 +128,14 @@ export default class J2sCardSequence extends LightningElement {
128
128
  return Boolean(this.tbidUserInfo);
129
129
  }
130
130
 
131
+ private get drmEmailUrl() {
132
+ return `${this.drmHandlerBaseUrl}/getEmail`;
133
+ }
134
+
135
+ private get formHandlerUrl() {
136
+ return `${this.drmHandlerBaseUrl}/form_handler`;
137
+ }
138
+
131
139
  private get formIncomingUserInfo() {
132
140
  if (!this.tbidUserInfo) {
133
141
  return {} as DrmFormData;
@@ -287,14 +295,14 @@ export default class J2sCardSequence extends LightningElement {
287
295
  }
288
296
 
289
297
  async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
290
- if (!this.formHandler || !this.isLoggedIn) {
298
+ if (!this.formHandlerUrl || !this.isLoggedIn) {
291
299
  return;
292
300
  }
293
301
 
294
302
  this._isFormSubmitting = true;
295
303
 
296
304
  try {
297
- const res = await fetch(this.formHandler, {
305
+ const res = await fetch(this.formHandlerUrl, {
298
306
  method: "POST",
299
307
  headers: {
300
308
  "Content-Type": "application/json",
@@ -413,7 +421,16 @@ export default class J2sCardSequence extends LightningElement {
413
421
  try {
414
422
  const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
415
423
  if (res.ok) {
416
- this.tbidUserInfo = await res.json();
424
+ const userInfo = await res.json();
425
+ const emailOverride = await this.getDrmEmailOverride(
426
+ userInfo?.user_id
427
+ );
428
+ this.tbidUserInfo = !emailOverride
429
+ ? userInfo
430
+ : {
431
+ ...userInfo,
432
+ email: emailOverride
433
+ };
417
434
  this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
418
435
  }
419
436
  } catch (ex) {
@@ -428,4 +445,28 @@ export default class J2sCardSequence extends LightningElement {
428
445
 
429
446
  this._isTbidLoading = false;
430
447
  }
448
+
449
+ private async getDrmEmailOverride(
450
+ tbid: string
451
+ ): Promise<string> {
452
+ let resolvedEmail = "";
453
+
454
+ if (!tbid) {
455
+ return resolvedEmail;
456
+ }
457
+
458
+ try {
459
+ const res = await fetch(`${this.drmEmailUrl}?tbid=${tbid}`);
460
+ if (res.ok) {
461
+ const resData = await res.json();
462
+ if (resData.message === "success") {
463
+ resolvedEmail = resData.Email;
464
+ }
465
+ }
466
+ } catch (ex) {
467
+ // noop; nothing to do here; just proceed with no email override
468
+ }
469
+
470
+ return resolvedEmail;
471
+ }
431
472
  }
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.