Skip to content

Commit

Permalink
feat(agent): Implement agent with basic mediation protocol, with exam…
Browse files Browse the repository at this point in the history
…ples (hyperledger#23)

Co-authored-by: Curtish <[email protected]>
Co-authored-by: Ianos <[email protected]>
Co-authored-by: Milos Dzepina <[email protected]>
Signed-off-by: Francisco Javier Ribó Labrador <[email protected]>
  • Loading branch information
4 people committed May 2, 2024
1 parent 808b33e commit a64f779
Show file tree
Hide file tree
Showing 147 changed files with 15,430 additions and 26,371 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*
/**/*.d.ts
16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},
"ignorePatterns":["castor/parser", "castor/protos"],
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"comma-dangle": 0,
"no-unused-vars": "warn",
"no-unexpected-multiline": "warn",
"prefer-const": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off"
},
"settings": {},
"env": {
"browser": true,
"node": true,
"jasmine": true,
"jest": true,
"es6": true
}
}
16 changes: 2 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,5 @@ jobs:
- name: Eslint
run: npx eslint .

- name: Build
run: npm run build

- name: Build tests
run: npm run build:test

- name: Test node
run: npm run test:node

- name: Test browser
run: npm run test:browser

- name: Check coverage
run: yarn coverage:check
- name: Tests with Code Coverage
run: npm run coverage
2 changes: 1 addition & 1 deletion .github/workflows/wallet-sdk-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
GIT_AUTHOR_NAME: ${{ steps.import_gpg.outputs.name }}
GIT_COMMITTER_NAME: ${{ steps.import_gpg.outputs.name }}
run: |
yarn install
npm install
npx semantic-release
109 changes: 18 additions & 91 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,97 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node
*.db
*.sqlite
### Custom
.rpt2_cache/
*.idea/
*.iml
dist/src
dist/tests
# dependencies
node_modules
/.pnp
.pnp.js

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
# testing
/coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.vscode
.idea

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node
npm-debug.log*
yarn-debug.log*
yarn-error.log*
build
tmp
6 changes: 0 additions & 6 deletions .mocharc.json

This file was deleted.

43 changes: 37 additions & 6 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
.vscode
examples
lib
cdn
# dependencies
/node_modules

# testing
/tests
/coverage

# docs
/docs

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
/.github
/demo
.esdoc.json

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Development folders and files
public
src
scripts
config
test.ts
build/tests
.travis.yml
CHANGELOG.md
README.md
.eslintignore
.eslintrc.json
webpack.config.js
babel.config.js
build/browser-test
build/node-test
build/types/demos
10 changes: 0 additions & 10 deletions .nycrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .vscode/extensions.json

This file was deleted.

27 changes: 14 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "NODE DEBUG",
"program": "${workspaceFolder}/build/node-test/index.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-r",
"ts-node/register",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/tests/**/*.ts"
],
"env": {
"TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\" }"
}
"name": "TEST",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": ["--colors", "--maxWorkers", "1"],
"skipFiles": [
"${workspaceRoot}/../../node_modules/**/*",
"<node_internals>/**/*"
]
}
]
}
25 changes: 13 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"editor.formatOnSave": true,


"typescript.tsdk": "./node_modules/typescript/lib",

"files.exclude": {
"**/.git": true,
"**/.DS_Store": true
},

"eslint.validate": ["typescript"]
}
"editor.formatOnSave": true,


"typescript.tsdk": "./node_modules/typescript/lib",

"files.exclude": {
"**/.git": true,
"**/.DS_Store": true
},

"eslint.validate": ["typescript"]
}

31 changes: 19 additions & 12 deletions apollo/Apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@ import { Secp256k1PublicKey } from "./utils/Secp256k1PublicKey";
import { Secp256k1PrivateKey } from "./utils/Secp256k1PrivateKey";
import { Ed25519PrivateKey } from "./utils/Ed25519PrivateKey";
import { Ed25519PublicKey } from "./utils/Ed25519PublicKey";
import { X25519PrivateKey } from "./utils/X25519PrivateKey";
import { Ed25519KeyPair } from "./utils/Ed25519KeyPair";
import { X25519KeyPair } from "./utils/X25519KeyPair";
import { ApolloError } from "../domain/models/Errors";

import { OctetKeyPair } from "./models/OctetKeyPair";
const EC = elliptic.ec;

export default class Apollo implements ApolloInterface {
getPrivateJWKJson(id: string, keyPair: KeyPair): string {
throw new Error("Method not implemented.");
}
getPublicJWKJson(id: string, keyPair: KeyPair): string {
throw new Error("Method not implemented.");
}
private getKeyPairForCurve(seed: Seed, curve: KeyCurve): KeyPair {
private getKeyPairForCurve(curve: KeyCurve, seed?: Seed): KeyPair {
const derivationPath = DerivationPath.fromPath(
`m/${curve.index || 0}'/0'/0'`
);
if (curve.curve == Curve.SECP256K1) {
if (!seed) {
throw new Error(
"Please provide a seed when creating a secp256k1 keypair"
);
}
const extendedKey = KeyDerivation.deriveKey(seed.value, derivationPath);
const keyPair = extendedKey.keyPair();
return {
Expand Down Expand Up @@ -116,11 +115,11 @@ export default class Apollo implements ApolloInterface {
mnemonics: mnemonics,
};
}
createKeyPairFromKeyCurve(seed: Seed, curve: KeyCurve): KeyPair {
return this.getKeyPairForCurve(seed, curve);
createKeyPairFromKeyCurve(curve: KeyCurve, seed?: Seed): KeyPair {
return this.getKeyPairForCurve(curve, seed);
}
createKeyPairFromPrivateKey(seed: Seed, privateKey: PrivateKey): KeyPair {
return this.getKeyPairForCurve(seed, privateKey.keyCurve);
createKeyPairFromPrivateKey(privateKey: PrivateKey, seed?: Seed): KeyPair {
return this.getKeyPairForCurve(privateKey.keyCurve, seed);
}
compressedPublicKeyFromPublicKey(publicKey: PublicKey): CompressedPublicKey {
const secp256k1PublicKey = Secp256k1PublicKey.secp256k1FromBytes(
Expand Down Expand Up @@ -221,4 +220,12 @@ export default class Apollo implements ApolloInterface {
}
return false;
}
getPrivateJWKJson(id: string, keyPair: KeyPair): string {
const jsonString = new OctetKeyPair(id, keyPair).privateJson;
return jsonString;
}
getPublicJWKJson(id: string, keyPair: KeyPair): string {
const jsonString = new OctetKeyPair(id, keyPair).publicJson;
return jsonString;
}
}
Loading

0 comments on commit a64f779

Please sign in to comment.