@toa.io/extensions.exposition 1.0.0-alpha.282 → 1.0.0-alpha.283
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/CHANGELOG.md +27 -0
- package/components/exposition.octets/manifest.toa.yaml +11 -0
- package/components/exposition.octets/types/index.d.ts +3 -0
- package/components/exposition.octets/types/toa.d.ts +41 -0
- package/components/identity.bans/types/index.d.ts +3 -0
- package/components/identity.bans/types/toa.d.ts +34 -0
- package/components/identity.basic/manifest.toa.yaml +13 -2
- package/components/identity.basic/operations/add.d.ts +3 -3
- package/components/identity.basic/operations/authenticate.d.ts +2 -2
- package/components/identity.basic/operations/check.d.ts +1 -1
- package/components/identity.basic/operations/delete.d.ts +2 -2
- package/components/identity.basic/operations/incept.d.ts +2 -2
- package/components/identity.basic/operations/info.d.ts +1 -1
- package/components/identity.basic/operations/transit.d.ts +4 -3
- package/components/identity.basic/operations/transit.js +2 -1
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/source/add.ts +3 -3
- package/components/identity.basic/source/authenticate.ts +2 -2
- package/components/identity.basic/source/check.ts +1 -1
- package/components/identity.basic/source/delete.ts +2 -2
- package/components/identity.basic/source/incept.ts +2 -2
- package/components/identity.basic/source/info.ts +1 -1
- package/components/identity.basic/source/transit.ts +6 -4
- package/components/identity.basic/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/types/index.d.ts +21 -0
- package/components/identity.basic/types/toa.d.ts +121 -0
- package/components/identity.clients/manifest.toa.yaml +243 -0
- package/components/identity.clients/operations/describe.d.ts +27 -0
- package/components/identity.clients/operations/describe.js +44 -0
- package/components/identity.clients/operations/describe.js.map +1 -0
- package/components/identity.clients/operations/lib/Context.d.ts +29 -0
- package/components/identity.clients/operations/lib/Context.js +2 -0
- package/components/identity.clients/operations/lib/Context.js.map +1 -0
- package/components/identity.clients/operations/lib/Entity.d.ts +29 -0
- package/components/identity.clients/operations/lib/Entity.js +2 -0
- package/components/identity.clients/operations/lib/Entity.js.map +1 -0
- package/components/identity.clients/operations/lib/canonical.d.ts +11 -0
- package/components/identity.clients/operations/lib/canonical.js +24 -0
- package/components/identity.clients/operations/lib/canonical.js.map +1 -0
- package/components/identity.clients/operations/lib/cimd.d.ts +8 -0
- package/components/identity.clients/operations/lib/cimd.js +86 -0
- package/components/identity.clients/operations/lib/cimd.js.map +1 -0
- package/components/identity.clients/operations/lib/errors.d.ts +7 -0
- package/components/identity.clients/operations/lib/errors.js +5 -0
- package/components/identity.clients/operations/lib/errors.js.map +1 -0
- package/components/identity.clients/operations/lib/index.d.ts +6 -0
- package/components/identity.clients/operations/lib/index.js +7 -0
- package/components/identity.clients/operations/lib/index.js.map +1 -0
- package/components/identity.clients/operations/lib/redirect.d.ts +10 -0
- package/components/identity.clients/operations/lib/redirect.js +32 -0
- package/components/identity.clients/operations/lib/redirect.js.map +1 -0
- package/components/identity.clients/operations/register.d.ts +37 -0
- package/components/identity.clients/operations/register.js +84 -0
- package/components/identity.clients/operations/register.js.map +1 -0
- package/components/identity.clients/source/describe.ts +65 -0
- package/components/identity.clients/source/lib/Context.ts +38 -0
- package/components/identity.clients/source/lib/Entity.ts +31 -0
- package/components/identity.clients/source/lib/canonical.test.ts +43 -0
- package/components/identity.clients/source/lib/canonical.ts +27 -0
- package/components/identity.clients/source/lib/cimd.test.ts +120 -0
- package/components/identity.clients/source/lib/cimd.ts +107 -0
- package/components/identity.clients/source/lib/errors.ts +4 -0
- package/components/identity.clients/source/lib/index.ts +6 -0
- package/components/identity.clients/source/lib/redirect.test.ts +41 -0
- package/components/identity.clients/source/lib/redirect.ts +35 -0
- package/components/identity.clients/source/register.ts +125 -0
- package/components/identity.clients/tsconfig.json +10 -0
- package/components/identity.clients/tsconfig.tsbuildinfo +1 -0
- package/components/identity.clients/types/index.d.ts +3 -0
- package/components/identity.clients/types/toa.d.ts +109 -0
- package/components/identity.credentials/operations/list.d.ts +2 -1
- package/components/identity.credentials/operations/list.js.map +1 -1
- package/components/identity.credentials/source/list.ts +2 -1
- package/components/identity.credentials/tsconfig.tsbuildinfo +1 -1
- package/components/identity.credentials/types/index.d.ts +3 -0
- package/components/identity.credentials/types/toa.d.ts +30 -0
- package/components/identity.federation/manifest.toa.yaml +37 -1
- package/components/identity.federation/operations/authenticate.d.ts +1 -1
- package/components/identity.federation/operations/lib/Ctx.d.ts +2 -2
- package/components/identity.federation/operations/lib/decode.js +22 -8
- package/components/identity.federation/operations/lib/decode.js.map +1 -1
- package/components/identity.federation/operations/lib/errors.d.ts +7 -0
- package/components/identity.federation/operations/lib/errors.js +4 -0
- package/components/identity.federation/operations/lib/errors.js.map +1 -1
- package/components/identity.federation/operations/lib/exchange.js +11 -6
- package/components/identity.federation/operations/lib/exchange.js.map +1 -1
- package/components/identity.federation/operations/types/configuration.d.ts +1 -1
- package/components/identity.federation/operations/types/context.d.ts +3 -2
- package/components/identity.federation/source/authenticate.ts +1 -1
- package/components/identity.federation/source/lib/Ctx.ts +2 -2
- package/components/identity.federation/source/lib/decode.ts +25 -9
- package/components/identity.federation/source/lib/errors.ts +5 -0
- package/components/identity.federation/source/lib/exchange.ts +11 -7
- package/components/identity.federation/source/types/configuration.ts +1 -1
- package/components/identity.federation/source/types/context.ts +3 -2
- package/components/identity.federation/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/types/index.d.ts +3 -0
- package/components/identity.federation/types/toa.d.ts +127 -0
- package/components/identity.grants/manifest.toa.yaml +245 -0
- package/components/identity.grants/operations/authorize.d.ts +35 -0
- package/components/identity.grants/operations/authorize.js +54 -0
- package/components/identity.grants/operations/authorize.js.map +1 -0
- package/components/identity.grants/operations/exchange.d.ts +37 -0
- package/components/identity.grants/operations/exchange.js +89 -0
- package/components/identity.grants/operations/exchange.js.map +1 -0
- package/components/identity.grants/operations/lib/code.d.ts +15 -0
- package/components/identity.grants/operations/lib/code.js +30 -0
- package/components/identity.grants/operations/lib/code.js.map +1 -0
- package/components/identity.grants/operations/lib/identify.d.ts +6 -0
- package/components/identity.grants/operations/lib/identify.js +15 -0
- package/components/identity.grants/operations/lib/identify.js.map +1 -0
- package/components/identity.grants/operations/lib/index.d.ts +3 -0
- package/components/identity.grants/operations/lib/index.js +3 -0
- package/components/identity.grants/operations/lib/index.js.map +1 -0
- package/components/identity.grants/operations/list.d.ts +13 -0
- package/components/identity.grants/operations/list.js +18 -0
- package/components/identity.grants/operations/list.js.map +1 -0
- package/components/identity.grants/operations/revoke.d.ts +18 -0
- package/components/identity.grants/operations/revoke.js +25 -0
- package/components/identity.grants/operations/revoke.js.map +1 -0
- package/components/identity.grants/source/authorize.ts +90 -0
- package/components/identity.grants/source/exchange.ts +130 -0
- package/components/identity.grants/source/lib/code.ts +39 -0
- package/components/identity.grants/source/lib/identify.ts +16 -0
- package/components/identity.grants/source/lib/index.ts +3 -0
- package/components/identity.grants/source/list.ts +28 -0
- package/components/identity.grants/source/revoke.ts +38 -0
- package/components/identity.grants/tsconfig.json +10 -0
- package/components/identity.grants/tsconfig.tsbuildinfo +1 -0
- package/components/identity.grants/types/index.d.ts +60 -0
- package/components/identity.grants/types/toa.d.ts +108 -0
- package/components/identity.keys/manifest.toa.yaml +1 -0
- package/components/identity.keys/operations/create.d.ts +1 -1
- package/components/identity.keys/operations/revoke.d.ts +1 -1
- package/components/identity.keys/source/create.ts +1 -1
- package/components/identity.keys/source/revoke.ts +1 -1
- package/components/identity.keys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.keys/types/index.d.ts +3 -0
- package/components/identity.keys/types/toa.d.ts +47 -0
- package/components/identity.otp/operations/lib/Context.d.ts +4 -2
- package/components/identity.otp/source/lib/Context.ts +4 -2
- package/components/identity.otp/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/types/index.d.ts +3 -0
- package/components/identity.otp/types/toa.d.ts +56 -0
- package/components/identity.passkeys/manifest.toa.yaml +3 -0
- package/components/identity.passkeys/operations/authenticate.d.ts +1 -1
- package/components/identity.passkeys/operations/challenge.d.ts +1 -1
- package/components/identity.passkeys/operations/create.d.ts +1 -1
- package/components/identity.passkeys/operations/types/Context.d.ts +2 -1
- package/components/identity.passkeys/operations/use.d.ts +1 -1
- package/components/identity.passkeys/source/authenticate.ts +1 -1
- package/components/identity.passkeys/source/challenge.ts +1 -1
- package/components/identity.passkeys/source/create.ts +1 -1
- package/components/identity.passkeys/source/types/Context.ts +2 -1
- package/components/identity.passkeys/source/use.ts +1 -1
- package/components/identity.passkeys/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/types/index.d.ts +3 -0
- package/components/identity.passkeys/types/toa.d.ts +120 -0
- package/components/identity.roles/operations/principal.d.ts +1 -1
- package/components/identity.roles/source/principal.ts +1 -1
- package/components/identity.roles/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/types/index.d.ts +3 -0
- package/components/identity.roles/types/toa.d.ts +43 -0
- package/components/identity.tokens/manifest.toa.yaml +34 -3
- package/components/identity.tokens/operations/authenticate.d.ts +2 -1
- package/components/identity.tokens/operations/authenticate.js +8 -0
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.d.ts +2 -1
- package/components/identity.tokens/operations/decrypt.js +2 -2
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/encrypt.d.ts +2 -1
- package/components/identity.tokens/operations/encrypt.js.map +1 -1
- package/components/identity.tokens/operations/issue.d.ts +2 -1
- package/components/identity.tokens/operations/issue.js +2 -1
- package/components/identity.tokens/operations/issue.js.map +1 -1
- package/components/identity.tokens/operations/lib/form.d.ts +8 -0
- package/components/identity.tokens/operations/lib/form.js +24 -0
- package/components/identity.tokens/operations/lib/form.js.map +1 -0
- package/components/identity.tokens/operations/lib/index.d.ts +2 -1
- package/components/identity.tokens/operations/lib/index.js +1 -1
- package/components/identity.tokens/operations/lib/index.js.map +1 -1
- package/components/identity.tokens/source/authenticate.test.ts +8 -5
- package/components/identity.tokens/source/authenticate.ts +12 -1
- package/components/identity.tokens/source/decrypt.test.ts +1 -1
- package/components/identity.tokens/source/decrypt.ts +4 -3
- package/components/identity.tokens/source/encrypt.test.ts +1 -1
- package/components/identity.tokens/source/encrypt.ts +2 -1
- package/components/identity.tokens/source/issue.test.ts +71 -0
- package/components/identity.tokens/source/issue.ts +4 -2
- package/components/identity.tokens/source/lib/form.test.ts +25 -0
- package/components/identity.tokens/source/lib/form.ts +31 -0
- package/components/identity.tokens/source/lib/index.ts +2 -1
- package/components/identity.tokens/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/types/index.d.ts +61 -0
- package/components/identity.tokens/types/toa.d.ts +113 -0
- package/documentation/cache.md +10 -1
- package/documentation/consent.md +101 -0
- package/documentation/identity.md +3 -1
- package/documentation/io.md +36 -2
- package/documentation/oauth.md +179 -0
- package/documentation/protocol.md +4 -0
- package/features/auth.bearer.feature +120 -0
- package/features/cache.feature +46 -0
- package/features/oauth.clients.feature +195 -0
- package/features/oauth.discovery.feature +165 -0
- package/features/oauth.grants.feature +286 -0
- package/features/steps/Gateway.ts +6 -1
- package/features/steps/Parameters.ts +4 -0
- package/features/steps/components/echo/manifest.toa.yaml +2 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +2 -0
- package/features/steps/components/octets.tester/operations/redirect.js +6 -1
- package/features/steps/components/users/manifest.toa.yaml +1 -0
- package/package.json +8 -6
- package/readme.md +3 -0
- package/schemas/annotation.cos.yaml +30 -0
- package/source/Annotation.ts +23 -0
- package/source/Factory.ts +1 -1
- package/source/HTTP/Server.ts +9 -5
- package/source/HTTP/formats/form.ts +21 -0
- package/source/HTTP/formats/index.ts +17 -2
- package/source/HTTP/messages.test.ts +25 -1
- package/source/HTTP/messages.ts +10 -3
- package/source/Interception.ts +8 -2
- package/source/deployment.ts +4 -1
- package/source/directives/auth/Authorization.ts +46 -19
- package/source/directives/auth/Incept.ts +14 -9
- package/source/directives/auth/schemes.test.ts +8 -4
- package/source/directives/auth/schemes.ts +22 -9
- package/source/directives/auth/types.ts +5 -2
- package/source/directives/cache/Cache.ts +13 -4
- package/source/directives/cache/Control.ts +0 -3
- package/source/directives/flow/Fetch.ts +1 -1
- package/source/directives/index.ts +2 -1
- package/source/directives/io/IO.ts +2 -0
- package/source/directives/io/Output.ts +4 -1
- package/source/directives/io/Status.test.ts +84 -0
- package/source/directives/io/Status.ts +46 -0
- package/source/directives/oauth/Discovery.ts +76 -0
- package/source/directives/oauth/documents.ts +113 -0
- package/source/directives/oauth/index.ts +3 -0
- package/source/directives/octets/Delete.ts +1 -1
- package/source/directives/octets/Get.ts +1 -1
- package/source/directives/octets/Workflow.ts +1 -1
- package/source/directives/octets/workflows/Execution.ts +1 -1
- package/source/index.ts +6 -0
- package/source/octets.d.ts +17 -0
- package/source/userland.ts +47 -0
- package/transpiled/Annotation.d.ts +17 -0
- package/transpiled/Factory.js +1 -1
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +4 -1
- package/transpiled/HTTP/Server.js +4 -3
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/formats/form.d.ts +9 -0
- package/transpiled/HTTP/formats/form.js +18 -0
- package/transpiled/HTTP/formats/form.js.map +1 -0
- package/transpiled/HTTP/formats/index.d.ts +10 -2
- package/transpiled/HTTP/formats/index.js +10 -0
- package/transpiled/HTTP/formats/index.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +6 -0
- package/transpiled/HTTP/messages.js +3 -3
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/Interception.d.ts +4 -1
- package/transpiled/Interception.js +4 -2
- package/transpiled/Interception.js.map +1 -1
- package/transpiled/deployment.js +2 -0
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Authorization.d.ts +1 -1
- package/transpiled/directives/auth/Authorization.js +38 -18
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Incept.d.ts +1 -1
- package/transpiled/directives/auth/Incept.js +11 -7
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/auth/schemes.d.ts +16 -4
- package/transpiled/directives/auth/schemes.js +20 -8
- package/transpiled/directives/auth/schemes.js.map +1 -1
- package/transpiled/directives/auth/types.d.ts +4 -2
- package/transpiled/directives/cache/Cache.js +9 -2
- package/transpiled/directives/cache/Cache.js.map +1 -1
- package/transpiled/directives/cache/Control.js +0 -2
- package/transpiled/directives/cache/Control.js.map +1 -1
- package/transpiled/directives/index.js +2 -1
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/io/IO.js +2 -0
- package/transpiled/directives/io/IO.js.map +1 -1
- package/transpiled/directives/io/Output.js +4 -1
- package/transpiled/directives/io/Output.js.map +1 -1
- package/transpiled/directives/io/Status.d.ts +19 -0
- package/transpiled/directives/io/Status.js +34 -0
- package/transpiled/directives/io/Status.js.map +1 -0
- package/transpiled/directives/oauth/Discovery.d.ts +23 -0
- package/transpiled/directives/oauth/Discovery.js +58 -0
- package/transpiled/directives/oauth/Discovery.js.map +1 -0
- package/transpiled/directives/oauth/documents.d.ts +9 -0
- package/transpiled/directives/oauth/documents.js +82 -0
- package/transpiled/directives/oauth/documents.js.map +1 -0
- package/transpiled/directives/oauth/index.d.ts +2 -0
- package/transpiled/directives/oauth/index.js +3 -0
- package/transpiled/directives/oauth/index.js.map +1 -0
- package/transpiled/index.d.ts +2 -0
- package/transpiled/userland.d.ts +39 -0
- package/transpiled/userland.js +7 -0
- package/transpiled/userland.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +0 -61
- package/components/identity.basic/operations/types.js +0 -2
- package/components/identity.basic/operations/types.js.map +0 -1
- package/components/identity.basic/source/types.ts +0 -69
- package/components/identity.tokens/operations/lib/types.d.ts +0 -88
- package/components/identity.tokens/operations/lib/types.js +0 -2
- package/components/identity.tokens/operations/lib/types.js.map +0 -1
- package/components/identity.tokens/source/lib/types.ts +0 -102
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../source/issue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../source/issue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAKvC,MAAM,OAAO,MAAM;IACT,IAAI,CAAwC;IAC5C,KAAK,CAAyC;IAC9C,OAAO,CAA8B;IACrC,QAAQ,CAAS;IAElB,KAAK,CAAE,OAAgB;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;QACxC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAA;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAA;QACpC,sDAAsD;QACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAA;IAChD,CAAC;IAEM,KAAK,CAAC,OAAO,CAAE,KAAY;QAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAA;QAEhD,MAAM,OAAO,GAAG,QAAQ,KAAK,CAAC;YAC5B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;QAEpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YACjC,KAAK,EAAE;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,OAAO;aACR;SACF,CAAC,CAAA;QAEF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAClC,KAAK,EAAE;gBACL,QAAQ,EAAE,aAAa,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;gBAC9C,KAAK,EAAE,IAAI;aACZ;SACF,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAa;YACzB,EAAE,EAAE,KAAK,CAAC,QAAQ;YAClB,KAAK;SACN,CAAA;QAED,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;QAEhD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAC/B,KAAK,EAAE;gBACL,SAAS;gBACT,QAAQ;gBACR,QAAQ;gBACR,MAAM;gBACN,WAAW;gBACX,GAAG;aACJ;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,OAAO,KAAK,CAAA;QAEd,OAAO;YACL,GAAG,EAAE,GAAG,CAAC,EAAE;YACX,iDAAiD;YACjD,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;YAC9C,KAAK;SACN,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The form of a token this component issues, or nothing for a credential it did not:
|
|
3
|
+
* a compact JWE has five segments, where a JWS — an OpenID `id_token`, say — has three.
|
|
4
|
+
* Read without decrypting, and without trusting: a credential that lies about its form
|
|
5
|
+
* only reaches a verifier that rejects it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function form(token: string): Form | null;
|
|
8
|
+
export type Form = 'paseto' | 'jwe';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The form of a token this component issues, or nothing for a credential it did not:
|
|
3
|
+
* a compact JWE has five segments, where a JWS — an OpenID `id_token`, say — has three.
|
|
4
|
+
* Read without decrypting, and without trusting: a credential that lies about its form
|
|
5
|
+
* only reaches a verifier that rejects it.
|
|
6
|
+
*/
|
|
7
|
+
export function form(token) {
|
|
8
|
+
if (token.startsWith(PASETO))
|
|
9
|
+
return 'paseto';
|
|
10
|
+
if (segments(token) === JWE_SEGMENTS)
|
|
11
|
+
return 'jwe';
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
function segments(token) {
|
|
15
|
+
let count = 1;
|
|
16
|
+
for (let i = 0; i < token.length; i++)
|
|
17
|
+
if (token.charCodeAt(i) === DOT)
|
|
18
|
+
count++;
|
|
19
|
+
return count;
|
|
20
|
+
}
|
|
21
|
+
const PASETO = 'v3.local.';
|
|
22
|
+
const JWE_SEGMENTS = 5;
|
|
23
|
+
const DOT = 46;
|
|
24
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../source/lib/form.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAE,KAAa;IACjC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1B,OAAO,QAAQ,CAAA;IAEjB,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,YAAY;QAClC,OAAO,KAAK,CAAA;IAEd,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,QAAQ,CAAE,KAAa;IAC9B,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QACnC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG;YAC7B,KAAK,EAAE,CAAA;IAEX,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,MAAM,GAAG,WAAW,CAAA;AAC1B,MAAM,YAAY,GAAG,CAAC,CAAA;AACtB,MAAM,GAAG,GAAG,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -4,7 +4,7 @@ import assert from 'node:assert/strict'
|
|
|
4
4
|
import { generate } from 'randomstring'
|
|
5
5
|
import { Computation as Authenticate } from './authenticate.js'
|
|
6
6
|
import type { Configuration, Context, DecryptOutput, Identity } from './lib/index.js'
|
|
7
|
-
import type { Secret } from '@toa.io/
|
|
7
|
+
import type { Secret } from '@toa.io/extensions.configuration'
|
|
8
8
|
|
|
9
9
|
let configuration: Configuration
|
|
10
10
|
let context: Context
|
|
@@ -14,6 +14,9 @@ let authenticate: Authenticate
|
|
|
14
14
|
const identity: Identity = { id: generate(), roles: [] }
|
|
15
15
|
const authority = generate()
|
|
16
16
|
|
|
17
|
+
/** Compact JWE shape: `authenticate` reads it before decrypting, and `decrypt` is mocked. */
|
|
18
|
+
const credentials = 'header.key.iv.ciphertext.tag'
|
|
19
|
+
|
|
17
20
|
beforeEach(() => {
|
|
18
21
|
configuration = {
|
|
19
22
|
keys: [
|
|
@@ -53,7 +56,7 @@ for (const [expected, shift] of [
|
|
|
53
56
|
|
|
54
57
|
const result = await authenticate.execute({
|
|
55
58
|
authority,
|
|
56
|
-
credentials
|
|
59
|
+
credentials
|
|
57
60
|
})
|
|
58
61
|
|
|
59
62
|
assert.deepStrictEqual(result, { identity, refresh: expected })
|
|
@@ -68,7 +71,7 @@ for (const refresh of [true, false])
|
|
|
68
71
|
|
|
69
72
|
const result = await authenticate.execute({
|
|
70
73
|
authority,
|
|
71
|
-
credentials
|
|
74
|
+
credentials
|
|
72
75
|
})
|
|
73
76
|
|
|
74
77
|
assert.deepStrictEqual(result, { identity, refresh })
|
|
@@ -80,7 +83,7 @@ it('should not refresh an aged custom token', async () => {
|
|
|
80
83
|
|
|
81
84
|
output = { iss: authority, identity, exp, iat, refresh: false, custom: true }
|
|
82
85
|
|
|
83
|
-
const result = await authenticate.execute({ authority, credentials
|
|
86
|
+
const result = await authenticate.execute({ authority, credentials })
|
|
84
87
|
|
|
85
88
|
assert.deepStrictEqual(result, { identity, refresh: false })
|
|
86
89
|
})
|
|
@@ -93,7 +96,7 @@ it('should check revocation of an aged custom token', async () => {
|
|
|
93
96
|
context.local.observe = mock.fn(async () => ({ revokedAt: Date.now() })) as unknown as Context['local']['observe']
|
|
94
97
|
authenticate.mount(context)
|
|
95
98
|
|
|
96
|
-
const result: any = await authenticate.execute({ authority, credentials
|
|
99
|
+
const result: any = await authenticate.execute({ authority, credentials })
|
|
97
100
|
|
|
98
101
|
assert.deepStrictEqual(result.code, 'TOKEN_REVOKED')
|
|
99
102
|
})
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Maybe
|
|
1
|
+
import type { Maybe } from '@toa.io/core'
|
|
2
|
+
import type { Operation } from '@toa.io/bridges.node'
|
|
3
|
+
import { form } from './lib/index.js'
|
|
2
4
|
import type { AuthenticateInput, AuthenticateOutput, Context } from './lib/index.js'
|
|
3
5
|
|
|
4
6
|
export class Computation implements Operation {
|
|
@@ -13,6 +15,11 @@ export class Computation implements Operation {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
public async execute (input: AuthenticateInput): Promise<Maybe<AuthenticateOutput>> {
|
|
18
|
+
// `Bearer` is presented by an OpenID id_token too, and the gateway asks each provider
|
|
19
|
+
// in turn: a credential this component did not issue is declined, not rejected
|
|
20
|
+
if (form(input.credentials) === null)
|
|
21
|
+
return ERR_UNRECOGNIZED
|
|
22
|
+
|
|
16
23
|
const claims = await this.decrypt({ input: input.credentials })
|
|
17
24
|
|
|
18
25
|
if (claims instanceof Error)
|
|
@@ -43,6 +50,10 @@ export class Computation implements Operation {
|
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
|
|
53
|
+
const ERR_UNRECOGNIZED = new (class UnrecognizedError extends Error {
|
|
54
|
+
public readonly code = 'UNRECOGNIZED'
|
|
55
|
+
})()
|
|
56
|
+
|
|
46
57
|
const ERR_AUTHORITY = new (class AuthorityMismatchError extends Error {
|
|
47
58
|
public readonly code = 'AUTHORITY_MISMATCH'
|
|
48
59
|
})()
|
|
@@ -6,7 +6,7 @@ import { EncryptFactory, ImportKeyFactory } from 'paseto/v3/local'
|
|
|
6
6
|
import { Effect as Encrypt } from './encrypt.js'
|
|
7
7
|
import { Computation as Decrypt } from './decrypt.js'
|
|
8
8
|
import { type Configuration, type Context, type Identity } from './lib/index.js'
|
|
9
|
-
import type { Secret } from '@toa.io/
|
|
9
|
+
import type { Secret } from '@toa.io/extensions.configuration'
|
|
10
10
|
|
|
11
11
|
let configuration: Configuration
|
|
12
12
|
let context: Context
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DecryptFactory, ImportKeyFactory } from 'paseto/v3/local'
|
|
2
2
|
import { LRUCache } from 'lru-cache'
|
|
3
|
-
import { jweKey } from './lib/index.js'
|
|
3
|
+
import { form, jweKey } from './lib/index.js'
|
|
4
4
|
import { load } from './lib/jose.js'
|
|
5
|
-
import type { Maybe
|
|
5
|
+
import type { Maybe } from '@toa.io/core'
|
|
6
|
+
import type { Operation } from '@toa.io/bridges.node'
|
|
6
7
|
import type { Context, Claims, DecryptOutput, JWEClaims } from './lib/index.js'
|
|
7
8
|
|
|
8
9
|
export class Computation implements Operation {
|
|
@@ -32,7 +33,7 @@ export class Computation implements Operation {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
public async execute (token: string): Promise<Maybe<DecryptOutput>> {
|
|
35
|
-
const legacy = token
|
|
36
|
+
const legacy = form(token) === 'paseto'
|
|
36
37
|
const kid = legacy ? this.pasetoKid(token) : await this.jweKid(token)
|
|
37
38
|
|
|
38
39
|
if (kid instanceof Error)
|
|
@@ -6,7 +6,7 @@ import { timeout } from '@toa.io/generic'
|
|
|
6
6
|
import { Effect as Encrypt } from './encrypt.js'
|
|
7
7
|
import { Computation as Decrypt } from './decrypt.js'
|
|
8
8
|
import { type Context, type Identity } from './lib/index.js'
|
|
9
|
-
import type { Secret } from '@toa.io/
|
|
9
|
+
import type { Secret } from '@toa.io/extensions.configuration'
|
|
10
10
|
|
|
11
11
|
let encrypt: Encrypt
|
|
12
12
|
let decrypt: Decrypt
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jweKey } from './lib/index.js'
|
|
2
2
|
import { load } from './lib/jose.js'
|
|
3
|
-
import type { Operation
|
|
3
|
+
import type { Operation } from '@toa.io/bridges.node'
|
|
4
|
+
import type { Maybe } from '@toa.io/core'
|
|
4
5
|
import type { Identity, Context, EncryptInput, Key } from './lib/index.js'
|
|
5
6
|
|
|
6
7
|
export class Effect implements Operation {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { it, beforeEach, mock } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import { generate } from 'randomstring'
|
|
5
|
+
import { Effect as Issue } from './issue.js'
|
|
6
|
+
import type { Context, EncryptInput } from './lib/index.js'
|
|
7
|
+
|
|
8
|
+
const LIFETIME = 2592000 // seconds, the configured default
|
|
9
|
+
const identity = generate()
|
|
10
|
+
const authority = generate()
|
|
11
|
+
const label = generate()
|
|
12
|
+
|
|
13
|
+
let issue: Issue
|
|
14
|
+
let encrypted: EncryptInput
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
const context = {
|
|
18
|
+
configuration: { lifetime: LIFETIME },
|
|
19
|
+
remote: {
|
|
20
|
+
identity: {
|
|
21
|
+
keys: { create: mock.fn(async () => ({ id: 'kid0', key: 'secret' })) },
|
|
22
|
+
roles: { list: mock.fn(async () => []) }
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
local: {
|
|
26
|
+
encrypt: mock.fn(async ({ input }: { input: EncryptInput }) => {
|
|
27
|
+
encrypted = input
|
|
28
|
+
|
|
29
|
+
return 'token'
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
} as unknown as Context
|
|
33
|
+
|
|
34
|
+
issue = new Issue()
|
|
35
|
+
issue.mount(context)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The configured lifetime is seconds, as the schema says and as `encrypt` reads it. Storing
|
|
40
|
+
* it as milliseconds and then multiplying again put the expiration some eighty thousand years
|
|
41
|
+
* out, and only on this path — every scenario passes a lifetime of its own.
|
|
42
|
+
*/
|
|
43
|
+
it('should expire a token issued without a lifetime as the configuration says', async () => {
|
|
44
|
+
const now = Date.now()
|
|
45
|
+
const reply: any = await issue.execute({ authority, identity, label })
|
|
46
|
+
|
|
47
|
+
const seconds = (reply.exp - now) / 1000
|
|
48
|
+
|
|
49
|
+
assert.ok(Math.abs(seconds - LIFETIME) < 10,
|
|
50
|
+
`expected to expire in about ${LIFETIME} seconds, got ${seconds}`)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should hand the lifetime to `encrypt` in the seconds it reads', async () => {
|
|
54
|
+
await issue.execute({ authority, identity, label })
|
|
55
|
+
|
|
56
|
+
assert.equal(encrypted.lifetime, LIFETIME)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('should expire a token as its own lifetime says', async () => {
|
|
60
|
+
const now = Date.now()
|
|
61
|
+
const reply: any = await issue.execute({ authority, identity, label, lifetime: 600 })
|
|
62
|
+
|
|
63
|
+
assert.ok(Math.abs((reply.exp - now) / 1000 - 600) < 10)
|
|
64
|
+
assert.equal(encrypted.lifetime, 600)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('should issue a token that does not expire INSECURE', async () => {
|
|
68
|
+
const reply: any = await issue.execute({ authority, identity, label, lifetime: 0 })
|
|
69
|
+
|
|
70
|
+
assert.equal(reply.exp, undefined)
|
|
71
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { quote } from '@toa.io/generic'
|
|
2
|
-
import type { Maybe
|
|
2
|
+
import type { Maybe } from '@toa.io/core'
|
|
3
|
+
import type { Operation } from '@toa.io/bridges.node'
|
|
3
4
|
import type { Context, Identity } from './lib/index.js'
|
|
4
5
|
|
|
5
6
|
export class Effect implements Operation {
|
|
@@ -12,7 +13,8 @@ export class Effect implements Operation {
|
|
|
12
13
|
this.keys = context.remote.identity.keys
|
|
13
14
|
this.roles = context.remote.identity.roles
|
|
14
15
|
this.encrypt = context.local.encrypt
|
|
15
|
-
|
|
16
|
+
// seconds, as `input.lifetime` and `encrypt` both are
|
|
17
|
+
this.lifetime = context.configuration.lifetime
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
public async execute (input: Input): Promise<Maybe<Output>> {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { it } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import { form } from './form.js'
|
|
5
|
+
|
|
6
|
+
it('should recognize a compact JWE by its five segments', () => {
|
|
7
|
+
assert.equal(form('header.key.iv.ciphertext.tag'), 'jwe')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('should recognize a legacy PASETO by its prefix', () => {
|
|
11
|
+
assert.equal(form('v3.local.payload'), 'paseto')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('should not recognize a JWS, which is what an id_token is', () => {
|
|
15
|
+
assert.equal(form('header.payload.signature'), null)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should not recognize what is not a token at all', () => {
|
|
19
|
+
for (const value of ['', 'token', 'header.key.iv.ciphertext.tag.extra'])
|
|
20
|
+
assert.equal(form(value), null)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should read the shape and nothing else, leaving the rest to the verifier', () => {
|
|
24
|
+
assert.equal(form('....'), 'jwe')
|
|
25
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The form of a token this component issues, or nothing for a credential it did not:
|
|
3
|
+
* a compact JWE has five segments, where a JWS — an OpenID `id_token`, say — has three.
|
|
4
|
+
* Read without decrypting, and without trusting: a credential that lies about its form
|
|
5
|
+
* only reaches a verifier that rejects it.
|
|
6
|
+
*/
|
|
7
|
+
export function form (token: string): Form | null {
|
|
8
|
+
if (token.startsWith(PASETO))
|
|
9
|
+
return 'paseto'
|
|
10
|
+
|
|
11
|
+
if (segments(token) === JWE_SEGMENTS)
|
|
12
|
+
return 'jwe'
|
|
13
|
+
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function segments (token: string): number {
|
|
18
|
+
let count = 1
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < token.length; i++)
|
|
21
|
+
if (token.charCodeAt(i) === DOT)
|
|
22
|
+
count++
|
|
23
|
+
|
|
24
|
+
return count
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const PASETO = 'v3.local.'
|
|
28
|
+
const JWE_SEGMENTS = 5
|
|
29
|
+
const DOT = 46
|
|
30
|
+
|
|
31
|
+
export type Form = 'paseto' | 'jwe'
|