@salesforcedevs/dw-components 1.3.396 → 1.3.397-canary.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.396",
3
+ "version": "1.3.397-canary.1",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -25,6 +25,5 @@
25
25
  "@types/lodash.uniqby": "4.7.9",
26
26
  "@types/setimmediate": "1.0.4",
27
27
  "setimmediate": "1.0.5"
28
- },
29
- "gitHead": "ef208488b6cf979514f09d3b4a643bee356d984b"
28
+ }
30
29
  }
@@ -117,6 +117,8 @@
117
117
  <span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
118
118
  </dx-checkbox>
119
119
 
120
+ <slot class="form-captcha-slot" name="form-captcha-slot"></slot>
121
+
120
122
  <dx-button
121
123
  class="submit-button"
122
124
  variant="custom"
@@ -47,6 +47,7 @@ export default class DeSignupForm extends LightningElement {
47
47
  private marketingText: string = "";
48
48
  private showLegalCheckbox: boolean = false;
49
49
  private privacyText: string = "";
50
+ private recaptchaToken = "";
50
51
 
51
52
  @track knownDuplicateUsers: string[] = [];
52
53
 
@@ -73,6 +74,26 @@ export default class DeSignupForm extends LightningElement {
73
74
  return stateMap[this.country] || [];
74
75
  }
75
76
 
77
+ @api
78
+ recaptchaCallback(responseToken: string) {
79
+ this.recaptchaToken = responseToken;
80
+ }
81
+
82
+ @api
83
+ recaptchaExpiredCallback() {
84
+ this.recaptchaToken = "";
85
+ }
86
+
87
+ @api
88
+ recaptchaErrorCallback() {
89
+ this.resetRecaptcha();
90
+ }
91
+
92
+ private resetRecaptcha() {
93
+ this.recaptchaToken = "";
94
+ (window as any).grecaptcha?.reset();
95
+ }
96
+
76
97
  connectedCallback(): void {
77
98
  this.getCountryList();
78
99
  }
@@ -119,11 +140,14 @@ export default class DeSignupForm extends LightningElement {
119
140
  );
120
141
  }
121
142
 
122
- trackFormCompletion(target: EventTarget, formData: SignupForm, convertingPage = "success") {
143
+ trackFormCompletion(
144
+ target: EventTarget,
145
+ formData: SignupForm,
146
+ convertingPage = "success"
147
+ ) {
123
148
  trackGtm(target!, "custEv_formCompletion", {
124
149
  converting_page: `SFDC:us:signup:${convertingPage}`,
125
- converting_page_url:
126
- `https://developer.salesforce.com/signup/${convertingPage}`,
150
+ converting_page_url: `https://developer.salesforce.com/signup/${convertingPage}`,
127
151
  form_country: formData.user.country,
128
152
  form_name: "Dev Edition Signup",
129
153
  form_primary_product_interest: "Developer Edition",
@@ -145,7 +169,7 @@ export default class DeSignupForm extends LightningElement {
145
169
  }
146
170
 
147
171
  const formData = this.prepareUserData();
148
- if (!formData) {
172
+ if (!formData || !this.recaptchaToken) {
149
173
  return;
150
174
  }
151
175
 
@@ -164,7 +188,7 @@ export default class DeSignupForm extends LightningElement {
164
188
  );
165
189
 
166
190
  this.setSubmitButtonDisabled(true);
167
- submitForm(formData)
191
+ submitForm(formData, this.recaptchaToken)
168
192
  .then(() => {
169
193
  trackGtm(event.target!, "custEv_signUp", {
170
194
  authentication_method: "email",
@@ -176,13 +200,18 @@ export default class DeSignupForm extends LightningElement {
176
200
  })
177
201
  .catch((error) => {
178
202
  if (error.message === ErrorCode.GENERIC && didSubmitTimeout) {
179
- this.trackFormCompletion(event.target!, formData, "account-verification");
203
+ this.trackFormCompletion(
204
+ event.target!,
205
+ formData,
206
+ "account-verification"
207
+ );
180
208
  // If the timeout time has passed at the point of error, and the error code is simply "GENERIC",
181
209
  // we do not know whether the org will ultimately be created (and we have no current way of confirming),
182
210
  // so we navigate the user to an interim page that tells them to watch their email.
183
211
  window.location.href = "/signup/account-verification";
184
212
  } else {
185
213
  this.setSubmitButtonDisabled(false);
214
+ this.resetRecaptcha();
186
215
  if (error.message === ErrorCode.DUPLICATE) {
187
216
  this.knownDuplicateUsers.push(formData.user.username);
188
217
  } else {
@@ -79,13 +79,19 @@ const checkOrgStatus = (id: string, retries = 0): Promise<void> => {
79
79
  });
80
80
  };
81
81
 
82
- export const submitForm = async (formData: SignupForm): Promise<void> => {
82
+ export const submitForm = async (
83
+ formData: SignupForm,
84
+ recaptchaToken: string
85
+ ): Promise<void> => {
83
86
  const response = await fetch(CREATE_PATH, {
84
87
  method: "POST",
85
88
  headers: {
86
89
  "Content-Type": "application/json"
87
90
  },
88
- body: JSON.stringify(formData)
91
+ body: JSON.stringify({
92
+ ...formData,
93
+ "g-recaptcha-response": recaptchaToken
94
+ })
89
95
  });
90
96
 
91
97
  if (!response.ok) {
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.