Skip to content

Commit 919413c

Browse files
authored
Merge App Check feature branch (#4833)
1 parent 8d63eac commit 919413c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3767
-183
lines changed

common/api-review/storage.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
```ts
66

7+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
78
import { CompleteFn } from '@firebase/util';
89
import { FirebaseApp } from '@firebase/app';
910
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @firebase/app-check-interop-types
2+
3+
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export interface FirebaseAppCheckInternal {
19+
// Get the current AttestationToken. Attaches to the most recent in-flight request if one
20+
// is present. Returns null if no token is present and no token requests are in-flight.
21+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
22+
23+
// Registers a listener to changes in the token state. There can be more than one listener
24+
// registered at the same time for one or more FirebaseAppAttestation instances. The
25+
// listeners call back on the UI thread whenever the current token associated with this
26+
// FirebaseAppAttestation changes.
27+
addTokenListener(listener: AppCheckTokenListener): void;
28+
29+
// Unregisters a listener to changes in the token state.
30+
removeTokenListener(listener: AppCheckTokenListener): void;
31+
}
32+
33+
type AppCheckTokenListener = (token: AppCheckTokenResult) => void;
34+
35+
// If the error field is defined, the token field will be populated with a dummy token
36+
interface AppCheckTokenResult {
37+
readonly token: string;
38+
readonly error?: Error;
39+
}
40+
41+
export type AppCheckInternalComponentName = 'app-check-internal';
42+
43+
declare module '@firebase/component' {
44+
interface NameServiceMapping {
45+
'app-check-internal': FirebaseAppCheckInternal;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@firebase/app-check-interop-types",
3+
"private": true,
4+
"version": "0.1.0",
5+
"description": "@firebase/app-check-interop-types Types",
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"license": "Apache-2.0",
8+
"scripts": {
9+
"test": "tsc",
10+
"test:ci": "node ../../scripts/run_tests_in_ci.js"
11+
},
12+
"files": [
13+
"index.d.ts"
14+
],
15+
"repository": {
16+
"directory": "packages/app-check-interop-types",
17+
"type": "git",
18+
"url": "https://github.com/firebase/firebase-js-sdk.git"
19+
},
20+
"bugs": {
21+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
22+
},
23+
"devDependencies": {
24+
"typescript": "4.2.2"
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../config/tsconfig.base.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
},
6+
"exclude": [
7+
"dist/**/*"
8+
]
9+
}

packages/app-check-types/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @firebase/app-check-types
2+
3+
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.**

packages/app-check-types/index.d.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export interface FirebaseAppCheck {
19+
/**
20+
* Activate AppCheck
21+
* @param siteKeyOrOrovider - reCAPTCHA sitekey or custom token provider
22+
*/
23+
activate(siteKeyOrProvider: string | AppCheckProvider): void;
24+
}
25+
26+
interface AppCheckProvider {
27+
/**
28+
* returns an AppCheck token
29+
*/
30+
getToken(): Promise<AppCheckToken>;
31+
}
32+
33+
interface AppCheckToken {
34+
readonly token: string;
35+
/**
36+
* The local timestamp after which the token will expire.
37+
*/
38+
readonly expireTimeMillis: number;
39+
}
40+
41+
export type AppCheckComponentName = 'appCheck';
42+
declare module '@firebase/component' {
43+
interface NameServiceMapping {
44+
'appCheck': FirebaseAppCheck;
45+
}
46+
}

packages/app-check-types/package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@firebase/app-check-types",
3+
"private": true,
4+
"version": "0.1.0",
5+
"description": "@firebase/app-check Types",
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"license": "Apache-2.0",
8+
"scripts": {
9+
"test": "tsc",
10+
"test:ci": "node ../../scripts/run_tests_in_ci.js"
11+
},
12+
"files": [
13+
"index.d.ts"
14+
],
15+
"repository": {
16+
"directory": "packages/app-check-types",
17+
"type": "git",
18+
"url": "https://github.com/firebase/firebase-js-sdk.git"
19+
},
20+
"bugs": {
21+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
22+
},
23+
"devDependencies": {
24+
"typescript": "4.2.2"
25+
}
26+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../config/tsconfig.base.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
},
6+
"exclude": [
7+
"dist/**/*"
8+
]
9+
}

packages/app-check/.eslintrc.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
module.exports = {
19+
extends: '../../config/.eslintrc.js',
20+
parserOptions: {
21+
project: 'tsconfig.json',
22+
// to make vscode-eslint work with monorepo
23+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
24+
tsconfigRootDir: __dirname
25+
}
26+
};

packages/app-check/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @firebase/app-check
2+
3+
App Check SDK

packages/app-check/karma.conf.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const karmaBase = require('../../config/karma.base');
19+
20+
const files = [`src/**/*.test.ts`];
21+
22+
module.exports = function (config) {
23+
const karmaConfig = {
24+
...karmaBase,
25+
// files to load into karma
26+
files,
27+
// frameworks to use
28+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
29+
frameworks: ['mocha']
30+
};
31+
32+
config.set(karmaConfig);
33+
};
34+
35+
module.exports.files = files;

packages/app-check/package.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "@firebase/app-check",
3+
"version": "0.1.0",
4+
"private": true,
5+
"description": "The App Check component of the Firebase JS SDK",
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"main": "dist/index.cjs.js",
8+
"browser": "dist/index.cjs.js",
9+
"module": "dist/index.esm.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"files": [
12+
"dist"
13+
],
14+
"scripts": {
15+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
16+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
17+
"build": "rollup -c",
18+
"build:deps": "lerna run --scope @firebase/app-check --include-dependencies build",
19+
"dev": "rollup -c -w",
20+
"test": "yarn type-check && yarn test:browser",
21+
"test:ci": "node ../../scripts/run_tests_in_ci.js",
22+
"test:browser": "karma start --single-run",
23+
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
24+
"type-check": "tsc -p . --noEmit",
25+
"prepare": "yarn build"
26+
},
27+
"peerDependencies": {
28+
"@firebase/app": "0.x",
29+
"@firebase/app-types": "0.x"
30+
},
31+
"dependencies": {
32+
"@firebase/app-check-types": "0.1.0",
33+
"@firebase/app-check-interop-types": "0.1.0",
34+
"@firebase/util": "1.0.0",
35+
"@firebase/component": "0.4.1",
36+
"@firebase/logger": "0.2.6",
37+
"tslib": "^2.1.0"
38+
},
39+
"license": "Apache-2.0",
40+
"devDependencies": {
41+
"@firebase/app": "0.6.20",
42+
"rollup": "2.35.1",
43+
"@rollup/plugin-json": "4.1.0",
44+
"rollup-plugin-typescript2": "0.29.0",
45+
"typescript": "4.2.2"
46+
},
47+
"repository": {
48+
"directory": "packages/app-check",
49+
"type": "git",
50+
"url": "https://github.com/firebase/firebase-js-sdk.git"
51+
},
52+
"bugs": {
53+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
54+
},
55+
"typings": "dist/index.d.ts",
56+
"nyc": {
57+
"extension": [
58+
".ts"
59+
],
60+
"reportDir": "./coverage/node"
61+
}
62+
}

0 commit comments

Comments
 (0)