@toa.io/extensions.exposition 1.0.0-alpha.185 → 1.0.0-alpha.187
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/components/identity.basic/manifest.toa.yaml +18 -3
- package/components/identity.basic/operations/add.d.ts +3 -0
- package/components/identity.basic/operations/add.js +16 -0
- package/components/identity.basic/operations/add.js.map +1 -0
- package/components/identity.basic/operations/transit.js +5 -1
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +7 -1
- package/components/identity.basic/source/add.ts +14 -0
- package/components/identity.basic/source/transit.ts +6 -2
- package/components/identity.basic/source/types.ts +8 -1
- package/components/identity.otp/manifest.toa.yaml +13 -4
- package/components/identity.otp/operations/issue.d.ts +1 -0
- package/components/identity.otp/operations/issue.js +3 -2
- package/components/identity.otp/operations/issue.js.map +1 -1
- package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/source/issue.ts +5 -3
- package/documentation/components.md +10 -2
- package/features/identity.basic.feature +50 -0
- package/package.json +2 -2
- package/components/identity.basic/operations/assert.d.ts +0 -5
- package/components/identity.basic/operations/assert.js +0 -7
- package/components/identity.basic/operations/assert.js.map +0 -1
|
@@ -31,7 +31,13 @@ export interface TransitInput {
|
|
|
31
31
|
authority: string;
|
|
32
32
|
username?: string;
|
|
33
33
|
password?: string;
|
|
34
|
-
|
|
34
|
+
inception?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface AddInput {
|
|
37
|
+
id: string;
|
|
38
|
+
authority: string;
|
|
39
|
+
username: string;
|
|
40
|
+
password: string;
|
|
35
41
|
}
|
|
36
42
|
export interface IdOutput {
|
|
37
43
|
id: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AddInput, Context, IdOutput } from './types'
|
|
2
|
+
import type { Maybe } from '@toa.io/types'
|
|
3
|
+
|
|
4
|
+
export async function effect(input: AddInput, context: Context): Promise<Maybe<IdOutput>> {
|
|
5
|
+
return await context.local.transit({
|
|
6
|
+
input: {
|
|
7
|
+
authority: input.authority,
|
|
8
|
+
username: input.username,
|
|
9
|
+
password: input.password,
|
|
10
|
+
inception: true
|
|
11
|
+
},
|
|
12
|
+
query: { id: input.id }
|
|
13
|
+
})
|
|
14
|
+
}
|
|
@@ -24,9 +24,12 @@ export class Transition implements Operation {
|
|
|
24
24
|
public async execute (input: TransitInput, object: Entity): Promise<Maybe<IdOutput>> {
|
|
25
25
|
const existent = object._version !== 0
|
|
26
26
|
|
|
27
|
-
if (existent)
|
|
27
|
+
if (existent) {
|
|
28
|
+
if (input.inception === true)
|
|
29
|
+
return ERR_EXISTS
|
|
30
|
+
|
|
28
31
|
await this.tokens.revoke({ query: { id: object.id } })
|
|
29
|
-
else
|
|
32
|
+
} else
|
|
30
33
|
object.authority = input.authority
|
|
31
34
|
|
|
32
35
|
if (input.username !== undefined) {
|
|
@@ -66,5 +69,6 @@ function invalid (value: string, expressions: RegExp[]): boolean {
|
|
|
66
69
|
const ERR_PRINCIPAL_LOCKED = new Err('PRINCIPAL_LOCKED', 'Principal username cannot be changed')
|
|
67
70
|
const ERR_INVALID_USERNAME = new Err('INVALID_USERNAME', 'Username is not meeting the requirements')
|
|
68
71
|
const ERR_INVALID_PASSWORD = new Err('INVALID_PASSWORD', 'Password is not meeting the requirements')
|
|
72
|
+
const ERR_EXISTS = new Err('EXISTS', 'Basic credentials already exist')
|
|
69
73
|
|
|
70
74
|
type Tokens = Context['remote']['identity']['tokens']
|
|
@@ -34,7 +34,14 @@ export interface TransitInput {
|
|
|
34
34
|
authority: string
|
|
35
35
|
username?: string
|
|
36
36
|
password?: string
|
|
37
|
-
|
|
37
|
+
inception?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AddInput {
|
|
41
|
+
id: string
|
|
42
|
+
authority: string
|
|
43
|
+
username: string
|
|
44
|
+
password: string
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
export interface IdOutput {
|
|
@@ -2,8 +2,8 @@ namespace: identity
|
|
|
2
2
|
name: otp
|
|
3
3
|
|
|
4
4
|
entity:
|
|
5
|
-
schema:
|
|
6
|
-
properties:
|
|
5
|
+
schema:
|
|
6
|
+
properties: &properties
|
|
7
7
|
authority: { type: string }
|
|
8
8
|
username: { type: string }
|
|
9
9
|
required: [authority, username]
|
|
@@ -14,7 +14,14 @@ entity:
|
|
|
14
14
|
|
|
15
15
|
operations:
|
|
16
16
|
issue:
|
|
17
|
-
input:
|
|
17
|
+
input:
|
|
18
|
+
properties:
|
|
19
|
+
<<: *properties
|
|
20
|
+
lifetime: &lifetime
|
|
21
|
+
type: number
|
|
22
|
+
minimum: 1
|
|
23
|
+
maximum: 36000 # 10 hours
|
|
24
|
+
required: [authority, username]
|
|
18
25
|
authenticate:
|
|
19
26
|
input:
|
|
20
27
|
properties:
|
|
@@ -34,6 +41,8 @@ operations:
|
|
|
34
41
|
configuration:
|
|
35
42
|
schema:
|
|
36
43
|
properties:
|
|
37
|
-
lifetime:
|
|
44
|
+
lifetime:
|
|
45
|
+
<<: *lifetime
|
|
46
|
+
default: 300
|
|
38
47
|
|
|
39
48
|
stash: ~
|
|
@@ -5,8 +5,9 @@ async function effect(input, context) {
|
|
|
5
5
|
const { authority, username } = input;
|
|
6
6
|
const code = Math.floor(100000 + Math.random() * 900000).toString();
|
|
7
7
|
const key = `${authority}:${username}:${code}`;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const lifetime = input.lifetime ?? context.configuration.lifetime;
|
|
9
|
+
context.logs.debug('Issue OTP', { authority, username, code, lifetime });
|
|
10
|
+
await context.stash.set(key, 1, 'EX', lifetime);
|
|
10
11
|
return { code };
|
|
11
12
|
}
|
|
12
13
|
exports.effect = effect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../source/issue.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,KAAY,EAAE,OAAgB;IAC1D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IACnE,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../source/issue.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,KAAY,EAAE,OAAgB;IAC1D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;IACnE,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAA;IAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAA;IAEjE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAExE,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAE/C,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC;AAXD,wBAWC"}
|