Skip to content

Commit

Permalink
security/bitwarden-cli: add port: Bitwarden client command-line inter…
Browse files Browse the repository at this point in the history
…face

The Bitwarden CLI is a powerful, full-featured command-line interface
(CLI) tool to access and manage a Bitwarden vault. The CLI is written
with TypeScript and Node.js and can be run on Windows, macOS, and
Linux distributions.

WWW: https://bitwarden.com

Requested by:	000.fbsd@quip.cz (via ports)
Tested by:	000.fbsd@quip.cz
  • Loading branch information
tagattie committed Jul 31, 2023
1 parent 9c1690c commit d2062f3
Show file tree
Hide file tree
Showing 18 changed files with 36,824 additions and 0 deletions.
1 change: 1 addition & 0 deletions security/Makefile
Expand Up @@ -53,6 +53,7 @@
SUBDIR += belier
SUBDIR += bfbtester
SUBDIR += binwalk
SUBDIR += bitwarden-cli
SUBDIR += boringssl
SUBDIR += botan2
SUBDIR += bruteblock
Expand Down
132 changes: 132 additions & 0 deletions security/bitwarden-cli/Makefile
@@ -0,0 +1,132 @@
PORTNAME= bitwarden-cli
DISTVERSIONPREFIX= cli-v
DISTVERSION= 2023.7.0
CATEGORIES= security
MASTER_SITES= https://nodejs.org/dist/v${PKG_NODE_VER}/:node
DISTFILES= node-v${PKG_NODE_VER}${EXTRACT_SUFX}:node \
${PREFETCH_FILE}:prefetch

MAINTAINER= tagattie@FreeBSD.org
COMMENT= Bitwarden client command-line interface
WWW= https://bitwarden.com

LICENSE= BITWARDEN GPLv3
LICENSE_COMB= multi
LICENSE_NAME_BITWARDEN= BITWARDEN LICENSE AGREEMENT
LICENSE_FILE_BITWARDEN= ${WRKSRC}/LICENSE_BITWARDEN.txt
LICENSE_FILE_GPLv3= ${WRKSRC}/LICENSE_GPL.txt
LICENSE_PERMS_BITWARDEN=none

ONLY_FOR_ARCHS= aarch64 amd64

FETCH_DEPENDS= npm:www/npm${NODEJS_SUFFIX}
BUILD_DEPENDS= npm:www/npm${NODEJS_SUFFIX}
LIB_DEPENDS= libbrotlidec.so:archivers/brotli \
libicui18n.so:devel/icu \
libuv.so:devel/libuv \
libcares.so:dns/c-ares \
libnghttp2.so:www/libnghttp2
RUN_DEPENDS= xdg-open:devel/xdg-utils \
ca_root_nss>0:security/ca_root_nss
TEST_DEPENDS= npm:www/npm${NODEJS_SUFFIX}

USES= gmake localbase:ldflags nodejs:18,build pkgconfig \
python:build ssl

USE_GITHUB= yes
GH_ACCOUNT= bitwarden
GH_PROJECT= clients

BUILD_WRKSRC= ${WRKSRC}/apps/cli

PLIST_FILES= bin/bw \
share/zsh/site-functions/_bw

PORTDOCS= CONTRIBUTING.md README.md SECURITY.md

OPTIONS_DEFINE= DOCS

PREFETCH_FILE= ${PKGNAME}-node-modules${EXTRACT_SUFX}
PREFETCH_TIMESTAMP= 1690268784
PKG_NODE_VER= 18.15.0
PKG_FETCH_VER= 3.5
PKG_NODE_CONFIGURE_ARGS=--openssl-use-def-ca-store \
--shared-brotli \
--shared-cares \
--shared-libuv \
--shared-nghttp2 \
--shared-openssl \
--shared-zlib \
--with-intl=system-icu
NODE_ARCH= ${ARCH:S/aarch64/arm64/:S/amd64/x64/:S/i386/ia32/}

pre-fetch:
if [ ! -f ${DISTDIR}/${PREFETCH_FILE} ]; then \
${MKDIR} ${WRKDIR}/node-modules-cache; \
${CP} -R ${FILESDIR}/packagejsons/* ${WRKDIR}/node-modules-cache; \
cd ${WRKDIR}/node-modules-cache && \
${SETENV} HOME=${WRKDIR} npm ci --ignore-scripts --no-progress; \
${FIND} ${WRKDIR}/node-modules-cache -depth 1 -print | \
${GREP} -v node_modules | ${XARGS} ${RM} -r; \
${FIND} ${WRKDIR}/node-modules-cache -type d -exec ${CHMOD} 755 {} ';'; \
cd ${WRKDIR}/node-modules-cache && \
${MTREE_CMD} -cbnSp node_modules | ${MTREE_CMD} -C | ${SED} \
-e 's:time=[0-9.]*:time=${PREFETCH_TIMESTAMP}.000000000:' \
-e 's:\([gu]id\)=[0-9]*:\1=0:g' \
-e 's:flags=.*:flags=none:' \
-e 's:^\.:./node_modules:' > node-modules-cache.mtree; \
${TAR} -cz --options 'gzip:!timestamp' \
-f ${DISTDIR}/${PREFETCH_FILE} \
@node-modules-cache.mtree; \
${RM} -r ${WRKDIR}; \
fi

post-extract:
${MV} ${WRKDIR}/node_modules ${WRKSRC}

post-patch:
# apply FreeBSD patches for node
for p in ${.CURDIR:H:H}/www/node${NODEJS_VERSION}/files/patch-*; do \
${PATCH} -s -p0 -d ${WRKDIR}/node-v${PKG_NODE_VER} < $${p}; \
done
# apply node patch from pkg-fetch
${PATCH} -s -p1 -d ${WRKDIR}/node-v${PKG_NODE_VER} < \
${WRKSRC}/node_modules/pkg-fetch/patches/node.v${PKG_NODE_VER}.cpp.patch

pre-build:
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npm run postinstall
# build patched node for pkg
cd ${WRKDIR}/node-v${PKG_NODE_VER} && \
${SETENV} ${CONFIGURE_ENV} CC=${CC} CXX=${CXX} ./configure ${PKG_NODE_CONFIGURE_ARGS} && \
${SETENV} ${MAKE_ENV} ${MAKE_CMD} -j ${MAKE_JOBS_NUMBER}
${MKDIR} ${WRKDIR}/.pkg-cache/v${PKG_FETCH_VER}
${MV} ${WRKDIR}/node-v${PKG_NODE_VER}/out/Release/node \
${WRKDIR}/.pkg-cache/v${PKG_FETCH_VER}/built-v${PKG_NODE_VER}-freebsd-${NODE_ARCH}
${STRIP_CMD} ${WRKDIR}/.pkg-cache/v${PKG_FETCH_VER}/built-v${PKG_NODE_VER}-freebsd-${NODE_ARCH}
# rebuild node modules against patched node
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ELECTRON_SKIP_BINARY_DOWNLOAD=1 \
npm rebuild --nodedir=${WRKDIR}/node-v${PKG_NODE_VER} --verbose

do-build:
cd ${BUILD_WRKSRC} && ${SETENV} ${MAKE_ENV} \
npm run build:prod
cd ${BUILD_WRKSRC} && ${SETENV} ${MAKE_ENV} \
npx pkg . --targets node${NODEJS_VERSION}-freebsd-${NODE_ARCH} --output ./dist/bw
cd ${BUILD_WRKSRC} && ${SETENV} ${MAKE_ENV} \
./dist/bw completion --shell zsh > _bw

do-install:
# don't strip executable since it causes error
${INSTALL_KLD} ${BUILD_WRKSRC}/dist/bw ${STAGEDIR}${PREFIX}/bin
@${MKDIR} ${STAGEDIR}${PREFIX}/share/zsh/site-functions
${INSTALL_DATA} ${BUILD_WRKSRC}/_bw \
${STAGEDIR}${PREFIX}/share/zsh/site-functions/_bw

do-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_MAN} ${PORTDOCS:S|^|${WRKSRC}/|} ${STAGEDIR}${DOCSDIR}

do-test:
cd ${BUILD_WRKSRC} && ${SETENV} ${TEST_ENV} npm run test

.include <bsd.port.mk>
7 changes: 7 additions & 0 deletions security/bitwarden-cli/distinfo
@@ -0,0 +1,7 @@
TIMESTAMP = 1690273877
SHA256 (node-v18.15.0.tar.gz) = d65c4c3ef3c8815bccda9502081a29458c7c80797db0763f8752f270a824ac2b
SIZE (node-v18.15.0.tar.gz) = 85359314
SHA256 (bitwarden-cli-2023.7.0-node-modules.tar.gz) = 797598d351cc1c47f49334eb753d8ab5e81da902c4bc7bc2f917fe7794afe283
SIZE (bitwarden-cli-2023.7.0-node-modules.tar.gz) = 226744723
SHA256 (bitwarden-clients-cli-v2023.7.0_GH0.tar.gz) = 293484f386707bd5c1014402a3c2fbbe9ad14e1c17f2a6b53676bdf0ad110868
SIZE (bitwarden-clients-cli-v2023.7.0_GH0.tar.gz) = 18982338
@@ -0,0 +1,25 @@
{
"name": "@bitwarden/browser",
"version": "2023.7.1",
"scripts": {
"build": "webpack",
"build:mv3": "cross-env MANIFEST_VERSION=3 webpack",
"build:watch": "webpack --watch",
"build:watch:mv3": "cross-env MANIFEST_VERSION=3 webpack --watch",
"build:watch:autofill": "cross-env AUTOFILL_VERSION=2 webpack --watch",
"build:prod": "cross-env NODE_ENV=production webpack",
"build:prod:watch": "cross-env NODE_ENV=production webpack --watch",
"dist": "npm run build:prod && gulp dist",
"dist:mv3": "cross-env MANIFEST_VERSION=3 npm run build:prod && cross-env MANIFEST_VERSION=3 gulp dist",
"dist:chrome": "npm run build:prod && gulp dist:chrome",
"dist:firefox": "npm run build:prod && gulp dist:firefox",
"dist:opera": "npm run build:prod && gulp dist:opera",
"dist:safari": "npm run build:prod && gulp dist:safari",
"dist:safari:mas": "npm run build:prod && gulp dist:safari:mas",
"dist:safari:masdev": "npm run build:prod && gulp dist:safari:masdev",
"dist:safari:dmg": "npm run build:prod && gulp dist:safari:dmg",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
}
}
77 changes: 77 additions & 0 deletions security/bitwarden-cli/files/packagejsons/apps/cli/package.json
@@ -0,0 +1,77 @@
{
"name": "@bitwarden/cli",
"description": "A secure and free password manager for all of your devices.",
"version": "2023.7.0",
"keywords": [
"bitwarden",
"password",
"vault",
"password manager",
"cli"
],
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
"homepage": "https://bitwarden.com",
"repository": {
"type": "git",
"url": "https://github.com/bitwarden/clients"
},
"license": "GPL-3.0-only",
"scripts": {
"clean": "rimraf dist",
"build": "webpack",
"build:debug": "npm run build && node --inspect ./build/bw.js",
"build:watch": "webpack --watch",
"build:prod": "cross-env NODE_ENV=production webpack",
"build:prod:watch": "cross-env NODE_ENV=production webpack --watch",
"package": "npm run package:win && npm run package:mac && npm run package:lin",
"package:win": "pkg . --targets win-x64 --output ./dist/windows/bw.exe",
"package:mac": "pkg . --targets macos-x64 --output ./dist/macos/bw",
"package:lin": "pkg . --targets linux-x64 --output ./dist/linux/bw",
"debug": "node --inspect ./build/bw.js",
"dist": "npm run build:prod && npm run clean && npm run package",
"dist:win": "npm run build:prod && npm run clean && npm run package:win",
"dist:mac": "npm run build:prod && npm run clean && npm run package:mac",
"dist:lin": "npm run build:prod && npm run clean && npm run package:lin",
"publish:npm": "npm run build:prod && npm publish --access public",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
},
"bin": {
"bw": "build/bw.js"
},
"pkg": {
"assets": [
"./build/**/*",
"../../node_modules/argon2/**/*"
]
},
"dependencies": {
"@koa/multer": "3.0.2",
"@koa/router": "12.0.0",
"argon2": "0.30.3",
"big-integer": "1.6.51",
"browser-hrtime": "1.1.8",
"chalk": "4.1.2",
"commander": "7.2.0",
"form-data": "4.0.0",
"https-proxy-agent": "5.0.1",
"inquirer": "8.2.5",
"jsdom": "22.1.0",
"jszip": "3.10.1",
"koa": "2.14.2",
"koa-bodyparser": "4.4.0",
"koa-json": "2.0.2",
"lowdb": "1.0.0",
"lunr": "2.3.9",
"multer": "1.4.5-lts.1",
"node-fetch": "2.6.11",
"node-forge": "1.3.1",
"open": "8.4.2",
"papaparse": "5.4.1",
"proper-lockfile": "4.1.2",
"rxjs": "7.8.1",
"tldts": "6.0.5",
"zxcvbn": "4.4.2"
}
}
@@ -0,0 +1,31 @@
{
"name": "@bitwarden/desktop-native",
"version": "0.1.0",
"description": "",
"scripts": {
"build": "napi build --release --platform --js false",
"build:debug": "napi build --platform --js false",
"build:cross-platform": "node build.js",
"test": "cargo test"
},
"author": "",
"license": "GPL-3.0",
"devDependencies": {
"@napi-rs/cli": "2.16.1"
},
"napi": {
"name": "desktop_native",
"triples": {
"defaults": true,
"additional": [
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-gnu",
"i686-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"aarch64-apple-darwin",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc"
]
}
}
}
@@ -0,0 +1,58 @@
{
"name": "@bitwarden/desktop",
"description": "A secure and free password manager for all of your devices.",
"version": "2023.7.0",
"keywords": [
"bitwarden",
"password",
"vault",
"password manager"
],
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
"homepage": "https://bitwarden.com",
"repository": {
"type": "git",
"url": "git+https://github.com/bitwarden/clients.git"
},
"license": "GPL-3.0",
"scripts": {
"postinstall": "electron-rebuild",
"start": "cross-env ELECTRON_IS_DEV=0 ELECTRON_NO_UPDATER=1 electron ./build",
"build-native": "cargo build --manifest-path=./desktop_native/Cargo.toml",
"build": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\"",
"build:dev": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main:dev\" \"npm run build:renderer:dev\"",
"build:main": "cross-env NODE_ENV=production webpack --config webpack.main.js",
"build:main:dev": "npm run build-native && cross-env NODE_ENV=development webpack --config webpack.main.js",
"build:main:watch": "npm run build-native && cross-env NODE_ENV=development webpack --config webpack.main.js --watch",
"build:renderer": "cross-env NODE_ENV=production webpack --config webpack.renderer.js",
"build:renderer:dev": "cross-env NODE_ENV=development webpack --config webpack.renderer.js",
"build:renderer:watch": "cross-env NODE_ENV=development webpack --config webpack.renderer.js --watch",
"electron": "node ./scripts/start.js",
"electron:ignore": "node ./scripts/start.js --ignore-certificate-errors",
"clean:dist": "rimraf ./dist",
"pack:dir": "npm run clean:dist && electron-builder --dir -p never",
"pack:lin": "npm run clean:dist && electron-builder --linux --x64 -p never",
"pack:mac": "npm run clean:dist && electron-builder --mac --universal -p never",
"pack:mac:arm64": "npm run clean:dist && electron-builder --mac --arm64 -p never",
"pack:mac:mas": "npm run clean:dist && electron-builder --mac mas --universal -p never",
"pack:mac:masdev": "npm run clean:dist && electron-builder --mac mas-dev --universal -p never",
"pack:win": "npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p never -c.win.certificateSubjectName=\"8bit Solutions LLC\"",
"pack:win:ci": "npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p never",
"dist:dir": "npm run build && npm run pack:dir",
"dist:lin": "npm run build && npm run pack:lin",
"dist:mac": "npm run build && npm run pack:mac",
"dist:mac:mas": "npm run build && npm run pack:mac:mas",
"dist:mac:masdev": "npm run build && npm run pack:mac:masdev",
"dist:win": "npm run build && npm run pack:win",
"dist:win:ci": "npm run build && npm run pack:win:ci",
"publish:lin": "npm run build && npm run clean:dist && electron-builder --linux --x64 -p always",
"publish:mac": "npm run build && npm run clean:dist && electron-builder --mac -p always",
"publish:mac:mas": "npm run dist:mac:mas && npm run upload:mas",
"publish:win": "npm run build && npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p always -c.win.certificateSubjectName=\"8bit Solutions LLC\"",
"publish:win:dev": "npm run build && npm run clean:dist && electron-builder --win --x64 --arm64 --ia32 -p always",
"upload:mas": "xcrun altool --upload-app --type osx --file \"$(find ./dist/mas-universal/Bitwarden*.pkg)\" --username $APPLE_ID_USERNAME --password $APPLE_ID_PASSWORD",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
}
}
29 changes: 29 additions & 0 deletions security/bitwarden-cli/files/packagejsons/apps/web/package.json
@@ -0,0 +1,29 @@
{
"name": "@bitwarden/web-vault",
"version": "2023.7.0",
"scripts": {
"build:oss": "webpack",
"build:bit": "webpack -c ../../bitwarden_license/bit-web/webpack.config.js",
"build:oss:watch": "webpack serve",
"build:bit:watch": "webpack serve -c ../../bitwarden_license/bit-web/webpack.config.js",
"build:bit:dev": "cross-env ENV=development npm run build:bit",
"build:bit:dev:analyze": "cross-env LOGGING=false webpack -c ../../bitwarden_license/bit-web/webpack.config.js --profile --json > stats.json && npx webpack-bundle-analyzer stats.json build/",
"build:bit:dev:watch": "cross-env ENV=development npm run build:bit:watch",
"build:bit:qa": "cross-env NODE_ENV=production ENV=qa npm run build:bit",
"build:bit:euprd": "cross-env NODE_ENV=production ENV=euprd npm run build:bit",
"build:bit:euqa": "cross-env NODE_ENV=production ENV=euqa npm run build:bit",
"build:bit:cloud": "cross-env NODE_ENV=production ENV=cloud npm run build:bit",
"build:oss:selfhost:watch": "cross-env ENV=selfhosted npm run build:oss:watch",
"build:bit:selfhost:watch": "cross-env ENV=selfhosted npm run build:bit:watch",
"build:oss:selfhost:prod": "cross-env ENV=selfhosted NODE_ENV=production npm run build:oss",
"build:bit:selfhost:prod": "cross-env ENV=selfhosted NODE_ENV=production npm run build:bit",
"build:bit:ee": "cross-env NODE_ENV=production ENV=ee npm run build:bit",
"clean:l10n": "git push origin --delete l10n_master",
"dist:bit:cloud": "npm run build:bit:cloud",
"dist:oss:selfhost": "npm run build:oss:selfhost:prod",
"dist:bit:selfhost": "npm run build:bit:selfhost:prod",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
}
}
@@ -0,0 +1,20 @@
{
"name": "@bitwarden/angular",
"version": "0.0.0",
"description": "Common code used across Bitwarden JavaScript projects.",
"keywords": [
"bitwarden"
],
"author": "Bitwarden Inc.",
"homepage": "https://bitwarden.com",
"repository": {
"type": "git",
"url": "https://github.com/bitwarden/jslib"
},
"license": "GPL-3.0",
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && tsc",
"build:watch": "npm run clean && tsc -watch"
}
}

0 comments on commit d2062f3

Please sign in to comment.