@dnsid-ai/sdk 0.27.0 → 0.28.0

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.
package/dist/index.d.cts CHANGED
@@ -28,7 +28,8 @@ interface RotateManagedOperationalKeyOptions {
28
28
  idempotencyKey: string;
29
29
  /** Durably persists exact bytes and every subsequent reconciliation state. */
30
30
  persistRotation: (rotation: ManagedKeyRotationResult) => Promise<void>;
31
- /** Pauses application signing before submission and resumes it only after durable activation. */
31
+ /** Blocks new application signing and drains in-flight request/directory signing before resolving;
32
+ * resumes signing only after durable activation. */
32
33
  setApplicationSigningPaused: (paused: boolean) => Promise<void>;
33
34
  }
34
35
  interface ManagedKeyRotationResult {
package/dist/index.d.ts CHANGED
@@ -28,7 +28,8 @@ interface RotateManagedOperationalKeyOptions {
28
28
  idempotencyKey: string;
29
29
  /** Durably persists exact bytes and every subsequent reconciliation state. */
30
30
  persistRotation: (rotation: ManagedKeyRotationResult) => Promise<void>;
31
- /** Pauses application signing before submission and resumes it only after durable activation. */
31
+ /** Blocks new application signing and drains in-flight request/directory signing before resolving;
32
+ * resumes signing only after durable activation. */
32
33
  setApplicationSigningPaused: (paused: boolean) => Promise<void>;
33
34
  }
34
35
  interface ManagedKeyRotationResult {
package/dist/node.cjs CHANGED
@@ -66,6 +66,8 @@ async function readJson(filePath) {
66
66
  // src/local-key-provider.ts
67
67
  var LocalKeyProvider = class _LocalKeyProvider {
68
68
  store;
69
+ signing = /* @__PURE__ */ new Set();
70
+ activating = false;
69
71
  filePath;
70
72
  // ponytail: per-instance queue; use a cross-process lock and reload before writes if shared writers are needed.
71
73
  mutations = Promise.resolve();
@@ -144,6 +146,16 @@ var LocalKeyProvider = class _LocalKeyProvider {
144
146
  return this.signKey(this.store.active.kid, payload);
145
147
  }
146
148
  async signKey(kid, payload) {
149
+ if (this.activating) throw new import_protocol.ArgumentError("key activation is in progress");
150
+ const operation = this.signWithKey(kid, payload);
151
+ this.signing.add(operation);
152
+ try {
153
+ return await operation;
154
+ } finally {
155
+ this.signing.delete(operation);
156
+ }
157
+ }
158
+ async signWithKey(kid, payload) {
147
159
  const key = kid === this.store.active.kid ? this.store.active : this.store.pending.find((candidate) => candidate.kid === kid);
148
160
  if (!key) throw new import_protocol.ArgumentError(`key is not active or pending for signing: ${kid}`);
149
161
  const cryptoKey = await importPrivateKey(key);
@@ -158,13 +170,20 @@ var LocalKeyProvider = class _LocalKeyProvider {
158
170
  });
159
171
  }
160
172
  async activate(kid) {
161
- await this.mutate((next) => {
162
- const idx = next.pending.findIndex((k) => k.kid === kid);
163
- if (idx === -1) throw new import_protocol.ArgumentError(`no pending key with kid "${kid}"`);
164
- const [incoming] = next.pending.splice(idx, 1);
165
- next.retained.push(next.active);
166
- next.active = incoming;
167
- });
173
+ if (this.activating) throw new import_protocol.ArgumentError("key activation is already in progress");
174
+ this.activating = true;
175
+ try {
176
+ await Promise.allSettled(this.signing);
177
+ await this.mutate((next) => {
178
+ const idx = next.pending.findIndex((k) => k.kid === kid);
179
+ if (idx === -1) throw new import_protocol.ArgumentError(`no pending key with kid "${kid}"`);
180
+ const [incoming] = next.pending.splice(idx, 1);
181
+ next.retained.push(next.active);
182
+ next.active = incoming;
183
+ });
184
+ } finally {
185
+ this.activating = false;
186
+ }
168
187
  }
169
188
  async supersede(kid) {
170
189
  await this.mutate((next) => {
package/dist/node.d.cts CHANGED
@@ -19,6 +19,8 @@ type LocalKeyAlgorithm = 'EdDSA' | 'ES256';
19
19
  */
20
20
  declare class LocalKeyProvider implements KeyProvider {
21
21
  private store;
22
+ private readonly signing;
23
+ private activating;
22
24
  private readonly filePath;
23
25
  private mutations;
24
26
  private constructor();
@@ -33,6 +35,7 @@ declare class LocalKeyProvider implements KeyProvider {
33
35
  listKeyIds(): Promise<string[]>;
34
36
  sign(payload: Uint8Array): Promise<Uint8Array>;
35
37
  signKey(kid: string, payload: Uint8Array): Promise<Uint8Array>;
38
+ private signWithKey;
36
39
  generateKey(): Promise<string>;
37
40
  activate(kid: string): Promise<void>;
38
41
  supersede(kid: string): Promise<void>;
package/dist/node.d.ts CHANGED
@@ -19,6 +19,8 @@ type LocalKeyAlgorithm = 'EdDSA' | 'ES256';
19
19
  */
20
20
  declare class LocalKeyProvider implements KeyProvider {
21
21
  private store;
22
+ private readonly signing;
23
+ private activating;
22
24
  private readonly filePath;
23
25
  private mutations;
24
26
  private constructor();
@@ -33,6 +35,7 @@ declare class LocalKeyProvider implements KeyProvider {
33
35
  listKeyIds(): Promise<string[]>;
34
36
  sign(payload: Uint8Array): Promise<Uint8Array>;
35
37
  signKey(kid: string, payload: Uint8Array): Promise<Uint8Array>;
38
+ private signWithKey;
36
39
  generateKey(): Promise<string>;
37
40
  activate(kid: string): Promise<void>;
38
41
  supersede(kid: string): Promise<void>;
package/dist/node.js CHANGED
@@ -19,6 +19,8 @@ async function readJson(filePath) {
19
19
  // src/local-key-provider.ts
20
20
  var LocalKeyProvider = class _LocalKeyProvider {
21
21
  store;
22
+ signing = /* @__PURE__ */ new Set();
23
+ activating = false;
22
24
  filePath;
23
25
  // ponytail: per-instance queue; use a cross-process lock and reload before writes if shared writers are needed.
24
26
  mutations = Promise.resolve();
@@ -97,6 +99,16 @@ var LocalKeyProvider = class _LocalKeyProvider {
97
99
  return this.signKey(this.store.active.kid, payload);
98
100
  }
99
101
  async signKey(kid, payload) {
102
+ if (this.activating) throw new ArgumentError("key activation is in progress");
103
+ const operation = this.signWithKey(kid, payload);
104
+ this.signing.add(operation);
105
+ try {
106
+ return await operation;
107
+ } finally {
108
+ this.signing.delete(operation);
109
+ }
110
+ }
111
+ async signWithKey(kid, payload) {
100
112
  const key = kid === this.store.active.kid ? this.store.active : this.store.pending.find((candidate) => candidate.kid === kid);
101
113
  if (!key) throw new ArgumentError(`key is not active or pending for signing: ${kid}`);
102
114
  const cryptoKey = await importPrivateKey(key);
@@ -111,13 +123,20 @@ var LocalKeyProvider = class _LocalKeyProvider {
111
123
  });
112
124
  }
113
125
  async activate(kid) {
114
- await this.mutate((next) => {
115
- const idx = next.pending.findIndex((k) => k.kid === kid);
116
- if (idx === -1) throw new ArgumentError(`no pending key with kid "${kid}"`);
117
- const [incoming] = next.pending.splice(idx, 1);
118
- next.retained.push(next.active);
119
- next.active = incoming;
120
- });
126
+ if (this.activating) throw new ArgumentError("key activation is already in progress");
127
+ this.activating = true;
128
+ try {
129
+ await Promise.allSettled(this.signing);
130
+ await this.mutate((next) => {
131
+ const idx = next.pending.findIndex((k) => k.kid === kid);
132
+ if (idx === -1) throw new ArgumentError(`no pending key with kid "${kid}"`);
133
+ const [incoming] = next.pending.splice(idx, 1);
134
+ next.retained.push(next.active);
135
+ next.active = incoming;
136
+ });
137
+ } finally {
138
+ this.activating = false;
139
+ }
121
140
  }
122
141
  async supersede(kid) {
123
142
  await this.mutate((next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnsid-ai/sdk",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Runtime-neutral DNSid SDK entrypoint with optional Node.js convenience helpers.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -39,16 +39,16 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@dnsid-ai/protocol": "^0.27.0",
43
- "@dnsid-ai/http-signatures": "^0.27.0",
44
- "@dnsid-ai/jose": "^0.27.0",
45
- "@dnsid-ai/log-c2sp-tlog": "^0.27.0",
46
- "@dnsid-ai/registry": "^0.27.0",
47
- "@dnsid-ai/web-bot-auth": "^0.27.0"
42
+ "@dnsid-ai/protocol": "^0.28.0",
43
+ "@dnsid-ai/http-signatures": "^0.28.0",
44
+ "@dnsid-ai/jose": "^0.28.0",
45
+ "@dnsid-ai/log-c2sp-tlog": "^0.28.0",
46
+ "@dnsid-ai/registry": "^0.28.0",
47
+ "@dnsid-ai/web-bot-auth": "^0.28.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@dnsid-ai/key-aws": "^0.27.0",
51
- "@dnsid-ai/transport": "^0.27.0"
50
+ "@dnsid-ai/key-aws": "^0.28.0",
51
+ "@dnsid-ai/transport": "^0.28.0"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
54
  "@dnsid-ai/key-aws": {