Skip to content

Commit

Permalink
Update GRPC and other JS deps, improve client wrapping
Browse files Browse the repository at this point in the history
Signed-off-by: Silas Davis <[email protected]>
  • Loading branch information
Silas Davis committed Nov 20, 2020
1 parent f7981db commit fe68336
Show file tree
Hide file tree
Showing 29 changed files with 5,551 additions and 3,884 deletions.
19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV GORELEASER_VERSION "v0.104.1"

RUN apk add --update --no-cache \
nodejs \
npm \
yarn \
netcat-openbsd \
git \
openssh-client \
Expand All @@ -24,7 +24,7 @@ RUN apk add --update --no-cache \
py-pip

RUN pip install docker-compose
RUN npm install -g npm-cli-login
RUN yarn install -g yarn-cli-login

RUN curl -OL https://github.com/google/protobuf/releases/download/v${PROTO_VERSION}/protoc-${PROTO_VERSION}-linux-x86_64.zip
RUN mkdir -p protobuf
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ jobs:
if: success()

js:
name: npm
name: yarn
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
git config --global user.email "${GITHUB_ACTOR}"
git config --global user.name "${GITHUB_ACTOR}"
cd hoard-js
npm install
npm run build
npm version $RELEASE_VERSION
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
npm publish --access public .
cd js
yarn install
yarn build
yarn version --no-git-tag-version --new-version $(git describe --tags)
yarn config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
yarn publish --access public .
docker:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
id: go
- uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: '14.x'
- uses: actions/checkout@v1
- run: make build
- run: make test
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# [Monax Hoard](https://github.com/monax/hoard) Changelog
## [Unreleased]
### Changed
- Move to pure-js @grpc/grpc-js library
- Expose more usable methods from the client
- Make default ChunkSize 3 MiB


## [8.2.3] - 2020-03-27
### Added
- ReadHeader will stop once it gets the head
Expand Down Expand Up @@ -81,7 +88,7 @@ This release makes some changes to the Hoard protobuf and service that are backw

## [5.0.1] - 2019-06-20
### Fixed
- JS client - v5, npm publish
- JS client - v5, yarn publish


## [5.0.0] - 2019-05-24
Expand Down Expand Up @@ -202,6 +209,7 @@ This is the first Hoard open source release and includes:
- Hoar-Daemon hoard
- Hoar-Control hoarctl CLI

[Unreleased]: https://github.com/monax/hoard/compare/v8.2.3...HEAD
[8.2.3]: https://github.com/monax/hoard/compare/v8.2.2...v8.2.3
[8.2.2]: https://github.com/monax/hoard/compare/v8.2.1...v8.2.2
[8.2.1]: https://github.com/monax/hoard/compare/v8.2.0...v8.2.1
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ REPO := $(shell pwd)
GOFILES := $(shell find . -name '*.pb.go' -prune -o -not -path './vendor/*' -type f -name '*.go' -print)

# Protobuf generated go files
PROTO_FILES = $(shell find . -path ./hoard-js -prune -o -path ./node_modules -prune -o -type f -name '*.proto' -print)
PROTO_FILES = $(shell find . -path ./js -prune -o -path ./node_modules -prune -o -type f -name '*.proto' -print)
PROTO_GO_FILES = $(patsubst %.proto, %.pb.go, $(PROTO_FILES))
PROTO_GO_FILES_REAL = $(shell find . -type f -name '*.pb.go' -print)
PROTO_TS_FILES = $(patsubst %.proto, %.pb.ts, $(PROTO_FILES))

HOARD_TS_PATH = ./hoard-js
HOARD_TS_PATH = ./js
PROTO_GEN_TS_PATH = ${HOARD_TS_PATH}/proto
PROTOC_GEN_TS_PATH = ${HOARD_TS_PATH}/node_modules/.bin/protoc-gen-ts
PROTOC_GEN_GRPC_PATH= ${HOARD_TS_PATH}/node_modules/.bin/grpc_tools_node_protoc_plugin
Expand Down Expand Up @@ -96,8 +96,8 @@ commit_hash:
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
--plugin=protoc-gen-grpc=${PROTOC_GEN_GRPC_PATH} \
--js_out="import_style=commonjs,binary:${PROTO_GEN_TS_PATH}" \
--ts_out="service=grpc-node:${PROTO_GEN_TS_PATH}" \
--grpc_out="${PROTO_GEN_TS_PATH}" $<
--ts_out="service=grpc-node,mode=grpc-js:${PROTO_GEN_TS_PATH}" \
--grpc_out="grpc_js:${PROTO_GEN_TS_PATH}" $<


.PHONY: protobuf
Expand All @@ -107,17 +107,17 @@ protobuf: ${PROTO_GO_FILES} ${PROTO_TS_FILES}

.PHONY: clean_protobuf
clean_protobuf:
@rm -f $(PROTO_GO_FILES_REAL)
rm -f $(PROTO_GO_FILES_REAL)

.PHONY: npm_install
npm_install:
@cd ${HOARD_TS_PATH} && npm install
.PHONY: yarn_install
yarn_install:
cd ${HOARD_TS_PATH} && yarn install

.PHONY: protobuf_deps
protobuf_deps:
@go get -u github.com/gogo/protobuf/protoc-gen-gogo
@cd ${HOARD_TS_PATH} && npm install grpc-tools
@cd ${HOARD_TS_PATH} && npm install ts-protoc-gen
go get -u github.com/gogo/protobuf/protoc-gen-gogo
cd ${HOARD_TS_PATH} && yarn install grpc-tools
cd ${HOARD_TS_PATH} && yarn install ts-protoc-gen

## build the hoard binary
.PHONY: build_hoard
Expand Down Expand Up @@ -155,7 +155,7 @@ test: check
@scripts/bin_wrapper.sh go test -v ./... ${GO_TEST_ARGS}

.PHONY: test_js
test_js: build install npm_install
test_js: build install yarn_install
@scripts/test_js.sh

## run tests including integration tests
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ make build && make install
```

## Javascript Client
A Javascript client library can be found here: [hoard-js](https://github.com/monax/hoard/tree/master/hoard-js).
A Javascript client library can be found here: [js](https://github.com/monax/hoard/tree/master/js).

Hoard-js is a fairly lightweight wrapper around the Hoard GRPC API. It mainly serves to abstract over the dynamic protobuf library and the static protobuf generation.

Expand All @@ -149,7 +149,7 @@ of the API. To run use:

```shell
# Get dependencies
npm install
yarn install
# Run example
node example.js
```
```
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const DefaultListenAddress = "tcp://:53431"

const DefaultChunkSize = 1 << 16 // 64 Kb
const DefaultChunkSize = 3 * (1 << 20) // 3 MiB

var DefaultHoardConfig = NewHoardConfig(DefaultListenAddress, DefaultChunkSize, NewDefaultStorage(), DefaultLogging)

Expand Down
2 changes: 2 additions & 0 deletions grant/grant.pb.go

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

2 changes: 1 addition & 1 deletion grant/symmetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func SymmetricReferenceV2(ciphertext, secret []byte) (reference.Refs, error) {
encryptedData, nonce := encryption.Desalinate(ciphertext, encryption.NonceSize)
data, err := encryption.Decrypt(encryptedData, nonce, secret)
if err != nil {
return nil, fmt.Errorf("SymmetricReferenceV1 failed to decrypt: %v", err)
return nil, fmt.Errorf("SymmetricReferenceV2 failed to decrypt: %v", err)
}
return reference.RepeatedFromPlaintext(string(data)), nil
}
Loading

0 comments on commit fe68336

Please sign in to comment.