Skip to content

Commit cff9069

Browse files
authored
Merge pull request #2 from mlabs-haskell/connor/simple-password-tree-root-update
Merkle Memberships Program; Clean up
2 parents e4afe58 + 2100e6a commit cff9069

32 files changed

+8210
-689
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint", "prettier"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"prettier"
10+
],
11+
"rules": {
12+
// "no-console": 1, // Means warning
13+
"prettier/prettier": 2 // Means error
14+
}
15+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
132+
# nix stuff
133+
.pre-commit-config.yaml
134+
result
135+
result-*

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "none",
4+
"singleQuote": true,
5+
"printWidth": 80
6+
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# MinAuth
2-
Rapid development of POC of MinAuth - MinAuth is a library and a set of tools for providing JWT-based authentication protocol that uses SnarkyJS zero-knowledge proofs as the basis of the authentication. It uses plugins to prove statements about external data such as on-chain data or 3rd-party data.
32

3+
Rapid development of POC of MinAuth - MinAuth is a library and a set of tools for providing JWT-based authentication protocol that uses SnarkyJS zero-knowledge proofs as the basis of the authentication. It uses plugins to prove statements about external data such as on-chain data or 3rd-party data.
44

55
### Current status
66

77
The current code implements minimal authentication flow that recreates the usual passport authentication, but using snarkyjs ZKPs.
88

9-
109
### Repository Structure
1110

1211
Currently the source code of the repository is structure like this:

flake.lock

Lines changed: 142 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,95 @@
44
inputs = {
55
flake-parts.url = "github:hercules-ci/flake-parts";
66
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
8+
gitignore = {
9+
url = "github:hercules-ci/gitignore.nix";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
712
};
813

9-
outputs = inputs@{ flake-parts, ... }:
10-
flake-parts.lib.mkFlake { inherit inputs; } {
14+
outputs = inputs @ {
15+
flake-parts,
16+
pre-commit-hooks-nix,
17+
gitignore,
18+
...
19+
}:
20+
flake-parts.lib.mkFlake {inherit inputs;} {
1121
imports = [
22+
inputs.pre-commit-hooks-nix.flakeModule
23+
];
24+
systems = [
25+
"x86_64-linux"
26+
"aarch64-linux"
27+
"aarch64-darwin"
28+
"x86_64-darwin"
1229
];
13-
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
14-
perSystem = { config, self', inputs', pkgs, system, ... }: {
30+
perSystem = {
31+
config,
32+
self',
33+
inputs',
34+
pkgs,
35+
system,
36+
...
37+
}: let
38+
nodeMajorVersion = 18;
39+
runNode2Nix = pkgs.writeShellScriptBin "runNode2Nix" ''
40+
${pkgs.node2nix}/bin/node2nix \
41+
-${builtins.toString nodeMajorVersion} \
42+
--input package.json \
43+
--lock package-lock.json \
44+
--node-env ./nix/node-env.nix \
45+
--composition ./nix/default.nix \
46+
--output ./nix/node-package.nix \
47+
--development \
48+
--include-peer-dependencies
49+
'';
50+
nodejs = pkgs."nodejs-${builtins.toString nodeMajorVersion}_x";
51+
node2nixOutput = import ./nix {inherit pkgs nodejs system;};
52+
nodeDependencies = node2nixOutput.nodeDependencies;
53+
minAuth = pkgs.stdenv.mkDerivation {
54+
name = "MinAuth";
55+
version = "0.1.0";
56+
src = gitignore.lib.gitignoreSource ./.;
57+
buildInputs = [nodejs];
58+
buildPhase = ''
59+
runHook preBuild
60+
ln -sf ${nodeDependencies}/lib/node_modules ./node_modules
61+
export PATH="${nodeDependencies}/bin:$PATH"
62+
npm run build
63+
runHook postBuild
64+
'';
65+
installPhase = ''
66+
runHook preInstall
67+
mkdir -p $out
68+
cp package.json $out/package.json
69+
cp -r dist $out/dist
70+
ln -sf ${nodeDependencies}/lib/node_modules $out/node_modules
71+
runHook postInstall
72+
'';
73+
};
74+
in {
75+
pre-commit.settings.hooks = {
76+
eslint.enable = true;
77+
prettier.enable = true;
78+
alejandra.enable = true;
79+
};
1580
devShells.default = pkgs.mkShell {
16-
packages = with pkgs; [
81+
packages = [
1782
nodejs
18-
nodePackages.typescript
19-
nodePackages.typescript-language-server
83+
config.pre-commit.settings.package
84+
runNode2Nix
2085
];
86+
shellHook = config.pre-commit.installationScript;
87+
};
88+
checks.default = self'.checks.pre-commit;
89+
packages = {
90+
inherit minAuth;
91+
default = minAuth;
2192
};
2293
};
2394
flake = {
95+
herculesCI.ciSystems = ["x86_64-linux"];
2496
};
2597
};
2698
}

nix/default.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This file has been generated by node2nix 1.11.1. Do not edit!
2+
{
3+
pkgs ?
4+
import <nixpkgs> {
5+
inherit system;
6+
},
7+
system ? builtins.currentSystem,
8+
nodejs ? pkgs."nodejs_18",
9+
}: let
10+
nodeEnv = import ./node-env.nix {
11+
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
12+
inherit pkgs nodejs;
13+
libtool =
14+
if pkgs.stdenv.isDarwin
15+
then pkgs.darwin.cctools
16+
else null;
17+
};
18+
in
19+
import ./node-package.nix {
20+
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
21+
inherit nodeEnv;
22+
}

0 commit comments

Comments
 (0)