3
3
* Licensed under the MIT License.
4
4
*/
5
5
import { AuthError } from "./AuthError" ;
6
- import { IdToken } from "../auth /IdToken" ;
7
- import { ScopeSet } from "../auth /ScopeSet" ;
6
+ import { IdToken } from "../account /IdToken" ;
7
+ import { ScopeSet } from "../request /ScopeSet" ;
8
8
9
9
/**
10
10
* ClientAuthErrorMessage class containing string constants used by error codes and messages.
@@ -105,7 +105,7 @@ export const ClientAuthErrorMessage = {
105
105
* Error thrown when there is an error in the client code running on the browser.
106
106
*/
107
107
export class ClientAuthError extends AuthError {
108
-
108
+
109
109
constructor ( errorCode : string , errorMessage ?: string ) {
110
110
super ( errorCode , errorMessage ) ;
111
111
this . name = "ClientAuthError" ;
@@ -115,7 +115,7 @@ export class ClientAuthError extends AuthError {
115
115
116
116
/**
117
117
* Creates an error thrown when client info object doesn't decode correctly.
118
- * @param caughtError
118
+ * @param caughtError
119
119
*/
120
120
static createClientInfoDecodingError ( caughtError : string ) : ClientAuthError {
121
121
return new ClientAuthError ( ClientAuthErrorMessage . clientInfoDecodingError . code ,
@@ -124,7 +124,7 @@ export class ClientAuthError extends AuthError {
124
124
125
125
/**
126
126
* Creates an error thrown if the client info is empty.
127
- * @param rawClientInfo
127
+ * @param rawClientInfo
128
128
*/
129
129
static createClientInfoEmptyError ( rawClientInfo : string ) : ClientAuthError {
130
130
return new ClientAuthError ( ClientAuthErrorMessage . clientInfoEmptyError . code ,
@@ -133,7 +133,7 @@ export class ClientAuthError extends AuthError {
133
133
134
134
/**
135
135
* Creates an error thrown when the id token extraction errors out.
136
- * @param err
136
+ * @param err
137
137
*/
138
138
static createIdTokenParsingError ( caughtExtractionError : string ) : ClientAuthError {
139
139
return new ClientAuthError ( ClientAuthErrorMessage . idTokenParsingError . code ,
@@ -142,7 +142,7 @@ export class ClientAuthError extends AuthError {
142
142
143
143
/**
144
144
* Creates an error thrown when the id token string is null or empty.
145
- * @param invalidRawTokenString
145
+ * @param invalidRawTokenString
146
146
*/
147
147
static createIdTokenNullOrEmptyError ( invalidRawTokenString : string ) : ClientAuthError {
148
148
return new ClientAuthError ( ClientAuthErrorMessage . nullOrEmptyIdToken . code ,
@@ -151,66 +151,66 @@ export class ClientAuthError extends AuthError {
151
151
152
152
/**
153
153
* Creates an error thrown when the token request could not be retrieved from the cache
154
- * @param errDetail
154
+ * @param errDetail
155
155
*/
156
156
static createTokenRequestCacheError ( errDetail : string ) : ClientAuthError {
157
- return new ClientAuthError ( ClientAuthErrorMessage . tokenRequestCacheError . code ,
157
+ return new ClientAuthError ( ClientAuthErrorMessage . tokenRequestCacheError . code ,
158
158
`${ ClientAuthErrorMessage . tokenRequestCacheError . desc } Error Detail: ${ errDetail } ` ) ;
159
159
}
160
160
161
161
/**
162
162
* Creates an error thrown when the endpoint discovery doesn't complete correctly.
163
163
*/
164
164
static createEndpointDiscoveryIncompleteError ( errDetail : string ) : ClientAuthError {
165
- return new ClientAuthError ( ClientAuthErrorMessage . endpointResolutionError . code ,
165
+ return new ClientAuthError ( ClientAuthErrorMessage . endpointResolutionError . code ,
166
166
`${ ClientAuthErrorMessage . endpointResolutionError . desc } Detail: ${ errDetail } ` ) ;
167
167
}
168
168
169
169
/**
170
170
* Creates an error thrown if authority type is not valid.
171
- * @param invalidAuthorityError
171
+ * @param invalidAuthorityError
172
172
*/
173
173
static createInvalidAuthorityTypeError ( givenUrl : string ) : ClientAuthError {
174
- return new ClientAuthError ( ClientAuthErrorMessage . invalidAuthorityType . code ,
174
+ return new ClientAuthError ( ClientAuthErrorMessage . invalidAuthorityType . code ,
175
175
`${ ClientAuthErrorMessage . invalidAuthorityType . desc } Given Url: ${ givenUrl } ` ) ;
176
176
}
177
177
178
178
/**
179
179
* Creates an error thrown when the hash cannot be deserialized.
180
- * @param invalidAuthorityError
180
+ * @param invalidAuthorityError
181
181
*/
182
182
static createHashNotDeserializedError ( hashParamObj : string ) : ClientAuthError {
183
- return new ClientAuthError ( ClientAuthErrorMessage . hashNotDeserialized . code ,
183
+ return new ClientAuthError ( ClientAuthErrorMessage . hashNotDeserialized . code ,
184
184
`${ ClientAuthErrorMessage . hashNotDeserialized . desc } Given Object: ${ hashParamObj } ` ) ;
185
185
}
186
186
187
187
/**
188
188
* Creates an error thrown when two states do not match.
189
189
*/
190
190
static createStateMismatchError ( ) : ClientAuthError {
191
- return new ClientAuthError ( ClientAuthErrorMessage . stateMismatchError . code ,
191
+ return new ClientAuthError ( ClientAuthErrorMessage . stateMismatchError . code ,
192
192
ClientAuthErrorMessage . stateMismatchError . desc ) ;
193
193
}
194
194
195
195
/**
196
196
* Creates an error thrown when the nonce does not match.
197
197
*/
198
198
static createNonceMismatchError ( ) : ClientAuthError {
199
- return new ClientAuthError ( ClientAuthErrorMessage . nonceMismatchError . code ,
199
+ return new ClientAuthError ( ClientAuthErrorMessage . nonceMismatchError . code ,
200
200
ClientAuthErrorMessage . nonceMismatchError . desc ) ;
201
201
}
202
202
203
- /**
203
+ /**
204
204
* Creates an error thrown when the cached account and response account do not match.
205
205
*/
206
206
static createAccountMismatchError ( ) : ClientAuthError {
207
- return new ClientAuthError ( ClientAuthErrorMessage . accountMismatchError . code ,
207
+ return new ClientAuthError ( ClientAuthErrorMessage . accountMismatchError . code ,
208
208
ClientAuthErrorMessage . accountMismatchError . desc ) ;
209
209
}
210
210
211
211
/**
212
212
* Throws error if idToken is not correctly formed
213
- * @param idToken
213
+ * @param idToken
214
214
*/
215
215
static createInvalidIdTokenError ( idToken : IdToken ) : ClientAuthError {
216
216
return new ClientAuthError ( ClientAuthErrorMessage . invalidIdToken . code ,
@@ -221,15 +221,15 @@ export class ClientAuthError extends AuthError {
221
221
* Creates an error thrown when the authorization code required for a token request is null or empty.
222
222
*/
223
223
static createNoTokensFoundError ( scopes : string ) : ClientAuthError {
224
- return new ClientAuthError ( ClientAuthErrorMessage . noTokensFoundError . code ,
224
+ return new ClientAuthError ( ClientAuthErrorMessage . noTokensFoundError . code ,
225
225
`${ ClientAuthErrorMessage . noTokensFoundError . desc } Scopes: ${ scopes } ` ) ;
226
226
}
227
227
228
228
/**
229
229
* Creates an error in cache parsing.
230
230
*/
231
231
static createCacheParseError ( cacheKey : string ) : ClientAuthError {
232
- return new ClientAuthError ( ClientAuthErrorMessage . cacheParseError . code ,
232
+ return new ClientAuthError ( ClientAuthErrorMessage . cacheParseError . code ,
233
233
`${ ClientAuthErrorMessage . cacheParseError . desc } Cache key: ${ cacheKey } ` ) ;
234
234
}
235
235
@@ -243,7 +243,7 @@ export class ClientAuthError extends AuthError {
243
243
244
244
/**
245
245
* Throws error when multiple tokens are in cache for the given scope.
246
- * @param scope
246
+ * @param scope
247
247
*/
248
248
static createMultipleMatchingTokensInCacheError ( scope : string ) : ClientAuthError {
249
249
return new ClientAuthError ( ClientAuthErrorMessage . multipleMatchingTokens . code ,
@@ -259,31 +259,31 @@ export class ClientAuthError extends AuthError {
259
259
260
260
/**
261
261
* Throws error when attempting to append a null, undefined or empty scope to a set
262
- * @param givenScope
262
+ * @param givenScope
263
263
*/
264
264
static createAppendEmptyScopeToSetError ( givenScope : string ) : ClientAuthError {
265
265
return new ClientAuthError ( ClientAuthErrorMessage . appendEmptyScopeError . code , `${ ClientAuthErrorMessage . appendEmptyScopeError . desc } Given Scope: ${ givenScope } ` ) ;
266
266
}
267
267
268
268
/**
269
269
* Throws error when attempting to append a null, undefined or empty scope to a set
270
- * @param givenScope
270
+ * @param givenScope
271
271
*/
272
272
static createRemoveEmptyScopeFromSetError ( givenScope : string ) : ClientAuthError {
273
273
return new ClientAuthError ( ClientAuthErrorMessage . removeEmptyScopeError . code , `${ ClientAuthErrorMessage . removeEmptyScopeError . desc } Given Scope: ${ givenScope } ` ) ;
274
274
}
275
275
276
276
/**
277
277
* Throws error when attempting to append null or empty ScopeSet.
278
- * @param appendError
278
+ * @param appendError
279
279
*/
280
280
static createAppendScopeSetError ( appendError : string ) : ClientAuthError {
281
281
return new ClientAuthError ( ClientAuthErrorMessage . appendScopeSetError . code , `${ ClientAuthErrorMessage . appendScopeSetError . desc } Detail Error: ${ appendError } ` ) ;
282
282
}
283
283
284
284
/**
285
285
* Throws error if ScopeSet is null or undefined.
286
- * @param givenScopeSet
286
+ * @param givenScopeSet
287
287
*/
288
288
static createEmptyInputScopeSetError ( givenScopeSet : ScopeSet ) : ClientAuthError {
289
289
return new ClientAuthError ( ClientAuthErrorMessage . emptyInputScopeSetError . code , `${ ClientAuthErrorMessage . emptyInputScopeSetError . desc } Given ScopeSet: ${ givenScopeSet } ` ) ;
0 commit comments