Skip to content

Commit 68f9c7d

Browse files
authored
Merge pull request #26 from MatrixAI/feature-bundling
Bundling and pkg fixes
2 parents bc1879a + ee1de51 commit 68f9c7d

File tree

118 files changed

+3971
-9896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3971
-9896
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"message": "Use `globalThis` instead"
3939
}
4040
],
41+
"prefer-rest-params": 0,
4142
"require-yield": 0,
4243
"eqeqeq": ["error", "smart"],
4344
"spaced-comment": [

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
!.env.example
55
# nix
66
/result*
7-
/builds
8-
# node-gyp
97
/build
10-
# prebuildify
11-
/prebuilds
8+
/builds
9+
/prebuild
10+
/prepublishOnly
11+
/target
1212

1313
# Logs
1414
logs

.gitlab-ci.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,6 @@ stages:
4444
- integration # Cross-platform application bundling, integration tests, and pre-release
4545
- release # Cross-platform distribution and deployment
4646

47-
check:scratch:
48-
stage: check
49-
needs: []
50-
script:
51-
- >
52-
nix-shell --arg ci true --run $'
53-
npm test -- --ci tests/scratch.test.ts;
54-
'
55-
allow_failure: true
56-
rules:
57-
- when: manual
58-
5947
check:lint:
6048
stage: check
6149
needs: []
@@ -78,7 +66,8 @@ check:nix-dry:
7866
stage: check
7967
needs: []
8068
script:
81-
- nix-build -v -v --dry-run ./release.nix
69+
- npmDepsHash="$(prefetch-npm-deps ./package-lock.json)"
70+
- nix-build -v -v --dry-run ./release.nix --argstr npmDepsHash "$npmDepsHash"
8271
rules:
8372
# Runs on feature and staging commits and ignores version commits
8473
- if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
@@ -240,16 +229,18 @@ integration:builds:
240229
- build:platforms
241230
script:
242231
- mkdir -p ./builds
232+
- npmDepsHash="$(prefetch-npm-deps ./package-lock.json)"
243233
- >
244234
build_application="$(nix-build \
245235
--max-jobs "$(nproc)" --cores "$(nproc)" \
246236
./release.nix \
247237
--attr application \
238+
--argstr npmDepsHash "$npmDepsHash" \
248239
)"
249240
- >
250241
nix-store --export $( \
251242
nix-store --query --requisites "$build_application" \
252-
) | gzip > ./builds/js-polykey.closure.gz
243+
) | gzip > ./builds/polykey-cli.closure.gz
253244
# non-nix targets
254245
- >
255246
builds="$(nix-build \
@@ -259,7 +250,7 @@ integration:builds:
259250
--attr package.linux.x64.elf \
260251
--attr package.windows.x64.exe \
261252
--attr package.macos.x64.macho \
262-
--attr package.macos.arm64.macho)"
253+
--argstr npmDepsHash "$npmDepsHash")"
263254
- cp -r $builds ./builds/
264255
artifacts:
265256
paths:
@@ -281,7 +272,7 @@ integration:deployment:
281272
environment:
282273
name: 'testnet'
283274
deployment_tier: 'staging'
284-
url: 'https://testnet.polykey.io'
275+
url: 'https://testnet.polykey.com'
285276
variables:
286277
REGISTRY_AUTH_FILE: "./tmp/registry-auth-file.json"
287278
# Override CI_REGISTRY_IMAGE to point to ECR
@@ -321,7 +312,7 @@ integration:nix:
321312
script:
322313
- >
323314
build_application="$( \
324-
gunzip -c ./builds/js-polykey.closure.gz | \
315+
gunzip -c ./builds/polykey-cli.closure.gz | \
325316
nix-store --import | \
326317
tail -1 \
327318
)"
@@ -387,6 +378,7 @@ integration:linux:
387378
- windows
388379
before_script:
389380
- mkdir -Force "$CI_PROJECT_DIR/tmp"
381+
- Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
390382
script:
391383
- Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName}
392384
rules:
@@ -541,7 +533,7 @@ release:deployment:branch:
541533
environment:
542534
name: 'mainnet'
543535
deployment_tier: 'production'
544-
url: 'https://mainnet.polykey.io'
536+
url: 'https://mainnet.polykey.com'
545537
variables:
546538
REGISTRY_AUTH_FILE: "./tmp/registry-auth-file.json"
547539
# Override CI_REGISTRY_IMAGE to point to ECR
@@ -579,7 +571,7 @@ release:deployment:tag:
579571
environment:
580572
name: 'mainnet'
581573
deployment_tier: 'production'
582-
url: 'https://mainnet.polykey.io'
574+
url: 'https://mainnet.polykey.com'
583575
variables:
584576
REGISTRY_AUTH_FILE: "./tmp/registry-auth-file.json"
585577
# Override CI_REGISTRY_IMAGE to point to ECR

README.md

Lines changed: 32 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,50 @@
33
staging:[![pipeline status](https://gitlab.com/MatrixAI/open-source/Polykey-CLI/badges/staging/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/Polykey-CLI/commits/staging)
44
master:[![pipeline status](https://gitlab.com/MatrixAI/open-source/Polykey-CLI/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/Polykey-CLI/commits/master)
55

6-
Polykey is an open-source decentralized secrets management and sharing system. It is made for today's decentralized world of people, services and devices.
6+
Polykey is an open-source, peer-to-peer system that addresses the critical challenge in cybersecurity: the secure sharing and delegation of authority, in the form of secrets like keys, tokens, certificates, and passwords.
7+
8+
It allows users including developers, organizations, and machines—to store these secrets in encrypted vaults on their own devices, and share them directly with trusted parties.
9+
10+
All data is end-to-end encrypted, both in transit and at rest, eliminating the risk associated with third-party storage.
11+
12+
Polykey provides a command line interface, desktop and mobile GUI, and a web-based control plane for organizational management.
13+
14+
By treating secrets as tokenized authority, it offers a fresh approach to managing and delegating authority in zero-trust architectures without adding burdensome policy complexity - a pervasive issue in existing zero-trust systems.
15+
16+
Unlike complex self-hosted secrets management systems that require specialized skills and infrastructure, Polykey is installed and running directly from the end-user device.
17+
18+
It is built to automatically navigate network complexities like NAT traversal, connecting securely to other nodes without manual configuration.
19+
20+
Key features:
721

822
* Decentralized Encrypted Storage - No storage of secrets on third parties, secrets are stored on your device and synchronised point-to-point between Polykey nodes.
9-
* Secure Peer-to-Peer Communications - Polykey bootstraps TLS keys by federating trusted social identities (e.g. GitHub).
10-
* Secure Computational Workflows - Share secrets (passwords, keys, tokens and certificates) with people, between teams, and across machine infrastructure.
23+
* Secure Peer-to-Peer Communication - Polykey bootstraps TLS keys by federating trusted social identities (e.g. GitHub).
24+
* Secure Computational Workflows - Share static secrets (passwords, keys, tokens and certificates) with people, between teams, and across machine infrastructure. Create dynamic (short-lived) smart-tokens with embedded policy for more sophisticated zero-trust authority verification.
25+
* With Polykey Enterprise, you can create private networks of Polykey nodes and apply mandatory policy governing node behaviour.
1126

1227
<p align="center">
1328
<img src="./images/cli_demo.gif" alt="Polykey CLI Demo"/>
1429
</p>
1530

16-
Polykey synthesizes a unified workflow between interactive password management and infrastructure key management.
17-
18-
You have complete end-to-end control and privacy over your secrets, with no third-party data collection.
19-
20-
Polykey runs on distributed keynodes referred to as "nodes". Any computing system can run multiple keynodes. Each node manages one or more vaults which are encrypted filesystems with automatic version history. Vaults can be shared between the nodes.
21-
22-
This repository is the core library for Polykey.
31+
This repository is the CLI for Polykey.
2332

2433
The Polykey project is split up into these main repositories:
2534

2635
* [Polykey](https://github.com/MatrixAI/Polykey) - Polykey Core Library
2736
* [Polykey-CLI](https://github.com/MatrixAI/Polykey-CLI) - CLI of Polykey
2837
* [Polykey-Desktop](https://github.com/MatrixAI/Polykey-Desktop) - Polykey Desktop (Windows, Mac, Linux) application
2938
* [Polykey-Mobile](https://github.com/MatrixAI/Polykey-Mobile) - Polykey Mobile (iOS & Android) Application
39+
* [Polykey Enterprise](https://polykey.com) - Web Control Plane SaaS
3040

3141
Have a bug or a feature-request? Please submit it the issues of the relevant subproject above.
3242

33-
For tutorials, how-to guides, reference and theory, see the [docs](https://polykey.io/docs).
43+
For tutorials, how-to guides, reference and theory, see the [docs](https://polykey.com/docs).
3444

3545
Have a question? Join our [discussion board](https://github.com/MatrixAI/Polykey/discussions).
3646

37-
Our main website is https://polykey.io
47+
Have a security issue you want to let us know? You can contact us on our website.
48+
49+
Our main website is https://polykey.com
3850

3951
## Installation
4052

@@ -43,25 +55,26 @@ Note that JavaScript libraries are not packaged in Nix. Only JavaScript applicat
4355
Building the package:
4456

4557
```sh
46-
nix-build -E '(import ./pkgs.nix {}).callPackage ./default.nix {}'
58+
npmDepsHash="$(prefetch-npm-deps ./package-lock.json)"
59+
nix-build -E "(import ./pkgs.nix {}).callPackage ./default.nix { npmDepsHash = \"$npmDepsHash\"; }"
4760
```
4861

4962
### Nix/NixOS
5063

5164
Building the releases:
5265

5366
```sh
54-
nix-build ./release.nix --attr application
55-
nix-build ./release.nix --attr docker
56-
nix-build ./release.nix --attr package.linux.x64.elf
57-
nix-build ./release.nix --attr package.windows.x64.exe
58-
nix-build ./release.nix --attr package.macos.x64.macho
67+
nix-build ./release.nix --attr application --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
68+
nix-build ./release.nix --attr docker --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
69+
nix-build ./release.nix --attr package.linux.x64.elf --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
70+
nix-build ./release.nix --attr package.windows.x64.exe --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
71+
nix-build ./release.nix --attr package.macos.x64.macho --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
5972
```
6073

6174
Install into Nix user profile:
6275

6376
```sh
64-
nix-env -f ./release.nix --install --attr application
77+
nix-env -f ./release.nix --install --attr application --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)"
6578
```
6679

6780
### Docker
@@ -145,48 +158,6 @@ You would need to add these paths to `tsconfig.json`:
145158
},
146159
```
147160

148-
### Native Module Toolchain
149-
150-
There are some nuances when packaging with native modules.
151-
Included native modules are level witch include leveldown and utp-native.
152-
153-
If a module is not set to public then pkg defaults to including it as bytecode.
154-
To avoid this breaking with the `--no-bytecode` flag we need to add `--public-packages "*"`
155-
156-
#### leveldown
157-
158-
To get leveldown to work with pkg we need to include the prebuilds with the executable.
159-
after building with pkg you need to copy from `node_modules/leveldown/prebuilds` -> `path_to_executable/prebuilds`
160-
You only need to include the prebuilds for the arch you are targeting. e.g. for linux-x64 you need `prebuild/linux-x64`.
161-
162-
The folder structure for the executable should look like this.
163-
- linux_executable_elf
164-
- prebuilds
165-
- linux-x64
166-
- (node files)
167-
168-
#### threads.js
169-
170-
To make sure that the worker threads work properly you need to include the compiled worker scripts as an asset.
171-
This can be fixed by adding the following to `package.json`
172-
173-
```json
174-
"pkg": {
175-
"assets": "dist/bin/worker.js"
176-
}
177-
```
178-
179-
If you need to include multiple assets then add them as an array.
180-
181-
```json
182-
"pkg": {
183-
"assets": [
184-
"node_modules/utp-native/**/*",
185-
"dist/bin/worker.js"
186-
]
187-
}
188-
```
189-
190161
### Docs Generation
191162

192163
```sh
@@ -197,26 +168,6 @@ See the docs at: https://matrixai.github.io/TypeScript-Demo-Lib/
197168

198169
### Publishing
199170

200-
Publishing is handled automatically by the staging pipeline.
201-
202-
Prerelease:
203-
204-
```sh
205-
# npm login
206-
npm version prepatch --preid alpha # premajor/preminor/prepatch
207-
git push --follow-tags
208-
```
209-
210-
Release:
211-
212-
```sh
213-
# npm login
214-
npm version patch # major/minor/patch
215-
git push --follow-tags
216-
```
217-
218-
Manually:
219-
220171
```sh
221172
# npm login
222173
npm version patch # major/minor/patch
@@ -225,17 +176,6 @@ npm publish --access public
225176
git push
226177
git push --tags
227178
```
228-
### Packaging Cross-Platform Executables
229-
230-
We use `pkg` to package the source code into executables.
231-
232-
This requires a specific version of `pkg` and also `node-gyp-build`.
233-
234-
Configuration for `pkg` is done in:
235-
236-
* `package.json` - Pins `pkg` and `node-gyp-build`, and configures assets and scripts.
237-
* `utils.nix` - Pins `pkg` for Nix usage
238-
* `release.nix` - Build expressions for executables
239179

240180
## Deployment
241181

0 commit comments

Comments
 (0)