@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,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var interaction_exports = {};
|
|
28
|
+
__export(interaction_exports, {
|
|
29
|
+
handleInteractionGet: () => handleInteractionGet,
|
|
30
|
+
handleInteractionPost: () => handleInteractionPost
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(interaction_exports);
|
|
33
|
+
var import_provider_dispatch = require("./provider-dispatch");
|
|
34
|
+
function asStringArray(value) {
|
|
35
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
36
|
+
}
|
|
37
|
+
function getPromptDetails(details) {
|
|
38
|
+
return details.prompt.details || {};
|
|
39
|
+
}
|
|
40
|
+
function getInteractionPromptDetails(details) {
|
|
41
|
+
const promptDetails = getPromptDetails(details);
|
|
42
|
+
const missingScope = asStringArray(promptDetails.missingOIDCScope).join(" ");
|
|
43
|
+
const missingClaims = asStringArray(promptDetails.missingOIDCClaims).join(", ");
|
|
44
|
+
const missingResourceScopes = Object.entries(promptDetails.missingResourceScopes || {}).map(([resource, scopes]) => `${resource}: ${asStringArray(scopes).join(" ")}`).join("; ");
|
|
45
|
+
return [missingScope, missingClaims, missingResourceScopes].filter(Boolean).join(" | ");
|
|
46
|
+
}
|
|
47
|
+
async function getInteractionRedirect(ctx, provider, service, result, mergeWithLastSubmission) {
|
|
48
|
+
const redirectTo = await provider.interactionResult(ctx.req, ctx.res, result, {
|
|
49
|
+
mergeWithLastSubmission
|
|
50
|
+
});
|
|
51
|
+
return (0, import_provider_dispatch.rewriteProviderLocationHeader)(ctx, service, redirectTo);
|
|
52
|
+
}
|
|
53
|
+
async function completeLogin(ctx, provider, service, accountId) {
|
|
54
|
+
return getInteractionRedirect(
|
|
55
|
+
ctx,
|
|
56
|
+
provider,
|
|
57
|
+
service,
|
|
58
|
+
{
|
|
59
|
+
login: {
|
|
60
|
+
accountId
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
false
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
async function handleInteractionGet(ctx, provider, user, service) {
|
|
67
|
+
var _a;
|
|
68
|
+
const details = await provider.interactionDetails(ctx.req, ctx.res);
|
|
69
|
+
const interactionUser = user || await service.resolveInteractionSessionUser((_a = details.session) == null ? void 0 : _a.accountId);
|
|
70
|
+
if (details.prompt.name === "login") {
|
|
71
|
+
if (!interactionUser) {
|
|
72
|
+
ctx.body = {
|
|
73
|
+
prompt: "login"
|
|
74
|
+
};
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
ctx.body = {
|
|
78
|
+
redirectTo: await completeLogin(ctx, provider, service, String(interactionUser.id))
|
|
79
|
+
};
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (details.prompt.name === "consent") {
|
|
83
|
+
const clientId = String(details.params.client_id || "");
|
|
84
|
+
const client = await provider.Client.find(clientId);
|
|
85
|
+
ctx.body = {
|
|
86
|
+
prompt: "consent",
|
|
87
|
+
clientName: (client == null ? void 0 : client.clientName) || (client == null ? void 0 : client.clientId) || clientId,
|
|
88
|
+
details: getInteractionPromptDetails(details)
|
|
89
|
+
};
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
ctx.throw(501, `Unsupported interaction prompt: ${details.prompt.name}`);
|
|
93
|
+
}
|
|
94
|
+
async function handleInteractionPost(ctx, provider, user, service) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
const details = await provider.interactionDetails(ctx.req, ctx.res);
|
|
97
|
+
const interactionUser = user || await service.resolveInteractionSessionUser((_a = details.session) == null ? void 0 : _a.accountId);
|
|
98
|
+
if ((_b = ctx.request.body) == null ? void 0 : _b.cancel) {
|
|
99
|
+
ctx.body = {
|
|
100
|
+
redirectTo: await getInteractionRedirect(
|
|
101
|
+
ctx,
|
|
102
|
+
provider,
|
|
103
|
+
service,
|
|
104
|
+
{
|
|
105
|
+
error: "access_denied",
|
|
106
|
+
error_description: "End-User aborted interaction"
|
|
107
|
+
},
|
|
108
|
+
false
|
|
109
|
+
)
|
|
110
|
+
};
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!interactionUser) {
|
|
114
|
+
ctx.body = {
|
|
115
|
+
prompt: "login"
|
|
116
|
+
};
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (details.prompt.name === "login") {
|
|
120
|
+
ctx.body = {
|
|
121
|
+
redirectTo: await completeLogin(ctx, provider, service, String(interactionUser.id))
|
|
122
|
+
};
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (details.prompt.name === "consent") {
|
|
126
|
+
const promptDetails = getPromptDetails(details);
|
|
127
|
+
const clientId = String(details.params.client_id || "");
|
|
128
|
+
let grant;
|
|
129
|
+
if (details.grantId) {
|
|
130
|
+
grant = await provider.Grant.find(details.grantId);
|
|
131
|
+
} else {
|
|
132
|
+
grant = new provider.Grant({
|
|
133
|
+
accountId: String(interactionUser.id),
|
|
134
|
+
clientId
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const missingOIDCScope = asStringArray(promptDetails.missingOIDCScope);
|
|
138
|
+
if (missingOIDCScope.length) {
|
|
139
|
+
grant.addOIDCScope(missingOIDCScope.join(" "));
|
|
140
|
+
}
|
|
141
|
+
const missingOIDCClaims = asStringArray(promptDetails.missingOIDCClaims);
|
|
142
|
+
if (missingOIDCClaims.length) {
|
|
143
|
+
grant.addOIDCClaims(missingOIDCClaims);
|
|
144
|
+
}
|
|
145
|
+
const missingResourceScopes = promptDetails.missingResourceScopes || {};
|
|
146
|
+
if (Object.keys(missingResourceScopes).length) {
|
|
147
|
+
for (const [indicator, scopes] of Object.entries(missingResourceScopes)) {
|
|
148
|
+
grant.addResourceScope(indicator, asStringArray(scopes).join(" "));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
ctx.body = {
|
|
152
|
+
redirectTo: await getInteractionRedirect(
|
|
153
|
+
ctx,
|
|
154
|
+
provider,
|
|
155
|
+
service,
|
|
156
|
+
{
|
|
157
|
+
consent: {
|
|
158
|
+
grantId: await grant.save()
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
true
|
|
162
|
+
)
|
|
163
|
+
};
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
ctx.throw(501, `Unsupported interaction prompt: ${details.prompt.name}`);
|
|
167
|
+
}
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
handleInteractionGet,
|
|
171
|
+
handleInteractionPost
|
|
172
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export type IdpOauthPaths = ReturnType<typeof createIdpOauthPaths>;
|
|
10
|
+
export declare function createIdpOauthPaths(apiBasePath?: string): {
|
|
11
|
+
apiBasePath: string;
|
|
12
|
+
providerPathPrefix: string;
|
|
13
|
+
interactionPathPrefix: string;
|
|
14
|
+
oauthMetadataPath: string;
|
|
15
|
+
openidMetadataPath: string;
|
|
16
|
+
isProviderPath(path: string): boolean;
|
|
17
|
+
isDiscoveryPath(path: string): boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function getProviderInternalPath(pathname: string, apiBasePath: string): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var paths_exports = {};
|
|
28
|
+
__export(paths_exports, {
|
|
29
|
+
createIdpOauthPaths: () => createIdpOauthPaths,
|
|
30
|
+
getProviderInternalPath: () => getProviderInternalPath
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(paths_exports);
|
|
33
|
+
var import_utils = require("./utils");
|
|
34
|
+
function createIdpOauthPaths(apiBasePath = process.env.API_BASE_PATH || "/api") {
|
|
35
|
+
const normalizedApiBasePath = (0, import_utils.normalizeBasePath)(apiBasePath);
|
|
36
|
+
const providerPathPrefix = `${normalizedApiBasePath}/idpOAuth/`;
|
|
37
|
+
const interactionPathPrefix = `${providerPathPrefix}interaction/`;
|
|
38
|
+
const oauthMetadataPath = `${normalizedApiBasePath}/.well-known/oauth-authorization-server`;
|
|
39
|
+
const openidMetadataPath = `${normalizedApiBasePath}/.well-known/openid-configuration`;
|
|
40
|
+
return {
|
|
41
|
+
apiBasePath: normalizedApiBasePath,
|
|
42
|
+
providerPathPrefix,
|
|
43
|
+
interactionPathPrefix,
|
|
44
|
+
oauthMetadataPath,
|
|
45
|
+
openidMetadataPath,
|
|
46
|
+
isProviderPath(path) {
|
|
47
|
+
return path.startsWith(providerPathPrefix) || path === oauthMetadataPath || path === openidMetadataPath;
|
|
48
|
+
},
|
|
49
|
+
isDiscoveryPath(path) {
|
|
50
|
+
return path === oauthMetadataPath || path === openidMetadataPath;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function getProviderInternalPath(pathname, apiBasePath) {
|
|
55
|
+
if (pathname.startsWith(`${apiBasePath}/`)) {
|
|
56
|
+
return pathname.slice(apiBasePath.length) || "/";
|
|
57
|
+
}
|
|
58
|
+
return pathname;
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
createIdpOauthPaths,
|
|
63
|
+
getProviderInternalPath
|
|
64
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from '@nocobase/server';
|
|
10
|
+
import { IdpOauthService } from './service';
|
|
11
|
+
export declare class PluginIdpOauthServer extends Plugin {
|
|
12
|
+
service: IdpOauthService;
|
|
13
|
+
load(): Promise<void>;
|
|
14
|
+
remove(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export default PluginIdpOauthServer;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var plugin_exports = {};
|
|
28
|
+
__export(plugin_exports, {
|
|
29
|
+
PluginIdpOauthServer: () => PluginIdpOauthServer,
|
|
30
|
+
default: () => plugin_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
+
var import_server = require("@nocobase/server");
|
|
34
|
+
var import_interaction = require("./interaction");
|
|
35
|
+
var import_paths = require("./paths");
|
|
36
|
+
var import_provider_dispatch = require("./provider-dispatch");
|
|
37
|
+
var import_service = require("./service");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
class PluginIdpOauthServer extends import_server.Plugin {
|
|
40
|
+
service;
|
|
41
|
+
async load() {
|
|
42
|
+
const bridgeTokenCache = await this.app.cacheManager.createCache({
|
|
43
|
+
name: "idp-oauth-token",
|
|
44
|
+
prefix: "idp-oauth:token",
|
|
45
|
+
store: "memory"
|
|
46
|
+
});
|
|
47
|
+
this.service = new import_service.IdpOauthService(this.app, bridgeTokenCache);
|
|
48
|
+
const paths = (0, import_paths.createIdpOauthPaths)();
|
|
49
|
+
this.app.use(
|
|
50
|
+
async (ctx, next) => {
|
|
51
|
+
if (ctx.path.startsWith(paths.interactionPathPrefix)) {
|
|
52
|
+
await next();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (paths.isProviderPath(ctx.path)) {
|
|
56
|
+
await (0, import_provider_dispatch.dispatchCurrentRequestToProvider)(ctx, this.service, paths.apiBasePath);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await next();
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
tag: "idp-oauth-provider",
|
|
63
|
+
before: "dataSource"
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
this.app.use(
|
|
67
|
+
async (ctx, next) => {
|
|
68
|
+
await this.service.authenticateResourceRequest(ctx);
|
|
69
|
+
await next();
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
tag: "idp-oauth-resource-auth",
|
|
73
|
+
before: "dataSource"
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
this.app.use(
|
|
77
|
+
async (ctx, next) => {
|
|
78
|
+
if (!ctx.path.startsWith(paths.interactionPathPrefix)) {
|
|
79
|
+
await next();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
ctx.withoutDataWrapping = true;
|
|
83
|
+
const provider = await this.service.ensureProviderForContext(ctx);
|
|
84
|
+
const user = await (0, import_utils.resolveCurrentUser)(ctx, this.service);
|
|
85
|
+
if (ctx.method === "GET") {
|
|
86
|
+
await (0, import_interaction.handleInteractionGet)(ctx, provider, user, this.service);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (ctx.method === "POST") {
|
|
90
|
+
await (0, import_interaction.handleInteractionPost)(ctx, provider, user, this.service);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
ctx.throw(405);
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
tag: "idp-oauth-interaction",
|
|
97
|
+
before: "dataSource"
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
async remove() {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var plugin_default = PluginIdpOauthServer;
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
PluginIdpOauthServer
|
|
108
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { IdpOauthService } from './service';
|
|
10
|
+
type Provider = import('oidc-provider').Provider;
|
|
11
|
+
type DispatchContext = {
|
|
12
|
+
method: string;
|
|
13
|
+
path: string;
|
|
14
|
+
querystring?: string;
|
|
15
|
+
headers: Record<string, string | string[] | undefined>;
|
|
16
|
+
logger?: {
|
|
17
|
+
debug?: (message: string, meta?: Record<string, any>) => void;
|
|
18
|
+
warn?: (message: string, meta?: Record<string, any>) => void;
|
|
19
|
+
};
|
|
20
|
+
request: {
|
|
21
|
+
body?: Record<string, any> | string | null;
|
|
22
|
+
};
|
|
23
|
+
get(name: string): string;
|
|
24
|
+
set(name: string, value: string | string[]): void;
|
|
25
|
+
body?: unknown;
|
|
26
|
+
status?: number;
|
|
27
|
+
withoutDataWrapping?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare function rewriteProviderLocationHeader(ctx: DispatchContext, service: IdpOauthService, location: string): string;
|
|
30
|
+
export declare function dispatchToProvider(ctx: DispatchContext, provider: Provider, pathname: string, service: IdpOauthService): Promise<void>;
|
|
31
|
+
export declare function dispatchCurrentRequestToProvider(ctx: DispatchContext, service: IdpOauthService, apiBasePath: string): Promise<void>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var provider_dispatch_exports = {};
|
|
38
|
+
__export(provider_dispatch_exports, {
|
|
39
|
+
dispatchCurrentRequestToProvider: () => dispatchCurrentRequestToProvider,
|
|
40
|
+
dispatchToProvider: () => dispatchToProvider,
|
|
41
|
+
rewriteProviderLocationHeader: () => rewriteProviderLocationHeader
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(provider_dispatch_exports);
|
|
44
|
+
var import_light_my_request = __toESM(require("light-my-request"));
|
|
45
|
+
var import_paths = require("./paths");
|
|
46
|
+
function buildPayload(ctx) {
|
|
47
|
+
const body = ctx.request.body;
|
|
48
|
+
if (body === void 0 || body === null) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const contentType = String(ctx.get("content-type") || "").toLowerCase();
|
|
52
|
+
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
53
|
+
return new URLSearchParams(body).toString();
|
|
54
|
+
}
|
|
55
|
+
if (contentType.includes("application/json")) {
|
|
56
|
+
return typeof body === "string" ? body : JSON.stringify(body);
|
|
57
|
+
}
|
|
58
|
+
return body;
|
|
59
|
+
}
|
|
60
|
+
function buildHeaders(ctx, service) {
|
|
61
|
+
const publicOrigin = service.getProviderContext(ctx).origin;
|
|
62
|
+
const headers = { ...ctx.headers, host: new URL(publicOrigin).host };
|
|
63
|
+
delete headers["content-length"];
|
|
64
|
+
delete headers["Content-Length"];
|
|
65
|
+
delete headers["transfer-encoding"];
|
|
66
|
+
delete headers["Transfer-Encoding"];
|
|
67
|
+
return headers;
|
|
68
|
+
}
|
|
69
|
+
function rewriteProviderPathname(ctx, service, pathname) {
|
|
70
|
+
const { issuerPath } = service.getProviderContext(ctx);
|
|
71
|
+
const externalPathPrefix = `${issuerPath}/idpOAuth/`;
|
|
72
|
+
const internalPathPrefix = "/idpOAuth/";
|
|
73
|
+
const metadataPrefixes = ["/.well-known/oauth-authorization-server", "/.well-known/openid-configuration"];
|
|
74
|
+
if (pathname.startsWith(externalPathPrefix) || pathname === issuerPath) {
|
|
75
|
+
return pathname;
|
|
76
|
+
}
|
|
77
|
+
if (pathname.startsWith(internalPathPrefix)) {
|
|
78
|
+
return `${issuerPath}${pathname}`;
|
|
79
|
+
}
|
|
80
|
+
if (metadataPrefixes.some((prefix) => pathname.startsWith(prefix))) {
|
|
81
|
+
return `${issuerPath}${pathname}`;
|
|
82
|
+
}
|
|
83
|
+
return pathname;
|
|
84
|
+
}
|
|
85
|
+
function rewriteProviderUrl(ctx, service, value) {
|
|
86
|
+
const { origin } = service.getProviderContext(ctx);
|
|
87
|
+
const publicOriginUrl = new URL(origin);
|
|
88
|
+
if (value.startsWith("/")) {
|
|
89
|
+
const url = new URL(value, origin);
|
|
90
|
+
url.pathname = rewriteProviderPathname(ctx, service, url.pathname);
|
|
91
|
+
return url.pathname + url.search + url.hash;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const url = new URL(value);
|
|
95
|
+
const rewrittenPathname = rewriteProviderPathname(ctx, service, url.pathname);
|
|
96
|
+
if (rewrittenPathname === url.pathname && url.origin !== origin) {
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
url.protocol = publicOriginUrl.protocol;
|
|
100
|
+
url.host = publicOriginUrl.host;
|
|
101
|
+
url.pathname = rewrittenPathname;
|
|
102
|
+
return url.toString();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function rewriteProviderLocationHeader(ctx, service, location) {
|
|
108
|
+
return rewriteProviderUrl(ctx, service, location);
|
|
109
|
+
}
|
|
110
|
+
function getFrontendInteractionCookiePath(originalPath) {
|
|
111
|
+
const match = originalPath.match(/^\/idp-oauth\/interaction\/([^/]+)\/([^/]+)$/);
|
|
112
|
+
if (!match) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
const [, appName, uid] = match;
|
|
116
|
+
return { appName, uid };
|
|
117
|
+
}
|
|
118
|
+
function rewriteProviderSetCookieHeader(ctx, service, cookie) {
|
|
119
|
+
const pathMatch = cookie.match(/;\s*path=([^;]+)/i);
|
|
120
|
+
if (!pathMatch) {
|
|
121
|
+
return cookie;
|
|
122
|
+
}
|
|
123
|
+
const originalPath = pathMatch[1];
|
|
124
|
+
let rewrittenPath = rewriteProviderLocationHeader(ctx, service, originalPath);
|
|
125
|
+
const providerContext = service.getProviderContext(ctx);
|
|
126
|
+
if (originalPath.startsWith("/idpOAuth/interaction/")) {
|
|
127
|
+
rewrittenPath = `${providerContext.issuerPath}${originalPath}`;
|
|
128
|
+
}
|
|
129
|
+
const frontendInteractionPath = getFrontendInteractionCookiePath(originalPath);
|
|
130
|
+
if (frontendInteractionPath) {
|
|
131
|
+
rewrittenPath = `${service.getIssuerPath(frontendInteractionPath.appName)}/idpOAuth/interaction/${frontendInteractionPath.uid}`;
|
|
132
|
+
}
|
|
133
|
+
if (rewrittenPath === originalPath) {
|
|
134
|
+
return cookie;
|
|
135
|
+
}
|
|
136
|
+
return cookie.replace(pathMatch[0], `; path=${rewrittenPath}`);
|
|
137
|
+
}
|
|
138
|
+
function rewriteProviderJsonBody(ctx, service, body) {
|
|
139
|
+
const { issuer } = service.getProviderContext(ctx);
|
|
140
|
+
const metadataPaths = [
|
|
141
|
+
"/idpOAuth/authorize",
|
|
142
|
+
"/idpOAuth/token",
|
|
143
|
+
"/idpOAuth/register",
|
|
144
|
+
"/idpOAuth/revoke",
|
|
145
|
+
"/idpOAuth/jwks",
|
|
146
|
+
"/idpOAuth/me",
|
|
147
|
+
"/idpOAuth/introspection",
|
|
148
|
+
"/idpOAuth/end-session"
|
|
149
|
+
];
|
|
150
|
+
const metadataKeys = [
|
|
151
|
+
"authorization_endpoint",
|
|
152
|
+
"token_endpoint",
|
|
153
|
+
"registration_endpoint",
|
|
154
|
+
"revocation_endpoint",
|
|
155
|
+
"jwks_uri",
|
|
156
|
+
"userinfo_endpoint",
|
|
157
|
+
"introspection_endpoint",
|
|
158
|
+
"end_session_endpoint"
|
|
159
|
+
];
|
|
160
|
+
if (ctx.path.endsWith("/.well-known/oauth-authorization-server") || ctx.path.endsWith("/.well-known/openid-configuration")) {
|
|
161
|
+
body.issuer = issuer;
|
|
162
|
+
body.scopes_supported = service.getSupportedScopes();
|
|
163
|
+
metadataKeys.forEach((key, index) => {
|
|
164
|
+
body[key] = `${issuer}${metadataPaths[index]}`;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (typeof body.registration_client_uri === "string") {
|
|
168
|
+
const registrationClientUri = new URL(body.registration_client_uri, issuer);
|
|
169
|
+
const clientId = body.client_id || registrationClientUri.pathname.split("/").pop();
|
|
170
|
+
body.registration_client_uri = `${issuer}/idpOAuth/register/${clientId}`;
|
|
171
|
+
}
|
|
172
|
+
return body;
|
|
173
|
+
}
|
|
174
|
+
function rewriteProviderResponseHeaders(ctx, service, headers) {
|
|
175
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
176
|
+
if (value === void 0) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (name.toLowerCase() === "location") {
|
|
180
|
+
const originalLocation = Array.isArray(value) ? String(value[0]) : String(value);
|
|
181
|
+
ctx.set(name, rewriteProviderLocationHeader(ctx, service, originalLocation));
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (name.toLowerCase() === "set-cookie") {
|
|
185
|
+
const cookies = Array.isArray(value) ? value.map(String) : [String(value)];
|
|
186
|
+
ctx.set(
|
|
187
|
+
name,
|
|
188
|
+
cookies.map((cookie) => rewriteProviderSetCookieHeader(ctx, service, cookie))
|
|
189
|
+
);
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
ctx.set(name, Array.isArray(value) ? value.map(String) : String(value));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function dispatchToProvider(ctx, provider, pathname, service) {
|
|
196
|
+
var _a, _b, _c, _d, _e, _f;
|
|
197
|
+
ctx.withoutDataWrapping = true;
|
|
198
|
+
const search = ctx.querystring ? `?${ctx.querystring}` : "";
|
|
199
|
+
(_b = (_a = ctx.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, "idp-oauth provider request", {
|
|
200
|
+
method: ctx.method,
|
|
201
|
+
externalPath: ctx.path,
|
|
202
|
+
internalPath: pathname,
|
|
203
|
+
search,
|
|
204
|
+
issuer: provider.issuer
|
|
205
|
+
});
|
|
206
|
+
const response = await (0, import_light_my_request.default)(provider.callback(), {
|
|
207
|
+
method: ctx.method,
|
|
208
|
+
url: `${pathname}${search}`,
|
|
209
|
+
headers: buildHeaders(ctx, service),
|
|
210
|
+
payload: buildPayload(ctx)
|
|
211
|
+
});
|
|
212
|
+
ctx.status = response.statusCode;
|
|
213
|
+
rewriteProviderResponseHeaders(ctx, service, response.headers);
|
|
214
|
+
const payload = response.rawPayload;
|
|
215
|
+
const contentType = String(response.headers["content-type"] || "").toLowerCase();
|
|
216
|
+
(_d = (_c = ctx.logger) == null ? void 0 : _c.debug) == null ? void 0 : _d.call(_c, "idp-oauth provider response", {
|
|
217
|
+
method: ctx.method,
|
|
218
|
+
externalPath: ctx.path,
|
|
219
|
+
internalPath: pathname,
|
|
220
|
+
status: response.statusCode,
|
|
221
|
+
contentType,
|
|
222
|
+
location: response.headers.location
|
|
223
|
+
});
|
|
224
|
+
if (payload.length && (contentType.includes("application/json") || contentType.includes("+json"))) {
|
|
225
|
+
try {
|
|
226
|
+
const body = rewriteProviderJsonBody(ctx, service, JSON.parse(payload.toString("utf8")));
|
|
227
|
+
ctx.body = body;
|
|
228
|
+
return;
|
|
229
|
+
} catch (error) {
|
|
230
|
+
(_f = (_e = ctx.logger) == null ? void 0 : _e.warn) == null ? void 0 : _f.call(_e, "idp-oauth provider json parse failed", {
|
|
231
|
+
method: ctx.method,
|
|
232
|
+
externalPath: ctx.path,
|
|
233
|
+
internalPath: pathname,
|
|
234
|
+
status: response.statusCode,
|
|
235
|
+
contentType,
|
|
236
|
+
error: error instanceof Error ? error.message : String(error),
|
|
237
|
+
payloadPreview: payload.toString("utf8").slice(0, 500)
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
ctx.body = payload.length ? payload : void 0;
|
|
242
|
+
}
|
|
243
|
+
async function dispatchCurrentRequestToProvider(ctx, service, apiBasePath) {
|
|
244
|
+
const provider = await service.ensureProviderForContext(ctx);
|
|
245
|
+
return dispatchToProvider(ctx, provider, (0, import_paths.getProviderInternalPath)(ctx.path, apiBasePath), service);
|
|
246
|
+
}
|
|
247
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
248
|
+
0 && (module.exports = {
|
|
249
|
+
dispatchCurrentRequestToProvider,
|
|
250
|
+
dispatchToProvider,
|
|
251
|
+
rewriteProviderLocationHeader
|
|
252
|
+
});
|