@travetto/auth-model 5.0.0-rc.1 → 5.0.0-rc.11

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/README.md CHANGED
@@ -35,6 +35,8 @@ Currently, the following are packages that provide [CRUD](https://github.com/tra
35
35
  * [MySQL Model Service](https://github.com/travetto/travetto/tree/main/module/model-mysql#readme "MySQL backing for the travetto model module, with real-time modeling support for SQL schemas.") - @travetto/model-mysql
36
36
  * [PostgreSQL Model Service](https://github.com/travetto/travetto/tree/main/module/model-postgres#readme "PostgreSQL backing for the travetto model module, with real-time modeling support for SQL schemas.") - @travetto/model-postgres
37
37
  * [SQLite Model Service](https://github.com/travetto/travetto/tree/main/module/model-sqlite#readme "SQLite backing for the travetto model module, with real-time modeling support for SQL schemas.") - @travetto/model-sqlite
38
+ * [Memory Model Support](https://github.com/travetto/travetto/tree/main/module/model-memory#readme "Memory backing for the travetto model module.") - @travetto/model-memory
39
+ * [File Model Support](https://github.com/travetto/travetto/tree/main/module/model-file#readme "File system backing for the travetto model module.") - @travetto/model-file
38
40
  The module itself is fairly straightforward, and truly the only integration point for this module to work is defined at the model level. The contract for authentication is established in code as providing translation to and from a [Registered Principal](https://github.com/travetto/travetto/tree/main/module/auth-model/src/model.ts#L9).
39
41
 
40
42
  A registered principal extends the base concept of an principal, by adding in additional fields needed for local registration, specifically password management information.
@@ -129,7 +131,7 @@ class AuthConfig {
129
131
 
130
132
  **Code: Sample usage**
131
133
  ```typescript
132
- import { AppError } from '@travetto/base';
134
+ import { AppError } from '@travetto/runtime';
133
135
  import { Injectable, Inject } from '@travetto/di';
134
136
  import { ModelAuthService } from '@travetto/auth-model';
135
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/auth-model",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.11",
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.0-rc.1",
29
- "@travetto/model": "^5.0.0-rc.1"
28
+ "@travetto/auth": "^5.0.0-rc.10",
29
+ "@travetto/model": "^5.0.0-rc.11"
30
30
  },
31
31
  "peerDependencies": {
32
- "@travetto/test": "^5.0.0-rc.1"
32
+ "@travetto/test": "^5.0.0-rc.10"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@travetto/test": {
package/src/model.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppError, Util, Class, TimeUtil, Env } from '@travetto/base';
1
+ import { AppError, Util, Class, TimeUtil, Runtime } from '@travetto/runtime';
2
2
  import { ModelCrudSupport, ModelType, NotFoundError, OptionalId } from '@travetto/model';
3
3
  import { AuthUtil, Principal, Authenticator, Authorizer } from '@travetto/auth';
4
4
  import { isStorageSupported } from '@travetto/model/src/internal/service/common';
@@ -49,7 +49,7 @@ export class ModelAuthService<T extends ModelType> implements
49
49
  constructor(
50
50
  modelService: ModelCrudSupport,
51
51
  cls: Class<T>,
52
- public toPrincipal: (t: T) => RegisteredPrincipal,
52
+ public toPrincipal: (t: OptionalId<T>) => RegisteredPrincipal,
53
53
  public fromPrincipal: (t: Partial<RegisteredPrincipal>) => Partial<T>,
54
54
  ) {
55
55
  this.#modelService = modelService;
@@ -91,7 +91,7 @@ export class ModelAuthService<T extends ModelType> implements
91
91
  }
92
92
 
93
93
  async postConstruct(): Promise<void> {
94
- if (isStorageSupported(this.#modelService) && Env.dynamic) {
94
+ if (isStorageSupported(this.#modelService) && Runtime.dynamic) {
95
95
  await this.#modelService.createModel?.(this.#cls);
96
96
  }
97
97
  }
@@ -101,8 +101,7 @@ export class ModelAuthService<T extends ModelType> implements
101
101
  * @param user The user to register
102
102
  */
103
103
  async register(user: OptionalId<T>): Promise<T> {
104
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
105
- const ident = this.toPrincipal(user as T);
104
+ const ident = this.toPrincipal(user);
106
105
 
107
106
  try {
108
107
  if (ident.id) {
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
 
3
- import { AppError, Class } from '@travetto/base';
3
+ import { AppError, castTo, Class } from '@travetto/runtime';
4
4
  import { Suite, Test } from '@travetto/test';
5
5
  import { Inject, InjectableFactory } from '@travetto/di';
6
6
  import { ModelCrudSupport, Model } from '@travetto/model';
@@ -29,7 +29,7 @@ class TestConfig {
29
29
  const src = new ModelAuthService<User>(
30
30
  svc,
31
31
  User,
32
- u => ({ ...u, details: u, source: 'model' }),
32
+ u => castTo({ ...u, details: u, source: 'model' }),
33
33
  reg => User.from({ ...reg })
34
34
  );
35
35
  return src;