├── .clang-format ├── .eslintrc.json ├── .evergreen ├── config.yml ├── install-dependencies.sh ├── prepare-shell.sh ├── run-prebuild.sh ├── run-tests-ubuntu.sh └── run-tests.sh ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── Issue_template.md │ └── config.yml ├── dependabot.yml ├── docker │ └── Dockerfile.glibc ├── pull_request_template.md ├── scripts │ ├── build.mjs │ ├── highlights.mjs │ ├── pr_list.mjs │ ├── release_notes.mjs │ └── util.mjs └── workflows │ ├── build.yml │ ├── codeql.yml │ ├── release.yml │ ├── release_notes.yml │ └── webpack.yml ├── .gitignore ├── .mocharc.json ├── .npmignore ├── .prettierrc.json ├── .release-please-manifest.json ├── HISTORY.md ├── LICENSE ├── README.md ├── binding.gyp ├── etc └── README.hbs ├── lib ├── auth_processes │ └── mongodb.js ├── index.js ├── kerberos.js └── util.js ├── package-lock.json ├── package.json ├── release-please-config.json ├── sbom.json ├── src ├── kerberos.cc ├── kerberos.h ├── kerberos_common.h ├── kerberos_worker.h ├── unix │ ├── base64.cc │ ├── base64.h │ ├── kerberos_gss.cc │ ├── kerberos_gss.h │ └── kerberos_unix.cc └── win32 │ ├── kerberos_sspi.cc │ ├── kerberos_sspi.h │ └── kerberos_win32.cc └── test ├── bundling └── webpack │ ├── .gitignore │ ├── install_kerberos.cjs │ ├── package-lock.json │ ├── package.json │ ├── readme.md │ ├── src │ └── index.js │ └── webpack.config.js ├── defineOperation_tests.js ├── exports_tests.js ├── kerberos_tests.js ├── kerberos_win32_tests.js └── tools ├── hooks └── environment_hook.js └── mongodb_reporter.js /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | AllowShortFunctionsOnASingleLine: Empty 3 | AllowShortIfStatementsOnASingleLine: false 4 | AllowShortLoopsOnASingleLine: false 5 | BinPackArguments: false 6 | BinPackParameters: false 7 | ColumnLimit: 100 8 | Cpp11BracedListStyle: true 9 | DerivePointerAlignment: false 10 | IndentWidth: 4 11 | MaxEmptyLinesToKeep: 1 12 | NamespaceIndentation: None 13 | SpaceBeforeAssignmentOperators: true 14 | Standard: Cpp11 15 | UseTab: Never 16 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:prettier/recommended" 6 | ], 7 | "env": { 8 | "node": true, 9 | "mocha": true, 10 | "es6": true 11 | }, 12 | "parserOptions": { 13 | "ecmaVersion": 2019 14 | }, 15 | "plugins": [ 16 | "prettier" 17 | ], 18 | "rules": { 19 | "no-restricted-properties": [ 20 | "error", 21 | { 22 | "object": "describe", 23 | "property": "only" 24 | }, 25 | { 26 | "object": "it", 27 | "property": "only" 28 | }, 29 | { 30 | "object": "context", 31 | "property": "only" 32 | } 33 | ], 34 | "prettier/prettier": "error", 35 | "no-console": "error", 36 | "valid-typeof": "error", 37 | "eqeqeq": ["error", "always", {"null": "ignore"}], 38 | "strict": ["error", "global"], 39 | "no-restricted-syntax": [ 40 | "error", 41 | { 42 | "selector": "TSEnumDeclaration", 43 | "message": "Do not declare enums" 44 | }, 45 | { 46 | "selector": "BinaryExpression[operator=/[=!]==/] Identifier[name='undefined']", 47 | "message": "Do not strictly check undefined" 48 | }, 49 | { 50 | "selector": "BinaryExpression[operator=/[=!]==/] Literal[raw='null']", 51 | "message": "Do not strictly check null" 52 | }, 53 | { 54 | "selector": "BinaryExpression[operator=/[=!]==?/] Literal[value='undefined']", 55 | "message": "Do not strictly check typeof undefined (NOTE: currently this rule only detects the usage of 'undefined' string literal so this could be a misfire)" 56 | } 57 | ] 58 | }, 59 | "overrides": [ 60 | { 61 | // Settings for javascript test files 62 | "files": [ 63 | "test/**/*.js" 64 | ], 65 | "rules": { 66 | "no-console": "off", 67 | "no-restricted-syntax": "off" 68 | } 69 | } 70 | ] 71 | } 72 | -------------------------------------------------------------------------------- /.evergreen/config.yml: -------------------------------------------------------------------------------- 1 | # Run previous commits to pinpoint a failure's origin. 2 | stepback: true 3 | 4 | # Mark failures other than test failures with a purple box. 5 | command_type: system 6 | 7 | # Limit maximum test running time. 8 | exec_timeout_secs: 900 # 15 minutes 9 | 10 | # What to do when evergreen hits the timeout 11 | timeout: 12 | - command: shell.exec 13 | params: 14 | script: | 15 | ls -la 16 | 17 | functions: 18 | fetch source: 19 | - command: git.get_project 20 | params: 21 | directory: src 22 | - command: subprocess.exec 23 | params: 24 | working_dir: src 25 | binary: bash 26 | add_expansions_to_env: true 27 | args: 28 | - '.evergreen/prepare-shell.sh' 29 | - command: expansions.update 30 | params: 31 | file: src/expansion.yml 32 | run tests: 33 | - command: subprocess.exec 34 | type: test 35 | params: 36 | working_dir: src 37 | binary: bash 38 | args: 39 | - '.evergreen/run-tests.sh' 40 | env: 41 | PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} 42 | NODE_LTS_VERSION: ${NODE_LTS_VERSION} 43 | run tests ubuntu: 44 | - command: subprocess.exec 45 | type: test 46 | params: 47 | binary: docker 48 | working_dir: src 49 | env: 50 | PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} 51 | NODE_LTS_VERSION: ${NODE_LTS_VERSION} 52 | PROJECT: ${project} 53 | GYP_DEFINES: ${GYP_DEFINES|} 54 | args: 55 | - run 56 | - '--interactive' 57 | - '--volume' 58 | - ${PROJECT_DIRECTORY}:/app 59 | - '--volume' 60 | - ${DRIVERS_TOOLS}:/drivers-tools 61 | - '--workdir' 62 | - /app 63 | - '--env' 64 | - PROJECT_DIRECTORY=/app 65 | - '--env' 66 | - DRIVERS_TOOLS=/drivers-tools 67 | - '--env' 68 | - GYP_DEFINES 69 | - '--env' 70 | - NODE_LTS_VERSION=${NODE_LTS_VERSION} 71 | - '--env' 72 | - NPM_VERSION=${NPM_VERSION} 73 | - 'ubuntu:22.04' 74 | - /bin/bash 75 | - /app/.evergreen/run-tests-ubuntu.sh 76 | run prebuild: 77 | - command: subprocess.exec 78 | type: test 79 | params: 80 | working_dir: src 81 | binary: bash 82 | args: 83 | - '.evergreen/run-prebuild.sh' 84 | env: 85 | PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} 86 | NODE_GITHUB_TOKEN: ${github_token} 87 | install dependencies: 88 | - command: subprocess.exec 89 | type: setup 90 | params: 91 | working_dir: src 92 | binary: bash 93 | add_expansions_to_env: true 94 | args: 95 | - .evergreen/install-dependencies.sh 96 | env: 97 | PROJECT_DIRECTORY: ${PROJECT_DIRECTORY} 98 | NODE_LTS_VERSION: ${NODE_LTS_VERSION} 99 | NPM_VERSION: "9" 100 | 101 | pre: 102 | - func: fetch source 103 | 104 | tasks: 105 | - name: run-tests 106 | commands: 107 | - func: install dependencies 108 | - func: run tests 109 | - name: run-tests-ubuntu 110 | commands: 111 | - func: run tests ubuntu 112 | - name: run-tests-ubuntu-rtld 113 | commands: 114 | - func: run tests ubuntu 115 | vars: 116 | GYP_DEFINES: kerberos_use_rtld=false 117 | - name: run-prebuild 118 | commands: 119 | - func: install dependencies 120 | - func: run prebuild 121 | 122 | buildvariants: 123 | - name: ubuntu2204-x64-node-16 124 | display_name: 'Ubuntu 22.04 x64 - Node 16' 125 | run_on: ubuntu2204-small 126 | expansions: 127 | has_packages: true 128 | packager_distro: ubuntu2204 129 | packager_arch: x86_64 130 | NODE_LTS_VERSION: "16" 131 | NPM_VERSION: "9" 132 | tasks: 133 | - run-tests-ubuntu 134 | - run-tests-ubuntu-rtld 135 | - name: ubuntu2204-x64-node-18 136 | display_name: 'Ubuntu 22.04 x64 - Node 18' 137 | run_on: ubuntu2204-small 138 | expansions: 139 | has_packages: true 140 | packager_distro: ubuntu2204 141 | packager_arch: x86_64 142 | NODE_LTS_VERSION: "18" 143 | tasks: 144 | - run-tests-ubuntu 145 | - run-tests-ubuntu-rtld 146 | - name: ubuntu2204-x64-node-20 147 | display_name: 'Ubuntu 22.04 x64 - Node 20' 148 | run_on: ubuntu2204-small 149 | expansions: 150 | has_packages: true 151 | packager_distro: ubuntu2204 152 | packager_arch: x86_64 153 | NODE_LTS_VERSION: "20" 154 | tasks: 155 | - run-tests-ubuntu 156 | - run-tests-ubuntu-rtld 157 | - name: ubuntu2204-x64-node-22 158 | display_name: 'Ubuntu 22.04 x64 - Node 22' 159 | run_on: ubuntu2204-small 160 | expansions: 161 | has_packages: true 162 | packager_distro: ubuntu2204 163 | packager_arch: x86_64 164 | NODE_LTS_VERSION: "22" 165 | tasks: 166 | - run-tests-ubuntu 167 | - run-tests-ubuntu-rtld 168 | - name: ubuntu2204-arm64-node-16 169 | display_name: 'Ubuntu 22.04 arm64 - Node 16' 170 | run_on: ubuntu2204-arm64-small 171 | expansions: 172 | has_packages: true 173 | packager_distro: ubuntu2204 174 | packager_arch: arm64 175 | NODE_LTS_VERSION: "16" 176 | NPM_VERSION: "9" 177 | tasks: 178 | - run-tests-ubuntu 179 | - run-tests-ubuntu-rtld 180 | - name: ubuntu2204-arm64-node-18 181 | display_name: 'Ubuntu 22.04 arm64 - Node 18' 182 | run_on: ubuntu2204-arm64-small 183 | expansions: 184 | has_packages: true 185 | packager_distro: ubuntu2204 186 | packager_arch: arm64 187 | NODE_LTS_VERSION: "18" 188 | tasks: 189 | - run-tests-ubuntu 190 | - run-tests-ubuntu-rtld 191 | - name: ubuntu2204-arm64-node-20 192 | display_name: 'Ubuntu 22.04 arm64 - Node 20' 193 | run_on: ubuntu2204-arm64-small 194 | expansions: 195 | has_packages: true 196 | packager_distro: ubuntu2204 197 | packager_arch: arm64 198 | NODE_LTS_VERSION: "20" 199 | tasks: 200 | - run-tests-ubuntu 201 | - run-tests-ubuntu-rtld 202 | - name: ubuntu2204-arm64-node-22 203 | display_name: 'Ubuntu 22.04 arm64 - Node 22' 204 | run_on: ubuntu2204-arm64-small 205 | expansions: 206 | has_packages: true 207 | packager_distro: ubuntu2204 208 | packager_arch: arm64 209 | NODE_LTS_VERSION: "22" 210 | tasks: 211 | - run-tests-ubuntu 212 | - run-tests-ubuntu-rtld 213 | -------------------------------------------------------------------------------- /.evergreen/install-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o errexit # Exit the script with error if any of the commands fail 3 | 4 | # allowed values: 5 | ## a nodejs major version (i.e., 16) 6 | ## 'latest' 7 | ## a full nodejs version, in the format v..patch 8 | export NODE_LTS_VERSION=${NODE_LTS_VERSION:-14} 9 | # npm version can be defined in the environment for cases where we need to install 10 | # a version lower than latest to support EOL Node versions. When not provided will 11 | # be handled by this script in drivers tools. 12 | source $DRIVERS_TOOLS/.evergreen/install-node.sh 13 | 14 | npm install --build-from-source 15 | ldd build/*/kerberos.node || true 16 | -------------------------------------------------------------------------------- /.evergreen/prepare-shell.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # Only set errexit and xtrace if shell is NOT interactive 4 | [[ $- == *i* ]] || set -o xtrace 5 | [[ $- == *i* ]] || set -o errexit 6 | 7 | PROJECT_DIRECTORY="$(pwd)" 8 | DRIVERS_TOOLS=$(cd .. && echo "$(pwd)/drivers-tools") 9 | export PROJECT_DIRECTORY 10 | export DRIVERS_TOOLS 11 | 12 | if [ ! -d "$DRIVERS_TOOLS" ]; then 13 | # Only clone driver tools if it does not exist 14 | git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}" 15 | fi 16 | 17 | echo "installed DRIVERS_TOOLS from commit $(git -C "${DRIVERS_TOOLS}" rev-parse HEAD)" 18 | 19 | 20 | # Get the current unique version of this checkout 21 | if [ "${is_patch}" = "true" ]; then 22 | CURRENT_VERSION=$(git describe)-patch-${version_id} 23 | else 24 | CURRENT_VERSION=latest 25 | fi 26 | 27 | # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory 28 | if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin 29 | export PROJECT_DIRECTORY=$(cygpath -m "$PROJECT_DIRECTORY") 30 | fi 31 | 32 | cat < expansion.yml 33 | CURRENT_VERSION: "$CURRENT_VERSION" 34 | PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" 35 | DRIVERS_TOOLS: "$DRIVERS_TOOLS" 36 | PREPARE_SHELL: | 37 | set -o errexit 38 | set -o xtrace 39 | export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" 40 | export PROJECT="${project}" 41 | export DRIVERS_TOOLS="$DRIVERS_TOOLS" 42 | EOT 43 | 44 | # See what we've done 45 | cat expansion.yml 46 | -------------------------------------------------------------------------------- /.evergreen/run-prebuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit # Exit the script with error if any of the commands fail 4 | set -o xtrace 5 | 6 | source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh 7 | 8 | # mongodbtoolchain is necessary for building on Windows 9 | export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" 10 | 11 | echo "Node Version $(node -v)" 12 | 13 | npm run prebuild 14 | echo "Local prebuild successful." 15 | ls prebuilds 16 | -------------------------------------------------------------------------------- /.evergreen/run-tests-ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | 5 | IP_ADDRESS=$(hostname -I) 6 | HOSTNAME=$(cat /etc/hostname) 7 | 8 | export KERBEROS_USERNAME="administrator" 9 | export KERBEROS_PASSWORD="Password01" 10 | export KERBEROS_REALM="example.com" 11 | export KERBEROS_HOSTNAME="hostname.example.com" 12 | export KERBEROS_PORT="80" 13 | 14 | export KERBEROS_HOSTNAME=$HOSTNAME.$KERBEROS_REALM 15 | export DEBIAN_FRONTEND=noninteractive 16 | 17 | export NODE_LTS_VERSION=$NODE_LTS_VERSION 18 | 19 | echo "Installing all the packages required in this test" 20 | apt-get update 21 | apt-get -y -qq install \ 22 | python3 curl \ 23 | build-essential libkrb5-dev \ 24 | krb5-user krb5-kdc krb5-admin-server \ 25 | apache2 libapache2-mod-auth-gssapi 26 | 27 | set -o xtrace # enable logging after apt install 28 | 29 | echo "Configure the hosts file for Kerberos to work in a container" 30 | cp /etc/hosts ~/hosts.new 31 | sed -i "/.*$HOSTNAME/c\\$IP_ADDRESS\t$KERBEROS_HOSTNAME" ~/hosts.new 32 | cp -f ~/hosts.new /etc/hosts 33 | 34 | echo "Setting up Kerberos config file at /etc/krb5.conf" 35 | cat > /etc/krb5.conf << EOL 36 | [libdefaults] 37 | default_realm = ${KERBEROS_REALM^^} 38 | dns_lookup_realm = false 39 | dns_lookup_kdc = false 40 | [realms] 41 | ${KERBEROS_REALM^^} = { 42 | kdc = $KERBEROS_HOSTNAME 43 | admin_server = $KERBEROS_HOSTNAME 44 | } 45 | [domain_realm] 46 | .$KERBEROS_REALM = ${KERBEROS_REALM^^} 47 | [logging] 48 | kdc = FILE:/var/log/krb5kdc.log 49 | admin_server = FILE:/var/log/kadmin.log 50 | default = FILE:/var/log/krb5lib.log 51 | EOL 52 | 53 | echo "Setting up kerberos ACL configuration at /etc/krb5kdc/kadm5.acl" 54 | mkdir -p /etc/krb5kdc 55 | echo -e "*/*@${KERBEROS_REALM^^}\t*" > /etc/krb5kdc/kadm5.acl 56 | 57 | echo "Creating KDC database" 58 | # krb5_newrealm returns non-0 return code as it is running in a container, ignore it for this command only 59 | set +e 60 | printf "$KERBEROS_PASSWORD\n$KERBEROS_PASSWORD" | krb5_newrealm 61 | set -e 62 | 63 | echo "Creating principals for tests" 64 | kadmin.local -q "addprinc -pw $KERBEROS_PASSWORD $KERBEROS_USERNAME" 65 | 66 | echo "Adding principal for Kerberos auth and creating keytabs" 67 | kadmin.local -q "addprinc -randkey HTTP/$KERBEROS_HOSTNAME" 68 | kadmin.local -q "addprinc -randkey host/$KERBEROS_HOSTNAME@${KERBEROS_REALM^^}" 69 | kadmin.local -q "addprinc -randkey host/${KERBEROS_HOSTNAME^^}@${KERBEROS_REALM^^}" 70 | kadmin.local -q "addprinc -randkey ${KERBEROS_HOSTNAME^^}@${KERBEROS_REALM^^}" 71 | 72 | kadmin.local -q "ktadd -k /etc/krb5.keytab host/$KERBEROS_HOSTNAME@${KERBEROS_REALM^^}" 73 | kadmin.local -q "ktadd -k /etc/krb5.keytab host/${KERBEROS_HOSTNAME^^}@${KERBEROS_REALM^^}" 74 | kadmin.local -q "ktadd -k /etc/krb5.keytab ${KERBEROS_HOSTNAME^^}@${KERBEROS_REALM^^}" 75 | kadmin.local -q "ktadd -k /etc/krb5.keytab HTTP/$KERBEROS_HOSTNAME" 76 | chmod 777 /etc/krb5.keytab 77 | 78 | echo "Restarting Kerberos KDS service" 79 | service krb5-kdc restart 80 | 81 | echo "Add ServerName to Apache config" 82 | grep -q -F "ServerName $KERBEROS_HOSTNAME" /etc/apache2/apache2.conf || echo "ServerName $KERBEROS_HOSTNAME" >> /etc/apache2/apache2.conf 83 | 84 | echo "Deleting default virtual host file" 85 | rm /etc/apache2/sites-enabled/000-default.conf 86 | rm /etc/apache2/sites-available/000-default.conf 87 | rm /etc/apache2/sites-available/default-ssl.conf 88 | 89 | echo "Create website directory structure and pages" 90 | mkdir -p /var/www/example.com/public_html 91 | chmod -R 755 /var/www 92 | echo "Titlebody mesage" > /var/www/example.com/public_html/index.html 93 | 94 | echo "Create virtual host files" 95 | cat > /etc/apache2/sites-available/example.com.conf << EOL 96 | 97 | ServerName $KERBEROS_HOSTNAME 98 | ServerAlias $KERBEROS_HOSTNAME 99 | DocumentRoot /var/www/example.com/public_html 100 | ErrorLog ${APACHE_LOG_DIR}/error.log 101 | CustomLog ${APACHE_LOG_DIR}/access.log combined 102 | 103 | AuthType GSSAPI 104 | AuthName "GSSAPI Single Sign On Login" 105 | Require user $KERBEROS_USERNAME@${KERBEROS_REALM^^} 106 | GssapiCredStore keytab:/etc/krb5.keytab 107 | 108 | 109 | EOL 110 | 111 | echo "Enabling virtual host site" 112 | a2ensite example.com.conf 113 | service apache2 restart 114 | 115 | echo "Getting ticket for Kerberos user" 116 | echo -n "$KERBEROS_PASSWORD" | kinit "$KERBEROS_USERNAME@${KERBEROS_REALM^^}" 117 | 118 | echo "Try out the curl connection" 119 | CURL_OUTPUT=$(curl --negotiate -u : "http://$KERBEROS_HOSTNAME") 120 | 121 | if [ "$CURL_OUTPUT" != "Titlebody mesage" ]; then 122 | echo -e "ERROR: Did not get success message, cannot continue with actual tests:\nActual Output:\n$CURL_OUTPUT" 123 | exit 1 124 | else 125 | echo -e "SUCCESS: Apache site built and set for Kerberos auth\nActual Output:\n$CURL_OUTPUT" 126 | fi 127 | 128 | echo "Run: install Node.js" 129 | source "${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh" 130 | 131 | npm test 132 | -------------------------------------------------------------------------------- /.evergreen/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit # Exit the script with error if any of the commands fail 4 | set -o xtrace 5 | 6 | source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh 7 | 8 | npm run check:lint 9 | npm test 10 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Everything 2 | * @mongodb-js/dbx-node-devs 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Issue_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue 3 | about: Please use JIRA instead 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | 17 | 18 | **Kerberos Version:** 1.1.x 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | blank_issues_enabled: false 3 | contact_links: 4 | - 5 | about: "Please ask and answer usage questions on our Community Forums." 6 | name: Questions 7 | url: "https://developer.mongodb.com/community/forums/tags/c/drivers-odms/7/node-js" 8 | - 9 | about: "Please submit all issues or feature requests to our JIRA." 10 | name: Issues & Feature Requests 11 | url: "https://jira.mongodb.org/browse/NODE" 12 | - 13 | about: "Please check the FAQ before filing new issues" 14 | name: "MongoDB NodeJS FAQ" 15 | url: "https://docs.mongodb.com/drivers/node/faq" 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "monthly" 12 | - package-ecosystem: "npm" # See documentation for possible values 13 | directory: "/" # Location of package manifests 14 | schedule: 15 | interval: "monthly" 16 | ignore: 17 | # chai is esmodule only. 18 | - dependency-name: "chai" 19 | versions: [">=5.0.0"] 20 | # sinon-chai 4.x+ supports chai 5.x+. 21 | - dependency-name: "sinon-chai" 22 | versions: [">=4.0.0"] 23 | # chalk is esmodule only. 24 | - dependency-name: "chalk" 25 | versions: [">=5.0.0"] 26 | # nyc is Node18+ only starting on nyc@16.x. 27 | - dependency-name: "nyc" 28 | versions: [">=16.0.0"] 29 | # we ignore TS as a part of quarterly dependency updates. 30 | - dependency-name: "typescript" 31 | # node-gyp now depends on python 3.10, we install 3.6 in our dockerfile 32 | - dependency-name: "node-gyp" 33 | - dependency-name: "prebuild" 34 | 35 | groups: 36 | development-dependencies: 37 | dependency-type: "development" 38 | applies-to: version-updates 39 | update-types: 40 | - "minor" 41 | - "patch" -------------------------------------------------------------------------------- /.github/docker/Dockerfile.glibc: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic AS build 2 | 3 | # Possible values: s390x, arm64, x64 4 | ARG NODE_ARCH 5 | ADD https://nodejs.org/dist/v16.20.1/node-v16.20.1-linux-${NODE_ARCH}.tar.gz / 6 | RUN mkdir -p /nodejs && tar -xzf /node-v16.20.1-linux-${NODE_ARCH}.tar.gz --strip-components=1 -C /nodejs 7 | ENV PATH=$PATH:/nodejs/bin 8 | 9 | WORKDIR /kerberos 10 | COPY . . 11 | 12 | RUN apt-get -qq update && apt-get -qq install -y python3 build-essential libkrb5-dev && ldd --version 13 | 14 | RUN node .github/scripts/build.mjs 15 | 16 | FROM scratch 17 | 18 | COPY --from=build /kerberos/prebuilds/ / 19 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | #### What is changing? 4 | 5 | ##### Is there new documentation needed for these changes? 6 | 7 | #### What is the motivation for this change? 8 | 9 | 10 | 11 | 12 | 18 | 19 | ### Release Highlight 20 | 21 | 22 | 23 | ### Fill in title or leave empty for no highlight 24 | 25 | 26 | 27 | ### Double check the following 28 | 29 | - [ ] Ran `npm run check:lint` script 30 | - [ ] Self-review completed using the [steps outlined here](https://github.com/mongodb/node-mongodb-native/blob/HEAD/CONTRIBUTING.md#reviewer-guidelines) 31 | - [ ] PR title follows the [correct format](https://www.conventionalcommits.org/en/v1.0.0/): `type(NODE-xxxx)[!]: description` 32 | - Example: `feat(NODE-1234)!: rewriting everything in coffeescript` 33 | - [ ] Changes are covered by tests 34 | - [ ] New TODOs have a related JIRA ticket 35 | -------------------------------------------------------------------------------- /.github/scripts/build.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | import util from 'node:util'; 4 | import process from 'node:process'; 5 | import fs from 'node:fs/promises'; 6 | import child_process from 'node:child_process'; 7 | import events from 'node:events'; 8 | import path from 'node:path'; 9 | import url from 'node:url'; 10 | 11 | const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); 12 | 13 | /** Resolves to the root of this repository */ 14 | function resolveRoot(...paths) { 15 | return path.resolve(__dirname, '..', '..', ...paths); 16 | } 17 | 18 | async function parseArguments() { 19 | const pkg = JSON.parse(await fs.readFile(resolveRoot('package.json'), 'utf8')); 20 | 21 | const options = { 22 | 'kerberos_use_rtld': { type: 'boolean', default: true }, 23 | help: { short: 'h', type: 'boolean', default: false } 24 | }; 25 | 26 | const args = util.parseArgs({ args: process.argv.slice(2), options, allowPositionals: false }); 27 | 28 | if (args.values.help) { 29 | console.log( 30 | `${path.basename(process.argv[1])} ${[...Object.keys(options)] 31 | .filter(k => k !== 'help') 32 | .map(k => `[--${k}=${options[k].type}]`) 33 | .join(' ')}` 34 | ); 35 | process.exit(0); 36 | } 37 | 38 | return { 39 | kerberos_use_rtld: !!args.values.kerberos_use_rtld, 40 | pkg 41 | }; 42 | } 43 | 44 | /** `xtrace` style command runner, uses spawn so that stdio is inherited */ 45 | async function run(command, args = [], options = {}) { 46 | const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}`; 47 | console.error(commandDetails); 48 | const proc = child_process.spawn(command, args, { 49 | shell: process.platform === 'win32', 50 | stdio: 'inherit', 51 | cwd: resolveRoot('.'), 52 | ...options 53 | }); 54 | await events.once(proc, 'exit'); 55 | 56 | if (proc.exitCode != 0) throw new Error(`CRASH(${proc.exitCode}): ${commandDetails}`); 57 | } 58 | 59 | async function buildBindings(args, pkg) { 60 | await fs.rm(resolveRoot('build'), { force: true, recursive: true }); 61 | await fs.rm(resolveRoot('prebuilds'), { force: true, recursive: true }); 62 | 63 | // install with "ignore-scripts" so that we don't attempt to download a prebuild 64 | await run('npm', ['install', '--ignore-scripts']); 65 | // The prebuild command will make both a .node file in `./build` (local and CI testing will run on current code) 66 | // it will also produce `./prebuilds/kerberos-vVERSION-napi-vNAPI_VERSION-OS-ARCH.tar.gz`. 67 | 68 | let gypDefines = process.env.GYP_DEFINES ?? ''; 69 | if (!args.kerberos_use_rtld) { 70 | gypDefines += ' kerberos_use_rtld=false'; 71 | } 72 | 73 | gypDefines = gypDefines.trim(); 74 | const prebuildOptions = 75 | gypDefines.length > 0 76 | ? { env: { ...process.env, GYP_DEFINES: gypDefines } } 77 | : undefined; 78 | 79 | await run('npm', ['run', 'prebuild'], prebuildOptions); 80 | 81 | // TODO(NODE-5140): When we have a TS build step 82 | // await run('npm', ['run', 'prepare']); 83 | 84 | if (process.platform === 'darwin' && process.arch === 'arm64') { 85 | // The "arm64" build is actually a universal binary 86 | const armTar = `kerberos-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`; 87 | const x64Tar = `kerberos-v${pkg.version}-napi-v4-darwin-x64.tar.gz`; 88 | await fs.copyFile(resolveRoot('prebuilds', armTar), resolveRoot('prebuilds', x64Tar)); 89 | } 90 | 91 | await run('node', ['--print', `require('.')`], { cwd: resolveRoot() }) 92 | } 93 | 94 | async function main() { 95 | const { pkg, ...args } = await parseArguments(); 96 | console.log(args); 97 | await buildBindings(args, pkg); 98 | } 99 | 100 | await main(); 101 | -------------------------------------------------------------------------------- /.github/scripts/highlights.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import * as process from 'node:process'; 3 | import { output } from './util.mjs'; 4 | 5 | const { 6 | GITHUB_TOKEN = '', 7 | PR_LIST = '', 8 | REPOSITORY = '' 9 | } = process.env; 10 | if (GITHUB_TOKEN === '') throw new Error('GITHUB_TOKEN cannot be empty'); 11 | if (REPOSITORY === '') throw new Error('REPOSITORY cannot be empty') 12 | 13 | const API_REQ_INFO = { 14 | headers: { 15 | Accept: 'application/vnd.github.v3+json', 16 | 'X-GitHub-Api-Version': '2022-11-28', 17 | Authorization: `Bearer ${GITHUB_TOKEN}` 18 | } 19 | } 20 | 21 | const prs = PR_LIST.split(',').map(pr => { 22 | const prNum = Number(pr); 23 | if (Number.isNaN(prNum)) 24 | throw Error(`expected PR number list: ${PR_LIST}, offending entry: ${pr}`); 25 | return prNum; 26 | }); 27 | 28 | /** @param {number} pull_number */ 29 | async function getPullRequestContent(pull_number) { 30 | const startIndicator = 'RELEASE_HIGHLIGHT_START -->'; 31 | const endIndicator = '