diff --git a/CHANGELOG.md b/CHANGELOG.md index ba400f0499..2d71f8b0e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - [fixed] Correctly parses error codes with details messages in Firebase Auth. - [fixed] Fixed optional fields in UserRecord types to be optional. +- [added] `admin.projectManagement().shaCertificate()` method to create an + instance of admin.projectManagement.ShaCertificate. # v6.4.0 diff --git a/src/index.d.ts b/src/index.d.ts index 3cf6bb6e35..f587f0f794 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -713,6 +713,7 @@ declare namespace admin.projectManagement { listIosApps(): Promise; androidApp(appId: string): admin.projectManagement.AndroidApp; iosApp(appId: string): admin.projectManagement.IosApp; + shaCertificate(shaHash: string): admin.projectManagement.ShaCertificate; createAndroidApp( packageName: string, displayName?: string): Promise; createIosApp(bundleId: string, displayName?: string): Promise; diff --git a/src/project-management/project-management.ts b/src/project-management/project-management.ts index eab36454fc..02123b88a2 100644 --- a/src/project-management/project-management.ts +++ b/src/project-management/project-management.ts @@ -19,7 +19,7 @@ import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../ import { FirebaseProjectManagementError } from '../utils/error'; import * as utils from '../utils/index'; import * as validator from '../utils/validator'; -import { AndroidApp } from './android-app'; +import { AndroidApp, ShaCertificate } from './android-app'; import { IosApp } from './ios-app'; import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request'; @@ -102,6 +102,13 @@ export class ProjectManagement implements FirebaseServiceInterface { return new IosApp(appId, this.requestHandler); } + /** + * Returns a ShaCertificate object for the given shaHash. No RPC is made. + */ + public shaCertificate(shaHash: string): ShaCertificate { + return new ShaCertificate(shaHash); + } + /** * Creates a new Firebase Android app, associated with this Firebase project. */ diff --git a/test/unit/project-management/project-management.spec.ts b/test/unit/project-management/project-management.spec.ts index 36ad3f5b54..08ef23d867 100644 --- a/test/unit/project-management/project-management.spec.ts +++ b/test/unit/project-management/project-management.spec.ts @@ -34,6 +34,8 @@ const PACKAGE_NAME = 'test-package-name'; const BUNDLE_ID = 'test-bundle-id'; const EXPECTED_ERROR = new FirebaseProjectManagementError('internal-error', 'message'); +const VALID_SHA_256_HASH = '0123456789abcdefABCDEF01234567890123456701234567890123456789abcd'; + describe('ProjectManagement', () => { // Stubs used to simulate underlying api calls. let stubs: sinon.SinonStub[] = []; @@ -276,6 +278,14 @@ describe('ProjectManagement', () => { }); }); + describe('shaCertificate', () => { + it('should successfully return a ShaCertificate', () => { + const shaCertificate = projectManagement.shaCertificate(VALID_SHA_256_HASH); + shaCertificate.shaHash.should.equal(VALID_SHA_256_HASH); + shaCertificate.certType.should.equal('sha256'); + }); + }); + describe('createAndroidApp', () => { it('should propagate intial API response errors', () => { const stub = sinon