Skip to content

Port 3P token API to app-check-exp #5069

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 5 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"firebase-messaging-integration-test",
"firebase-compat-interop-test",
"firebase-compat-typings-test",
"@firebase/app-compat",
"@firebase/app-exp",
"@firebase/app-check-compat",
"@firebase/app-check-exp",
"@firebase/analytics-compat",
"@firebase/analytics-exp",
Expand All @@ -32,7 +34,6 @@
"@firebase/remote-config-exp",
"@firebase/remote-config-compat",
"firebase-exp",
"@firebase/app-compat",
"@firebase/changelog-generator",
"firebase-size-analysis"
],
Expand Down
21 changes: 20 additions & 1 deletion common/api-review/app-check-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
```ts

import { FirebaseApp } from '@firebase/app-exp';
import { PartialObserver } from '@firebase/util';
import { Unsubscribe } from '@firebase/util';

// @public
export interface AppCheck {
Expand All @@ -30,6 +32,14 @@ export interface AppCheckToken {
readonly token: string;
}

// @public
export type AppCheckTokenListener = (token: AppCheckTokenResult) => void;

// @public
export interface AppCheckTokenResult {
readonly token: string;
}

// Warning: (ae-forgotten-export) The symbol "AppCheckProvider" needs to be exported by the entry point index.d.ts
//
// @public
Expand All @@ -48,9 +58,18 @@ export interface CustomProviderOptions {
getToken: () => Promise<AppCheckToken>;
}

// @public
export function getToken(appCheckInstance: AppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;

// @public
export function initializeAppCheck(app: FirebaseApp | undefined, options: AppCheckOptions): AppCheck;

// @public
export function onTokenChanged(appCheckInstance: AppCheck, observer: PartialObserver<AppCheckTokenResult>): Unsubscribe;

// @public
export function onTokenChanged(appCheckInstance: AppCheck, onNext: (tokenResult: AppCheckTokenResult) => void, onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;

// @public
export class ReCaptchaV3Provider implements AppCheckProvider {
constructor(_siteKey: string);
Expand All @@ -61,7 +80,7 @@ export class ReCaptchaV3Provider implements AppCheckProvider {
}

// @public
export function setTokenAutoRefreshEnabled(app: FirebaseApp, isTokenAutoRefreshEnabled: boolean): void;
export function setTokenAutoRefreshEnabled(appCheckInstance: AppCheck, isTokenAutoRefreshEnabled: boolean): void;


// (No @packageDocumentation comment for this package)
Expand Down
33 changes: 33 additions & 0 deletions packages-exp/app-check-compat/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license
* Copyright 2021 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 path = require('path');

module.exports = {
'extends': '../../config/.eslintrc.js',
'parserOptions': {
'project': 'tsconfig.json',
'tsconfigRootDir': __dirname
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
'packageDir': [path.resolve(__dirname, '../../'), __dirname]
}
]
}
};
5 changes: 5 additions & 0 deletions packages-exp/app-check-compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @firebase/app-check-compat

This is the Firebase App Check component (compat version) of the Firebase JS SDK.

**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.**
32 changes: 32 additions & 0 deletions packages-exp/app-check-compat/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2021 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.
*/

// eslint-disable-next-line @typescript-eslint/no-require-imports
const karmaBase = require('../../config/karma.base');

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

module.exports = function (config) {
config.set({
...karmaBase,
files,
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
frameworks: ['mocha']
});
};

module.exports.files = files;
60 changes: 60 additions & 0 deletions packages-exp/app-check-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@firebase/app-check-compat",
"version": "0.0.900",
"private": true,
"description": "A compat App Check package for new firebase packages",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm2017.js",
"module": "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:release": "rollup -c rollup.config.release.js",
"build:deps": "lerna run --scope @firebase/app-check-compat --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:browser",
"test:browser": "karma start --single-run --nocache"
},
"peerDependencies": {
"@firebase/app-compat": "0.x"
},
"dependencies": {
"@firebase/app-check-exp": "0.0.900",
"@firebase/logger": "0.2.6",
"@firebase/util": "1.1.0",
"@firebase/component": "0.5.3",
"tslib": "^2.1.0"
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app-compat": "0.0.900",
"rollup": "2.33.2",
"@rollup/plugin-commonjs": "17.1.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "11.2.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/src/index.d.ts",
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
},
"esm5": "dist/index.esm.js"
}
58 changes: 58 additions & 0 deletions packages-exp/app-check-compat/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @license
* Copyright 2021 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.
*/

import json from '@rollup/plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';

/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript
}),
json()
];

const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins
}));

/**
* ES2017 Builds
*/
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
}
}),
json({ preferConst: true })
];

const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins
}));

export default [...es5Builds, ...es2017Builds];
67 changes: 67 additions & 0 deletions packages-exp/app-check-compat/rollup.config.release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @license
* Copyright 2021 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.
*/

import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import json from '@rollup/plugin-json';
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
import { es2017BuildsNoPlugin, es5BuildsNoPlugin } from './rollup.shared';

/**
* ES5 Builds
*/
const es5BuildPlugins = [
typescriptPlugin({
typescript,
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json()
];

const es5Builds = es5BuildsNoPlugin.map(build => ({
...build,
plugins: es5BuildPlugins
}));

/**
* ES2017 Builds
*/
const es2017BuildPlugins = [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
abortOnError: false,
clean: true,
transformers: [importPathTransformer]
}),
json({
preferConst: true
})
];

const es2017Builds = es2017BuildsNoPlugin.map(build => ({
...build,
plugins: es2017BuildPlugins
}));

export default [...es5Builds, ...es2017Builds];
54 changes: 54 additions & 0 deletions packages-exp/app-check-compat/rollup.shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @license
* Copyright 2021 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.
*/
import pkg from './package.json';

const deps = [
...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)),
'@firebase/app'
];

export const es5BuildsNoPlugin = [
/**
* Browser Builds
*/
{
input: 'src/index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.esm5, format: 'es', sourcemap: true }
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

/**
* ES2017 Builds
*/
export const es2017BuildsNoPlugin = [
{
/**
* Browser Build
*/
input: 'src/index.ts',
output: {
file: pkg.browser,
format: 'es',
sourcemap: true
},
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];
Loading