@travetto/auth-model 5.0.11 → 5.0.13

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/model.ts +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/auth-model",
3
- "version": "5.0.11",
3
+ "version": "5.0.13",
4
4
  "description": "Authentication model support for the Travetto framework",
5
5
  "keywords": [
6
6
  "authentication",
@@ -25,11 +25,11 @@
25
25
  "directory": "module/auth-model"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/auth": "^5.0.10",
29
- "@travetto/model": "^5.0.11"
28
+ "@travetto/auth": "^5.0.12",
29
+ "@travetto/model": "^5.0.13"
30
30
  },
31
31
  "peerDependencies": {
32
- "@travetto/test": "^5.0.10"
32
+ "@travetto/test": "^5.0.14"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@travetto/test": {
package/src/model.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AppError, Util, Class, TimeUtil, Runtime } from '@travetto/runtime';
1
+ import { Util, Class, TimeUtil, Runtime } from '@travetto/runtime';
2
2
  import { ModelCrudSupport, ModelType, NotFoundError, OptionalId } from '@travetto/model';
3
- import { AuthUtil, Principal, Authenticator, Authorizer } from '@travetto/auth';
3
+ import { AuthUtil, Principal, Authenticator, Authorizer, AuthenticationError } from '@travetto/auth';
4
4
  import { isStorageSupported } from '@travetto/model/src/internal/service/common';
5
5
 
6
6
  /**
@@ -83,7 +83,7 @@ export class ModelAuthService<T extends ModelType> implements
83
83
 
84
84
  const hash = await AuthUtil.generateHash(password, ident.salt!);
85
85
  if (hash !== ident.hash) {
86
- throw new AppError('Invalid password', 'authentication');
86
+ throw new AuthenticationError('Invalid password');
87
87
  } else {
88
88
  delete ident.password;
89
89
  return ident;
@@ -106,7 +106,7 @@ export class ModelAuthService<T extends ModelType> implements
106
106
  try {
107
107
  if (ident.id) {
108
108
  await this.#retrieve(ident.id);
109
- throw new AppError('That id is already taken.', 'data');
109
+ throw new AuthenticationError('That id is already taken.', { category: 'data' });
110
110
  }
111
111
  } catch (err) {
112
112
  if (!(err instanceof NotFoundError)) {
@@ -136,12 +136,12 @@ export class ModelAuthService<T extends ModelType> implements
136
136
 
137
137
  if (oldPassword === ident.resetToken) {
138
138
  if (ident.resetExpires && ident.resetExpires.getTime() < Date.now()) {
139
- throw new AppError('Reset token has expired', 'data');
139
+ throw new AuthenticationError('Reset token has expired', { category: 'data' });
140
140
  }
141
141
  } else if (oldPassword !== undefined) {
142
142
  const pw = await AuthUtil.generateHash(oldPassword, ident.salt!);
143
143
  if (pw !== ident.hash) {
144
- throw new AppError('Old password is required to change', 'authentication');
144
+ throw new AuthenticationError('Old password is required to change');
145
145
  }
146
146
  }
147
147