@travetto/auth-model 6.0.0-rc.1 → 6.0.0-rc.2
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 +6 -13
- package/__index__.ts +2 -2
- package/package.json +4 -4
- package/src/model.ts +4 -4
- package/support/test/model.ts +3 -3
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ yarn add @travetto/auth-model
|
|
|
15
15
|
|
|
16
16
|
This module supports the integration between the [Authentication](https://github.com/travetto/travetto/tree/main/module/auth#readme "Authentication scaffolding for the Travetto framework") module and the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.").
|
|
17
17
|
|
|
18
|
-
The asset module requires a [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/
|
|
18
|
+
The asset module requires a [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L11)-model to provide functionality for reading and storing user information. You can use any existing providers to serve as your [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L11), or you can roll your own.
|
|
19
19
|
|
|
20
20
|
**Install: provider**
|
|
21
21
|
```bash
|
|
@@ -25,7 +25,7 @@ npm install @travetto/model-{provider}
|
|
|
25
25
|
|
|
26
26
|
yarn add @travetto/model-{provider}
|
|
27
27
|
```
|
|
28
|
-
Currently, the following are packages that provide [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/
|
|
28
|
+
Currently, the following are packages that provide [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L11):
|
|
29
29
|
* [DynamoDB Model Support](https://github.com/travetto/travetto/tree/main/module/model-dynamodb#readme "DynamoDB backing for the travetto model module.") - @travetto/model-dynamodb
|
|
30
30
|
* [Elasticsearch Model Source](https://github.com/travetto/travetto/tree/main/module/model-elasticsearch#readme "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.") - @travetto/model-elasticsearch
|
|
31
31
|
* [Firestore Model Support](https://github.com/travetto/travetto/tree/main/module/model-firestore#readme "Firestore backing for the travetto model module.") - @travetto/model-firestore
|
|
@@ -37,11 +37,11 @@ Currently, the following are packages that provide [CRUD](https://github.com/tra
|
|
|
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
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
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
|
|
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 [
|
|
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 [RegisteredPrincipal](https://github.com/travetto/travetto/tree/main/module/auth-model/src/model.ts#L11).
|
|
41
41
|
|
|
42
42
|
A registered principal extends the base concept of an principal, by adding in additional fields needed for local registration, specifically password management information.
|
|
43
43
|
|
|
44
|
-
**Code:
|
|
44
|
+
**Code: RegisteredPrincipal**
|
|
45
45
|
```typescript
|
|
46
46
|
export interface RegisteredPrincipal extends Principal {
|
|
47
47
|
/**
|
|
@@ -95,7 +95,7 @@ import { InjectableFactory } from '@travetto/di';
|
|
|
95
95
|
import { ModelAuthService } from '@travetto/auth-model';
|
|
96
96
|
import { ModelCrudSupport } from '@travetto/model';
|
|
97
97
|
|
|
98
|
-
import { User } from './model';
|
|
98
|
+
import { User } from './model.ts';
|
|
99
99
|
|
|
100
100
|
class AuthConfig {
|
|
101
101
|
@InjectableFactory()
|
|
@@ -135,7 +135,7 @@ import { AppError } from '@travetto/runtime';
|
|
|
135
135
|
import { Injectable, Inject } from '@travetto/di';
|
|
136
136
|
import { ModelAuthService } from '@travetto/auth-model';
|
|
137
137
|
|
|
138
|
-
import { User } from './model';
|
|
138
|
+
import { User } from './model.ts';
|
|
139
139
|
|
|
140
140
|
@Injectable()
|
|
141
141
|
class UserService {
|
|
@@ -162,13 +162,6 @@ The [AuthModelUtil](https://github.com/travetto/travetto/tree/main/module/auth-m
|
|
|
162
162
|
|
|
163
163
|
**Code: Auth util structure**
|
|
164
164
|
```typescript
|
|
165
|
-
import crypto from 'node:crypto';
|
|
166
|
-
import util from 'node:util';
|
|
167
|
-
import { AppError, Util } from '@travetto/runtime';
|
|
168
|
-
const pbkdf2 = util.promisify(crypto.pbkdf2);
|
|
169
|
-
/**
|
|
170
|
-
* Standard auth utilities
|
|
171
|
-
*/
|
|
172
165
|
export class AuthModelUtil {
|
|
173
166
|
/**
|
|
174
167
|
* Generate a hash for a given value
|
package/__index__.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './src/model';
|
|
2
|
-
export * from './src/util';
|
|
1
|
+
export * from './src/model.ts';
|
|
2
|
+
export * from './src/util.ts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth-model",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.2",
|
|
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": "^6.0.0-rc.
|
|
29
|
-
"@travetto/model": "^6.0.0-rc.
|
|
28
|
+
"@travetto/auth": "^6.0.0-rc.2",
|
|
29
|
+
"@travetto/model": "^6.0.0-rc.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@travetto/test": "^6.0.0-rc.
|
|
32
|
+
"@travetto/test": "^6.0.0-rc.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"@travetto/test": {
|
package/src/model.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Util, Class, TimeUtil, Runtime } from '@travetto/runtime';
|
|
2
|
-
import { ModelCrudSupport, ModelType, NotFoundError, OptionalId } from '@travetto/model';
|
|
2
|
+
import { ModelCrudSupport, ModelType, NotFoundError, OptionalId, ModelStorageUtil } from '@travetto/model';
|
|
3
3
|
import { Principal, Authenticator, Authorizer, AuthenticationError } from '@travetto/auth';
|
|
4
|
-
import { isStorageSupported } from '@travetto/model/src/internal/service/common';
|
|
5
4
|
|
|
6
|
-
import { AuthModelUtil } from './util';
|
|
5
|
+
import { AuthModelUtil } from './util.ts';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* A set of registration data
|
|
9
|
+
* @concrete
|
|
10
10
|
*/
|
|
11
11
|
export interface RegisteredPrincipal extends Principal {
|
|
12
12
|
/**
|
|
@@ -99,7 +99,7 @@ export class ModelAuthService<T extends ModelType> implements Authenticator<T>,
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async postConstruct(): Promise<void> {
|
|
102
|
-
if (
|
|
102
|
+
if (ModelStorageUtil.isSupported(this.#modelService) && Runtime.dynamic) {
|
|
103
103
|
await this.#modelService.createModel?.(this.#cls);
|
|
104
104
|
}
|
|
105
105
|
}
|
package/support/test/model.ts
CHANGED
|
@@ -4,10 +4,10 @@ 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';
|
|
7
|
-
import { InjectableSuite } from '@travetto/di/support/test/suite';
|
|
8
|
-
import { ModelSuite } from '@travetto/model/support/test/suite';
|
|
7
|
+
import { InjectableSuite } from '@travetto/di/support/test/suite.ts';
|
|
8
|
+
import { ModelSuite } from '@travetto/model/support/test/suite.ts';
|
|
9
9
|
|
|
10
|
-
import { ModelAuthService, RegisteredPrincipal } from '../../src/model';
|
|
10
|
+
import { ModelAuthService, RegisteredPrincipal } from '../../src/model.ts';
|
|
11
11
|
|
|
12
12
|
export const TestModelSvcSymbol = Symbol.for('@travetto/auth:test-model-svc');
|
|
13
13
|
|