Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
15 changes: 15 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
// "no-console": 1, // Means warning
"prettier/prettier": 2 // Means error
}
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# nix stuff
.pre-commit-config.yaml
result
result-*
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 80
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# MinAuth
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.

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.

### Current status

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


### Repository Structure

Currently the source code of the repository is structure like this:
Expand Down
143 changes: 142 additions & 1 deletion flake.lock

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

86 changes: 79 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,95 @@
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
outputs = inputs @ {
flake-parts,
pre-commit-hooks-nix,
gitignore,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.pre-commit-hooks-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
nodeMajorVersion = 18;
runNode2Nix = pkgs.writeShellScriptBin "runNode2Nix" ''
${pkgs.node2nix}/bin/node2nix \
-${builtins.toString nodeMajorVersion} \
--input package.json \
--lock package-lock.json \
--node-env ./nix/node-env.nix \
--composition ./nix/default.nix \
--output ./nix/node-package.nix \
--development \
--include-peer-dependencies
'';
nodejs = pkgs."nodejs-${builtins.toString nodeMajorVersion}_x";
node2nixOutput = import ./nix {inherit pkgs nodejs system;};
nodeDependencies = node2nixOutput.nodeDependencies;
minAuth = pkgs.stdenv.mkDerivation {
name = "MinAuth";
version = "0.1.0";
src = gitignore.lib.gitignoreSource ./.;
buildInputs = [nodejs];
buildPhase = ''
runHook preBuild
ln -sf ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
npm run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp package.json $out/package.json
cp -r dist $out/dist
ln -sf ${nodeDependencies}/lib/node_modules $out/node_modules
runHook postInstall
'';
};
in {
pre-commit.settings.hooks = {
eslint.enable = true;
prettier.enable = true;
alejandra.enable = true;
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
packages = [
nodejs
nodePackages.typescript
nodePackages.typescript-language-server
config.pre-commit.settings.package
runNode2Nix
];
shellHook = config.pre-commit.installationScript;
};
checks.default = self'.checks.pre-commit;
packages = {
inherit minAuth;
default = minAuth;
};
};
flake = {
herculesCI.ciSystems = ["x86_64-linux"];
};
};
}
22 changes: 22 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{
pkgs ?
import <nixpkgs> {
inherit system;
},
system ? builtins.currentSystem,
nodejs ? pkgs."nodejs_18",
}: let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool =
if pkgs.stdenv.isDarwin
then pkgs.darwin.cctools
else null;
};
in
import ./node-package.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}
Loading