@nocobase/plugin-idp-oauth 2.1.0-alpha.10
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/LICENSE.txt +107 -0
- package/README.md +14 -0
- package/build.config.ts +46 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/ErrorPage.d.ts +11 -0
- package/dist/client/InteractionPage.d.ts +11 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/plugin.d.ts +13 -0
- package/dist/externalVersion.js +18 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/eta/LICENSE +7 -0
- package/dist/node_modules/eta/README.md +185 -0
- package/dist/node_modules/eta/dist/core.d.ts +179 -0
- package/dist/node_modules/eta/dist/core.d.ts.map +1 -0
- package/dist/node_modules/eta/dist/core.js +42 -0
- package/dist/node_modules/eta/dist/core.js.map +1 -0
- package/dist/node_modules/eta/dist/index.cjs +542 -0
- package/dist/node_modules/eta/dist/index.cjs.map +1 -0
- package/dist/node_modules/eta/dist/index.d.cts +187 -0
- package/dist/node_modules/eta/dist/index.d.cts.map +1 -0
- package/dist/node_modules/eta/dist/index.d.mts +187 -0
- package/dist/node_modules/eta/dist/index.d.mts.map +1 -0
- package/dist/node_modules/eta/dist/index.mjs +512 -0
- package/dist/node_modules/eta/dist/index.mjs.map +1 -0
- package/dist/node_modules/eta/package.json +75 -0
- package/dist/node_modules/jose/LICENSE.md +21 -0
- package/dist/node_modules/jose/README.md +153 -0
- package/dist/node_modules/jose/dist/types/index.d.ts +55 -0
- package/dist/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
- package/dist/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
- package/dist/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
- package/dist/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
- package/dist/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
- package/dist/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
- package/dist/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
- package/dist/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
- package/dist/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
- package/dist/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
- package/dist/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
- package/dist/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
- package/dist/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
- package/dist/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
- package/dist/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
- package/dist/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
- package/dist/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
- package/dist/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
- package/dist/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
- package/dist/node_modules/jose/dist/types/key/export.d.ts +33 -0
- package/dist/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
- package/dist/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
- package/dist/node_modules/jose/dist/types/key/import.d.ts +83 -0
- package/dist/node_modules/jose/dist/types/types.d.ts +852 -0
- package/dist/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
- package/dist/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
- package/dist/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
- package/dist/node_modules/jose/dist/types/util/errors.d.ts +213 -0
- package/dist/node_modules/jose/dist/webapi/index.js +32 -0
- package/dist/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
- package/dist/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
- package/dist/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +155 -0
- package/dist/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +165 -0
- package/dist/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
- package/dist/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
- package/dist/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
- package/dist/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
- package/dist/node_modules/jose/dist/webapi/jwks/local.js +119 -0
- package/dist/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
- package/dist/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
- package/dist/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
- package/dist/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
- package/dist/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
- package/dist/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
- package/dist/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
- package/dist/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
- package/dist/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
- package/dist/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
- package/dist/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
- package/dist/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
- package/dist/node_modules/jose/dist/webapi/key/export.js +11 -0
- package/dist/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
- package/dist/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
- package/dist/node_modules/jose/dist/webapi/key/import.js +57 -0
- package/dist/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
- package/dist/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
- package/dist/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
- package/dist/node_modules/jose/dist/webapi/lib/base64.js +22 -0
- package/dist/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
- package/dist/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
- package/dist/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
- package/dist/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
- package/dist/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
- package/dist/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
- package/dist/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
- package/dist/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
- package/dist/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
- package/dist/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
- package/dist/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
- package/dist/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
- package/dist/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
- package/dist/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
- package/dist/node_modules/jose/dist/webapi/lib/pbes2kw.js +39 -0
- package/dist/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
- package/dist/node_modules/jose/dist/webapi/lib/signing.js +68 -0
- package/dist/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
- package/dist/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
- package/dist/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
- package/dist/node_modules/jose/dist/webapi/util/base64url.js +30 -0
- package/dist/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
- package/dist/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
- package/dist/node_modules/jose/dist/webapi/util/errors.js +99 -0
- package/dist/node_modules/jose/package.json +200 -0
- package/dist/node_modules/light-my-request/.gitattributes +2 -0
- package/dist/node_modules/light-my-request/.github/dependabot.yml +13 -0
- package/dist/node_modules/light-my-request/.github/stale.yml +21 -0
- package/dist/node_modules/light-my-request/.github/workflows/benchmark.yml +30 -0
- package/dist/node_modules/light-my-request/.github/workflows/ci.yml +23 -0
- package/dist/node_modules/light-my-request/LICENSE +32 -0
- package/dist/node_modules/light-my-request/benchmark/benchmark.js +164 -0
- package/dist/node_modules/light-my-request/build/build-validation.js +100 -0
- package/dist/node_modules/light-my-request/eslint.config.js +9 -0
- package/dist/node_modules/light-my-request/index.js +2 -0
- package/dist/node_modules/light-my-request/lib/config-validator.js +919 -0
- package/dist/node_modules/light-my-request/lib/form-data.js +79 -0
- package/dist/node_modules/light-my-request/lib/parse-url.js +47 -0
- package/dist/node_modules/light-my-request/lib/request.js +290 -0
- package/dist/node_modules/light-my-request/lib/response.js +240 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.gitattributes +2 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.github/dependabot.yml +13 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.github/workflows/ci.yml +24 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/.taprc +2 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/benchmarks/warn.js +25 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/eslint.config.js +6 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/examples/example.js +11 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/index.js +124 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/package.json +73 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-interpolated-string.test.js +29 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-once-only.test.js +28 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-reset.test.js +36 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-set.test.js +30 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/emit-unlimited.test.js +37 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/index.test.js +99 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/issue-88.test.js +33 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/jest.test.js +22 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/test/no-warnings.test.js +80 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.d.ts +37 -0
- package/dist/node_modules/light-my-request/node_modules/process-warning/types/index.test-d.ts +36 -0
- package/dist/node_modules/light-my-request/package.json +1 -0
- package/dist/node_modules/light-my-request/test/async-await.test.js +55 -0
- package/dist/node_modules/light-my-request/test/index.test.js +2316 -0
- package/dist/node_modules/light-my-request/test/request.test.js +16 -0
- package/dist/node_modules/light-my-request/test/response.test.js +19 -0
- package/dist/node_modules/light-my-request/test/stream.test.js +359 -0
- package/dist/node_modules/light-my-request/types/index.d.ts +128 -0
- package/dist/node_modules/light-my-request/types/index.test-d.ts +149 -0
- package/dist/node_modules/oidc-provider/LICENSE.md +21 -0
- package/dist/node_modules/oidc-provider/README.md +174 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_claims.js +28 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/assign_defaults.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/authenticated_client_id.js +6 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_remap_errors.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/backchannel_request_response.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_ciba_context.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_claims.js +68 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client.js +21 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_client_grant_type.js +21 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_dpop_jkt.js +35 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_extra_params.js +18 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_id_token_hint.js +23 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_max_age.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_openid_scope.js +47 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_pkce.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_prompt.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_redirect_uri.js +41 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_requested_expiry.js +16 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_mode.js +54 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_response_type.js +26 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/check_scope.js +53 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_load_account.js +58 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/ciba_required.js +13 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_authorization_response.js +31 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow.js +31 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_errors.js +37 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/device_user_flow_response.js +55 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/index.js +200 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/interaction_emit.js +9 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/interactions.js +149 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_account.js +15 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_grant.js +29 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/load_pushed_authorization_request.js +36 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/oauth_required.js +11 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/oidc_required.js +27 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/one_redirect_uri_clients.js +20 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/process_request_object.js +214 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_remap_errors.js +17 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/pushed_authorization_request_response.js +65 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_registration.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_request_and_uri.js +12 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/reject_unsupported.js +33 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/respond.js +46 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/resume.js +111 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/strip_outside_jar_params.js +19 -0
- package/dist/node_modules/oidc-provider/lib/actions/authorization/unsupported_rar.js +9 -0
- package/dist/node_modules/oidc-provider/lib/actions/challenge.js +22 -0
- package/dist/node_modules/oidc-provider/lib/actions/code_verification.js +122 -0
- package/dist/node_modules/oidc-provider/lib/actions/discovery.js +151 -0
- package/dist/node_modules/oidc-provider/lib/actions/end_session.js +222 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/authorization_code.js +144 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/ciba.js +127 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/client_credentials.js +79 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/device_code.js +125 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/index.js +7 -0
- package/dist/node_modules/oidc-provider/lib/actions/grants/refresh_token.js +229 -0
- package/dist/node_modules/oidc-provider/lib/actions/index.js +25 -0
- package/dist/node_modules/oidc-provider/lib/actions/interaction.js +150 -0
- package/dist/node_modules/oidc-provider/lib/actions/introspection.js +164 -0
- package/dist/node_modules/oidc-provider/lib/actions/jwks.js +7 -0
- package/dist/node_modules/oidc-provider/lib/actions/registration.js +274 -0
- package/dist/node_modules/oidc-provider/lib/actions/revocation.js +81 -0
- package/dist/node_modules/oidc-provider/lib/actions/token.js +74 -0
- package/dist/node_modules/oidc-provider/lib/actions/userinfo.js +183 -0
- package/dist/node_modules/oidc-provider/lib/adapters/memory_adapter.js +95 -0
- package/dist/node_modules/oidc-provider/lib/consts/client_attributes.js +211 -0
- package/dist/node_modules/oidc-provider/lib/consts/dev_keystore.js +18 -0
- package/dist/node_modules/oidc-provider/lib/consts/index.js +13 -0
- package/dist/node_modules/oidc-provider/lib/consts/jwa.js +47 -0
- package/dist/node_modules/oidc-provider/lib/consts/non_rejectable_claims.js +1 -0
- package/dist/node_modules/oidc-provider/lib/consts/param_list.js +23 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/camel_case.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/defaults.js +28 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/difference.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/is_plain_object.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/map_keys.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/merge.js +25 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/omit_by.js +11 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/pick.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/pick_by.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/remove.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/set.js +18 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/snake_case.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/_/upper_first.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/account_claims.js +6 -0
- package/dist/node_modules/oidc-provider/lib/helpers/add_client.js +14 -0
- package/dist/node_modules/oidc-provider/lib/helpers/als.js +3 -0
- package/dist/node_modules/oidc-provider/lib/helpers/append_www_authenticate.js +9 -0
- package/dist/node_modules/oidc-provider/lib/helpers/attention.js +23 -0
- package/dist/node_modules/oidc-provider/lib/helpers/base64url.js +11 -0
- package/dist/node_modules/oidc-provider/lib/helpers/certificate_thumbprint.js +15 -0
- package/dist/node_modules/oidc-provider/lib/helpers/challenge.js +111 -0
- package/dist/node_modules/oidc-provider/lib/helpers/check_attest_binding.js +10 -0
- package/dist/node_modules/oidc-provider/lib/helpers/claims.js +79 -0
- package/dist/node_modules/oidc-provider/lib/helpers/client_id_metadata_document.js +198 -0
- package/dist/node_modules/oidc-provider/lib/helpers/client_schema.js +700 -0
- package/dist/node_modules/oidc-provider/lib/helpers/combined_scope.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/configuration.js +544 -0
- package/dist/node_modules/oidc-provider/lib/helpers/constant_equals.js +20 -0
- package/dist/node_modules/oidc-provider/lib/helpers/defaults.js +3510 -0
- package/dist/node_modules/oidc-provider/lib/helpers/epoch_time.js +1 -0
- package/dist/node_modules/oidc-provider/lib/helpers/err_out.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/errors.js +161 -0
- package/dist/node_modules/oidc-provider/lib/helpers/features.js +51 -0
- package/dist/node_modules/oidc-provider/lib/helpers/fetch_body_check.js +25 -0
- package/dist/node_modules/oidc-provider/lib/helpers/fetch_request.js +221 -0
- package/dist/node_modules/oidc-provider/lib/helpers/filter_claims.js +16 -0
- package/dist/node_modules/oidc-provider/lib/helpers/formatters.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/grant_common.js +214 -0
- package/dist/node_modules/oidc-provider/lib/helpers/html_safe.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_adapter.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_app.js +243 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_clients.js +24 -0
- package/dist/node_modules/oidc-provider/lib/helpers/initialize_keystore.js +310 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/check.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/index.js +43 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompt.js +95 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/consent.js +105 -0
- package/dist/node_modules/oidc-provider/lib/helpers/interaction_policy/prompts/login.js +162 -0
- package/dist/node_modules/oidc-provider/lib/helpers/jwt.js +211 -0
- package/dist/node_modules/oidc-provider/lib/helpers/keystore.js +301 -0
- package/dist/node_modules/oidc-provider/lib/helpers/nanoid.js +5 -0
- package/dist/node_modules/oidc-provider/lib/helpers/oidc_context.js +284 -0
- package/dist/node_modules/oidc-provider/lib/helpers/params.js +27 -0
- package/dist/node_modules/oidc-provider/lib/helpers/pkce.js +30 -0
- package/dist/node_modules/oidc-provider/lib/helpers/pkce_format.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/process_response_types.js +202 -0
- package/dist/node_modules/oidc-provider/lib/helpers/re_render_errors.js +39 -0
- package/dist/node_modules/oidc-provider/lib/helpers/redirect_uri.js +16 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resolve_resource.js +33 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resolve_response_mode.js +7 -0
- package/dist/node_modules/oidc-provider/lib/helpers/resource_server.js +20 -0
- package/dist/node_modules/oidc-provider/lib/helpers/revoke.js +27 -0
- package/dist/node_modules/oidc-provider/lib/helpers/script_src_sha.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/sector_identifier.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/sector_validate.js +55 -0
- package/dist/node_modules/oidc-provider/lib/helpers/set_rt_bindings.js +21 -0
- package/dist/node_modules/oidc-provider/lib/helpers/token_find.js +51 -0
- package/dist/node_modules/oidc-provider/lib/helpers/type_validators.js +8 -0
- package/dist/node_modules/oidc-provider/lib/helpers/user_code_form.js +19 -0
- package/dist/node_modules/oidc-provider/lib/helpers/user_codes.js +38 -0
- package/dist/node_modules/oidc-provider/lib/helpers/valid_url.js +8 -0
- package/dist/node_modules/oidc-provider/lib/helpers/validate_dpop.js +129 -0
- package/dist/node_modules/oidc-provider/lib/helpers/validate_presence.js +17 -0
- package/dist/node_modules/oidc-provider/lib/helpers/weak_cache.js +11 -0
- package/dist/node_modules/oidc-provider/lib/index.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/access_token.js +31 -0
- package/dist/node_modules/oidc-provider/lib/models/authorization_code.js +27 -0
- package/dist/node_modules/oidc-provider/lib/models/backchannel_authentication_request.js +26 -0
- package/dist/node_modules/oidc-provider/lib/models/base_model.js +141 -0
- package/dist/node_modules/oidc-provider/lib/models/base_token.js +86 -0
- package/dist/node_modules/oidc-provider/lib/models/client.js +593 -0
- package/dist/node_modules/oidc-provider/lib/models/client_credentials.js +19 -0
- package/dist/node_modules/oidc-provider/lib/models/device_code.js +44 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/dynamic.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/index.js +14 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/jwt.js +198 -0
- package/dist/node_modules/oidc-provider/lib/models/formats/opaque.js +58 -0
- package/dist/node_modules/oidc-provider/lib/models/grant.js +243 -0
- package/dist/node_modules/oidc-provider/lib/models/id_token.js +271 -0
- package/dist/node_modules/oidc-provider/lib/models/index.js +37 -0
- package/dist/node_modules/oidc-provider/lib/models/initial_access_token.js +12 -0
- package/dist/node_modules/oidc-provider/lib/models/interaction.js +73 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/apply.js +4 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/consumable.js +17 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_format.js +46 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_id.js +12 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_grant_type.js +8 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/has_policies.js +38 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_attestation_constrained.js +15 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_sender_constrained.js +50 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/is_session_bound.js +38 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/set_audience.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/stores_auth.js +16 -0
- package/dist/node_modules/oidc-provider/lib/models/mixins/stores_pkce.js +9 -0
- package/dist/node_modules/oidc-provider/lib/models/pushed_authorization_request.js +21 -0
- package/dist/node_modules/oidc-provider/lib/models/refresh_token.js +47 -0
- package/dist/node_modules/oidc-provider/lib/models/registration_access_token.js +8 -0
- package/dist/node_modules/oidc-provider/lib/models/replay_detection.js +31 -0
- package/dist/node_modules/oidc-provider/lib/models/session.js +192 -0
- package/dist/node_modules/oidc-provider/lib/provider.js +453 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/form_post.js +36 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/fragment.js +7 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/index.js +15 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/jwt.js +43 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/query.js +7 -0
- package/dist/node_modules/oidc-provider/lib/response_modes/web_message.js +55 -0
- package/dist/node_modules/oidc-provider/lib/shared/assemble_params.js +7 -0
- package/dist/node_modules/oidc-provider/lib/shared/attest_client_auth.js +111 -0
- package/dist/node_modules/oidc-provider/lib/shared/authorization_error_handler.js +104 -0
- package/dist/node_modules/oidc-provider/lib/shared/check_rar.js +75 -0
- package/dist/node_modules/oidc-provider/lib/shared/check_resource.js +77 -0
- package/dist/node_modules/oidc-provider/lib/shared/client_auth.js +263 -0
- package/dist/node_modules/oidc-provider/lib/shared/conditional_body.js +9 -0
- package/dist/node_modules/oidc-provider/lib/shared/cors.js +49 -0
- package/dist/node_modules/oidc-provider/lib/shared/error_handler.js +59 -0
- package/dist/node_modules/oidc-provider/lib/shared/jwt_client_auth.js +79 -0
- package/dist/node_modules/oidc-provider/lib/shared/no_cache.js +4 -0
- package/dist/node_modules/oidc-provider/lib/shared/reject_dupes.js +45 -0
- package/dist/node_modules/oidc-provider/lib/shared/reject_structured_tokens.js +18 -0
- package/dist/node_modules/oidc-provider/lib/shared/selective_body.js +60 -0
- package/dist/node_modules/oidc-provider/lib/shared/session.js +68 -0
- package/dist/node_modules/oidc-provider/lib/shared/set_www_authenticate_header.js +52 -0
- package/dist/node_modules/oidc-provider/lib/views/index.js +22 -0
- package/dist/node_modules/oidc-provider/lib/views/interaction.js +171 -0
- package/dist/node_modules/oidc-provider/lib/views/layout.js +237 -0
- package/dist/node_modules/oidc-provider/lib/views/login.js +43 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/LICENSE +21 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/README.md +1370 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.mts +1003 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.d.ts +1003 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.js +1616 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/dist/index.mjs +1573 -0
- package/dist/node_modules/oidc-provider/node_modules/@koa/router/package.json +122 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/LICENSE +20 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/README.md +481 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/package.json +64 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/oidc-provider/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/HISTORY.md +186 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/LICENSE +23 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/README.md +169 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/index.js +290 -0
- package/dist/node_modules/oidc-provider/node_modules/http-errors/package.json +54 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/LICENSE-MIT.txt +20 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/README.md +422 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/bin/jsesc +148 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/jsesc.js +337 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/man/jsesc.1 +94 -0
- package/dist/node_modules/oidc-provider/node_modules/jsesc/package.json +56 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/LICENSE +20 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/README.md +38 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/bin/nanoid.js +55 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.browser.js +29 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.d.ts +106 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/index.js +47 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/nanoid.js +1 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.d.ts +48 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/non-secure/index.js +21 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/package.json +46 -0
- package/dist/node_modules/oidc-provider/node_modules/nanoid/url-alphabet/index.js +2 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/LICENSE +21 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/Readme.md +224 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.d.ts +144 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js +409 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/dist/node_modules/oidc-provider/node_modules/path-to-regexp/package.json +64 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/HISTORY.md +87 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/LICENSE +23 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/README.md +139 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/codes.json +65 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/index.js +146 -0
- package/dist/node_modules/oidc-provider/node_modules/statuses/package.json +49 -0
- package/dist/node_modules/oidc-provider/package.json +95 -0
- package/dist/node_modules/quick-lru/index.d.ts +178 -0
- package/dist/node_modules/quick-lru/index.js +329 -0
- package/dist/node_modules/quick-lru/license +9 -0
- package/dist/node_modules/quick-lru/package.json +54 -0
- package/dist/node_modules/quick-lru/readme.md +236 -0
- package/dist/node_modules/statuses/HISTORY.md +65 -0
- package/dist/node_modules/statuses/LICENSE +23 -0
- package/dist/node_modules/statuses/README.md +127 -0
- package/dist/node_modules/statuses/codes.json +66 -0
- package/dist/node_modules/statuses/index.js +113 -0
- package/dist/node_modules/statuses/package.json +48 -0
- package/dist/server/cache-adapter.d.ts +33 -0
- package/dist/server/cache-adapter.js +159 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +48 -0
- package/dist/server/interaction.d.ts +26 -0
- package/dist/server/interaction.js +172 -0
- package/dist/server/paths.d.ts +19 -0
- package/dist/server/paths.js +64 -0
- package/dist/server/plugin.d.ts +16 -0
- package/dist/server/plugin.js +108 -0
- package/dist/server/provider-dispatch.d.ts +32 -0
- package/dist/server/provider-dispatch.js +252 -0
- package/dist/server/service.d.ts +63 -0
- package/dist/server/service.js +540 -0
- package/dist/server/utils.d.ts +12 -0
- package/dist/server/utils.js +58 -0
- package/package.json +24 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64URL encoding and decoding utilities
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Decodes a Base64URL encoded input. */
|
|
7
|
+
export declare function decode(input: Uint8Array | string): Uint8Array;
|
|
8
|
+
/** Encodes an input using Base64URL with no padding. */
|
|
9
|
+
export declare function encode(input: Uint8Array | string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Web Token (JWT) Claims Set Decoding (no validation, no signature checking)
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as types from '../types.d.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a signed JSON Web Token payload. This does not validate the JWT Claims Set types or
|
|
9
|
+
* values. This does not validate the JWS Signature. For a proper Signed JWT Claims Set validation
|
|
10
|
+
* and JWS signature verification use `jose.jwtVerify()`. For an encrypted JWT Claims Set validation
|
|
11
|
+
* and JWE decryption use `jose.jwtDecrypt()`.
|
|
12
|
+
*
|
|
13
|
+
* This function is exported (as a named export) from the main `'jose'` module entry point as well
|
|
14
|
+
* as from its subpath export `'jose/jwt/decode'`.
|
|
15
|
+
*
|
|
16
|
+
* @param jwt JWT token in compact JWS serialization.
|
|
17
|
+
*/
|
|
18
|
+
export declare function decodeJwt<PayloadType = types.JWTPayload>(jwt: string): PayloadType & types.JWTPayload;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JOSE Protected Header Decoding (JWE, JWS, all serialization syntaxes)
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as types from '../types.d.ts';
|
|
7
|
+
/** JWE and JWS Header Parameters */
|
|
8
|
+
export type ProtectedHeaderParameters = types.JWSHeaderParameters & types.JWEHeaderParameters;
|
|
9
|
+
/**
|
|
10
|
+
* Decodes the Protected Header of a JWE/JWS/JWT token utilizing any JOSE serialization.
|
|
11
|
+
*
|
|
12
|
+
* This function is exported (as a named export) from the main `'jose'` module entry point as well
|
|
13
|
+
* as from its subpath export `'jose/decode/protected_header'`.
|
|
14
|
+
*
|
|
15
|
+
* @param token JWE/JWS/JWT token in any JOSE serialization.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodeProtectedHeader(token: string | object): ProtectedHeaderParameters;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JOSE module errors and error codes
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as types from '../types.d.ts';
|
|
7
|
+
/**
|
|
8
|
+
* A generic Error that all other JOSE specific Error subclasses extend.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare class JOSEError extends Error {
|
|
12
|
+
/**
|
|
13
|
+
* A unique error code for the particular error subclass.
|
|
14
|
+
*
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
static code: string;
|
|
18
|
+
/** A unique error code for {@link JOSEError}. */
|
|
19
|
+
code: string;
|
|
20
|
+
/** @ignore */
|
|
21
|
+
constructor(message?: string, options?: {
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* An error subclass thrown when a JWT Claim Set member validation fails.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export declare class JWTClaimValidationFailed extends JOSEError {
|
|
30
|
+
/** @ignore */
|
|
31
|
+
static code: string;
|
|
32
|
+
/** A unique error code for {@link JWTClaimValidationFailed}. */
|
|
33
|
+
code: string;
|
|
34
|
+
/** The Claim for which the validation failed. */
|
|
35
|
+
claim: string;
|
|
36
|
+
/** Reason code for the validation failure. */
|
|
37
|
+
reason: string;
|
|
38
|
+
/**
|
|
39
|
+
* The parsed JWT Claims Set (aka payload). Other JWT claims may or may not have been verified at
|
|
40
|
+
* this point. The JSON Web Signature (JWS) or a JSON Web Encryption (JWE) structures' integrity
|
|
41
|
+
* has however been verified. Claims Set verification happens after the JWS Signature or JWE
|
|
42
|
+
* Decryption processes.
|
|
43
|
+
*/
|
|
44
|
+
payload: types.JWTPayload;
|
|
45
|
+
/** @ignore */
|
|
46
|
+
constructor(message: string, payload: types.JWTPayload, claim?: string, reason?: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* An error subclass thrown when a JWT is expired.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailed {
|
|
53
|
+
/** @ignore */
|
|
54
|
+
static code: string;
|
|
55
|
+
/** A unique error code for {@link JWTExpired}. */
|
|
56
|
+
code: string;
|
|
57
|
+
/** The Claim for which the validation failed. */
|
|
58
|
+
claim: string;
|
|
59
|
+
/** Reason code for the validation failure. */
|
|
60
|
+
reason: string;
|
|
61
|
+
/**
|
|
62
|
+
* The parsed JWT Claims Set (aka payload). Other JWT claims may or may not have been verified at
|
|
63
|
+
* this point. The JSON Web Signature (JWS) or a JSON Web Encryption (JWE) structures' integrity
|
|
64
|
+
* has however been verified. Claims Set verification happens after the JWS Signature or JWE
|
|
65
|
+
* Decryption processes.
|
|
66
|
+
*/
|
|
67
|
+
payload: types.JWTPayload;
|
|
68
|
+
/** @ignore */
|
|
69
|
+
constructor(message: string, payload: types.JWTPayload, claim?: string, reason?: string);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* An error subclass thrown when a JOSE Algorithm is not allowed per developer preference.
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
export declare class JOSEAlgNotAllowed extends JOSEError {
|
|
76
|
+
/** @ignore */
|
|
77
|
+
static code: string;
|
|
78
|
+
/** A unique error code for {@link JOSEAlgNotAllowed}. */
|
|
79
|
+
code: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* An error subclass thrown when a particular feature or algorithm is not supported by this
|
|
83
|
+
* implementation or JOSE in general.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export declare class JOSENotSupported extends JOSEError {
|
|
87
|
+
/** @ignore */
|
|
88
|
+
static code: string;
|
|
89
|
+
/** A unique error code for {@link JOSENotSupported}. */
|
|
90
|
+
code: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* An error subclass thrown when a JWE ciphertext decryption fails.
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
export declare class JWEDecryptionFailed extends JOSEError {
|
|
97
|
+
/** @ignore */
|
|
98
|
+
static code: string;
|
|
99
|
+
/** A unique error code for {@link JWEDecryptionFailed}. */
|
|
100
|
+
code: string;
|
|
101
|
+
/** @ignore */
|
|
102
|
+
constructor(message?: string, options?: {
|
|
103
|
+
cause?: unknown;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* An error subclass thrown when a JWE is invalid.
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
export declare class JWEInvalid extends JOSEError {
|
|
111
|
+
/** @ignore */
|
|
112
|
+
static code: string;
|
|
113
|
+
/** A unique error code for {@link JWEInvalid}. */
|
|
114
|
+
code: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* An error subclass thrown when a JWS is invalid.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
export declare class JWSInvalid extends JOSEError {
|
|
121
|
+
/** @ignore */
|
|
122
|
+
static code: string;
|
|
123
|
+
/** A unique error code for {@link JWSInvalid}. */
|
|
124
|
+
code: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An error subclass thrown when a JWT is invalid.
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
export declare class JWTInvalid extends JOSEError {
|
|
131
|
+
/** @ignore */
|
|
132
|
+
static code: string;
|
|
133
|
+
/** A unique error code for {@link JWTInvalid}. */
|
|
134
|
+
code: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* An error subclass thrown when a JWK is invalid.
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
export declare class JWKInvalid extends JOSEError {
|
|
141
|
+
/** @ignore */
|
|
142
|
+
static code: string;
|
|
143
|
+
/** A unique error code for {@link JWKInvalid}. */
|
|
144
|
+
code: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* An error subclass thrown when a JWKS is invalid.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
export declare class JWKSInvalid extends JOSEError {
|
|
151
|
+
/** @ignore */
|
|
152
|
+
static code: string;
|
|
153
|
+
/** A unique error code for {@link JWKSInvalid}. */
|
|
154
|
+
code: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* An error subclass thrown when no keys match from a JWKS.
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
export declare class JWKSNoMatchingKey extends JOSEError {
|
|
161
|
+
/** @ignore */
|
|
162
|
+
static code: string;
|
|
163
|
+
/** A unique error code for {@link JWKSNoMatchingKey}. */
|
|
164
|
+
code: string;
|
|
165
|
+
/** @ignore */
|
|
166
|
+
constructor(message?: string, options?: {
|
|
167
|
+
cause?: unknown;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* An error subclass thrown when multiple keys match from a JWKS.
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
export declare class JWKSMultipleMatchingKeys extends JOSEError {
|
|
175
|
+
/** @ignore */
|
|
176
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<types.CryptoKey>;
|
|
177
|
+
/** @ignore */
|
|
178
|
+
static code: string;
|
|
179
|
+
/** A unique error code for {@link JWKSMultipleMatchingKeys}. */
|
|
180
|
+
code: string;
|
|
181
|
+
/** @ignore */
|
|
182
|
+
constructor(message?: string, options?: {
|
|
183
|
+
cause?: unknown;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Timeout was reached when retrieving the JWKS response.
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
export declare class JWKSTimeout extends JOSEError {
|
|
191
|
+
/** @ignore */
|
|
192
|
+
static code: string;
|
|
193
|
+
/** A unique error code for {@link JWKSTimeout}. */
|
|
194
|
+
code: string;
|
|
195
|
+
/** @ignore */
|
|
196
|
+
constructor(message?: string, options?: {
|
|
197
|
+
cause?: unknown;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* An error subclass thrown when JWS signature verification fails.
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
export declare class JWSSignatureVerificationFailed extends JOSEError {
|
|
205
|
+
/** @ignore */
|
|
206
|
+
static code: string;
|
|
207
|
+
/** A unique error code for {@link JWSSignatureVerificationFailed}. */
|
|
208
|
+
code: string;
|
|
209
|
+
/** @ignore */
|
|
210
|
+
constructor(message?: string, options?: {
|
|
211
|
+
cause?: unknown;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { compactDecrypt } from './jwe/compact/decrypt.js';
|
|
2
|
+
export { flattenedDecrypt } from './jwe/flattened/decrypt.js';
|
|
3
|
+
export { generalDecrypt } from './jwe/general/decrypt.js';
|
|
4
|
+
export { GeneralEncrypt } from './jwe/general/encrypt.js';
|
|
5
|
+
export { compactVerify } from './jws/compact/verify.js';
|
|
6
|
+
export { flattenedVerify } from './jws/flattened/verify.js';
|
|
7
|
+
export { generalVerify } from './jws/general/verify.js';
|
|
8
|
+
export { jwtVerify } from './jwt/verify.js';
|
|
9
|
+
export { jwtDecrypt } from './jwt/decrypt.js';
|
|
10
|
+
export { CompactEncrypt } from './jwe/compact/encrypt.js';
|
|
11
|
+
export { FlattenedEncrypt } from './jwe/flattened/encrypt.js';
|
|
12
|
+
export { CompactSign } from './jws/compact/sign.js';
|
|
13
|
+
export { FlattenedSign } from './jws/flattened/sign.js';
|
|
14
|
+
export { GeneralSign } from './jws/general/sign.js';
|
|
15
|
+
export { SignJWT } from './jwt/sign.js';
|
|
16
|
+
export { EncryptJWT } from './jwt/encrypt.js';
|
|
17
|
+
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
18
|
+
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
19
|
+
export { createLocalJWKSet } from './jwks/local.js';
|
|
20
|
+
export { createRemoteJWKSet, jwksCache, customFetch } from './jwks/remote.js';
|
|
21
|
+
export { UnsecuredJWT } from './jwt/unsecured.js';
|
|
22
|
+
export { exportPKCS8, exportSPKI, exportJWK } from './key/export.js';
|
|
23
|
+
export { importSPKI, importPKCS8, importX509, importJWK } from './key/import.js';
|
|
24
|
+
export { decodeProtectedHeader } from './util/decode_protected_header.js';
|
|
25
|
+
export { decodeJwt } from './util/decode_jwt.js';
|
|
26
|
+
import * as errors from './util/errors.js';
|
|
27
|
+
export { errors };
|
|
28
|
+
export { generateKeyPair } from './key/generate_key_pair.js';
|
|
29
|
+
export { generateSecret } from './key/generate_secret.js';
|
|
30
|
+
import * as base64url from './util/base64url.js';
|
|
31
|
+
export { base64url };
|
|
32
|
+
export const cryptoRuntime = 'WebCryptoAPI';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { flattenedDecrypt } from '../flattened/decrypt.js';
|
|
2
|
+
import { JWEInvalid } from '../../util/errors.js';
|
|
3
|
+
import { decoder } from '../../lib/buffer_utils.js';
|
|
4
|
+
export async function compactDecrypt(jwe, key, options) {
|
|
5
|
+
if (jwe instanceof Uint8Array) {
|
|
6
|
+
jwe = decoder.decode(jwe);
|
|
7
|
+
}
|
|
8
|
+
if (typeof jwe !== 'string') {
|
|
9
|
+
throw new JWEInvalid('Compact JWE must be a string or Uint8Array');
|
|
10
|
+
}
|
|
11
|
+
const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length, } = jwe.split('.');
|
|
12
|
+
if (length !== 5) {
|
|
13
|
+
throw new JWEInvalid('Invalid Compact JWE');
|
|
14
|
+
}
|
|
15
|
+
const decrypted = await flattenedDecrypt({
|
|
16
|
+
ciphertext,
|
|
17
|
+
iv: iv || undefined,
|
|
18
|
+
protected: protectedHeader,
|
|
19
|
+
tag: tag || undefined,
|
|
20
|
+
encrypted_key: encryptedKey || undefined,
|
|
21
|
+
}, key, options);
|
|
22
|
+
const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };
|
|
23
|
+
if (typeof key === 'function') {
|
|
24
|
+
return { ...result, key: decrypted.key };
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FlattenedEncrypt } from '../flattened/encrypt.js';
|
|
2
|
+
export class CompactEncrypt {
|
|
3
|
+
#flattened;
|
|
4
|
+
constructor(plaintext) {
|
|
5
|
+
this.#flattened = new FlattenedEncrypt(plaintext);
|
|
6
|
+
}
|
|
7
|
+
setContentEncryptionKey(cek) {
|
|
8
|
+
this.#flattened.setContentEncryptionKey(cek);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
setInitializationVector(iv) {
|
|
12
|
+
this.#flattened.setInitializationVector(iv);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
setProtectedHeader(protectedHeader) {
|
|
16
|
+
this.#flattened.setProtectedHeader(protectedHeader);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setKeyManagementParameters(parameters) {
|
|
20
|
+
this.#flattened.setKeyManagementParameters(parameters);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
async encrypt(key, options) {
|
|
24
|
+
const jwe = await this.#flattened.encrypt(key, options);
|
|
25
|
+
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { decode as b64u } from '../../util/base64url.js';
|
|
2
|
+
import { decrypt } from '../../lib/content_encryption.js';
|
|
3
|
+
import { decodeBase64url } from '../../lib/helpers.js';
|
|
4
|
+
import { JOSEAlgNotAllowed, JOSENotSupported, JWEInvalid } from '../../util/errors.js';
|
|
5
|
+
import { isDisjoint } from '../../lib/type_checks.js';
|
|
6
|
+
import { isObject } from '../../lib/type_checks.js';
|
|
7
|
+
import { decryptKeyManagement } from '../../lib/key_management.js';
|
|
8
|
+
import { decoder, concat, encode } from '../../lib/buffer_utils.js';
|
|
9
|
+
import { generateCek } from '../../lib/content_encryption.js';
|
|
10
|
+
import { validateCrit } from '../../lib/validate_crit.js';
|
|
11
|
+
import { validateAlgorithms } from '../../lib/validate_algorithms.js';
|
|
12
|
+
import { normalizeKey } from '../../lib/normalize_key.js';
|
|
13
|
+
import { checkKeyType } from '../../lib/check_key_type.js';
|
|
14
|
+
import { decompress } from '../../lib/deflate.js';
|
|
15
|
+
export async function flattenedDecrypt(jwe, key, options) {
|
|
16
|
+
if (!isObject(jwe)) {
|
|
17
|
+
throw new JWEInvalid('Flattened JWE must be an object');
|
|
18
|
+
}
|
|
19
|
+
if (jwe.protected === undefined && jwe.header === undefined && jwe.unprotected === undefined) {
|
|
20
|
+
throw new JWEInvalid('JOSE Header missing');
|
|
21
|
+
}
|
|
22
|
+
if (jwe.iv !== undefined && typeof jwe.iv !== 'string') {
|
|
23
|
+
throw new JWEInvalid('JWE Initialization Vector incorrect type');
|
|
24
|
+
}
|
|
25
|
+
if (typeof jwe.ciphertext !== 'string') {
|
|
26
|
+
throw new JWEInvalid('JWE Ciphertext missing or incorrect type');
|
|
27
|
+
}
|
|
28
|
+
if (jwe.tag !== undefined && typeof jwe.tag !== 'string') {
|
|
29
|
+
throw new JWEInvalid('JWE Authentication Tag incorrect type');
|
|
30
|
+
}
|
|
31
|
+
if (jwe.protected !== undefined && typeof jwe.protected !== 'string') {
|
|
32
|
+
throw new JWEInvalid('JWE Protected Header incorrect type');
|
|
33
|
+
}
|
|
34
|
+
if (jwe.encrypted_key !== undefined && typeof jwe.encrypted_key !== 'string') {
|
|
35
|
+
throw new JWEInvalid('JWE Encrypted Key incorrect type');
|
|
36
|
+
}
|
|
37
|
+
if (jwe.aad !== undefined && typeof jwe.aad !== 'string') {
|
|
38
|
+
throw new JWEInvalid('JWE AAD incorrect type');
|
|
39
|
+
}
|
|
40
|
+
if (jwe.header !== undefined && !isObject(jwe.header)) {
|
|
41
|
+
throw new JWEInvalid('JWE Shared Unprotected Header incorrect type');
|
|
42
|
+
}
|
|
43
|
+
if (jwe.unprotected !== undefined && !isObject(jwe.unprotected)) {
|
|
44
|
+
throw new JWEInvalid('JWE Per-Recipient Unprotected Header incorrect type');
|
|
45
|
+
}
|
|
46
|
+
let parsedProt;
|
|
47
|
+
if (jwe.protected) {
|
|
48
|
+
try {
|
|
49
|
+
const protectedHeader = b64u(jwe.protected);
|
|
50
|
+
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new JWEInvalid('JWE Protected Header is invalid');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!isDisjoint(parsedProt, jwe.header, jwe.unprotected)) {
|
|
57
|
+
throw new JWEInvalid('JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint');
|
|
58
|
+
}
|
|
59
|
+
const joseHeader = {
|
|
60
|
+
...parsedProt,
|
|
61
|
+
...jwe.header,
|
|
62
|
+
...jwe.unprotected,
|
|
63
|
+
};
|
|
64
|
+
validateCrit(JWEInvalid, new Map(), options?.crit, parsedProt, joseHeader);
|
|
65
|
+
if (joseHeader.zip !== undefined && joseHeader.zip !== 'DEF') {
|
|
66
|
+
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
|
|
67
|
+
}
|
|
68
|
+
if (joseHeader.zip !== undefined && !parsedProt?.zip) {
|
|
69
|
+
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
|
|
70
|
+
}
|
|
71
|
+
const { alg, enc } = joseHeader;
|
|
72
|
+
if (typeof alg !== 'string' || !alg) {
|
|
73
|
+
throw new JWEInvalid('missing JWE Algorithm (alg) in JWE Header');
|
|
74
|
+
}
|
|
75
|
+
if (typeof enc !== 'string' || !enc) {
|
|
76
|
+
throw new JWEInvalid('missing JWE Encryption Algorithm (enc) in JWE Header');
|
|
77
|
+
}
|
|
78
|
+
const keyManagementAlgorithms = options && validateAlgorithms('keyManagementAlgorithms', options.keyManagementAlgorithms);
|
|
79
|
+
const contentEncryptionAlgorithms = options &&
|
|
80
|
+
validateAlgorithms('contentEncryptionAlgorithms', options.contentEncryptionAlgorithms);
|
|
81
|
+
if ((keyManagementAlgorithms && !keyManagementAlgorithms.has(alg)) ||
|
|
82
|
+
(!keyManagementAlgorithms && alg.startsWith('PBES2'))) {
|
|
83
|
+
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
|
|
84
|
+
}
|
|
85
|
+
if (contentEncryptionAlgorithms && !contentEncryptionAlgorithms.has(enc)) {
|
|
86
|
+
throw new JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed');
|
|
87
|
+
}
|
|
88
|
+
let encryptedKey;
|
|
89
|
+
if (jwe.encrypted_key !== undefined) {
|
|
90
|
+
encryptedKey = decodeBase64url(jwe.encrypted_key, 'encrypted_key', JWEInvalid);
|
|
91
|
+
}
|
|
92
|
+
let resolvedKey = false;
|
|
93
|
+
if (typeof key === 'function') {
|
|
94
|
+
key = await key(parsedProt, jwe);
|
|
95
|
+
resolvedKey = true;
|
|
96
|
+
}
|
|
97
|
+
checkKeyType(alg === 'dir' ? enc : alg, key, 'decrypt');
|
|
98
|
+
const k = await normalizeKey(key, alg);
|
|
99
|
+
let cek;
|
|
100
|
+
try {
|
|
101
|
+
cek = await decryptKeyManagement(alg, k, encryptedKey, joseHeader, options);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
cek = generateCek(enc);
|
|
108
|
+
}
|
|
109
|
+
let iv;
|
|
110
|
+
let tag;
|
|
111
|
+
if (jwe.iv !== undefined) {
|
|
112
|
+
iv = decodeBase64url(jwe.iv, 'iv', JWEInvalid);
|
|
113
|
+
}
|
|
114
|
+
if (jwe.tag !== undefined) {
|
|
115
|
+
tag = decodeBase64url(jwe.tag, 'tag', JWEInvalid);
|
|
116
|
+
}
|
|
117
|
+
const protectedHeader = jwe.protected !== undefined ? encode(jwe.protected) : new Uint8Array();
|
|
118
|
+
let additionalData;
|
|
119
|
+
if (jwe.aad !== undefined) {
|
|
120
|
+
additionalData = concat(protectedHeader, encode('.'), encode(jwe.aad));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
additionalData = protectedHeader;
|
|
124
|
+
}
|
|
125
|
+
const ciphertext = decodeBase64url(jwe.ciphertext, 'ciphertext', JWEInvalid);
|
|
126
|
+
const plaintext = await decrypt(enc, cek, ciphertext, iv, tag, additionalData);
|
|
127
|
+
const result = { plaintext };
|
|
128
|
+
if (joseHeader.zip === 'DEF') {
|
|
129
|
+
const maxDecompressedLength = options?.maxDecompressedLength ?? 250_000;
|
|
130
|
+
if (maxDecompressedLength === 0) {
|
|
131
|
+
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
|
132
|
+
}
|
|
133
|
+
if (maxDecompressedLength !== Infinity &&
|
|
134
|
+
(!Number.isSafeInteger(maxDecompressedLength) || maxDecompressedLength < 1)) {
|
|
135
|
+
throw new TypeError('maxDecompressedLength must be 0, a positive safe integer, or Infinity');
|
|
136
|
+
}
|
|
137
|
+
result.plaintext = await decompress(plaintext, maxDecompressedLength);
|
|
138
|
+
}
|
|
139
|
+
if (jwe.protected !== undefined) {
|
|
140
|
+
result.protectedHeader = parsedProt;
|
|
141
|
+
}
|
|
142
|
+
if (jwe.aad !== undefined) {
|
|
143
|
+
result.additionalAuthenticatedData = decodeBase64url(jwe.aad, 'aad', JWEInvalid);
|
|
144
|
+
}
|
|
145
|
+
if (jwe.unprotected !== undefined) {
|
|
146
|
+
result.sharedUnprotectedHeader = jwe.unprotected;
|
|
147
|
+
}
|
|
148
|
+
if (jwe.header !== undefined) {
|
|
149
|
+
result.unprotectedHeader = jwe.header;
|
|
150
|
+
}
|
|
151
|
+
if (resolvedKey) {
|
|
152
|
+
return { ...result, key: k };
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { encode as b64u } from '../../util/base64url.js';
|
|
2
|
+
import { unprotected, assertNotSet } from '../../lib/helpers.js';
|
|
3
|
+
import { encrypt } from '../../lib/content_encryption.js';
|
|
4
|
+
import { encryptKeyManagement } from '../../lib/key_management.js';
|
|
5
|
+
import { JOSENotSupported, JWEInvalid } from '../../util/errors.js';
|
|
6
|
+
import { isDisjoint } from '../../lib/type_checks.js';
|
|
7
|
+
import { concat, encode } from '../../lib/buffer_utils.js';
|
|
8
|
+
import { validateCrit } from '../../lib/validate_crit.js';
|
|
9
|
+
import { normalizeKey } from '../../lib/normalize_key.js';
|
|
10
|
+
import { checkKeyType } from '../../lib/check_key_type.js';
|
|
11
|
+
import { compress } from '../../lib/deflate.js';
|
|
12
|
+
export class FlattenedEncrypt {
|
|
13
|
+
#plaintext;
|
|
14
|
+
#protectedHeader;
|
|
15
|
+
#sharedUnprotectedHeader;
|
|
16
|
+
#unprotectedHeader;
|
|
17
|
+
#aad;
|
|
18
|
+
#cek;
|
|
19
|
+
#iv;
|
|
20
|
+
#keyManagementParameters;
|
|
21
|
+
constructor(plaintext) {
|
|
22
|
+
if (!(plaintext instanceof Uint8Array)) {
|
|
23
|
+
throw new TypeError('plaintext must be an instance of Uint8Array');
|
|
24
|
+
}
|
|
25
|
+
this.#plaintext = plaintext;
|
|
26
|
+
}
|
|
27
|
+
setKeyManagementParameters(parameters) {
|
|
28
|
+
assertNotSet(this.#keyManagementParameters, 'setKeyManagementParameters');
|
|
29
|
+
this.#keyManagementParameters = parameters;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
setProtectedHeader(protectedHeader) {
|
|
33
|
+
assertNotSet(this.#protectedHeader, 'setProtectedHeader');
|
|
34
|
+
this.#protectedHeader = protectedHeader;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
|
38
|
+
assertNotSet(this.#sharedUnprotectedHeader, 'setSharedUnprotectedHeader');
|
|
39
|
+
this.#sharedUnprotectedHeader = sharedUnprotectedHeader;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
setUnprotectedHeader(unprotectedHeader) {
|
|
43
|
+
assertNotSet(this.#unprotectedHeader, 'setUnprotectedHeader');
|
|
44
|
+
this.#unprotectedHeader = unprotectedHeader;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
setAdditionalAuthenticatedData(aad) {
|
|
48
|
+
this.#aad = aad;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
setContentEncryptionKey(cek) {
|
|
52
|
+
assertNotSet(this.#cek, 'setContentEncryptionKey');
|
|
53
|
+
this.#cek = cek;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
setInitializationVector(iv) {
|
|
57
|
+
assertNotSet(this.#iv, 'setInitializationVector');
|
|
58
|
+
this.#iv = iv;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
async encrypt(key, options) {
|
|
62
|
+
if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
|
|
63
|
+
throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');
|
|
64
|
+
}
|
|
65
|
+
if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader, this.#sharedUnprotectedHeader)) {
|
|
66
|
+
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
|
67
|
+
}
|
|
68
|
+
const joseHeader = {
|
|
69
|
+
...this.#protectedHeader,
|
|
70
|
+
...this.#unprotectedHeader,
|
|
71
|
+
...this.#sharedUnprotectedHeader,
|
|
72
|
+
};
|
|
73
|
+
validateCrit(JWEInvalid, new Map(), options?.crit, this.#protectedHeader, joseHeader);
|
|
74
|
+
if (joseHeader.zip !== undefined && joseHeader.zip !== 'DEF') {
|
|
75
|
+
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
|
|
76
|
+
}
|
|
77
|
+
if (joseHeader.zip !== undefined && !this.#protectedHeader?.zip) {
|
|
78
|
+
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
|
|
79
|
+
}
|
|
80
|
+
const { alg, enc } = joseHeader;
|
|
81
|
+
if (typeof alg !== 'string' || !alg) {
|
|
82
|
+
throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
|
|
83
|
+
}
|
|
84
|
+
if (typeof enc !== 'string' || !enc) {
|
|
85
|
+
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
|
86
|
+
}
|
|
87
|
+
let encryptedKey;
|
|
88
|
+
if (this.#cek && (alg === 'dir' || alg === 'ECDH-ES')) {
|
|
89
|
+
throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${alg}`);
|
|
90
|
+
}
|
|
91
|
+
checkKeyType(alg === 'dir' ? enc : alg, key, 'encrypt');
|
|
92
|
+
let cek;
|
|
93
|
+
{
|
|
94
|
+
let parameters;
|
|
95
|
+
const k = await normalizeKey(key, alg);
|
|
96
|
+
({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, this.#cek, this.#keyManagementParameters));
|
|
97
|
+
if (parameters) {
|
|
98
|
+
if (options && unprotected in options) {
|
|
99
|
+
if (!this.#unprotectedHeader) {
|
|
100
|
+
this.setUnprotectedHeader(parameters);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.#unprotectedHeader = { ...this.#unprotectedHeader, ...parameters };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (!this.#protectedHeader) {
|
|
107
|
+
this.setProtectedHeader(parameters);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.#protectedHeader = { ...this.#protectedHeader, ...parameters };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let additionalData;
|
|
115
|
+
let protectedHeaderS;
|
|
116
|
+
let protectedHeaderB;
|
|
117
|
+
let aadMember;
|
|
118
|
+
if (this.#protectedHeader) {
|
|
119
|
+
protectedHeaderS = b64u(JSON.stringify(this.#protectedHeader));
|
|
120
|
+
protectedHeaderB = encode(protectedHeaderS);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
protectedHeaderS = '';
|
|
124
|
+
protectedHeaderB = new Uint8Array();
|
|
125
|
+
}
|
|
126
|
+
if (this.#aad) {
|
|
127
|
+
aadMember = b64u(this.#aad);
|
|
128
|
+
const aadMemberBytes = encode(aadMember);
|
|
129
|
+
additionalData = concat(protectedHeaderB, encode('.'), aadMemberBytes);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
additionalData = protectedHeaderB;
|
|
133
|
+
}
|
|
134
|
+
let plaintext = this.#plaintext;
|
|
135
|
+
if (joseHeader.zip === 'DEF') {
|
|
136
|
+
plaintext = await compress(plaintext);
|
|
137
|
+
}
|
|
138
|
+
const { ciphertext, tag, iv } = await encrypt(enc, plaintext, cek, this.#iv, additionalData);
|
|
139
|
+
const jwe = {
|
|
140
|
+
ciphertext: b64u(ciphertext),
|
|
141
|
+
};
|
|
142
|
+
if (iv) {
|
|
143
|
+
jwe.iv = b64u(iv);
|
|
144
|
+
}
|
|
145
|
+
if (tag) {
|
|
146
|
+
jwe.tag = b64u(tag);
|
|
147
|
+
}
|
|
148
|
+
if (encryptedKey) {
|
|
149
|
+
jwe.encrypted_key = b64u(encryptedKey);
|
|
150
|
+
}
|
|
151
|
+
if (aadMember) {
|
|
152
|
+
jwe.aad = aadMember;
|
|
153
|
+
}
|
|
154
|
+
if (this.#protectedHeader) {
|
|
155
|
+
jwe.protected = protectedHeaderS;
|
|
156
|
+
}
|
|
157
|
+
if (this.#sharedUnprotectedHeader) {
|
|
158
|
+
jwe.unprotected = this.#sharedUnprotectedHeader;
|
|
159
|
+
}
|
|
160
|
+
if (this.#unprotectedHeader) {
|
|
161
|
+
jwe.header = this.#unprotectedHeader;
|
|
162
|
+
}
|
|
163
|
+
return jwe;
|
|
164
|
+
}
|
|
165
|
+
}
|