@toa.io/extensions.exposition 1.0.0-alpha.195 → 1.0.0-alpha.197
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 +1 -0
- package/components/identity.federation/manifest.toa.yaml +2 -2
- package/components/identity.federation/operations/incept.d.ts +1 -1
- package/components/identity.federation/operations/incept.js +8 -9
- package/components/identity.federation/operations/incept.js.map +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/source/incept.ts +13 -13
- package/components/identity.otp/manifest.toa.yaml +1 -0
- package/components/identity.otp/operations/authenticate.js +4 -3
- package/components/identity.otp/operations/authenticate.js.map +1 -1
- package/components/identity.otp/operations/issue.js +3 -2
- package/components/identity.otp/operations/issue.js.map +1 -1
- package/components/identity.otp/operations/lib/Entity.d.ts +1 -0
- package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/source/authenticate.ts +5 -3
- package/components/identity.otp/source/issue.ts +2 -2
- package/components/identity.otp/source/lib/Entity.ts +1 -0
- package/package.json +2 -4
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decode } from './lib'
|
|
1
|
+
import { decode, exchange, type Ctx } from './lib'
|
|
3
2
|
import type { Request } from '@toa.io/types'
|
|
4
3
|
import type { Context, Entity, TransitInput, Scheme } from './types'
|
|
5
4
|
|
|
6
5
|
export async function effect (input: Input, context: Context): Promise<Output | Error> {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const payload = await decode(input.credentials, {
|
|
6
|
+
const ctx: Ctx = {
|
|
10
7
|
trust: context.configuration.trust,
|
|
11
8
|
logs: context.logs
|
|
12
|
-
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const claims = input.scheme === 'bearer'
|
|
12
|
+
? await decode(input.credentials, ctx)
|
|
13
|
+
: await exchange(input.credentials, ctx)
|
|
13
14
|
|
|
14
|
-
if (payload instanceof Error)
|
|
15
|
-
return payload
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (claims instanceof Error)
|
|
17
|
+
return claims
|
|
18
|
+
|
|
19
|
+
const { iss, sub } = claims
|
|
20
|
+
const request: Request<TransitInput> = { input: { authority: input.authority, iss, sub } }
|
|
19
21
|
|
|
20
22
|
if (input.id !== undefined)
|
|
21
23
|
request.query = { id: input.id }
|
|
@@ -23,12 +25,10 @@ export async function effect (input: Input, context: Context): Promise<Output |
|
|
|
23
25
|
return await context.local.transit(request)
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const ERR_SCHEME = new Err('ERR_SCHEME', 'Unsupported scheme')
|
|
27
|
-
|
|
28
28
|
export interface Input {
|
|
29
29
|
authority: string
|
|
30
|
+
scheme: Scheme
|
|
30
31
|
credentials: string
|
|
31
|
-
scheme?: Scheme
|
|
32
32
|
id?: string
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -13,15 +13,16 @@ async function effect(input, context) {
|
|
|
13
13
|
context.logs.debug('OTP code not found', { key });
|
|
14
14
|
return ERR_EXPIRED;
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const entry = await context.local.ensure({
|
|
17
17
|
entity: {
|
|
18
18
|
authority,
|
|
19
19
|
username
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
if (
|
|
22
|
+
if (entry === null)
|
|
23
23
|
return ERR_NOT_FOUND;
|
|
24
|
-
|
|
24
|
+
const id = entry.identity ?? entry.id;
|
|
25
|
+
return { identity: { id } };
|
|
25
26
|
}
|
|
26
27
|
exports.effect = effect;
|
|
27
28
|
const ERR_INVALID_CREDENTIALS = new error_value_1.Err('INVALID_CREDENTIALS');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../source/authenticate.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AAG1B,KAAK,UAAU,MAAM,CAAE,KAAY,EAAE,OAAgB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;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAEjD,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;QACvC,MAAM,EAAE;YACN,SAAS;YACT,QAAQ;SACT;KACF,CAAC,CAAA;IAEF,IAAI,KAAK,KAAK,IAAI;QAChB,OAAO,aAAa,CAAA;IAEtB,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAA;IAErC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,CAAA;AAC7B,CAAC;AA7BD,wBA6BC;AAED,MAAM,uBAAuB,GAAG,IAAI,iBAAG,CAAC,qBAAqB,CAAC,CAAA;AAC9D,MAAM,WAAW,GAAG,IAAI,iBAAG,CAAC,SAAS,CAAC,CAAA;AACtC,MAAM,aAAa,GAAG,IAAI,iBAAG,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -6,12 +6,13 @@ async function effect(input, context) {
|
|
|
6
6
|
const code = Math.floor(100000 + Math.random() * 900000).toString();
|
|
7
7
|
const key = `${authority}:${username}:${code}`;
|
|
8
8
|
const lifetime = input.lifetime ?? context.configuration.lifetime;
|
|
9
|
+
debugger;
|
|
9
10
|
if (identity !== undefined)
|
|
10
11
|
await context.local.ensure({
|
|
11
12
|
entity: {
|
|
12
|
-
id: identity,
|
|
13
13
|
authority,
|
|
14
|
-
username
|
|
14
|
+
username,
|
|
15
|
+
identity,
|
|
15
16
|
}
|
|
16
17
|
});
|
|
17
18
|
context.logs.debug('Issue OTP', { authority, username, identity, code, lifetime });
|
|
@@ -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,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