Skip to content

Commit b232114

Browse files
nbegleyhiranya911
authored andcommitted
Make ShaCertificate constructor available through admin.projectManagement().shaCertificate(shaHash). (#417)
* Make ShaCertificate constructor available through admin.projectManagement().shaCertificate(shaHash). * Add unit test for projectManagement.shaCertificate(). * Update changelog.
1 parent fb9d779 commit b232114

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- [fixed] Correctly parses error codes with details messages in Firebase Auth.
44
- [fixed] Fixed optional fields in UserRecord types to be optional.
5+
- [added] `admin.projectManagement().shaCertificate()` method to create an
6+
instance of admin.projectManagement.ShaCertificate.
57

68
# v6.4.0
79

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ declare namespace admin.projectManagement {
713713
listIosApps(): Promise<admin.projectManagement.IosApp[]>;
714714
androidApp(appId: string): admin.projectManagement.AndroidApp;
715715
iosApp(appId: string): admin.projectManagement.IosApp;
716+
shaCertificate(shaHash: string): admin.projectManagement.ShaCertificate;
716717
createAndroidApp(
717718
packageName: string, displayName?: string): Promise<admin.projectManagement.AndroidApp>;
718719
createIosApp(bundleId: string, displayName?: string): Promise<admin.projectManagement.IosApp>;

src/project-management/project-management.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../
1919
import { FirebaseProjectManagementError } from '../utils/error';
2020
import * as utils from '../utils/index';
2121
import * as validator from '../utils/validator';
22-
import { AndroidApp } from './android-app';
22+
import { AndroidApp, ShaCertificate } from './android-app';
2323
import { IosApp } from './ios-app';
2424
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
2525

@@ -102,6 +102,13 @@ export class ProjectManagement implements FirebaseServiceInterface {
102102
return new IosApp(appId, this.requestHandler);
103103
}
104104

105+
/**
106+
* Returns a ShaCertificate object for the given shaHash. No RPC is made.
107+
*/
108+
public shaCertificate(shaHash: string): ShaCertificate {
109+
return new ShaCertificate(shaHash);
110+
}
111+
105112
/**
106113
* Creates a new Firebase Android app, associated with this Firebase project.
107114
*/

test/unit/project-management/project-management.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const PACKAGE_NAME = 'test-package-name';
3434
const BUNDLE_ID = 'test-bundle-id';
3535
const EXPECTED_ERROR = new FirebaseProjectManagementError('internal-error', 'message');
3636

37+
const VALID_SHA_256_HASH = '0123456789abcdefABCDEF01234567890123456701234567890123456789abcd';
38+
3739
describe('ProjectManagement', () => {
3840
// Stubs used to simulate underlying api calls.
3941
let stubs: sinon.SinonStub[] = [];
@@ -276,6 +278,14 @@ describe('ProjectManagement', () => {
276278
});
277279
});
278280

281+
describe('shaCertificate', () => {
282+
it('should successfully return a ShaCertificate', () => {
283+
const shaCertificate = projectManagement.shaCertificate(VALID_SHA_256_HASH);
284+
shaCertificate.shaHash.should.equal(VALID_SHA_256_HASH);
285+
shaCertificate.certType.should.equal('sha256');
286+
});
287+
});
288+
279289
describe('createAndroidApp', () => {
280290
it('should propagate intial API response errors', () => {
281291
const stub = sinon

0 commit comments

Comments
 (0)