agentmail 0.5.16 → 0.5.18

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.
Files changed (132) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +94 -0
  3. package/dist/cjs/api/resources/apiKeys/client/Client.js +372 -0
  4. package/dist/cjs/api/resources/apiKeys/client/requests/ListPublicKeysRequest.d.ts +10 -0
  5. package/dist/cjs/api/resources/apiKeys/client/requests/ListPublicKeysRequest.js +3 -0
  6. package/dist/cjs/api/resources/apiKeys/client/requests/RevokeAllAgentIdSignInKeysRequest.d.ts +10 -0
  7. package/dist/cjs/api/resources/apiKeys/client/requests/RevokeAllAgentIdSignInKeysRequest.js +3 -0
  8. package/dist/cjs/api/resources/apiKeys/client/requests/index.d.ts +2 -0
  9. package/dist/cjs/api/resources/apiKeys/types/ApiKeyPermissions.d.ts +8 -6
  10. package/dist/cjs/api/resources/apiKeys/types/CreatePublicKeyRequest.d.ts +21 -0
  11. package/dist/cjs/api/resources/apiKeys/types/CreatePublicKeyRequest.js +3 -0
  12. package/dist/cjs/api/resources/apiKeys/types/InboxPublicKeyScope.d.ts +7 -0
  13. package/dist/cjs/api/resources/apiKeys/types/InboxPublicKeyScope.js +3 -0
  14. package/dist/cjs/api/resources/apiKeys/types/ListPublicKeysResponse.d.ts +7 -0
  15. package/dist/cjs/api/resources/apiKeys/types/ListPublicKeysResponse.js +3 -0
  16. package/dist/cjs/api/resources/apiKeys/types/OrganizationPublicKeyScope.d.ts +4 -0
  17. package/dist/cjs/api/resources/apiKeys/types/OrganizationPublicKeyScope.js +3 -0
  18. package/dist/cjs/api/resources/apiKeys/types/PodPublicKeyScope.d.ts +7 -0
  19. package/dist/cjs/api/resources/apiKeys/types/PodPublicKeyScope.js +3 -0
  20. package/dist/cjs/api/resources/apiKeys/types/PublicJwk.d.ts +13 -0
  21. package/dist/cjs/api/resources/apiKeys/types/PublicJwk.js +3 -0
  22. package/dist/cjs/api/resources/apiKeys/types/PublicJwkCoordinate.d.ts +4 -0
  23. package/dist/cjs/api/resources/apiKeys/types/PublicJwkCoordinate.js +3 -0
  24. package/dist/cjs/api/resources/apiKeys/types/PublicKeyCredential.d.ts +22 -0
  25. package/dist/cjs/api/resources/apiKeys/types/PublicKeyCredential.js +3 -0
  26. package/dist/cjs/api/resources/apiKeys/types/PublicKeyMaterial.d.ts +9 -0
  27. package/dist/cjs/api/resources/apiKeys/types/PublicKeyMaterial.js +3 -0
  28. package/dist/cjs/api/resources/apiKeys/types/PublicKeyScope.d.ts +16 -0
  29. package/dist/cjs/api/resources/apiKeys/types/PublicKeyScope.js +3 -0
  30. package/dist/cjs/api/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.d.ts +8 -0
  31. package/dist/cjs/api/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.js +3 -0
  32. package/dist/cjs/api/resources/apiKeys/types/UpdatePublicKeyNameRequest.d.ts +7 -0
  33. package/dist/cjs/api/resources/apiKeys/types/UpdatePublicKeyNameRequest.js +3 -0
  34. package/dist/cjs/api/resources/apiKeys/types/index.d.ts +12 -0
  35. package/dist/cjs/api/resources/apiKeys/types/index.js +12 -0
  36. package/dist/cjs/serialization/resources/apiKeys/types/ApiKeyPermissions.d.ts +3 -2
  37. package/dist/cjs/serialization/resources/apiKeys/types/ApiKeyPermissions.js +3 -2
  38. package/dist/cjs/serialization/resources/apiKeys/types/CreatePublicKeyRequest.d.ts +14 -0
  39. package/dist/cjs/serialization/resources/apiKeys/types/CreatePublicKeyRequest.js +46 -0
  40. package/dist/cjs/serialization/resources/apiKeys/types/InboxPublicKeyScope.d.ts +9 -0
  41. package/dist/cjs/serialization/resources/apiKeys/types/InboxPublicKeyScope.js +41 -0
  42. package/dist/cjs/serialization/resources/apiKeys/types/ListPublicKeysResponse.d.ts +14 -0
  43. package/dist/cjs/serialization/resources/apiKeys/types/ListPublicKeysResponse.js +46 -0
  44. package/dist/cjs/serialization/resources/apiKeys/types/OrganizationPublicKeyScope.d.ts +7 -0
  45. package/dist/cjs/serialization/resources/apiKeys/types/OrganizationPublicKeyScope.js +39 -0
  46. package/dist/cjs/serialization/resources/apiKeys/types/PodPublicKeyScope.d.ts +9 -0
  47. package/dist/cjs/serialization/resources/apiKeys/types/PodPublicKeyScope.js +41 -0
  48. package/dist/cjs/serialization/resources/apiKeys/types/PublicJwk.d.ts +13 -0
  49. package/dist/cjs/serialization/resources/apiKeys/types/PublicJwk.js +45 -0
  50. package/dist/cjs/serialization/resources/apiKeys/types/PublicJwkCoordinate.d.ts +7 -0
  51. package/dist/cjs/serialization/resources/apiKeys/types/PublicJwkCoordinate.js +39 -0
  52. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyCredential.d.ts +20 -0
  53. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyCredential.js +52 -0
  54. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyMaterial.d.ts +11 -0
  55. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyMaterial.js +43 -0
  56. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyScope.d.ts +19 -0
  57. package/dist/cjs/serialization/resources/apiKeys/types/PublicKeyScope.js +51 -0
  58. package/dist/cjs/serialization/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.d.ts +11 -0
  59. package/dist/cjs/serialization/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.js +43 -0
  60. package/dist/cjs/serialization/resources/apiKeys/types/UpdatePublicKeyNameRequest.d.ts +9 -0
  61. package/dist/cjs/serialization/resources/apiKeys/types/UpdatePublicKeyNameRequest.js +41 -0
  62. package/dist/cjs/serialization/resources/apiKeys/types/index.d.ts +12 -0
  63. package/dist/cjs/serialization/resources/apiKeys/types/index.js +12 -0
  64. package/dist/cjs/version.d.ts +1 -1
  65. package/dist/cjs/version.js +1 -1
  66. package/dist/esm/BaseClient.mjs +2 -2
  67. package/dist/esm/api/resources/apiKeys/client/Client.d.mts +94 -0
  68. package/dist/esm/api/resources/apiKeys/client/Client.mjs +373 -1
  69. package/dist/esm/api/resources/apiKeys/client/requests/ListPublicKeysRequest.d.mts +10 -0
  70. package/dist/esm/api/resources/apiKeys/client/requests/ListPublicKeysRequest.mjs +2 -0
  71. package/dist/esm/api/resources/apiKeys/client/requests/RevokeAllAgentIdSignInKeysRequest.d.mts +10 -0
  72. package/dist/esm/api/resources/apiKeys/client/requests/RevokeAllAgentIdSignInKeysRequest.mjs +2 -0
  73. package/dist/esm/api/resources/apiKeys/client/requests/index.d.mts +2 -0
  74. package/dist/esm/api/resources/apiKeys/types/ApiKeyPermissions.d.mts +8 -6
  75. package/dist/esm/api/resources/apiKeys/types/CreatePublicKeyRequest.d.mts +21 -0
  76. package/dist/esm/api/resources/apiKeys/types/CreatePublicKeyRequest.mjs +2 -0
  77. package/dist/esm/api/resources/apiKeys/types/InboxPublicKeyScope.d.mts +7 -0
  78. package/dist/esm/api/resources/apiKeys/types/InboxPublicKeyScope.mjs +2 -0
  79. package/dist/esm/api/resources/apiKeys/types/ListPublicKeysResponse.d.mts +7 -0
  80. package/dist/esm/api/resources/apiKeys/types/ListPublicKeysResponse.mjs +2 -0
  81. package/dist/esm/api/resources/apiKeys/types/OrganizationPublicKeyScope.d.mts +4 -0
  82. package/dist/esm/api/resources/apiKeys/types/OrganizationPublicKeyScope.mjs +2 -0
  83. package/dist/esm/api/resources/apiKeys/types/PodPublicKeyScope.d.mts +7 -0
  84. package/dist/esm/api/resources/apiKeys/types/PodPublicKeyScope.mjs +2 -0
  85. package/dist/esm/api/resources/apiKeys/types/PublicJwk.d.mts +13 -0
  86. package/dist/esm/api/resources/apiKeys/types/PublicJwk.mjs +2 -0
  87. package/dist/esm/api/resources/apiKeys/types/PublicJwkCoordinate.d.mts +4 -0
  88. package/dist/esm/api/resources/apiKeys/types/PublicJwkCoordinate.mjs +2 -0
  89. package/dist/esm/api/resources/apiKeys/types/PublicKeyCredential.d.mts +22 -0
  90. package/dist/esm/api/resources/apiKeys/types/PublicKeyCredential.mjs +2 -0
  91. package/dist/esm/api/resources/apiKeys/types/PublicKeyMaterial.d.mts +9 -0
  92. package/dist/esm/api/resources/apiKeys/types/PublicKeyMaterial.mjs +2 -0
  93. package/dist/esm/api/resources/apiKeys/types/PublicKeyScope.d.mts +16 -0
  94. package/dist/esm/api/resources/apiKeys/types/PublicKeyScope.mjs +2 -0
  95. package/dist/esm/api/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.d.mts +8 -0
  96. package/dist/esm/api/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.mjs +2 -0
  97. package/dist/esm/api/resources/apiKeys/types/UpdatePublicKeyNameRequest.d.mts +7 -0
  98. package/dist/esm/api/resources/apiKeys/types/UpdatePublicKeyNameRequest.mjs +2 -0
  99. package/dist/esm/api/resources/apiKeys/types/index.d.mts +12 -0
  100. package/dist/esm/api/resources/apiKeys/types/index.mjs +12 -0
  101. package/dist/esm/serialization/resources/apiKeys/types/ApiKeyPermissions.d.mts +3 -2
  102. package/dist/esm/serialization/resources/apiKeys/types/ApiKeyPermissions.mjs +3 -2
  103. package/dist/esm/serialization/resources/apiKeys/types/CreatePublicKeyRequest.d.mts +14 -0
  104. package/dist/esm/serialization/resources/apiKeys/types/CreatePublicKeyRequest.mjs +10 -0
  105. package/dist/esm/serialization/resources/apiKeys/types/InboxPublicKeyScope.d.mts +9 -0
  106. package/dist/esm/serialization/resources/apiKeys/types/InboxPublicKeyScope.mjs +5 -0
  107. package/dist/esm/serialization/resources/apiKeys/types/ListPublicKeysResponse.d.mts +14 -0
  108. package/dist/esm/serialization/resources/apiKeys/types/ListPublicKeysResponse.mjs +10 -0
  109. package/dist/esm/serialization/resources/apiKeys/types/OrganizationPublicKeyScope.d.mts +7 -0
  110. package/dist/esm/serialization/resources/apiKeys/types/OrganizationPublicKeyScope.mjs +3 -0
  111. package/dist/esm/serialization/resources/apiKeys/types/PodPublicKeyScope.d.mts +9 -0
  112. package/dist/esm/serialization/resources/apiKeys/types/PodPublicKeyScope.mjs +5 -0
  113. package/dist/esm/serialization/resources/apiKeys/types/PublicJwk.d.mts +13 -0
  114. package/dist/esm/serialization/resources/apiKeys/types/PublicJwk.mjs +9 -0
  115. package/dist/esm/serialization/resources/apiKeys/types/PublicJwkCoordinate.d.mts +7 -0
  116. package/dist/esm/serialization/resources/apiKeys/types/PublicJwkCoordinate.mjs +3 -0
  117. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyCredential.d.mts +20 -0
  118. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyCredential.mjs +16 -0
  119. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyMaterial.d.mts +11 -0
  120. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyMaterial.mjs +7 -0
  121. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyScope.d.mts +19 -0
  122. package/dist/esm/serialization/resources/apiKeys/types/PublicKeyScope.mjs +15 -0
  123. package/dist/esm/serialization/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.d.mts +11 -0
  124. package/dist/esm/serialization/resources/apiKeys/types/RevokeAllAgentIdSignInKeysResponse.mjs +7 -0
  125. package/dist/esm/serialization/resources/apiKeys/types/UpdatePublicKeyNameRequest.d.mts +9 -0
  126. package/dist/esm/serialization/resources/apiKeys/types/UpdatePublicKeyNameRequest.mjs +5 -0
  127. package/dist/esm/serialization/resources/apiKeys/types/index.d.mts +12 -0
  128. package/dist/esm/serialization/resources/apiKeys/types/index.mjs +12 -0
  129. package/dist/esm/version.d.mts +1 -1
  130. package/dist/esm/version.mjs +1 -1
  131. package/package.json +1 -1
  132. package/reference.md +350 -0
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
- import { mergeHeaders } from "../../../../core/headers.mjs";
12
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
13
13
  import * as core from "../../../../core/index.mjs";
14
14
  import * as environments from "../../../../environments.mjs";
15
15
  import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
@@ -211,4 +211,376 @@ export class ApiKeysClient {
211
211
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v0/api-keys/{api_key_id}");
212
212
  });
213
213
  }
214
+ /**
215
+ * List only public-key credentials visible to the bearer caller's scope.
216
+ * Bearer credentials are never returned, even though both credential types
217
+ * share storage and pagination indexes. Requires `api_key_read`.
218
+ *
219
+ * @param {AgentMail.ListPublicKeysRequest} request
220
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
221
+ *
222
+ * @example
223
+ * await client.apiKeys.listPublicKeys()
224
+ */
225
+ listPublicKeys(request = {}, requestOptions) {
226
+ return core.HttpResponsePromise.fromPromise(this.__listPublicKeys(request, requestOptions));
227
+ }
228
+ __listPublicKeys() {
229
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
230
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
231
+ const { limit, pageToken, ascending } = request;
232
+ const _queryParams = {
233
+ limit,
234
+ page_token: pageToken,
235
+ ascending,
236
+ };
237
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
238
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
239
+ const _response = yield core.fetcher({
240
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
241
+ .http, "/v0/api-keys/public-keys"),
242
+ method: "GET",
243
+ headers: _headers,
244
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
245
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
246
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
247
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
248
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
249
+ logging: this._options.logging,
250
+ });
251
+ if (_response.ok) {
252
+ return {
253
+ data: serializers.ListPublicKeysResponse.parseOrThrow(_response.body, {
254
+ unrecognizedObjectKeys: "passthrough",
255
+ allowUnrecognizedUnionMembers: true,
256
+ allowUnrecognizedEnumValues: true,
257
+ skipValidation: true,
258
+ breadcrumbsPrefix: ["response"],
259
+ }),
260
+ rawResponse: _response.rawResponse,
261
+ };
262
+ }
263
+ if (_response.error.reason === "status-code") {
264
+ throw new errors.AgentMailError({
265
+ statusCode: _response.error.statusCode,
266
+ body: _response.error.body,
267
+ rawResponse: _response.rawResponse,
268
+ });
269
+ }
270
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v0/api-keys/public-keys");
271
+ });
272
+ }
273
+ /**
274
+ * Register a public P-256 JWK using an existing AgentMail bearer API key
275
+ * with `api_key_create`. Re-registering the same JWK creates a new
276
+ * credential ID; it does not replace or recover an earlier credential.
277
+ * The private key must never be sent to AgentMail.
278
+ *
279
+ * @param {AgentMail.CreatePublicKeyRequest} request
280
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
281
+ *
282
+ * @throws {@link AgentMail.ValidationError}
283
+ * @throws {@link AgentMail.ConflictError}
284
+ *
285
+ * @example
286
+ * await client.apiKeys.createPublicKey({
287
+ * publicKey: {
288
+ * kty: "EC",
289
+ * crv: "P-256",
290
+ * x: "blackcurrant...............................",
291
+ * y: "blackcurrant..............................."
292
+ * }
293
+ * })
294
+ */
295
+ createPublicKey(request, requestOptions) {
296
+ return core.HttpResponsePromise.fromPromise(this.__createPublicKey(request, requestOptions));
297
+ }
298
+ __createPublicKey(request, requestOptions) {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
301
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
302
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
303
+ const _response = yield core.fetcher({
304
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
305
+ .http, "/v0/api-keys/public-keys"),
306
+ method: "POST",
307
+ headers: _headers,
308
+ contentType: "application/json",
309
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
310
+ requestType: "json",
311
+ body: serializers.CreatePublicKeyRequest.jsonOrThrow(request, {
312
+ unrecognizedObjectKeys: "strip",
313
+ omitUndefined: true,
314
+ }),
315
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
316
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
317
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
318
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
319
+ logging: this._options.logging,
320
+ });
321
+ if (_response.ok) {
322
+ return {
323
+ data: serializers.PublicKeyCredential.parseOrThrow(_response.body, {
324
+ unrecognizedObjectKeys: "passthrough",
325
+ allowUnrecognizedUnionMembers: true,
326
+ allowUnrecognizedEnumValues: true,
327
+ skipValidation: true,
328
+ breadcrumbsPrefix: ["response"],
329
+ }),
330
+ rawResponse: _response.rawResponse,
331
+ };
332
+ }
333
+ if (_response.error.reason === "status-code") {
334
+ switch (_response.error.statusCode) {
335
+ case 400:
336
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
337
+ unrecognizedObjectKeys: "passthrough",
338
+ allowUnrecognizedUnionMembers: true,
339
+ allowUnrecognizedEnumValues: true,
340
+ skipValidation: true,
341
+ breadcrumbsPrefix: ["response"],
342
+ }), _response.rawResponse);
343
+ case 409:
344
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
345
+ unrecognizedObjectKeys: "passthrough",
346
+ allowUnrecognizedUnionMembers: true,
347
+ allowUnrecognizedEnumValues: true,
348
+ skipValidation: true,
349
+ breadcrumbsPrefix: ["response"],
350
+ }), _response.rawResponse);
351
+ default:
352
+ throw new errors.AgentMailError({
353
+ statusCode: _response.error.statusCode,
354
+ body: _response.error.body,
355
+ rawResponse: _response.rawResponse,
356
+ });
357
+ }
358
+ }
359
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/api-keys/public-keys");
360
+ });
361
+ }
362
+ /**
363
+ * Rename the credential. All security-relevant fields are immutable.
364
+ * Requires `api_key_update`.
365
+ *
366
+ * @param {string} api_key_id - Public-key credential ID returned by registration.
367
+ * @param {AgentMail.UpdatePublicKeyNameRequest} request
368
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
369
+ *
370
+ * @throws {@link AgentMail.ValidationError}
371
+ * @throws {@link AgentMail.NotFoundError}
372
+ *
373
+ * @example
374
+ * await client.apiKeys.updatePublicKeyName("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", {
375
+ * name: "x"
376
+ * })
377
+ */
378
+ updatePublicKeyName(api_key_id, request, requestOptions) {
379
+ return core.HttpResponsePromise.fromPromise(this.__updatePublicKeyName(api_key_id, request, requestOptions));
380
+ }
381
+ __updatePublicKeyName(api_key_id, request, requestOptions) {
382
+ return __awaiter(this, void 0, void 0, function* () {
383
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
384
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
385
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
386
+ const _response = yield core.fetcher({
387
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
388
+ .http, `/v0/api-keys/public-keys/${core.url.encodePathParam(api_key_id)}`),
389
+ method: "PATCH",
390
+ headers: _headers,
391
+ contentType: "application/json",
392
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
393
+ requestType: "json",
394
+ body: serializers.UpdatePublicKeyNameRequest.jsonOrThrow(request, {
395
+ unrecognizedObjectKeys: "strip",
396
+ omitUndefined: true,
397
+ }),
398
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
399
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
400
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
401
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
402
+ logging: this._options.logging,
403
+ });
404
+ if (_response.ok) {
405
+ return {
406
+ data: serializers.PublicKeyCredential.parseOrThrow(_response.body, {
407
+ unrecognizedObjectKeys: "passthrough",
408
+ allowUnrecognizedUnionMembers: true,
409
+ allowUnrecognizedEnumValues: true,
410
+ skipValidation: true,
411
+ breadcrumbsPrefix: ["response"],
412
+ }),
413
+ rawResponse: _response.rawResponse,
414
+ };
415
+ }
416
+ if (_response.error.reason === "status-code") {
417
+ switch (_response.error.statusCode) {
418
+ case 400:
419
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
420
+ unrecognizedObjectKeys: "passthrough",
421
+ allowUnrecognizedUnionMembers: true,
422
+ allowUnrecognizedEnumValues: true,
423
+ skipValidation: true,
424
+ breadcrumbsPrefix: ["response"],
425
+ }), _response.rawResponse);
426
+ case 404:
427
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
428
+ unrecognizedObjectKeys: "passthrough",
429
+ allowUnrecognizedUnionMembers: true,
430
+ allowUnrecognizedEnumValues: true,
431
+ skipValidation: true,
432
+ breadcrumbsPrefix: ["response"],
433
+ }), _response.rawResponse);
434
+ default:
435
+ throw new errors.AgentMailError({
436
+ statusCode: _response.error.statusCode,
437
+ body: _response.error.body,
438
+ rawResponse: _response.rawResponse,
439
+ });
440
+ }
441
+ }
442
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v0/api-keys/public-keys/{api_key_id}");
443
+ });
444
+ }
445
+ /**
446
+ * Permanently revoke one public-key credential. This hard-deletes the
447
+ * credential; repeating the request returns not found. Requires
448
+ * `api_key_delete`.
449
+ *
450
+ * @param {string} api_key_id - Public-key credential ID returned by registration.
451
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
452
+ *
453
+ * @throws {@link AgentMail.NotFoundError}
454
+ *
455
+ * @example
456
+ * await client.apiKeys.revokePublicKey("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")
457
+ */
458
+ revokePublicKey(api_key_id, requestOptions) {
459
+ return core.HttpResponsePromise.fromPromise(this.__revokePublicKey(api_key_id, requestOptions));
460
+ }
461
+ __revokePublicKey(api_key_id, requestOptions) {
462
+ return __awaiter(this, void 0, void 0, function* () {
463
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
464
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
465
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
466
+ const _response = yield core.fetcher({
467
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
468
+ .http, `/v0/api-keys/public-keys/${core.url.encodePathParam(api_key_id)}`),
469
+ method: "DELETE",
470
+ headers: _headers,
471
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
472
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
473
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
474
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
475
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
476
+ logging: this._options.logging,
477
+ });
478
+ if (_response.ok) {
479
+ return { data: undefined, rawResponse: _response.rawResponse };
480
+ }
481
+ if (_response.error.reason === "status-code") {
482
+ switch (_response.error.statusCode) {
483
+ case 404:
484
+ throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
485
+ unrecognizedObjectKeys: "passthrough",
486
+ allowUnrecognizedUnionMembers: true,
487
+ allowUnrecognizedEnumValues: true,
488
+ skipValidation: true,
489
+ breadcrumbsPrefix: ["response"],
490
+ }), _response.rawResponse);
491
+ default:
492
+ throw new errors.AgentMailError({
493
+ statusCode: _response.error.statusCode,
494
+ body: _response.error.body,
495
+ rawResponse: _response.rawResponse,
496
+ });
497
+ }
498
+ }
499
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v0/api-keys/public-keys/{api_key_id}");
500
+ });
501
+ }
502
+ /**
503
+ * Invalidate every current public-key credential in the caller's
504
+ * organization by advancing its AgentID key generation. The caller must be
505
+ * organization-scoped and either have `api_key_delete` or, for a verified
506
+ * self-serve agent organization, use an unrestricted unmanaged bearer
507
+ * credential. No request body is accepted.
508
+ *
509
+ * `Idempotency-Key` is required and must be a UUID. Reusing the same UUID
510
+ * returns the original permanent receipt without advancing the generation
511
+ * again. A new UUID performs a new generation advance.
512
+ *
513
+ * @param {AgentMail.RevokeAllAgentIdSignInKeysRequest} request
514
+ * @param {ApiKeysClient.RequestOptions} requestOptions - Request-specific configuration.
515
+ *
516
+ * @throws {@link AgentMail.ValidationError}
517
+ * @throws {@link AgentMail.ConflictError}
518
+ *
519
+ * @example
520
+ * await client.apiKeys.revokeAllAgentIdSignInKeys({
521
+ * idempotencyKey: "Idempotency-Key"
522
+ * })
523
+ */
524
+ revokeAllAgentIdSignInKeys(request, requestOptions) {
525
+ return core.HttpResponsePromise.fromPromise(this.__revokeAllAgentIdSignInKeys(request, requestOptions));
526
+ }
527
+ __revokeAllAgentIdSignInKeys(request, requestOptions) {
528
+ return __awaiter(this, void 0, void 0, function* () {
529
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
530
+ const { idempotencyKey } = request;
531
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
532
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
533
+ const _response = yield core.fetcher({
534
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
535
+ .http, "/v0/api-keys/public-keys/agentid-sign-in/revoke-all"),
536
+ method: "POST",
537
+ headers: _headers,
538
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
539
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
540
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
541
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
542
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
543
+ logging: this._options.logging,
544
+ });
545
+ if (_response.ok) {
546
+ return {
547
+ data: serializers.RevokeAllAgentIdSignInKeysResponse.parseOrThrow(_response.body, {
548
+ unrecognizedObjectKeys: "passthrough",
549
+ allowUnrecognizedUnionMembers: true,
550
+ allowUnrecognizedEnumValues: true,
551
+ skipValidation: true,
552
+ breadcrumbsPrefix: ["response"],
553
+ }),
554
+ rawResponse: _response.rawResponse,
555
+ };
556
+ }
557
+ if (_response.error.reason === "status-code") {
558
+ switch (_response.error.statusCode) {
559
+ case 400:
560
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
561
+ unrecognizedObjectKeys: "passthrough",
562
+ allowUnrecognizedUnionMembers: true,
563
+ allowUnrecognizedEnumValues: true,
564
+ skipValidation: true,
565
+ breadcrumbsPrefix: ["response"],
566
+ }), _response.rawResponse);
567
+ case 409:
568
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
569
+ unrecognizedObjectKeys: "passthrough",
570
+ allowUnrecognizedUnionMembers: true,
571
+ allowUnrecognizedEnumValues: true,
572
+ skipValidation: true,
573
+ breadcrumbsPrefix: ["response"],
574
+ }), _response.rawResponse);
575
+ default:
576
+ throw new errors.AgentMailError({
577
+ statusCode: _response.error.statusCode,
578
+ body: _response.error.body,
579
+ rawResponse: _response.rawResponse,
580
+ });
581
+ }
582
+ }
583
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v0/api-keys/public-keys/agentid-sign-in/revoke-all");
584
+ });
585
+ }
214
586
  }
@@ -0,0 +1,10 @@
1
+ import type * as AgentMail from "../../../../index.mjs";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface ListPublicKeysRequest {
7
+ limit?: AgentMail.Limit;
8
+ pageToken?: AgentMail.PageToken;
9
+ ascending?: AgentMail.Ascending;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * idempotencyKey: "Idempotency-Key"
5
+ * }
6
+ */
7
+ export interface RevokeAllAgentIdSignInKeysRequest {
8
+ /** Required UUID identifying this revoke-all operation permanently. */
9
+ idempotencyKey: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1 +1,3 @@
1
1
  export type { ListApiKeysRequest } from "./ListApiKeysRequest.mjs";
2
+ export type { ListPublicKeysRequest } from "./ListPublicKeysRequest.mjs";
3
+ export type { RevokeAllAgentIdSignInKeysRequest } from "./RevokeAllAgentIdSignInKeysRequest.mjs";
@@ -10,20 +10,20 @@ export interface ApiKeyPermissions {
10
10
  inboxUpdate?: boolean;
11
11
  /** Delete inboxes. */
12
12
  inboxDelete?: boolean;
13
- /** Read threads. */
14
- threadRead?: boolean;
15
- /** Delete threads. */
16
- threadDelete?: boolean;
17
- /** Read messages. */
13
+ /** Read messages. Also required to read threads. */
18
14
  messageRead?: boolean;
19
15
  /** Send messages. */
20
16
  messageSend?: boolean;
21
- /** Update message labels. */
17
+ /** Update message labels. Also required to update threads. */
22
18
  messageUpdate?: boolean;
19
+ /** Delete messages. Also required to delete threads. */
20
+ messageDelete?: boolean;
23
21
  /** Access messages labeled spam. */
24
22
  labelSpamRead?: boolean;
25
23
  /** Access messages labeled blocked. */
26
24
  labelBlockedRead?: boolean;
25
+ /** Access messages labeled unauthenticated. */
26
+ labelUnauthenticatedRead?: boolean;
27
27
  /** Access messages labeled trash. */
28
28
  labelTrashRead?: boolean;
29
29
  /** Read drafts. */
@@ -64,6 +64,8 @@ export interface ApiKeyPermissions {
64
64
  apiKeyRead?: boolean;
65
65
  /** Create API keys. */
66
66
  apiKeyCreate?: boolean;
67
+ /** Update API keys. */
68
+ apiKeyUpdate?: boolean;
67
69
  /** Delete API keys. */
68
70
  apiKeyDelete?: boolean;
69
71
  /** Read pods. */
@@ -0,0 +1,21 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * Register only a public P-256 JWK. Credential type, `api_key_id`, sign-in
4
+ * eligibility, permissions, and generation are server-owned and are not
5
+ * request properties.
6
+ */
7
+ export interface CreatePublicKeyRequest {
8
+ publicKey: AgentMail.PublicJwk;
9
+ /** Defaults to `AgentID key {first eight fingerprint characters}`. */
10
+ name?: string;
11
+ /**
12
+ * Omit to inherit the registering bearer key's exact scope. An explicit
13
+ * scope must be the caller's scope or a live descendant.
14
+ */
15
+ scope?: AgentMail.PublicKeyScope;
16
+ /**
17
+ * Future absolute expiry. Omit to inherit the registering bearer key's
18
+ * expiry. A child credential cannot outlive its creator.
19
+ */
20
+ expiresAt?: Date;
21
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Authority over one live inbox incarnation.
3
+ */
4
+ export interface InboxPublicKeyScope {
5
+ /** ID of the inbox. */
6
+ id: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,7 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ export interface ListPublicKeysResponse {
3
+ count: AgentMail.Count;
4
+ nextPageToken?: AgentMail.PageToken;
5
+ /** Public-key credentials only, ordered by creation time descending by default. */
6
+ publicKeys: AgentMail.PublicKeyCredential[];
7
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Organization-wide authority.
3
+ */
4
+ export type OrganizationPublicKeyScope = {};
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Authority over one live pod and its inboxes.
3
+ */
4
+ export interface PodPublicKeyScope {
5
+ /** ID of the pod. */
6
+ id: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,13 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * A public P-256 JWK. The object accepts exactly `kty`, `crv`, `x`, and `y`.
4
+ * Private key material such as `d`, embedded key IDs, and all other members
5
+ * are rejected. The server also rejects coordinates that are not a point on
6
+ * P-256.
7
+ */
8
+ export interface PublicJwk {
9
+ kty: "EC";
10
+ crv: "P-256";
11
+ x: AgentMail.PublicJwkCoordinate;
12
+ y: AgentMail.PublicJwkCoordinate;
13
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A 32-byte P-256 coordinate encoded as unpadded base64url.
3
+ */
4
+ export type PublicJwkCoordinate = string;
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,22 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * An AgentID sign-in credential. `type` and `api_key_id` are server-owned;
4
+ * use `api_key_id` as the JWS `kid`. This response never contains a bearer
5
+ * secret or private key.
6
+ */
7
+ export interface PublicKeyCredential {
8
+ /** Server-generated credential ID. Store this value as the signing key's `kid`. */
9
+ apiKeyId: string;
10
+ /** Server-owned credential discriminator. Callers cannot select or update it. */
11
+ type: "public_key";
12
+ /** Human-readable credential name. */
13
+ name: AgentMail.Name;
14
+ publicKey: AgentMail.PublicKeyMaterial;
15
+ scope: AgentMail.PublicKeyScope;
16
+ /** Immutable absolute expiry. Omitted when the credential does not expire. */
17
+ expiresAt?: Date;
18
+ /** Present when organization-wide revoke-all invalidated this credential generation. */
19
+ revokedAt?: Date;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,9 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * Registered public key material and its server-computed RFC 7638 thumbprint.
4
+ */
5
+ export interface PublicKeyMaterial {
6
+ jwk: AgentMail.PublicJwk;
7
+ /** RFC 7638 SHA-256 JWK thumbprint encoded as unpadded base64url. */
8
+ fingerprint: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,16 @@
1
+ import type * as AgentMail from "../../../index.mjs";
2
+ /**
3
+ * The immutable scope in which a public-key credential can approve AgentID sign-in.
4
+ */
5
+ export type PublicKeyScope = AgentMail.PublicKeyScope.Organization | AgentMail.PublicKeyScope.Pod | AgentMail.PublicKeyScope.Inbox;
6
+ export declare namespace PublicKeyScope {
7
+ interface Organization extends AgentMail.OrganizationPublicKeyScope {
8
+ type: "organization";
9
+ }
10
+ interface Pod extends AgentMail.PodPublicKeyScope {
11
+ type: "pod";
12
+ }
13
+ interface Inbox extends AgentMail.InboxPublicKeyScope {
14
+ type: "inbox";
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Permanent idempotency receipt for an organization-wide AgentID sign-in key revocation.
3
+ */
4
+ export interface RevokeAllAgentIdSignInKeysResponse {
5
+ previousGeneration: number;
6
+ currentGeneration: number;
7
+ revokedAt: Date;
8
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};