Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding privateKeyPath back to PolykeyAgent #600

Merged
merged 1 commit into from
Oct 24, 2023
Merged
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
4 changes: 3 additions & 1 deletion src/PolykeyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DeepPartial, FileSystem } from './types';
import type { PolykeyWorkerManagerInterface } from './workers/types';
import type { TLSConfig } from './network/types';
import type { SeedNodes } from './nodes/types';
import type { Key, PasswordOpsLimit, PasswordMemLimit } from './keys/types';
import type { Key, PasswordOpsLimit, PasswordMemLimit, PrivateKey } from "./keys/types";
import path from 'path';
import process from 'process';
import Logger from '@matrixai/logger';
Expand Down Expand Up @@ -61,6 +61,8 @@ type PolykeyAgentOptions = {
certDuration: number;
certRenewLeadTime: number;
recoveryCode: string;
privateKeyPath: string;
addievo marked this conversation as resolved.
Show resolved Hide resolved
privateKey: PrivateKey;
Comment on lines +64 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The privateKey: PrivateKey should be using a more open type, instead the opaque type because of PolykeyAgent taking parameters from outside world.

So if you want to keep this then you should be using privateKey: Buffer.

Also privateKey should be moved up top.

privateKey: Buffer;
privateKeyPath: string;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 options aren't even being used, if these 2 options are to be used, they should be passed to the KeyRing.createKeyRing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addievo link the new PR to fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PolykeyAgent.start should be taking DeepPartial of options, and the options need to keys: { recoveryCode; privateKey; privateKeyPath; }.

And also in the KeyRing.createKeyRing and KeyRing.start methods, these need to receive those options if you want to make them useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the PolykeyAgentOptions needs to match:

  } & ( // eslint-disable-next-line @typescript-eslint/ban-types
    | {}
    | {
        recoveryCode: RecoveryCode;
      }
    | {
        privateKey: PrivateKey;
      }
    | {
        privateKeyPath: string;
      }

Which ensures mutually independent options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So:

keys: ({} | { recoveryCode: string; } | { privateKey: Buffer } | { privateKeyPath: string })

And PolykeyAgent.start should take this.

};
client: {
keepAliveTimeoutTime: number;
Expand Down