Skip to content

Commit

Permalink
Merge branch 'master' into master-to-main
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-flinn committed Dec 12, 2023
2 parents fd1e1fc + 1b5d01b commit 30291a4
Show file tree
Hide file tree
Showing 67 changed files with 1,836 additions and 4,535 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate_schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: schemas.ts
path: ${{ github.workspace }}/languages/js_webassembly/bitwarden_client/schemas.ts
path: ${{ github.workspace }}/languages/js/sdk-client/src/schemas.ts
if-no-files-found: error

- name: Upload c# schemas artifact
Expand Down
120 changes: 67 additions & 53 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
---
name: Version Bump
run-name: Version Bump - v${{ inputs.version_number }}

on:
workflow_call:
inputs:
project:
description: "Project"
required: true
type: string
version_number:
description: "New version (example: '2024.1.0')"
required: true
type: string
workflow_dispatch:
inputs:
project:
Expand All @@ -16,20 +27,19 @@ on:
- cli
- bitwarden-json
version_number:
description: "New Version"
description: "New version (example: '2024.1.0')"
required: true

defaults:
run:
shell: bash

jobs:
bump_version:
name: "Bump ${{ github.event.inputs.project }} Version"
name: "Bump ${{ inputs.project }} Version to v${{ inputs.version_number }}"
runs-on: ubuntu-22.04
steps:
- name: Checkout Branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: bitwarden/sdk
ref: master

- name: Install rust
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 # stable
Expand All @@ -42,7 +52,7 @@ jobs:
- name: Install cargo-release
run: cargo install cargo-edit

- name: Login to Azure - Prod Subscription
- name: Login to Azure - CI Subscription
uses: Azure/login@de95379fe4dadc2defb305917eaa7e5dde727294 # v1.5.1
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
Expand All @@ -52,7 +62,9 @@ jobs:
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
secrets: "github-gpg-private-key, github-gpg-private-key-passphrase"
secrets: "github-gpg-private-key,
github-gpg-private-key-passphrase,
github-pat-bitwarden-devops-bot-repo-scope"

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
Expand All @@ -65,69 +77,62 @@ jobs:
- name: Create Version Branch
id: branch
env:
VERSION: ${{ github.event.inputs.version_number }}
PROJECT: ${{ github.event.inputs.project }}
VERSION: ${{ inputs.version_number }}
PROJECT: ${{ inputs.project }}
run: git switch -c sdk-${PROJECT}_version_bump_${VERSION}

- name: Create Version Branch
id: create-branch
run: |
NAME=version_bump_${{ github.ref_name }}_${{ inputs.project }}_${{ inputs.version_number }}
git switch -c $NAME
echo "name=$NAME" >> $GITHUB_OUTPUT
########################
# VERSION BUMP SECTION #
########################

### napi
- name: Bump @bitwarden/sdk-napi Version
if: ${{ github.event.inputs.project == 'napi' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
if: ${{ inputs.project == 'napi' }}
working-directory: "crates/bitwarden-napi"
run: |
npm ci
npm version ${VERSION}
npm version ${{ inputs.version_number }}
- name: Bump napi crate Version
if: ${{ github.event.inputs.project == 'napi' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bitwarden-napi ${VERSION}
if: ${{ inputs.project == 'napi' }}
run: cargo-set-version set-version -p bitwarden-napi ${{ inputs.version_number }}

### bitwarden

- name: Bump bitwarden crate Version
if: ${{ github.event.inputs.project == 'bitwarden' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bitwarden ${VERSION}
if: ${{ inputs.project == 'bitwarden' }}
run: cargo-set-version set-version -p bitwarden ${{ inputs.version_number }}

### bitwarden-api-api

- name: Bump bitwarden-api-api crate Version
if: ${{ github.event.inputs.project == 'bitwarden-api-api' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bitwarden-api-api ${VERSION}
if: ${{ inputs.project == 'bitwarden-api-api' }}
run: cargo-set-version set-version -p bitwarden-api-api ${{ inputs.version_number }}

### bitwarden-api-identity

- name: Bump bitwarden-api-identity crate Version
if: ${{ github.event.inputs.project == 'bitwarden-api-identity' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bitwarden-api-identity ${VERSION}
if: ${{ inputs.project == 'bitwarden-api-identity' }}
run: cargo-set-version set-version -p bitwarden-api-identity ${{ inputs.version_number }}

### cli

- name: Bump cli Version
if: ${{ github.event.inputs.project == 'cli' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bws ${VERSION}
if: ${{ inputs.project == 'cli' }}
run: cargo-set-version set-version -p bws ${{ inputs.version_number }}

### bitwarden-json

- name: Bump bitwarden-json crate Version
if: ${{ github.event.inputs.project == 'bitwarden-json' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
run: cargo-set-version set-version -p bitwarden-json ${VERSION}
if: ${{ inputs.project == 'bitwarden-json' }}
run: cargo-set-version set-version -p bitwarden-json ${{ inputs.version_number }}

############################
# VERSION BUMP SECTION END #
Expand Down Expand Up @@ -156,28 +161,24 @@ jobs:
- name: Commit files
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
PROJECT: ${{ github.event.inputs.project }}
run: git commit -m "Bumped sdk-${PROJECT} version to ${VERSION}" -a
run: git commit -m "Bumped sdk-${{ inputs.project }} version to ${{ inputs.version_number }}" -a

- name: Push changes
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }}
env:
VERSION: ${{ github.event.inputs.version_number }}
PROJECT: ${{ github.event.inputs.project }}
run: git push -u origin sdk-${PROJECT}_version_bump_${VERSION}
PR_BRANCH: ${{ steps.create-branch.outputs.name }}
run: git push -u origin $PR_BRANCH

- name: Create Bump Version PR
- name: Create Version PR
if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }}
id: create-pr
env:
PR_BRANCH: "sdk-${{ github.event.inputs.project }}_version_bump_${{ github.event.inputs.version_number }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
BASE_BRANCH: master
TITLE: "Bump ${{ github.event.inputs.project }} version to ${{ github.event.inputs.version_number }}"
PR_BRANCH: ${{ steps.create-branch.outputs.name }}
GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
TITLE: "Bump version to ${{ inputs.version_number }}"
run: |
gh pr create --title "$TITLE" \
--base "$BASE" \
PR_URL=$(gh pr create --title "$TITLE" \
--base "master" \
--head "$PR_BRANCH" \
--label "version update" \
--label "automated pr" \
Expand All @@ -190,4 +191,17 @@ jobs:
- [X] Other
## Objective
Automated ${{ github.event.inputs.project }} version bump to ${{ github.event.inputs.version_number }}"
Automated ${{ inputs.project }} version bump to ${{ inputs.version_number }}")
echo "pr_number=${PR_URL##*/}" >> $GITHUB_OUTPUT
- name: Approve PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.create-pr.outputs.pr_number }}
run: gh pr review $PR_NUMBER --approve

- name: Merge PR
env:
GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}
PR_NUMBER: ${{ steps.create-pr.outputs.pr_number }}
run: gh pr merge $PR_NUMBER --squash --auto --delete-branch
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ build/
bld/
[Bb]in/
[Oo]bj/
*.wasm

# Binary files
*.dylib
Expand Down Expand Up @@ -42,6 +43,7 @@ crates/bitwarden-napi/sdk-napi.*.node

# Complied TypeScript client
crates/bitwarden-napi/dist
languages/js/sdk-client/dist/

# Uniffi
languages/swift/BitwardenFFI.xcframework
Expand All @@ -52,11 +54,11 @@ languages/kotlin/sdk/src/main/java/com/bitwarden/sdk/bitwarden_uniffi.kt
languages/kotlin/sdk/src/main/java/com/bitwarden/core/bitwarden.kt

# Schemas
support/schemas
crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts
languages/csharp/Bitwarden.Sdk/schemas.cs
languages/js_webassembly/bitwarden_client/schemas.ts
languages/python/bitwarden_sdk/schemas.py
languages/cpp/include/schemas.hpp
languages/csharp/Bitwarden.Sdk/schemas.cs
languages/go/schema.go
languages/java/src/main/java/com/bitwarden/sdk/schema
languages/js/sdk-client/src/schemas.ts
languages/python/bitwarden_sdk/schemas.py
support/schemas
9 changes: 2 additions & 7 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion crates/bitwarden-c/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub async extern "C" fn run_command(
) -> *mut c_char {
let client = unsafe { ffi_ref!(client_ptr) };
let input_str = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr).to_bytes() }).unwrap();
println!("{}", input_str);

let result = client.run_command(input_str).await;
match std::ffi::CString::new(result) {
Expand Down
8 changes: 4 additions & 4 deletions crates/bitwarden-napi/package-lock.json

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

2 changes: 1 addition & 1 deletion crates/bitwarden-napi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@napi-rs/cli": "^2.13.2",
"ts-node": "10.9.1",
"ts-node": "10.9.2",
"typescript": "^5.0.0"
},
"engines": {
Expand Down
10 changes: 9 additions & 1 deletion crates/bitwarden-uniffi/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::sync::Arc;

use bitwarden::mobile::crypto::{InitOrgCryptoRequest, InitUserCryptoRequest};
use bitwarden::mobile::crypto::{
DerivePinKeyResponse, InitOrgCryptoRequest, InitUserCryptoRequest,
};

use crate::{error::Result, Client};

Expand Down Expand Up @@ -45,4 +47,10 @@ impl ClientCrypto {
.get_user_encryption_key()
.await?)
}

/// Generates a PIN protected user key from the provided PIN. The result can be stored and later used
/// to initialize another client instance by using the PIN and the PIN key with `initialize_user_crypto`.
pub async fn derive_pin_key(&self, pin: String) -> Result<DerivePinKeyResponse> {
Ok(self.0 .0.write().await.crypto().derive_pin_key(pin).await?)
}
}
7 changes: 5 additions & 2 deletions crates/bitwarden-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
rust-version = "1.57"

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[dependencies]
console_error_panic_hook = "0.1.7"
Expand All @@ -16,7 +16,10 @@ serde = { version = "1.0.193", features = ["derive"] }
wasm-bindgen = { version = "0.2.89", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.39"

bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] }
bitwarden-json = { path = "../bitwarden-json", features = [
"secrets",
"internal",
] }

[dev-dependencies]
wasm-bindgen-test = "0.3.39"
23 changes: 23 additions & 0 deletions crates/bitwarden-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Bitwarden-wasm

Requirements:

- `wasm32-unknown-unknown` rust target.
- `wasm-bindgen-cli` installed.
- `binaryen` installed for `wasm-opt` and `wasm2js`.

```bash
rustup target add wasm32-unknown-unknown
cargo install -f wasm-bindgen-cli
brew install binaryen
```

#### Build

```bash
# dev
./build.sh

# release
./build.sh -r
```
Loading

0 comments on commit 30291a4

Please sign in to comment.