Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1fb61ab
feat: get rate limit of GitHub user.
addievo Oct 13, 2023
a0cf85b
feat: GIthubProvider now uses GraphQL to speed up `getConnectedIdenti…
amydevs Oct 13, 2023
e318a6c
fix: added error handling for GraphQL queries in`GithubProvider.getCo…
amydevs Oct 13, 2023
6137948
fix: moved `JSON.stringify` to `GitHubProvider.getConnectedIdentityDa…
amydevs Oct 14, 2023
0a5899a
fix: `GitHubProvider.getConnectedIdentityDatas` would not correctly p…
amydevs Oct 19, 2023
56a6de5
Merge pull request #579 from MatrixAI/feature-improve-githubProvider
CMCDragonkai Oct 19, 2023
e57c36e
feat: encapsulates `WebSocketClient` into `PolykeyClient`
amydevs Oct 13, 2023
426b5dd
Merge pull request #582 from MatrixAI/feature-websocket_client-encaps…
CMCDragonkai Oct 21, 2023
bbc662d
feat: id utility `parseGestaltIdentityId` enables parsing just the `P…
addievo Oct 19, 2023
19569a8
Merge pull request #595 from MatrixAI/feature-claim-fix
CMCDragonkai Oct 21, 2023
5b01c9e
style: lint fix `GitHubProvider.ts`
CMCDragonkai Oct 21, 2023
6109fa6
fix: add privateKey and privateKeyPath back to PKA options
addievo Oct 24, 2023
9f52ca0
Merge pull request #600 from MatrixAI/feature-websocket_client-encaps…
addievo Oct 24, 2023
6123329
feat: refactored hole punch signalling procedure
tegefaulkes Oct 23, 2023
479f8b6
Merge pull request #555 from MatrixAI/feature-nat-signalling
tegefaulkes Oct 24, 2023
ec8b63f
1.2.1-alpha.15
tegefaulkes Oct 24, 2023
527040b
fix: change PrivateKey type to a more generic type
addievo Oct 24, 2023
9f1772a
fix: add recoveryCode, privateKey and privateKeyPath to PkAgent start…
addievo Oct 24, 2023
0fce357
lintfix
addievo Oct 24, 2023
231cbf6
fix: final fixup and review
tegefaulkes Oct 24, 2023
b15bdac
Merge pull request #601 from MatrixAI/feature-agent-fix
tegefaulkes Oct 24, 2023
4cba6af
1.2.1-alpha.16
tegefaulkes Oct 24, 2023
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
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polykey",
"version": "1.2.1-alpha.14",
"version": "1.2.1-alpha.16",
"homepage": "https://polykey.com",
"author": "Matrix AI",
"contributors": [
Expand Down
107 changes: 75 additions & 32 deletions src/PolykeyAgent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { DeepPartial, FileSystem } from './types';
import type { DeepPartial, FileSystem, ObjectEmpty } from './types';
import type { PolykeyWorkerManagerInterface } from './workers/types';
import type { TLSConfig } from './network/types';
import type { SeedNodes, NodesOptions } from './nodes/types';
import type { Key, KeysOptions } from './keys/types';
import type { SeedNodes } from './nodes/types';
import type { Key, PasswordOpsLimit, PasswordMemLimit } from './keys/types';
import path from 'path';
import process from 'process';
import Logger from '@matrixai/logger';
Expand Down Expand Up @@ -54,26 +54,35 @@ type PolykeyAgentOptions = {
seedNodes: SeedNodes;
workers: number;
ipv6Only: boolean;
keys: KeysOptions;
rpc: {
callTimeoutTime: number;
parserBufferSize: number;
};
keys: {
passwordOpsLimit: PasswordOpsLimit;
passwordMemLimit: PasswordMemLimit;
strictMemoryLock: boolean;
certDuration: number;
certRenewLeadTime: number;
recoveryCode: string;
} & (
| ObjectEmpty
| { recoveryCode: string }
| { privateKey: Buffer }
| { privateKeyPath: string }
);
client: {
connectTimeoutTime: number;
keepAliveTimeoutTime: number;
keepAliveIntervalTime: number;
rpcCallTimeoutTime: number;
rpcParserBufferSize: number;
};
nodes: {
connectionIdleTimeoutTime: number;
connectionFindConcurrencyLimit: number;
connectionConnectTimeoutTime: number;
connectionKeepAliveTimeoutTime: number;
connectionKeepAliveIntervalTime: number;
connectionHolePunchIntervalTime: number;
rpcCallTimeoutTime: number;
rpcParserBufferSize: number;
};
nodes: NodesOptions;
};

type PolykeyAgentStartOptions = {
clientServiceHost: string;
clientServicePort: number;
agentServiceHost: string;
agentServicePort: number;
ipv6Only: boolean;
workers: number;
};

interface PolykeyAgent extends CreateDestroyStartStop {}
Expand Down Expand Up @@ -113,9 +122,9 @@ class PolykeyAgent {
}: {
password: string;
options?: DeepPartial<PolykeyAgentOptions>;
fresh?: boolean;
fs?: FileSystem;
logger?: Logger;
fresh?: boolean;
}): Promise<PolykeyAgent> {
logger.info(`Creating ${this.name}`);
const umask = 0o077;
Expand All @@ -131,18 +140,18 @@ class PolykeyAgent {
workers: config.defaultsUser.workers,
ipv6Only: config.defaultsUser.ipv6Only,
keys: {
passwordOpsLimit: config.defaultsUser.passwordOpsLimit,
passwordMemLimit: config.defaultsUser.passwordMemLimit,
strictMemoryLock: config.defaultsUser.strictMemoryLock,
certDuration: config.defaultsUser.certDuration,
certRenewLeadTime: config.defaultsUser.certRenewLeadTime,
},
rpc: {
callTimeoutTime: config.defaultsSystem.rpcCallTimeoutTime,
parserBufferSize: config.defaultsSystem.rpcParserBufferSize,
},
client: {
connectTimoutTime: config.defaultsSystem.clientConnectTimeoutTime,
keepAliveTimeoutTime: config.defaultsSystem.clientKeepAliveTimeoutTime,
keepAliveIntervalTime:
config.defaultsSystem.clientKeepAliveIntervalTime,
rpcCallTimeoutTime: config.defaultsSystem.rpcCallTimeoutTime,
rpcParserBufferSize: config.defaultsSystem.rpcParserBufferSize,
},
nodes: {
connectionIdleTimeoutTime:
Expand Down Expand Up @@ -181,7 +190,6 @@ class PolykeyAgent {
const dbPath = path.join(statePath, config.paths.dbBase);
const keysPath = path.join(statePath, config.paths.keysBase);
const vaultsPath = path.join(statePath, config.paths.vaultsBase);

let status: Status | undefined;
let schema: Schema | undefined;
let keyRing: KeyRing | undefined;
Expand Down Expand Up @@ -217,11 +225,16 @@ class PolykeyAgent {
});
keyRing = await KeyRing.createKeyRing({
keysPath,
options: optionsDefaulted.keys,
fs,
fresh,
password,
logger: logger.getChild(KeyRing.name),
passwordMemLimit: optionsDefaulted.keys.passwordMemLimit,
passwordOpsLimit: optionsDefaulted.keys.passwordOpsLimit,
privateKey: optionsDefaulted.keys.privateKey,
privateKeyPath: optionsDefaulted.keys.privateKeyPath,
recoveryCode: optionsDefaulted.keys.recoveryCode,
strictMemoryLock: optionsDefaulted.keys.strictMemoryLock,
});
db = await DB.createDB({
dbPath,
Expand Down Expand Up @@ -256,7 +269,8 @@ class PolykeyAgent {
db,
keyRing,
taskManager,
options: optionsDefaulted.keys,
certDuration: optionsDefaulted.keys.certDuration,
certRenewLeadTime: optionsDefaulted.keys.certRenewLeadTime,
logger: logger.getChild(CertManager.name),
fresh,
});
Expand Down Expand Up @@ -310,7 +324,20 @@ class PolykeyAgent {
nodeGraph,
tlsConfig,
seedNodes: optionsDefaulted.seedNodes,
options: optionsDefaulted.nodes,
connectionFindConcurrencyLimit:
optionsDefaulted.nodes.connectionFindConcurrencyLimit,
connectionIdleTimeoutTime:
optionsDefaulted.nodes.connectionIdleTimeoutTime,
connectionConnectTimeoutTime:
optionsDefaulted.nodes.connectionConnectTimeoutTime,
connectionKeepAliveTimeoutTime:
optionsDefaulted.nodes.connectionKeepAliveTimeoutTime,
connectionKeepAliveIntervalTime:
optionsDefaulted.nodes.connectionKeepAliveIntervalTime,
connectionHolePunchIntervalTime:
optionsDefaulted.nodes.connectionHolePunchIntervalTime,
rpcParserBufferSize: optionsDefaulted.nodes.rpcParserBufferSize,
rpcCallTimeoutTime: optionsDefaulted.nodes.rpcCallTimeoutTime,
logger: logger.getChild(NodeConnectionManager.name),
});
nodeManager = new NodeManager({
Expand Down Expand Up @@ -387,8 +414,8 @@ class PolykeyAgent {
),
keepAliveTimeoutTime: optionsDefaulted.client.keepAliveTimeoutTime,
keepAliveIntervalTime: optionsDefaulted.client.keepAliveIntervalTime,
rpcCallTimeoutTime: optionsDefaulted.rpc.callTimeoutTime,
rpcParserBufferSize: optionsDefaulted.rpc.parserBufferSize,
rpcCallTimeoutTime: optionsDefaulted.client.rpcCallTimeoutTime,
rpcParserBufferSize: optionsDefaulted.client.rpcParserBufferSize,
logger: logger.getChild(ClientService.name),
});
} catch (e) {
Expand Down Expand Up @@ -469,6 +496,7 @@ class PolykeyAgent {
public readonly fs: FileSystem;
public readonly logger: Logger;
public readonly clientService: ClientService;
public readonly privateKeyPath: string;
protected workerManager: PolykeyWorkerManagerInterface | undefined;

protected handleEventCertManagerCertChange = async (
Expand Down Expand Up @@ -585,7 +613,19 @@ class PolykeyAgent {
fresh = false,
}: {
password: string;
options?: Partial<PolykeyAgentStartOptions>;
options?: DeepPartial<{
clientServiceHost: string;
clientServicePort: number;
agentServiceHost: string;
agentServicePort: number;
ipv6Only: boolean;
workers: number;
keys:
| ObjectEmpty
| { recoveryCode: string }
| { privateKey: Buffer }
| { privateKeyPath: string };
}>;
workers?: number;
fresh?: boolean;
}) {
Expand All @@ -610,6 +650,9 @@ class PolykeyAgent {
await this.keyRing.start({
password,
fresh,
recoveryCode: optionsDefaulted.keys?.recoveryCode,
privateKey: optionsDefaulted.keys?.privateKey,
privateKeyPath: optionsDefaulted.keys?.privateKeyPath,
});
await this.db.start({
crypto: {
Expand Down
Loading