@powersync/service-core 0.0.0-dev-20241219153510 → 0.0.0-dev-20250108073049

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,17 @@ const privateKeyEdDSA: jose.JWK = {
40
40
  alg: 'EdDSA'
41
41
  };
42
42
 
43
+ const privateKeyECDSA: jose.JWK = {
44
+ use: 'sig',
45
+ kty: 'EC',
46
+ crv: 'P-256',
47
+ kid: 'k3',
48
+ x: 'Y37HQjG1YvlQZ16CzO7UQxgkY_us-NfPxMPcHUDN-PE',
49
+ y: 'W3Jqs5_qlIh2UH79l8L3ApqNu14aFetM5oc9oCjAEaw',
50
+ d: 'p2HQaJApdgaAemVuVsL1hscCFOTd0r9uGxRnzvAelFU',
51
+ alg: 'ES256'
52
+ };
53
+
43
54
  describe('JWT Auth', () => {
44
55
  test('KeyStore basics', async () => {
45
56
  const keys = await StaticKeyCollector.importKeys([sharedKey]);
@@ -372,4 +383,26 @@ describe('JWT Auth', () => {
372
383
 
373
384
  expect(verified.claim).toEqual('test-claim');
374
385
  });
386
+
387
+ test('signing with ECDSA', async () => {
388
+ const keys = await StaticKeyCollector.importKeys([privateKeyECDSA]);
389
+ const store = new KeyStore(keys);
390
+ const signKey = (await jose.importJWK(privateKeyECDSA)) as jose.KeyLike;
391
+
392
+ const signedJwt = await new jose.SignJWT({ claim: 'test-claim-2' })
393
+ .setProtectedHeader({ alg: 'ES256', kid: 'k3' })
394
+ .setSubject('f1')
395
+ .setIssuedAt()
396
+ .setIssuer('tester')
397
+ .setAudience('tests')
398
+ .setExpirationTime('5m')
399
+ .sign(signKey);
400
+
401
+ const verified = (await store.verifyJwt(signedJwt, {
402
+ defaultAudiences: ['tests'],
403
+ maxAge: '6m'
404
+ })) as JwtPayload & { claim: string };
405
+
406
+ expect(verified.claim).toEqual('test-claim-2');
407
+ });
375
408
  });
@@ -20,7 +20,12 @@ vi.mock('@powersync/lib-services-framework', () => ({
20
20
  afterSend: () => Promise<void>;
21
21
  __micro_router_response = true;
22
22
 
23
- constructor({ status, data, headers, afterSend }: {
23
+ constructor({
24
+ status,
25
+ data,
26
+ headers,
27
+ afterSend
28
+ }: {
24
29
  status?: number;
25
30
  data: any;
26
31
  headers?: Record<string, string>;