Skip to content

Commit 8686e3d

Browse files
authored
Merge pull request #56 from powersync-ja/test-client-local-endpoint
[test-client] Include endpoint as additional audience
2 parents 0c253a6 + 68e3385 commit 8686e3d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

test-client/src/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function getCredentials(options: CredentialsOptions): Promise<{ end
3737
endpoint = `http://127.0.0.1:${parsed.port ?? 8080}`;
3838
}
3939

40-
const aud = parsed.client_auth?.audience?.[0] ?? endpoint;
40+
const aud = [parsed.client_auth?.audience?.[0], endpoint].filter((a) => a != null);
4141

4242
const rawKey = keys[0];
4343
const key = await jose.importJWK(rawKey);
@@ -50,7 +50,7 @@ export async function getCredentials(options: CredentialsOptions): Promise<{ end
5050
.setIssuedAt()
5151
.setIssuer('test-client')
5252
.setAudience(aud)
53-
.setExpirationTime('1h')
53+
.setExpirationTime('24h')
5454
.sign(key);
5555

5656
return { token, endpoint };

test-client/src/bin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ program
2020
.command('generate-token')
2121
.description('Generate a JWT from for a given powersync.yaml config file')
2222
.option('-c, --config [config]', 'path to powersync.yaml')
23-
.option('-u, --sub [sub]', 'sub field for auto-generated token')
23+
.option('-u, --sub [sub]', 'payload sub')
24+
.option('-e, --endpoint [endpoint]', 'additional payload aud')
2425
.action(async (options) => {
2526
const credentials = await getCredentials(options);
2627
const decoded = await jose.decodeJwt(credentials.token);

0 commit comments

Comments
 (0)