From 01a00d22d6795816895ce70b31a8ab7506047222 Mon Sep 17 00:00:00 2001 From: Dan Radenkovic Date: Mon, 23 Nov 2026 15:31:33 +0100 Subject: [PATCH] NYL-515: Add certificate fields to Credential UAS now returns two optional fields on Credential records for Dashboard-generated certificate credentials (connectorcertificate and adminconsentcertificate): certificate_expires_at and thumbprint. Add certificateExpiresAt and thumbprint to the Credential model, and add CONNECTORCERTIFICATE and ADMINCONSENTCERTIFICATE to CredentialType so list/find responses are typed. Create request types are unchanged, since these credentials cannot be created through the API. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 ++ src/models/credentials.ts | 20 +++++++++++++ tests/resources/credentials.spec.ts | 44 +++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24fe332f..20027724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Planned version: **8.5.1**. +### Added +- `certificateExpiresAt` and `thumbprint` on `Credential`, plus `CredentialType.CONNECTORCERTIFICATE` and `CredentialType.ADMINCONSENTCERTIFICATE`, for Dashboard-generated certificate credentials (NYL-515). + ### Fixed - Preserve upload-session HTTP header map keys while decoding API responses (NYL-476). - Patch vulnerable SDK tooling and example HTTP dependencies while preserving TypeDoc compatibility (NYL-471). diff --git a/src/models/credentials.ts b/src/models/credentials.ts index ce2e60e3..53ae61b7 100644 --- a/src/models/credentials.ts +++ b/src/models/credentials.ts @@ -26,6 +26,16 @@ export interface Credential { * Timestamp of when the credential was updated */ updatedAt?: number; + /** + * The certificate expiration date as a Unix timestamp. + * Returned only when `credentialType` is `connectorcertificate` or `adminconsentcertificate`. + */ + certificateExpiresAt?: number; + /** + * The certificate thumbprint. + * Returned only when `credentialType` is `connectorcertificate` or `adminconsentcertificate`. + */ + thumbprint?: string; } /** @@ -143,6 +153,16 @@ export enum CredentialType { ADMINCONSENT = 'adminconsent', SERVICEACCOUNT = 'serviceaccount', CONNECTOR = 'connector', + /** + * Certificate-based connector credential. Created from the Nylas Dashboard only; + * returned by list/find but cannot be created through the API. + */ + CONNECTORCERTIFICATE = 'connectorcertificate', + /** + * Certificate-based admin consent credential. Created from the Nylas Dashboard only; + * returned by list/find but cannot be created through the API. + */ + ADMINCONSENTCERTIFICATE = 'adminconsentcertificate', } /** diff --git a/tests/resources/credentials.spec.ts b/tests/resources/credentials.spec.ts index 5fd2d3ae..669aab87 100644 --- a/tests/resources/credentials.spec.ts +++ b/tests/resources/credentials.spec.ts @@ -1,6 +1,7 @@ import APIClient from '../../src/apiClient'; import { CredentialType } from '../../src/models/credentials'; import { Credentials } from '../../src/resources/credentials'; +import { objKeysToCamelCase } from '../../src/utils'; jest.mock('../../src/apiClient'); describe('Credentials', () => { @@ -61,6 +62,49 @@ describe('Credentials', () => { }); }); + it('should return certificate fields for certificate credentials', async () => { + // Shape of the API response after APIClient camelCases it. + const apiResponse = objKeysToCamelCase({ + request_id: 'req-1', + data: { + id: 'cert-cred-id', + name: 'Dashboard cert', + credential_type: 'connectorcertificate', + certificate_expires_at: 1798761600, + thumbprint: 'A1B2C3D4E5F6', + created_at: 1763900000, + updated_at: 1763900000, + }, + }); + apiClient.request.mockResolvedValueOnce(apiResponse); + + const { data } = await credentials.find({ + provider: 'microsoft', + credentialsId: 'cert-cred-id', + }); + + expect(data.credentialType).toBe(CredentialType.CONNECTORCERTIFICATE); + expect(data.certificateExpiresAt).toBe(1798761600); + expect(data.thumbprint).toBe('A1B2C3D4E5F6'); + }); + + it('should leave certificate fields undefined for other credential types', async () => { + apiClient.request.mockResolvedValueOnce( + objKeysToCamelCase({ + request_id: 'req-2', + data: { id: 'sa-id', name: 'SA', credential_type: 'serviceaccount' }, + }) + ); + + const { data } = await credentials.find({ + provider: 'google', + credentialsId: 'sa-id', + }); + + expect(data.certificateExpiresAt).toBeUndefined(); + expect(data.thumbprint).toBeUndefined(); + }); + it('should URL encode provider and credentialsId in find', async () => { await credentials.find({ provider: 'microsoft',