@toa.io/extensions.exposition 1.0.0-alpha.256 → 1.0.0-alpha.257

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/components/identity.basic/manifest.toa.yaml +7 -1
  3. package/components/identity.basic/operations/add.js +2 -1
  4. package/components/identity.basic/operations/add.js.map +1 -1
  5. package/components/identity.basic/operations/transit.js +2 -1
  6. package/components/identity.basic/operations/transit.js.map +1 -1
  7. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  8. package/components/identity.basic/operations/types.d.ts +2 -0
  9. package/components/identity.basic/source/add.ts +2 -1
  10. package/components/identity.basic/source/transit.ts +2 -1
  11. package/components/identity.basic/source/types.ts +3 -0
  12. package/components/identity.federation/events/principal.js +2 -2
  13. package/components/identity.federation/manifest.toa.yaml +15 -6
  14. package/components/identity.federation/operations/authenticate.js +13 -15
  15. package/components/identity.federation/operations/authenticate.js.map +1 -1
  16. package/components/identity.federation/operations/create.d.ts +8 -0
  17. package/components/identity.federation/operations/create.js +27 -0
  18. package/components/identity.federation/operations/create.js.map +1 -0
  19. package/components/identity.federation/operations/delete.js +1 -1
  20. package/components/identity.federation/operations/delete.js.map +1 -1
  21. package/components/identity.federation/operations/incept.d.ts +1 -1
  22. package/components/identity.federation/operations/incept.js +3 -26
  23. package/components/identity.federation/operations/incept.js.map +1 -1
  24. package/components/identity.federation/operations/lib/index.d.ts +1 -0
  25. package/components/identity.federation/operations/lib/index.js +3 -1
  26. package/components/identity.federation/operations/lib/index.js.map +1 -1
  27. package/components/identity.federation/operations/lib/resolve.d.ts +3 -0
  28. package/components/identity.federation/operations/lib/resolve.js +17 -0
  29. package/components/identity.federation/operations/lib/resolve.js.map +1 -0
  30. package/components/identity.federation/operations/list.js +1 -5
  31. package/components/identity.federation/operations/list.js.map +1 -1
  32. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  33. package/components/identity.federation/operations/types/context.d.ts +2 -5
  34. package/components/identity.federation/operations/types/entity.d.ts +2 -1
  35. package/components/identity.federation/source/authenticate.ts +15 -18
  36. package/components/identity.federation/source/create.ts +39 -0
  37. package/components/identity.federation/source/delete.ts +1 -1
  38. package/components/identity.federation/source/incept.ts +5 -37
  39. package/components/identity.federation/source/lib/index.ts +1 -0
  40. package/components/identity.federation/source/lib/resolve.ts +17 -0
  41. package/components/identity.federation/source/list.test.ts +3 -5
  42. package/components/identity.federation/source/list.ts +1 -8
  43. package/components/identity.federation/source/types/context.ts +2 -6
  44. package/components/identity.federation/source/types/entity.ts +2 -1
  45. package/components/identity.roles/receivers/identity.federation.principal.js +6 -0
  46. package/documentation/credentials.md +5 -2
  47. package/features/identity.basic.feature +54 -0
  48. package/features/identity.federation.feature +94 -1
  49. package/features/map.feature +2 -1
  50. package/package.json +3 -3
@@ -9,6 +9,7 @@ export async function effect (input: AddInput, context: Context): Promise<Maybe<
9
9
  password: input.password,
10
10
  inception: true
11
11
  },
12
- query: { id: input.id }
12
+ // `delete` leaves a tombstone, which the transition revives
13
+ query: { id: input.id, deleted: true }
13
14
  })
14
15
  }
@@ -22,7 +22,8 @@ export class Transition implements Operation {
22
22
  }
23
23
 
24
24
  public async execute (input: TransitInput, object: Entity): Promise<Maybe<IdOutput>> {
25
- const existent = object._version !== 0
25
+ const deleted = object._deleted !== undefined && object._deleted !== null
26
+ const existent = object._version !== 0 && !deleted
26
27
 
27
28
  if (existent) {
28
29
  if (input.inception === true)
@@ -29,6 +29,9 @@ export interface Entity {
29
29
  username: string
30
30
  password: string
31
31
  readonly _version: number
32
+
33
+ /** Deletion timestamp; `null` or absent while the credentials are in effect. */
34
+ _deleted?: number | null
32
35
  }
33
36
 
34
37
  export interface TransitInput {
@@ -15,8 +15,8 @@ exports.condition = function (event, context) {
15
15
  }
16
16
 
17
17
  /**
18
- * @param {{ state: import('../source/types').Entity & { id: string } }} event
18
+ * @param {{ state: import('../source/types').Entity }} event
19
19
  */
20
20
  exports.payload = function (event) {
21
- return { id: event.state.id }
21
+ return { identity: event.state.identity }
22
22
  }
@@ -2,7 +2,6 @@ namespace: identity
2
2
  name: federation
3
3
 
4
4
  entity:
5
- associated: true
6
5
  schema:
7
6
  type: object
8
7
  properties:
@@ -22,9 +21,11 @@ entity:
22
21
  - authority
23
22
  - iss
24
23
  - sub
24
+ - identity
25
25
  additionalProperties: false
26
26
  unique:
27
27
  token: [authority, iss, sub]
28
+ identity: [authority, iss, identity]
28
29
  index:
29
30
  list:
30
31
  authority: asc
@@ -38,13 +39,21 @@ operations:
38
39
  authority*: string
39
40
  iss*: string
40
41
  sub*: string
41
- identity: string
42
+ identity*: string
43
+ create:
44
+ input:
45
+ scheme*: [bearer, code]
46
+ authority*: string
47
+ credentials*: string
48
+ id*: string
49
+ errors:
50
+ - EXISTS
42
51
  incept:
43
52
  input:
44
53
  scheme*: [bearer, code]
45
54
  authority*: string
46
55
  credentials*: string
47
- id: string
56
+ id*: string
48
57
  output:
49
58
  id: string
50
59
  errors:
@@ -152,13 +161,13 @@ exposition:
152
161
  POST:
153
162
  map:authority: authority
154
163
  io:input: [scheme, credentials]
155
- io:output: false
156
- endpoint: incept
164
+ io:output: &credential [id, iss, _created]
165
+ endpoint: create
157
166
  GET:
158
167
  map:authority: authority
159
168
  map:segments:
160
169
  identity: id
161
- io:output: [id, iss, _created]
170
+ io:output: *credential
162
171
  endpoint: list
163
172
  /:credential:
164
173
  DELETE:
@@ -2,29 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.effect = void 0;
4
4
  const error_value_1 = require("error-value");
5
+ const generic_1 = require("@toa.io/generic");
5
6
  const lib_1 = require("./lib");
6
7
  async function effect({ scheme, authority, credentials }, context) {
7
8
  context.logs.debug('Authenticating', { scheme, authority, credentials });
8
- const ctx = {
9
- trust: context.configuration.trust,
10
- logs: context.logs,
11
- fetch: context.fetch
12
- };
13
- const claims = scheme === 'bearer'
14
- ? await (0, lib_1.decode)(credentials, ctx)
15
- : await (0, lib_1.exchange)(credentials, ctx);
9
+ const claims = await (0, lib_1.resolve)(scheme, credentials, context);
16
10
  if (claims instanceof Error)
17
11
  return claims;
18
12
  const { iss, sub } = claims;
19
13
  context.logs.debug('Token claims', claims);
20
- const identity = context.configuration.assert !== false
21
- ? await context.local.ensure({ entity: { authority, iss, sub } })
22
- : await context.local.observe({ query: { criteria: `authority==${authority};iss==${iss};sub==${sub}` } });
23
- if (identity === null)
14
+ const query = { criteria: `authority==${authority};iss==${iss};sub==${sub}` };
15
+ const credential = context.configuration.assert !== false
16
+ ? await context.local.ensure({
17
+ query,
18
+ entity: { authority, iss, sub, identity: (0, generic_1.newid)() }
19
+ })
20
+ : await context.local.observe({ query });
21
+ if (credential === null)
24
22
  return ERR_NOT_FOUND;
25
- if (identity instanceof Error)
26
- return identity;
27
- return { identity: { id: identity.identity ?? identity.id, claims } };
23
+ if (credential instanceof Error)
24
+ return credential;
25
+ return { identity: { id: credential.identity, claims } };
28
26
  }
29
27
  exports.effect = effect;
30
28
  const ERR_NOT_FOUND = new error_value_1.Err('NOT_FOUND');
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../source/authenticate.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AACjC,+BAAwC;AAMjC,KAAK,UAAU,MAAM,CAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAS,EAAE,OAAgB;IACvF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAA;IAExE,MAAM,GAAG,GAAQ;QACf,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;IAED,MAAM,MAAM,GAAG,MAAM,KAAK,QAAQ;QAChC,CAAC,CAAC,MAAM,IAAA,YAA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C,gBAAgB,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAA;IAExE,MAAM,MAAM,GAAG,MAAM,IAAA,aAAO,EAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;IAE1D,IAAI,MAAM,YAAY,KAAK;QACzB,OAAO,MAAM,CAAA;IAEf,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;IAE3B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IAE1C,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,cAAc,SAAS,SAAS,GAAG,SAAS,GAAG,EAAE,EAAE,CAAA;IAE7E,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,KAAK,KAAK;QACvD,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3B,KAAK;YACL,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAA,eAAK,GAAE,EAAE;SACnD,CAAC;QACF,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAE1C,IAAI,UAAU,KAAK,IAAI;QACrB,OAAO,aAAa,CAAA;IAEtB,IAAI,UAAU,YAAY,KAAK;QAC7B,OAAO,UAAU,CAAA;IAEnB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAA;AAC1D,CAAC;AA5BD,wBA4BC;AAED,MAAM,aAAa,GAAG,IAAI,iBAAG,CAAC,WAAW,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { Context, Entity, Scheme } from './types';
2
+ export declare function effect(input: Input, context: Context): Promise<Entity | Error>;
3
+ export interface Input {
4
+ authority: string;
5
+ scheme: Scheme;
6
+ credentials: string;
7
+ id: string;
8
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.effect = void 0;
4
+ const error_value_1 = require("error-value");
5
+ const lib_1 = require("./lib");
6
+ async function effect(input, context) {
7
+ const claims = await (0, lib_1.resolve)(input.scheme, input.credentials, context);
8
+ if (claims instanceof Error)
9
+ return claims;
10
+ const { iss, sub } = claims;
11
+ const existent = await context.local.observe({
12
+ query: { criteria: `authority==${input.authority};iss==${iss};sub==${sub}`, deleted: true }
13
+ });
14
+ const record = { authority: input.authority, iss, sub, identity: input.id };
15
+ if (existent === null)
16
+ return await context.local.transit({ input: record });
17
+ if (existent._deleted === undefined || existent._deleted === null)
18
+ return existent.identity === input.id ? existent : ERR_EXISTS;
19
+ // a deleted record still occupies the unique index, so the transition revives it
20
+ return await context.local.transit({
21
+ input: record,
22
+ query: { id: existent.id, deleted: true }
23
+ });
24
+ }
25
+ exports.effect = effect;
26
+ const ERR_EXISTS = new error_value_1.Err('EXISTS', 'Federation credentials are associated with another Identity');
27
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../source/create.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AACjC,+BAA+B;AAGxB,KAAK,UAAU,MAAM,CAAE,KAAY,EAAE,OAAgB;IAC1D,MAAM,MAAM,GAAG,MAAM,IAAA,aAAO,EAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IAEtE,IAAI,MAAM,YAAY,KAAK;QACzB,OAAO,MAAM,CAAA;IAEf,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;IAE3B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;QAC3C,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,KAAK,CAAC,SAAS,SAAS,GAAG,SAAS,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC5F,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAA;IAE3E,IAAI,QAAQ,KAAK,IAAI;QACnB,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI;QAC/D,OAAO,QAAQ,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAA;IAE/D,iFAAiF;IACjF,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;QACjC,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KAC1C,CAAC,CAAA;AACJ,CAAC;AAzBD,wBAyBC;AASD,MAAM,UAAU,GAAG,IAAI,iBAAG,CAAC,QAAQ,EAAE,6DAA6D,CAAC,CAAA"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.effect = void 0;
4
4
  async function effect({ authority, identity, credential }, context) {
5
5
  const object = await context.local.observe({ query: { id: credential } });
6
- if (object === null || object.authority !== authority || (object.identity ?? object.id) !== identity)
6
+ if (object === null || object.authority !== authority || object.identity !== identity)
7
7
  return null;
8
8
  return await context.local.terminate({ query: { id: credential } });
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"delete.js","sourceRoot":"","sources":["../source/delete.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAS,EAAE,OAAgB;IACxF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;IAEzE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,QAAQ;QAClG,OAAO,IAAI,CAAA;IAEb,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AACrE,CAAC;AAPD,wBAOC"}
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../source/delete.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAS,EAAE,OAAgB;IACxF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;IAEzE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ;QACnF,OAAO,IAAI,CAAA;IAEb,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AACrE,CAAC;AAPD,wBAOC"}
@@ -4,7 +4,7 @@ export interface Input {
4
4
  authority: string;
5
5
  scheme: Scheme;
6
6
  credentials: string;
7
- id?: string;
7
+ id: string;
8
8
  }
9
9
  export interface Output {
10
10
  id: string;
@@ -1,33 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.effect = void 0;
4
- const error_value_1 = require("error-value");
5
- const lib_1 = require("./lib");
4
+ const create_1 = require("./create");
6
5
  async function effect(input, context) {
7
- const ctx = {
8
- trust: context.configuration.trust,
9
- logs: context.logs,
10
- fetch: context.fetch
11
- };
12
- const claims = input.scheme === 'bearer'
13
- ? await (0, lib_1.decode)(input.credentials, ctx)
14
- : await (0, lib_1.exchange)(input.credentials, ctx);
15
- if (claims instanceof Error)
16
- return claims;
17
- const { iss, sub } = claims;
18
- if (input.id === undefined) {
19
- const request = { input: { authority: input.authority, iss, sub } };
20
- return await context.local.transit(request);
21
- }
22
- const existent = await context.local.observe({
23
- query: { criteria: `authority==${input.authority};iss==${iss};sub==${sub}` }
24
- });
25
- if (existent !== null)
26
- return (existent.identity ?? existent.id) === input.id ? { id: input.id } : ERR_EXISTS;
27
- return await context.local.transit({
28
- input: { authority: input.authority, iss, sub, identity: input.id }
29
- });
6
+ const credential = await (0, create_1.effect)(input, context);
7
+ return credential instanceof Error ? credential : { id: credential.identity };
30
8
  }
31
9
  exports.effect = effect;
32
- const ERR_EXISTS = new error_value_1.Err('EXISTS', 'Federation credentials are associated with another Identity');
33
10
  //# sourceMappingURL=incept.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"incept.js","sourceRoot":"","sources":["../source/incept.ts"],"names":[],"mappings":";;;AAAA,6CAAiC;AACjC,+BAAkD;AAI3C,KAAK,UAAU,MAAM,CAAE,KAAY,EAAE,OAAgB;IAC1D,MAAM,GAAG,GAAQ;QACf,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,QAAQ;QACtC,CAAC,CAAC,MAAM,IAAA,YAAM,EAAC,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC;QACtC,CAAC,CAAC,MAAM,IAAA,cAAQ,EAAC,KAAK,C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,EAAE,OAAgB;IAC1D,MAAM,UAAU,GAAG,MAAM,IAAA,eAAM,EAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAE/C,OAAO,UAAU,YAAY,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAA;AAC/E,CAAC;AAJD,wBAIC"}
@@ -1,3 +1,4 @@
1
1
  export { decode } from './decode';
2
2
  export { exchange } from './exchange';
3
+ export { resolve } from './resolve';
3
4
  export { type Ctx } from './Ctx';
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exchange = exports.decode = void 0;
3
+ exports.resolve = exports.exchange = exports.decode = void 0;
4
4
  var decode_1 = require("./decode");
5
5
  Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return decode_1.decode; } });
6
6
  var exchange_1 = require("./exchange");
7
7
  Object.defineProperty(exports, "exchange", { enumerable: true, get: function () { return exchange_1.exchange; } });
8
+ var resolve_1 = require("./resolve");
9
+ Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return resolve_1.resolve; } });
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/lib/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/lib/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Payload } from './Payload';
2
+ import type { Context, Scheme } from '../types';
3
+ export declare function resolve(scheme: Scheme, credentials: string, context: Context): Promise<Payload | Error>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolve = void 0;
4
+ const decode_1 = require("./decode");
5
+ const exchange_1 = require("./exchange");
6
+ async function resolve(scheme, credentials, context) {
7
+ const ctx = {
8
+ trust: context.configuration.trust,
9
+ logs: context.logs,
10
+ fetch: context.fetch
11
+ };
12
+ return scheme === 'bearer'
13
+ ? await (0, decode_1.decode)(credentials, ctx)
14
+ : await (0, exchange_1.exchange)(credentials, ctx);
15
+ }
16
+ exports.resolve = resolve;
17
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../source/lib/resolve.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,yCAAqC;AAK9B,KAAK,UAAU,OAAO,CAAE,MAAc,EAAE,WAAmB,EAAE,OAAgB;IAClF,MAAM,GAAG,GAAQ;QACf,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAA;IAED,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAC,MAAM,IAAA,eAAM,EAAC,WAAW,EAAE,GAAG,CAAC;QAChC,CAAC,CAAC,MAAM,IAAA,mBAAQ,EAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAVD,0BAUC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.computation = void 0;
4
4
  async function computation({ authority, identity }, context) {
5
- const objects = await context.local.enumerate({
5
+ return await context.local.enumerate({
6
6
  query: {
7
7
  criteria: `authority==${authority};identity==${identity}`,
8
8
  projection: ['iss'],
@@ -10,10 +10,6 @@ async function computation({ authority, identity }, context) {
10
10
  limit: 100
11
11
  }
12
12
  });
13
- const legacy = await context.local.observe({ query: { id: identity } });
14
- if (legacy !== null && legacy.authority === authority && legacy.identity === undefined)
15
- objects.push(legacy);
16
- return objects.sort((a, b) => b._created - a._created);
17
13
  }
18
14
  exports.computation = computation;
19
15
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../source/list.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,WAAW,CAAE,EAAE,SAAS,EAAE,QAAQ,EAAS,EAAE,OAAgB;IACjF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5C,KAAK,EAAE;YACL,QAAQ,EAAE,cAAc,SAAS,cAAc,QAAQ,EAAE;YACzD,UAAU,EAAE,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,CAAC,eAAe,CAAC;YACvB,KAAK,EAAE,GAAG;SACX;KACF,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;IAEvE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;QACpF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEtB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;AACxD,CAAC;AAhBD,kCAgBC"}
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../source/list.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,WAAW,CAAE,EAAE,SAAS,EAAE,QAAQ,EAAS,EAAE,OAAgB;IACjF,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QACnC,KAAK,EAAE;YACL,QAAQ,EAAE,cAAc,SAAS,cAAc,QAAQ,EAAE;YACzD,UAAU,EAAE,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,CAAC,eAAe,CAAC;YACvB,KAAK,EAAE,GAAG;SACX;KACF,CAAC,CAAA;AACJ,CAAC;AATD,kCASC"}