@travetto/auth-model 3.0.0-rc.4 → 3.0.0-rc.6
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 +11 -11
- package/{index.ts → __index__.ts} +0 -0
- package/package.json +17 -7
- package/src/model.ts +3 -4
- package/{test-support → support/test}/model.ts +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/auth-model/
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/auth-model/DOC.ts and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Authentication Model
|
|
4
4
|
## Authentication model support for the travetto framework
|
|
5
5
|
|
|
@@ -20,16 +20,16 @@ npm install @travetto/model-{provider}
|
|
|
20
20
|
Currently, the following are packages that provide [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/service/crud.ts#L11):
|
|
21
21
|
|
|
22
22
|
* [DynamoDB Model Support](https://github.com/travetto/travetto/tree/main/module/model-dynamodb#readme "DynamoDB backing for the travetto model module.") - @travetto/model-dynamodb
|
|
23
|
-
* [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
|
|
24
|
-
* [Firestore Model Support](https://github.com/travetto/travetto/tree/main/module/model-firestore#readme "Firestore backing for the travetto model module.") @travetto/model-firestore
|
|
25
|
-
* [MongoDB Model Support](https://github.com/travetto/travetto/tree/main/module/model-mongo#readme "Mongo backing for the travetto model module.") @travetto/model-mongo
|
|
26
|
-
* [Redis Model Support](https://github.com/travetto/travetto/tree/main/module/model-redis#readme "Redis backing for the travetto model module.") @travetto/model-redis
|
|
27
|
-
* [S3 Model Support](https://github.com/travetto/travetto/tree/main/module/model-s3#readme "S3 backing for the travetto model module.") @travetto/model-s3
|
|
28
|
-
* [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
|
|
29
|
-
* [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
|
|
30
|
-
* [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
|
|
31
|
-
|
|
32
|
-
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#
|
|
23
|
+
* [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
|
|
24
|
+
* [Firestore Model Support](https://github.com/travetto/travetto/tree/main/module/model-firestore#readme "Firestore backing for the travetto model module.") - @travetto/model-firestore
|
|
25
|
+
* [MongoDB Model Support](https://github.com/travetto/travetto/tree/main/module/model-mongo#readme "Mongo backing for the travetto model module.") - @travetto/model-mongo
|
|
26
|
+
* [Redis Model Support](https://github.com/travetto/travetto/tree/main/module/model-redis#readme "Redis backing for the travetto model module.") - @travetto/model-redis
|
|
27
|
+
* [S3 Model Support](https://github.com/travetto/travetto/tree/main/module/model-s3#readme "S3 backing for the travetto model module.") - @travetto/model-s3
|
|
28
|
+
* [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
|
|
29
|
+
* [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
|
|
30
|
+
* [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
|
|
31
|
+
|
|
32
|
+
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)
|
|
33
33
|
|
|
34
34
|
A registered principal extends the base concept of an principal, by adding in additional fields needed for local registration, specifically password management information.
|
|
35
35
|
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth-model",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.0-rc.4",
|
|
3
|
+
"version": "3.0.0-rc.6",
|
|
5
4
|
"description": "Authentication model support for the travetto framework",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"authentication",
|
|
@@ -16,18 +15,29 @@
|
|
|
16
15
|
"name": "Travetto Framework"
|
|
17
16
|
},
|
|
18
17
|
"files": [
|
|
19
|
-
"
|
|
18
|
+
"__index__.ts",
|
|
20
19
|
"src",
|
|
21
|
-
"
|
|
20
|
+
"support"
|
|
22
21
|
],
|
|
23
|
-
"main": "
|
|
22
|
+
"main": "__index__.ts",
|
|
24
23
|
"repository": {
|
|
25
24
|
"url": "https://github.com/travetto/travetto.git",
|
|
26
25
|
"directory": "module/auth-model"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@travetto/auth": "^3.0.0-rc.
|
|
30
|
-
"@travetto/model": "^3.0.0-rc.
|
|
28
|
+
"@travetto/auth": "^3.0.0-rc.4",
|
|
29
|
+
"@travetto/model": "^3.0.0-rc.6"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@travetto/test": "^3.0.0-rc.6"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@travetto/test": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"travetto": {
|
|
40
|
+
"displayName": "Authentication Model"
|
|
31
41
|
},
|
|
32
42
|
"private": false,
|
|
33
43
|
"publishConfig": {
|
package/src/model.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AppError, Util, Class } from '@travetto/base';
|
|
1
|
+
import { AppError, Util, Class, TimeUtil, GlobalEnv } from '@travetto/base';
|
|
2
2
|
import { ModelCrudSupport, ModelType, NotFoundError, OptionalId } from '@travetto/model';
|
|
3
|
-
import { EnvUtil } from '@travetto/boot';
|
|
4
3
|
import { AuthUtil, Principal, Authenticator, Authorizer } from '@travetto/auth';
|
|
5
4
|
import { isStorageSupported } from '@travetto/model/src/internal/service/common';
|
|
6
5
|
|
|
@@ -93,7 +92,7 @@ export class ModelAuthService<T extends ModelType> implements
|
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
async postConstruct(): Promise<void> {
|
|
96
|
-
if (isStorageSupported(this.#modelService) &&
|
|
95
|
+
if (isStorageSupported(this.#modelService) && GlobalEnv.dynamic) {
|
|
97
96
|
await this.#modelService.createModel?.(this.#cls);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -164,7 +163,7 @@ export class ModelAuthService<T extends ModelType> implements
|
|
|
164
163
|
const salt = await Util.uuid();
|
|
165
164
|
|
|
166
165
|
ident.resetToken = await AuthUtil.generateHash(Util.uuid(), salt, 25000, 32);
|
|
167
|
-
ident.resetExpires =
|
|
166
|
+
ident.resetExpires = TimeUtil.timeFromNow('1h');
|
|
168
167
|
|
|
169
168
|
Object.assign(user, this.fromPrincipal(ident));
|
|
170
169
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'assert';
|
|
2
2
|
|
|
3
3
|
import { AppError, Class } from '@travetto/base';
|
|
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/
|
|
8
|
-
import { ModelSuite } from '@travetto/model/
|
|
7
|
+
import { InjectableSuite } from '@travetto/di/support/test/suite';
|
|
8
|
+
import { ModelSuite } from '@travetto/model/support/test/suite';
|
|
9
9
|
|
|
10
|
-
import { ModelAuthService, RegisteredPrincipal } from '
|
|
10
|
+
import { ModelAuthService, RegisteredPrincipal } from '../../src/model';
|
|
11
11
|
|
|
12
|
-
export const TestModelSvcⲐ = Symbol.for('@
|
|
12
|
+
export const TestModelSvcⲐ = Symbol.for('@travetto/auth:test-model-svc');
|
|
13
13
|
|
|
14
14
|
@Model({ autoCreate: false })
|
|
15
15
|
class User implements RegisteredPrincipal {
|