Skip to content

Commit

Permalink
Merge branch 'main' into ps/secure-crypto-service
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Oct 7, 2024
2 parents 6ea6267 + 16a8496 commit 32088c7
Show file tree
Hide file tree
Showing 22 changed files with 713 additions and 14 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Build @bitwarden/sdk-internal

on:
pull_request:
push:
branches:
- "main"
- "rc"
- "hotfix-rc"
workflow_dispatch:

defaults:
run:
shell: bash
working-directory: crates/bitwarden-wasm-internal

jobs:
build:
name: Building @bitwarden/sdk-wasm-internal
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: 20
registry-url: "https://npm.pkg.github.com"
cache: "npm"

- name: Install dependencies
run: npm i -g binaryen

- name: Install rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown

- name: Cache cargo registry
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: wasm-cargo-cache

- name: Install wasm-bindgen-cli
run: cargo install wasm-bindgen-cli

- name: Build
run: ./build.sh -r

- name: Upload artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: sdk-internal
path: ${{ github.workspace }}/languages/js/sdk-internal/*
if-no-files-found: error
3 changes: 1 addition & 2 deletions .github/workflows/publish-bws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- Release
- Dry Run
version:
description: 'Version to publish (default: latest bws cli release)'
description: "Version to publish (default: latest bws cli release)"
required: true
type: string
default: latest
Expand Down Expand Up @@ -71,7 +71,6 @@ jobs:
description: "Deployment ${{ steps.version-output.outputs.version }} from branch ${{ github.ref_name }}"
task: release


publish:
name: Publish bws to crates.io
runs-on: ubuntu-22.04
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/publish-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ jobs:
uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7
id: deployment
with:
token: '${{ secrets.GITHUB_TOKEN }}'
initial-status: 'in_progress'
environment: 'dotnet - Production'
description: 'Deployment ${{ needs.validate.outputs.version }} from branch ${{ github.ref_name }}'
token: "${{ secrets.GITHUB_TOKEN }}"
initial-status: "in_progress"
environment: "dotnet - Production"
description: "Deployment ${{ needs.validate.outputs.version }} from branch ${{ github.ref_name }}"
task: release

- name: Download artifact
Expand Down Expand Up @@ -100,14 +100,14 @@ jobs:
if: ${{ inputs.release_type != 'Dry Run' && success() }}
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
with:
token: '${{ secrets.GITHUB_TOKEN }}'
state: 'success'
token: "${{ secrets.GITHUB_TOKEN }}"
state: "success"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

- name: Update deployment status to Failure
if: ${{ inputs.release_type != 'Dry Run' && failure() }}
uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
with:
token: '${{ secrets.GITHUB_TOKEN }}'
state: 'failure'
token: "${{ secrets.GITHUB_TOKEN }}"
state: "failure"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
94 changes: 94 additions & 0 deletions .github/workflows/publish-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: Publish @bitwarden/sdk-internal
run-name: Publish @bitwarden/sdk-internal ${{ inputs.release_type }}

on:
workflow_dispatch:
inputs:
release_type:
description: "Release Options"
required: true
default: "Release"
type: choice
options:
- Release
- Dry Run
version:
description: "Release Version"
required: true

defaults:
run:
working-directory: languages/js/sdk-internal

jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Branch check
if: ${{ inputs.release_type != 'Dry Run' }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "==================================="
echo "[!] Can only release from the 'main' branch"
echo "==================================="
exit 1
fi
npm:
name: Publish NPM
runs-on: ubuntu-22.04
needs: setup
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20

- name: Login to Azure
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Retrieve secrets
id: retrieve-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
secrets: "npm-api-key"

- name: Download artifact
uses: bitwarden/gh-actions/download-artifacts@main
with:
workflow: build-wasm-internal.yml
workflow_conclusion: success
branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }}
artifacts: sdk-internal
path: languages/js/sdk-internal

- name: Set version
run: |
npm version --no-git-tag-version ${{ inputs.version }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup NPM
run: |
echo 'registry="https://registry.npmjs.org/"' > ./.npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc
echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }}

- name: Publish NPM
if: ${{ inputs.release_type != 'Dry Run' }}
run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc
2 changes: 1 addition & 1 deletion .github/workflows/publish-rust-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- Redeploy
- Dry Run
version:
description: 'Version to publish (default: latest rust crates release)'
description: "Version to publish (default: latest rust crates release)"
required: true
type: string
default: latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
- Release
- Dry Run


jobs:
setup:
name: Setup
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
target
languages/*
!languages/js
languages/js/*
!languages/js/sdk-internal
languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js
schemas
/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts
about.hbs
Expand Down
51 changes: 51 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ serde_qs = ">=0.12.0, <0.14"
serde_repr = ">=0.1.12, <0.2"
thiserror = ">=1.0.40, <2.0"
tokio = { version = "1.36.0", features = ["macros"] }
tsify-next = { version = ">=0.5.4, <0.6", features = [
"js",
], default-features = false }
uniffi = "=0.28.1"
uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] }
validator = { version = "0.18.1", features = ["derive"] }
wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] }
wasm-bindgen = { version = ">=0.2.91, <0.3", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.41"

[workspace.lints.clippy]
Expand Down
3 changes: 3 additions & 0 deletions crates/bitwarden-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ no-memory-hardening = [
] # Disable memory hardening features
uniffi = ["bitwarden-crypto/uniffi", "dep:uniffi"] # Uniffi bindings
secrets = [] # Secrets manager API
wasm = ["dep:wasm-bindgen", "dep:tsify-next"] # WASM support

[dependencies]
base64 = ">=0.22.1, <0.23"
Expand All @@ -44,8 +45,10 @@ thiserror = { workspace = true }
uniffi = { workspace = true, optional = true, features = ["tokio"] }
uuid = { workspace = true }
validator = { workspace = true }
wasm-bindgen = { workspace = true, optional = true }
zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] }
zxcvbn = { version = ">=3.0.1, <4.0", optional = true }
tsify-next = { workspace = true, optional = true }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
# By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates
Expand Down
15 changes: 14 additions & 1 deletion crates/bitwarden-core/src/client/client_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
#[cfg_attr(
feature = "wasm",
derive(tsify_next::Tsify),
tsify(into_wasm_abi, from_wasm_abi)
)]
pub struct ClientSettings {
/// The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
pub identity_url: String,
Expand All @@ -44,6 +49,11 @@ impl Default for ClientSettings {
#[allow(non_camel_case_types)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, JsonSchema)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
#[cfg_attr(
feature = "wasm",
derive(tsify_next::Tsify),
tsify(into_wasm_abi, from_wasm_abi)
)]
pub enum DeviceType {
Android = 0,
iOS = 1,
Expand All @@ -66,6 +76,9 @@ pub enum DeviceType {
VivaldiBrowser = 18,
VivaldiExtension = 19,
SafariExtension = 20,

SDK = 21,
Server = 22,
WindowsCLI = 23,
MacOsCLI = 24,
LinuxCLI = 25,
}
Loading

0 comments on commit 32088c7

Please sign in to comment.