gdc-sdk-node-ts 2.9.21 → 2.9.23

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.
@@ -461,16 +461,14 @@ export class ServerProfileSessionManager {
461
461
  const walletKeyDerivationId = normalizedWalletKeyDerivationId(profile.walletKeyDerivationId, profile.profileId);
462
462
  const wallet = await this.createWallet(walletKeyDerivationId, seed);
463
463
  await requireRegisteredProfileKeys(wallet, walletContext(walletKeyDerivationId), profile);
464
- const updated = {
465
- ...profile,
464
+ const updated = withProfileUnlockState(profile, {
466
465
  protectedWalletSeed: await protectServerProfileSecret(seed, input.newPin, `${profile.profileId}:wallet-seed`, this.options.sealer, this.options.profileProtection),
467
466
  ...(profile.protectedVpToken ? {
468
467
  protectedVpToken: await protectServerProfileSecret(String(input.authorizedVpToken), input.newPin, `${profile.profileId}:vp-token`, this.options.sealer, this.options.profileProtection),
469
468
  } : {}),
470
469
  failedUnlocks: 0,
471
- lockedUntil: undefined,
472
470
  updatedAt: this.now().toISOString(),
473
- };
471
+ });
474
472
  await this.options.store.putProfile(updated);
475
473
  await this.options.store.deleteSessionsForProfile(profile.profileId);
476
474
  return updated;
@@ -498,7 +496,11 @@ export class ServerProfileSessionManager {
498
496
  const lockedUntil = failures >= max
499
497
  ? new Date(now.getTime() + (this.options.lockSeconds ?? 300) * 1000).toISOString()
500
498
  : undefined;
501
- await this.options.store.putProfile({ ...profile, failedUnlocks: failures, lockedUntil, updatedAt: now.toISOString() });
499
+ await this.options.store.putProfile(withProfileUnlockState(profile, {
500
+ failedUnlocks: failures,
501
+ lockedUntil,
502
+ updatedAt: now.toISOString(),
503
+ }));
502
504
  throw new Error('Profile PIN rejected.');
503
505
  }
504
506
  profile = await this.ensureRequiredStorageProfile(profile, seed);
@@ -531,7 +533,10 @@ export class ServerProfileSessionManager {
531
533
  throw new Error('SMART token exchange failed.');
532
534
  const sessionId = randomBytes(32).toString('base64url');
533
535
  const expiresAt = new Date(now.getTime() + (this.options.sessionTtlSeconds ?? 300) * 1000);
534
- await this.options.store.putProfile({ ...profile, failedUnlocks: 0, lockedUntil: undefined, updatedAt: now.toISOString() });
536
+ await this.options.store.putProfile(withProfileUnlockState(profile, {
537
+ failedUnlocks: 0,
538
+ updatedAt: now.toISOString(),
539
+ }));
535
540
  await this.options.store.putSession({
536
541
  sessionId,
537
542
  ownerId: input.ownerId,
@@ -577,22 +582,19 @@ export class ServerProfileSessionManager {
577
582
  const lockedUntil = failures >= max
578
583
  ? new Date(now.getTime() + (this.options.lockSeconds ?? 300) * 1000).toISOString()
579
584
  : undefined;
580
- await this.options.store.putProfile({
581
- ...profile,
585
+ await this.options.store.putProfile(withProfileUnlockState(profile, {
582
586
  failedUnlocks: failures,
583
587
  lockedUntil,
584
588
  updatedAt: now.toISOString(),
585
- });
589
+ }));
586
590
  throw new Error('Profile PIN rejected.');
587
591
  }
588
592
  profile = await this.ensureRequiredStorageProfile(profile, seed);
589
593
  const sessionId = randomBytes(32).toString('base64url');
590
- await this.options.store.putProfile({
591
- ...profile,
594
+ await this.options.store.putProfile(withProfileUnlockState(profile, {
592
595
  failedUnlocks: 0,
593
- lockedUntil: undefined,
594
596
  updatedAt: now.toISOString(),
595
- });
597
+ }));
596
598
  await this.options.store.putSession({
597
599
  sessionId,
598
600
  ownerId: input.ownerId,
@@ -1354,6 +1356,20 @@ function sameGovernedRole(left, right) {
1354
1356
  && leftRole.codingSystem === rightRole.codingSystem
1355
1357
  && leftRole.code === rightRole.code);
1356
1358
  }
1359
+ /**
1360
+ * Resets or advances the persisted PIN lock state without writing an
1361
+ * `undefined` optional property. Durable store adapters receive an omitted
1362
+ * `lockedUntil` field when no lock exists.
1363
+ */
1364
+ function withProfileUnlockState(profile, updates) {
1365
+ const { lockedUntil: _previousLock, ...unlockedProfile } = profile;
1366
+ const { lockedUntil, ...definedUpdates } = updates;
1367
+ return {
1368
+ ...unlockedProfile,
1369
+ ...definedUpdates,
1370
+ ...(lockedUntil ? { lockedUntil } : {}),
1371
+ };
1372
+ }
1357
1373
  function unique(values) {
1358
1374
  return [...new Set(values.map((value) => String(value).trim()).filter(Boolean))].sort();
1359
1375
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-node-ts",
3
- "version": "2.9.21",
3
+ "version": "2.9.23",
4
4
  "description": "Next-generation Node runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",