@travetto/auth-model 5.0.0-rc.0 → 5.0.0-rc.10
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 +1 -1
- package/package.json +4 -4
- package/src/model.ts +4 -5
- package/support/test/model.ts +1 -1
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ class AuthConfig {
|
|
|
129
129
|
|
|
130
130
|
**Code: Sample usage**
|
|
131
131
|
```typescript
|
|
132
|
-
import { AppError } from '@travetto/
|
|
132
|
+
import { AppError } from '@travetto/runtime';
|
|
133
133
|
import { Injectable, Inject } from '@travetto/di';
|
|
134
134
|
import { ModelAuthService } from '@travetto/auth-model';
|
|
135
135
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth-model",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.10",
|
|
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.
|
|
29
|
-
"@travetto/model": "^5.0.0-rc.
|
|
28
|
+
"@travetto/auth": "^5.0.0-rc.9",
|
|
29
|
+
"@travetto/model": "^5.0.0-rc.10"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@travetto/test": "^5.0.0-rc.
|
|
32
|
+
"@travetto/test": "^5.0.0-rc.9"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"@travetto/test": {
|
package/src/model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppError, Util, Class, TimeUtil,
|
|
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) &&
|
|
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
|
-
|
|
105
|
-
const ident = this.toPrincipal(user as T);
|
|
104
|
+
const ident = this.toPrincipal(user);
|
|
106
105
|
|
|
107
106
|
try {
|
|
108
107
|
if (ident.id) {
|
package/support/test/model.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
|
|
3
|
-
import { AppError, Class } from '@travetto/
|
|
3
|
+
import { AppError, 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';
|