|
9 | 9 | callAllowApi, |
10 | 10 | callAuditApi, |
11 | 11 | CitadelAllowParams, |
| 12 | + CitadelAllowParamsSetOrUnsetFlag, |
12 | 13 | CitadelAuthFlowAuditParams, |
13 | 14 | Curve, |
14 | 15 | encodeEd25519Point, |
@@ -165,15 +166,13 @@ class Torus { |
165 | 166 | recordId, |
166 | 167 | }; |
167 | 168 |
|
168 | | - let result: TorusKey; |
| 169 | + // for auditing the auth flow |
| 170 | + const auditParams: CitadelAuthFlowAuditParams = { |
| 171 | + // at this point, user has completed the oauth login |
| 172 | + oauthCompleted: true, |
| 173 | + }; |
169 | 174 |
|
170 | | - if (!params.recordId) { |
171 | | - // report oauth completed, we won't await this call as it's only for analytics tracking |
172 | | - // if recordId isn't provided in the params, we will also report oauth initiated |
173 | | - this.reportSignerAllow({ ...allowParams, oauthCompleted: true, oauthInitiated: true }); |
174 | | - } else { |
175 | | - this.reportUserAuthFlowAudit({ ...params, recordId }, { oauthCompleted: true }); |
176 | | - } |
| 175 | + let result: TorusKey; |
177 | 176 |
|
178 | 177 | try { |
179 | 178 | result = await retrieveOrImportShare({ |
@@ -202,18 +201,20 @@ class Torus { |
202 | 201 | } catch (error) { |
203 | 202 | if (params.recordId) { |
204 | 203 | // report oauth verification failed, we won't await this call as it's only for analytics tracking |
205 | | - this.reportUserAuthFlowAudit({ ...params, recordId }, { oauthVerificationFailed: true }); |
| 204 | + auditParams.oauthVerificationFailed = true; |
| 205 | + this.reportUserAuthFlowAudit({ ...params, recordId }, auditParams); |
206 | 206 | } else { |
207 | | - this.reportSignerAllow({ ...allowParams, oauthVerificationFailed: true }); |
| 207 | + this.reportSignerAllow({ ...allowParams, oauthVerificationFailed: CitadelAllowParamsSetOrUnsetFlag.SET }); |
208 | 208 | } |
209 | 209 | throw error; |
210 | 210 | } |
211 | 211 |
|
212 | 212 | if (!params.recordId) { |
213 | | - this.reportSignerAllow({ ...allowParams, oauthVerified: true }); |
| 213 | + this.reportSignerAllow({ ...allowParams, oauthVerified: CitadelAllowParamsSetOrUnsetFlag.SET }); |
214 | 214 | } else { |
215 | 215 | // report oauth verified, we won't await this call as it's only for analytics tracking |
216 | | - this.reportUserAuthFlowAudit({ ...params, recordId }, { oauthVerified: true }); |
| 216 | + auditParams.oauthVerified = true; |
| 217 | + this.reportUserAuthFlowAudit({ ...params, recordId }, auditParams); |
217 | 218 | } |
218 | 219 | return result; |
219 | 220 | } |
|
0 commit comments