Skip to content

Commit

Permalink
Merge pull request #47 from PolymeshAssociation/ignore-non-ed25519
Browse files Browse the repository at this point in the history
Ignore non ed25519
  • Loading branch information
polymath-eric committed Apr 16, 2024
2 parents 9e7a845 + 024d340 commit 291b63f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@polkadot/util": "^12.4.2",
"@polkadot/util-crypto": "^12.4.2",
"cross-fetch": "^3.1.5",
"lodash": "^4.17.21",
"tslib": "^2.0.0"
},
"devDependencies": {
Expand All @@ -46,7 +45,6 @@
"@nrwl/workspace": "13.8.2",
"@open-wc/webpack-import-meta-loader": "^0.4.7",
"@types/jest": "27.0.2",
"@types/lodash": "^4.14.179",
"@types/node": "16.11.7",
"@types/require-from-string": "^1.2.1",
"@typescript-eslint/eslint-plugin": "~5.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ describe('HashicorpVault class', () => {
keys: {
'1': {
public_key: 'cqWlP2oERZqOjtJmzASNt/jI0/qsAgT5ntWTQAutY2w=',
name: 'ed25519',
},
'2': {
public_key: '7CYkynab5bxXzSPw8djAag9orAalfgA1U2HUUACvfCg=',
name: 'ed25519',
},
},
},
Expand All @@ -67,6 +69,7 @@ describe('HashicorpVault class', () => {
keys: {
'1': {
public_key: 'GvM3BzqsB8JiK6OThUhQNBz/ES1dY4De8j7jI7DUiAI=',
name: 'ed25519',
},
},
},
Expand Down Expand Up @@ -114,9 +117,11 @@ describe('HashicorpVault class', () => {
/* eslint-disable @typescript-eslint/naming-convention */
'1': {
public_key: 'cqWlP2oERZqOjtJmzASNt/jI0/qsAgT5ntWTQAutY2w=',
name: 'ed25519',
},
'2': {
public_key: '7CYkynab5bxXzSPw8djAag9orAalfgA1U2HUUACvfCg=',
name: 'ed25519',
},
/* eslint-enable @typescript-eslint/naming-convention */
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HexString } from '@polkadot/util/types';
import fetch from 'cross-fetch';
import { flatten, map } from 'lodash';

import {
GetKeyResponse,
Expand Down Expand Up @@ -55,7 +54,7 @@ export class HashicorpVault {

const allKeys = await Promise.all(keys.map(name => this.fetchKeysByName(name)));

return flatten(allKeys);
return allKeys.flat();
}

/**
Expand All @@ -77,15 +76,17 @@ export class HashicorpVault {
data: { keys },
}: GetKeyResponse = await response.json();

return map(keys, ({ public_key: publicKey }, version) => {
const hexKey = Buffer.from(publicKey, 'base64').toString('hex');

return {
publicKey: `0x${hexKey}`,
version: Number(version),
name,
};
});
return Object.entries(keys)
.filter(([, { name }]) => name === 'ed25519') // N.B response "name" is the encryption type
.map(([version, { public_key: publicKey }]) => {
const hexKey = Buffer.from(publicKey, 'base64').toString('hex');

return {
publicKey: `0x${hexKey}`,
version: Number(version),
name,
};
});
}

/**
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3258,11 +3258,6 @@
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=

"@types/lodash@^4.14.179":
version "4.14.179"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.179.tgz#490ec3288088c91295780237d2497a3aa9dfb5c5"
integrity sha512-uwc1x90yCKqGcIOAT6DwOSuxnrAbpkdPsUOZtwrXb4D/6wZs+6qG7QnIawDuZWg0sWpxl+ltIKCaLoMlna678w==

"@types/mime@^1":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
Expand Down

0 comments on commit 291b63f

Please sign in to comment.