Skip to content

Commit 80aaa86

Browse files
committed
fix: align gestalt parser types with polykey
1 parent 7a7cff1 commit 80aaa86

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

npmDepsHash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sha256-XCPXt+ESgufgJBBTvy+TZBjcovFef4pW/E0f4/JaAc0=
1+
sha256-j3S6Zig9cm8n29qoJxBmj82WE6YHG2SOSFBuDhJ7xmo=

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"nexpect": "^0.6.0",
163163
"node-gyp-build": "^4.8.4",
164164
"open": "^10.1.2",
165-
"polykey": "^2.4.0",
165+
"polykey": "^2.5.0",
166166
"shelljs": "^0.8.5",
167167
"shx": "^0.3.4",
168168
"tsx": "^3.12.7",

src/auth/CommandLogin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CommandLogin extends CommandPolykey {
88
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
99
super(...args);
1010
this.name('login');
11-
this.description('Login to a platform with Polykey identity');
11+
this.description('Login to a platform with your Polykey identity');
1212
this.argument('<url>', 'The URL to login using Polykey');
1313
this.addOption(binOptions.nodeId);
1414
this.addOption(binOptions.clientHost);
@@ -70,7 +70,9 @@ class CommandLogin extends CommandPolykey {
7070

7171
// Try to open the URL in the browser
7272
try {
73-
process.stderr.write('Opening URL in browser...\n');
73+
process.stderr.write(
74+
'Attempting to open this URL in your browser...\n',
75+
);
7476
await open(targetURL.toString());
7577
} catch (e) {
7678
process.stderr.write(`Failed to open browser: ${e.message}\n`);

src/utils/parsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { GestaltAction } from 'polykey/gestalts/types.js';
12
import type { Host, Hostname, Port } from 'polykey/network/types.js';
23
import type { SeedNodes } from 'polykey/nodes/types.js';
34
import type { ParsedSecretPathValue } from '../types.js';
@@ -13,7 +14,6 @@ const vaultNameRegex = /^(?!.*[:])[ -~\t\n]*$/s;
1314
const secretPathRegex = /^(?!.*[=])[ -~\t\n]*$/s;
1415
const secretPathValueRegex = /^([a-zA-Z_][\w]+)?$/;
1516
const environmentVariableRegex = /^([a-zA-Z_]+[a-zA-Z0-9_]*)?$/;
16-
const base64UrlRegex = /^[A-Za-z0-9\-_]+$/;
1717

1818
/**
1919
* Converts a validation parser to commander argument parser
@@ -163,7 +163,7 @@ const parseIdentityId: (data: string) => ids.IdentityId =
163163
const parseProviderIdList: (data: string) => Array<ids.ProviderId> =
164164
validateParserToArgListParser(ids.parseProviderId);
165165

166-
const parseGestaltAction: (data: string) => 'notify' | 'scan' | 'claim' =
166+
const parseGestaltAction: (data: string) => GestaltAction =
167167
validateParserToArgParser(gestaltsUtils.parseGestaltAction);
168168

169169
const parseHost: (data: string) => Host = validateParserToArgParser(

tests/auth/login.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import type {
33
TokenProtectedHeaderEncoded,
44
TokenSignatureEncoded,
55
} from 'polykey/tokens/types.js';
6-
import path from 'node:path';
76
import type open from 'open';
7+
import path from 'node:path';
88
import fs from 'node:fs';
9+
import { spawn } from 'node:child_process';
910
import { jest } from '@jest/globals';
1011
import { test } from '@fast-check/jest';
11-
import { spawn } from 'node:child_process';
1212
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
1313
import PolykeyAgent from 'polykey/PolykeyAgent.js';
1414
import Token from 'polykey/tokens/Token.js';
@@ -46,6 +46,7 @@ describe('commandAuthLogin', () => {
4646
});
4747
});
4848
afterEach(async () => {
49+
jest.useRealTimers();
4950
jest.restoreAllMocks();
5051
await polykeyAgent.stop();
5152
await fs.promises.rm(dataDir, {
@@ -92,7 +93,7 @@ describe('commandAuthLogin', () => {
9293
expect(nodeId).toBeDefined();
9394
const nodeIdPublicKey = keysUtils.publicKeyFromNodeId(nodeId!);
9495
expect(receivedToken.verifyWithPublicKey(nodeIdPublicKey)).toBeTrue();
95-
expect(receivedToken.payload.exp).toBe(Math.floor(Date.now() / 1000));
96+
expect(receivedToken.payload.exp).toBe(Math.floor(Date.now() / 1000) + 60);
9697
expect(receivedToken.payload.jti).toBeDefined();
9798
});
9899
});

0 commit comments

Comments
 (0)