Skip to content

Merge App Check feature branch #4833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/api-review/storage.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

```ts

import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { CompleteFn } from '@firebase/util';
import { FirebaseApp } from '@firebase/app';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
Expand Down
3 changes: 3 additions & 0 deletions packages/app-check-interop-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @firebase/app-check-interop-types

**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.**
47 changes: 47 additions & 0 deletions packages/app-check-interop-types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export interface FirebaseAppCheckInternal {
// Get the current AttestationToken. Attaches to the most recent in-flight request if one
// is present. Returns null if no token is present and no token requests are in-flight.
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;

// Registers a listener to changes in the token state. There can be more than one listener
// registered at the same time for one or more FirebaseAppAttestation instances. The
// listeners call back on the UI thread whenever the current token associated with this
// FirebaseAppAttestation changes.
addTokenListener(listener: AppCheckTokenListener): void;

// Unregisters a listener to changes in the token state.
removeTokenListener(listener: AppCheckTokenListener): void;
}

type AppCheckTokenListener = (token: AppCheckTokenResult) => void;

// If the error field is defined, the token field will be populated with a dummy token
interface AppCheckTokenResult {
readonly token: string;
readonly error?: Error;
}

export type AppCheckInternalComponentName = 'app-check-internal';

declare module '@firebase/component' {
interface NameServiceMapping {
'app-check-internal': FirebaseAppCheckInternal;
}
}
26 changes: 26 additions & 0 deletions packages/app-check-interop-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@firebase/app-check-interop-types",
"private": true,
"version": "0.1.0",
"description": "@firebase/app-check-interop-types Types",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"license": "Apache-2.0",
"scripts": {
"test": "tsc",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"files": [
"index.d.ts"
],
"repository": {
"directory": "packages/app-check-interop-types",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"devDependencies": {
"typescript": "4.2.2"
}
}
9 changes: 9 additions & 0 deletions packages/app-check-interop-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"noEmit": true
},
"exclude": [
"dist/**/*"
]
}
3 changes: 3 additions & 0 deletions packages/app-check-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @firebase/app-check-types

**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.**
46 changes: 46 additions & 0 deletions packages/app-check-types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export interface FirebaseAppCheck {
/**
* Activate AppCheck
* @param siteKeyOrOrovider - reCAPTCHA sitekey or custom token provider
*/
activate(siteKeyOrProvider: string | AppCheckProvider): void;
}

interface AppCheckProvider {
/**
* returns an AppCheck token
*/
getToken(): Promise<AppCheckToken>;
}

interface AppCheckToken {
readonly token: string;
/**
* The local timestamp after which the token will expire.
*/
readonly expireTimeMillis: number;
}

export type AppCheckComponentName = 'appCheck';
declare module '@firebase/component' {
interface NameServiceMapping {
'appCheck': FirebaseAppCheck;
}
}
26 changes: 26 additions & 0 deletions packages/app-check-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@firebase/app-check-types",
"private": true,
"version": "0.1.0",
"description": "@firebase/app-check Types",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"license": "Apache-2.0",
"scripts": {
"test": "tsc",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"files": [
"index.d.ts"
],
"repository": {
"directory": "packages/app-check-types",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"devDependencies": {
"typescript": "4.2.2"
}
}
9 changes: 9 additions & 0 deletions packages/app-check-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"noEmit": true
},
"exclude": [
"dist/**/*"
]
}
26 changes: 26 additions & 0 deletions packages/app-check/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
extends: '../../config/.eslintrc.js',
parserOptions: {
project: 'tsconfig.json',
// to make vscode-eslint work with monorepo
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
tsconfigRootDir: __dirname
}
};
3 changes: 3 additions & 0 deletions packages/app-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @firebase/app-check

App Check SDK
35 changes: 35 additions & 0 deletions packages/app-check/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const karmaBase = require('../../config/karma.base');

const files = [`src/**/*.test.ts`];

module.exports = function (config) {
const karmaConfig = {
...karmaBase,
// files to load into karma
files,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha']
};

config.set(karmaConfig);
};

module.exports.files = files;
62 changes: 62 additions & 0 deletions packages/app-check/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@firebase/app-check",
"version": "0.1.0",
"private": true,
"description": "A template package for new firebase packages",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"browser": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"files": [
"dist"
],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/app-check --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && yarn test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
"type-check": "tsc -p . --noEmit",
"prepare": "yarn build"
},
"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/app-types": "0.x"
},
"dependencies": {
"@firebase/app-check-types": "0.1.0",
"@firebase/app-check-interop-types": "0.1.0",
"@firebase/util": "1.0.0",
"@firebase/component": "0.4.1",
"@firebase/logger": "0.2.6",
"tslib": "^2.1.0"
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.6.20",
"rollup": "2.35.1",
"@rollup/plugin-json": "4.1.0",
"rollup-plugin-typescript2": "0.29.0",
"typescript": "4.2.2"
},
"repository": {
"directory": "packages/app-check",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "dist/index.d.ts",
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
}
}
Loading