Skip to content

Commit c06b4fe

Browse files
inlinedTheIronDev
andauthored
Bump admin SDK version. Remove vendored APIs + sniffing (#1139)
* Bump admin SDK version. Remove vendored APIs + sniffing * Bump node version; remove tests for old node versions * Package lock * Update v2 rtdb to expose RawRTDBEvent and RawRTDBCloudEventData (#1137) * Update v2 rtdb to expose RawRTDBEvent and RawRTDBCloudEventData This commit updates the v2 database provider to also expose the RawRTDB Events. This will be used in test-sdk when mocking returned DatabaseEvents. * Adding @hidden instead of @internal * Revert package lock * Run formatter Co-authored-by: Tyler Stark <[email protected]>
1 parent 8c96c81 commit c06b4fe

File tree

4 files changed

+10
-73
lines changed

4 files changed

+10
-73
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- 10.x
17-
- 12.x
1816
- 14.x
1917
- 16.x
2018
steps:
@@ -38,7 +36,6 @@ jobs:
3836
strategy:
3937
matrix:
4038
node-version:
41-
- 12.x
4239
- 14.x
4340
- 16.x
4441
steps:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@
229229
"yargs": "^15.3.1"
230230
},
231231
"peerDependencies": {
232-
"firebase-admin": "^8.0.0 || ^9.0.0 || ^10.0.0"
232+
"firebase-admin": "^10.0.0"
233233
},
234234
"engines": {
235-
"node": "^8.13.0 || >=10.10.0"
235+
"node": ">=14.10.0"
236236
}
237237
}

src/common/providers/https.ts

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
import * as cors from 'cors';
2424
import * as express from 'express';
25-
import * as firebase from 'firebase-admin';
25+
import { DecodedAppCheckToken } from 'firebase-admin/app-check';
26+
import { DecodedIdToken } from 'firebase-admin/auth';
2627

2728
import * as logger from '../../logger';
2829

@@ -40,60 +41,6 @@ export interface Request extends express.Request {
4041
rawBody: Buffer;
4142
}
4243

43-
// This is actually a firebase.appCheck.DecodedAppCheckToken, but
44-
// that type may not be available in some supported SDK versions.
45-
// Declare as an inline type, which DecodedAppCheckToken will be
46-
// able to merge with.
47-
// TODO: Replace with the real type once we bump the min-version of
48-
// the admin SDK
49-
interface DecodedAppCheckToken {
50-
/**
51-
* The issuer identifier for the issuer of the response.
52-
*
53-
* This value is a URL with the format
54-
* `https://firebaseappcheck.googleapis.com/<PROJECT_NUMBER>`, where `<PROJECT_NUMBER>` is the
55-
* same project number specified in the [`aud`](#aud) property.
56-
*/
57-
iss: string;
58-
59-
/**
60-
* The Firebase App ID corresponding to the app the token belonged to.
61-
*
62-
* As a convenience, this value is copied over to the [`app_id`](#app_id) property.
63-
*/
64-
sub: string;
65-
66-
/**
67-
* The audience for which this token is intended.
68-
*
69-
* This value is a JSON array of two strings, the first is the project number of your
70-
* Firebase project, and the second is the project ID of the same project.
71-
*/
72-
aud: string[];
73-
74-
/**
75-
* The App Check token's expiration time, in seconds since the Unix epoch. That is, the
76-
* time at which this App Check token expires and should no longer be considered valid.
77-
*/
78-
exp: number;
79-
80-
/**
81-
* The App Check token's issued-at time, in seconds since the Unix epoch. That is, the
82-
* time at which this App Check token was issued and should start to be considered
83-
* valid.;
84-
*/
85-
iat: number;
86-
87-
/**
88-
* The App ID corresponding to the App the App Check token belonged to.
89-
*
90-
* This value is not actually one of the JWT token claims. It is added as a
91-
* convenience, and is set as the value of the [`sub`](#sub) property.
92-
*/
93-
app_id: string;
94-
[key: string]: any;
95-
}
96-
9744
/**
9845
* The interface for AppCheck tokens verified in Callable functions
9946
*/
@@ -107,7 +54,7 @@ export interface AppCheckData {
10754
*/
10855
export interface AuthData {
10956
uid: string;
110-
token: firebase.auth.DecodedIdToken;
57+
token: DecodedIdToken;
11158
}
11259

11360
// This type is the direct v1 callable interface and is also an interface
@@ -553,10 +500,8 @@ export function unsafeDecodeToken(token: string): unknown {
553500
* This is exposed only for testing.
554501
*/
555502
/** @internal */
556-
export function unsafeDecodeIdToken(
557-
token: string
558-
): firebase.auth.DecodedIdToken {
559-
const decoded = unsafeDecodeToken(token) as firebase.auth.DecodedIdToken;
503+
export function unsafeDecodeIdToken(token: string): DecodedIdToken {
504+
const decoded = unsafeDecodeToken(token) as DecodedIdToken;
560505
decoded.uid = decoded.sub;
561506
return decoded;
562507
}
@@ -642,7 +587,7 @@ export async function checkAuthToken(
642587
if (match) {
643588
const idToken = match[1];
644589
try {
645-
let authToken: firebase.auth.DecodedIdToken;
590+
let authToken: DecodedIdToken;
646591
if (isDebugFeatureEnabled('skipTokenVerification')) {
647592
authToken = unsafeDecodeIdToken(idToken);
648593
} else {
@@ -672,11 +617,6 @@ async function checkAppCheckToken(
672617
return 'MISSING';
673618
}
674619
try {
675-
if (!apps().admin.appCheck) {
676-
throw new Error(
677-
'Cannot validate AppCheck token. Please update Firebase Admin SDK to >= v9.8.0'
678-
);
679-
}
680620
let appCheckData;
681621
if (isDebugFeatureEnabled('skipTokenVerification')) {
682622
const decodedToken = unsafeDecodeAppCheckToken(appCheck);

src/v2/providers/database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ export const updatedEventType = 'google.firebase.database.ref.v1.updated';
4444
/** @internal */
4545
export const deletedEventType = 'google.firebase.database.ref.v1.deleted';
4646

47-
/** @internal */
47+
/** @hidden */
4848
export interface RawRTDBCloudEventData {
4949
['@type']: 'type.googleapis.com/google.events.firebase.database.v1.ReferenceEventData';
5050
data: any;
5151
delta: any;
5252
}
5353

54-
/** @internal */
54+
/** @hidden */
5555
export interface RawRTDBCloudEvent extends CloudEvent<RawRTDBCloudEventData> {
5656
firebasedatabasehost: string;
5757
instance: string;

0 commit comments

Comments
 (0)