Skip to content

Commit 3ab54ad

Browse files
Migrate FAC code (#1245)
* Refactor CryptoSigner (#21) * Refactor Crypto Signer * Introduce new CryptoSignerError type * reorder imports * PR fixes * PR clean up * feat(fac): Implement the App Check API (#22) * Implement the App Check API * Add AppCheck public API (#23) * Add AppCheck public API * Add AppCheck public api unit tests * Add FAC Verify Token API (#26) * (feat): Add FAC Verify token API - Re-try with all the keys when kid is not present in the token header. - Add JWKS key fetcher - Add public API for FAC verify token * Add ref docs and unit tests * PR fixes * Update api extractor report * Add more tests for token-verifier * export jwks key pairs * PR fixes * More PR fixes * Update src/app-check/index.ts Co-authored-by: Kevin Cheung <[email protected]> Co-authored-by: Kevin Cheung <[email protected]> * Add App ID Co-authored-by: Kevin Cheung <[email protected]>
1 parent 8267b56 commit 3ab54ad

36 files changed

+3124
-470
lines changed

.github/scripts/run_integration_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}"
2222

2323
echo "${FIREBASE_API_KEY}" > test/resources/apikey.txt
2424

25+
echo "${FIREBASE_APP_ID}" > test/resources/appid.txt
26+
2527
npm run test:integration -- --updateRules --testMultiTenancy

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
env:
5656
FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
5757
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
58+
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
5859

5960
- name: Package release artifacts
6061
run: |

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
env:
6767
FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
6868
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
69+
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
6970

7071
- name: Package release artifacts
7172
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ node_modules/
1414
# Real key file should not be checked in
1515
test/resources/key.json
1616
test/resources/apikey.txt
17+
test/resources/appid.txt
1718

1819
# Release tarballs should not be checked in
1920
firebase-admin-*.tgz

docgen/content-sources/node/toc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ toc:
1919
- title: "App"
2020
path: /docs/reference/admin/node/admin.app.App-1
2121

22+
- title: "admin.appCheck"
23+
path: /docs/reference/admin/node/admin.appCheck
24+
section:
25+
- title: "AppCheck"
26+
path: /docs/reference/admin/node/admin.appCheck.AppCheck-1
27+
- title: "AppCheckToken"
28+
path: /docs/reference/admin/node/admin.appCheck.AppCheckToken
29+
- title: "DecodedAppCheckToken"
30+
path: /docs/reference/admin/node/admin.appCheck.DecodedAppCheckToken
31+
- title: "VerifyAppCheckTokenResponse"
32+
path: /docs/reference/admin/node/admin.appCheck.VerifyAppCheckTokenResponse
33+
2234
- title: "admin.auth"
2335
path: /docs/reference/admin/node/admin.auth
2436
section:

etc/firebase-admin.api.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export function app(name?: string): app.App;
1515
// @public (undocumented)
1616
export namespace app {
1717
export interface App {
18+
// (undocumented)
19+
appCheck(): appCheck.AppCheck;
1820
// (undocumented)
1921
auth(): auth.Auth;
2022
// (undocumented)
@@ -41,6 +43,37 @@ export namespace app {
4143
}
4244
}
4345

46+
// @public
47+
export function appCheck(app?: app.App): appCheck.AppCheck;
48+
49+
// @public (undocumented)
50+
export namespace appCheck {
51+
export interface AppCheck {
52+
// (undocumented)
53+
app: app.App;
54+
createToken(appId: string): Promise<AppCheckToken>;
55+
verifyToken(appCheckToken: string): Promise<VerifyAppCheckTokenResponse>;
56+
}
57+
export interface AppCheckToken {
58+
token: string;
59+
ttlMillis: number;
60+
}
61+
export interface DecodedAppCheckToken {
62+
// (undocumented)
63+
[key: string]: any;
64+
app_id: string;
65+
aud: string[];
66+
exp: number;
67+
iat: number;
68+
iss: string;
69+
sub: string;
70+
}
71+
export interface VerifyAppCheckTokenResponse {
72+
appId: string;
73+
token: appCheck.DecodedAppCheckToken;
74+
}
75+
}
76+
4477
// @public
4578
export interface AppOptions {
4679
credential?: credential.Credential;

0 commit comments

Comments
 (0)