@firebase/app-check-compat 0.3.16-canary.a97ac88db → 0.3.16-canary.e577a408c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.esm2017.js +117 -117
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/errors.d.ts +27 -27
- package/dist/esm/src/index.d.ts +29 -29
- package/dist/esm/src/service.d.ts +29 -29
- package/dist/esm/src/service.test.d.ts +1 -1
- package/dist/index.cjs.js +117 -117
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/errors.d.ts +27 -27
- package/dist/src/index.d.ts +102 -34
- package/dist/src/service.d.ts +29 -29
- package/dist/src/service.test.d.ts +1 -1
- package/package.json +9 -9
|
@@ -4,128 +4,128 @@ import { ReCaptchaV3Provider, ReCaptchaEnterpriseProvider, CustomProvider, initi
|
|
|
4
4
|
import { ErrorFactory } from '@firebase/util';
|
|
5
5
|
|
|
6
6
|
const name = "@firebase/app-check-compat";
|
|
7
|
-
const version = "0.3.16-canary.
|
|
7
|
+
const version = "0.3.16-canary.e577a408c";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright 2021 Google LLC
|
|
12
|
-
*
|
|
13
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License.
|
|
15
|
-
* You may obtain a copy of the License at
|
|
16
|
-
*
|
|
17
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
*
|
|
19
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
-
* See the License for the specific language governing permissions and
|
|
23
|
-
* limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
const ERRORS = {
|
|
26
|
-
["use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */]: 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +
|
|
27
|
-
'Call activate() before instantiating other Firebase services.'
|
|
28
|
-
};
|
|
9
|
+
/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2021 Google LLC
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const ERRORS = {
|
|
26
|
+
["use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */]: 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +
|
|
27
|
+
'Call activate() before instantiating other Firebase services.'
|
|
28
|
+
};
|
|
29
29
|
const ERROR_FACTORY = new ErrorFactory('appCheck', 'AppCheck', ERRORS);
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* @license
|
|
33
|
-
* Copyright 2021 Google LLC
|
|
34
|
-
*
|
|
35
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
-
* you may not use this file except in compliance with the License.
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
*
|
|
39
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
-
*
|
|
41
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
-
* See the License for the specific language governing permissions and
|
|
45
|
-
* limitations under the License.
|
|
46
|
-
*/
|
|
47
|
-
class AppCheckService {
|
|
48
|
-
constructor(app) {
|
|
49
|
-
this.app = app;
|
|
50
|
-
}
|
|
51
|
-
activate(siteKeyOrProvider, isTokenAutoRefreshEnabled) {
|
|
52
|
-
let provider;
|
|
53
|
-
if (typeof siteKeyOrProvider === 'string') {
|
|
54
|
-
provider = new ReCaptchaV3Provider(siteKeyOrProvider);
|
|
55
|
-
}
|
|
56
|
-
else if (siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||
|
|
57
|
-
siteKeyOrProvider instanceof ReCaptchaV3Provider ||
|
|
58
|
-
siteKeyOrProvider instanceof CustomProvider) {
|
|
59
|
-
provider = siteKeyOrProvider;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });
|
|
63
|
-
}
|
|
64
|
-
this._delegate = initializeAppCheck(this.app, {
|
|
65
|
-
provider,
|
|
66
|
-
isTokenAutoRefreshEnabled
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled) {
|
|
70
|
-
if (!this._delegate) {
|
|
71
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
72
|
-
appName: this.app.name
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
setTokenAutoRefreshEnabled(this._delegate, isTokenAutoRefreshEnabled);
|
|
76
|
-
}
|
|
77
|
-
getToken(forceRefresh) {
|
|
78
|
-
if (!this._delegate) {
|
|
79
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
80
|
-
appName: this.app.name
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return getToken(this._delegate, forceRefresh);
|
|
84
|
-
}
|
|
85
|
-
onTokenChanged(onNextOrObserver, onError, onCompletion) {
|
|
86
|
-
if (!this._delegate) {
|
|
87
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
88
|
-
appName: this.app.name
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
return onTokenChanged(this._delegate,
|
|
92
|
-
/**
|
|
93
|
-
* Exp onTokenChanged() will handle both overloads but we need
|
|
94
|
-
* to specify one to not confuse TypeScript.
|
|
95
|
-
*/
|
|
96
|
-
onNextOrObserver, onError, onCompletion);
|
|
97
|
-
}
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2021 Google LLC
|
|
34
|
+
*
|
|
35
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License.
|
|
37
|
+
* You may obtain a copy of the License at
|
|
38
|
+
*
|
|
39
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
+
*
|
|
41
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
+
* See the License for the specific language governing permissions and
|
|
45
|
+
* limitations under the License.
|
|
46
|
+
*/
|
|
47
|
+
class AppCheckService {
|
|
48
|
+
constructor(app) {
|
|
49
|
+
this.app = app;
|
|
50
|
+
}
|
|
51
|
+
activate(siteKeyOrProvider, isTokenAutoRefreshEnabled) {
|
|
52
|
+
let provider;
|
|
53
|
+
if (typeof siteKeyOrProvider === 'string') {
|
|
54
|
+
provider = new ReCaptchaV3Provider(siteKeyOrProvider);
|
|
55
|
+
}
|
|
56
|
+
else if (siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||
|
|
57
|
+
siteKeyOrProvider instanceof ReCaptchaV3Provider ||
|
|
58
|
+
siteKeyOrProvider instanceof CustomProvider) {
|
|
59
|
+
provider = siteKeyOrProvider;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });
|
|
63
|
+
}
|
|
64
|
+
this._delegate = initializeAppCheck(this.app, {
|
|
65
|
+
provider,
|
|
66
|
+
isTokenAutoRefreshEnabled
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled) {
|
|
70
|
+
if (!this._delegate) {
|
|
71
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
72
|
+
appName: this.app.name
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
setTokenAutoRefreshEnabled(this._delegate, isTokenAutoRefreshEnabled);
|
|
76
|
+
}
|
|
77
|
+
getToken(forceRefresh) {
|
|
78
|
+
if (!this._delegate) {
|
|
79
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
80
|
+
appName: this.app.name
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return getToken(this._delegate, forceRefresh);
|
|
84
|
+
}
|
|
85
|
+
onTokenChanged(onNextOrObserver, onError, onCompletion) {
|
|
86
|
+
if (!this._delegate) {
|
|
87
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
88
|
+
appName: this.app.name
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return onTokenChanged(this._delegate,
|
|
92
|
+
/**
|
|
93
|
+
* Exp onTokenChanged() will handle both overloads but we need
|
|
94
|
+
* to specify one to not confuse TypeScript.
|
|
95
|
+
*/
|
|
96
|
+
onNextOrObserver, onError, onCompletion);
|
|
97
|
+
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
* @license
|
|
102
|
-
* Copyright 2021 Google LLC
|
|
103
|
-
*
|
|
104
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
105
|
-
* you may not use this file except in compliance with the License.
|
|
106
|
-
* You may obtain a copy of the License at
|
|
107
|
-
*
|
|
108
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
109
|
-
*
|
|
110
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
111
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
112
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
113
|
-
* See the License for the specific language governing permissions and
|
|
114
|
-
* limitations under the License.
|
|
115
|
-
*/
|
|
116
|
-
const factory = (container) => {
|
|
117
|
-
// Dependencies
|
|
118
|
-
const app = container.getProvider('app-compat').getImmediate();
|
|
119
|
-
return new AppCheckService(app);
|
|
120
|
-
};
|
|
121
|
-
function registerAppCheck() {
|
|
122
|
-
firebase.INTERNAL.registerComponent(new Component('appCheck-compat', factory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps({
|
|
123
|
-
ReCaptchaEnterpriseProvider,
|
|
124
|
-
ReCaptchaV3Provider,
|
|
125
|
-
CustomProvider
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
registerAppCheck();
|
|
100
|
+
/**
|
|
101
|
+
* @license
|
|
102
|
+
* Copyright 2021 Google LLC
|
|
103
|
+
*
|
|
104
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
105
|
+
* you may not use this file except in compliance with the License.
|
|
106
|
+
* You may obtain a copy of the License at
|
|
107
|
+
*
|
|
108
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
109
|
+
*
|
|
110
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
111
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
112
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
113
|
+
* See the License for the specific language governing permissions and
|
|
114
|
+
* limitations under the License.
|
|
115
|
+
*/
|
|
116
|
+
const factory = (container) => {
|
|
117
|
+
// Dependencies
|
|
118
|
+
const app = container.getProvider('app-compat').getImmediate();
|
|
119
|
+
return new AppCheckService(app);
|
|
120
|
+
};
|
|
121
|
+
function registerAppCheck() {
|
|
122
|
+
firebase.INTERNAL.registerComponent(new Component('appCheck-compat', factory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps({
|
|
123
|
+
ReCaptchaEnterpriseProvider,
|
|
124
|
+
ReCaptchaV3Provider,
|
|
125
|
+
CustomProvider
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
registerAppCheck();
|
|
129
129
|
firebase.registerVersion(name, version);
|
|
130
130
|
|
|
131
131
|
export { registerAppCheck };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm2017.js","sources":["../../src/errors.ts","../../src/service.ts","../../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum AppCheckError {\n USE_BEFORE_ACTIVATION = 'use-before-activation'\n}\n\nconst ERRORS: ErrorMap<AppCheckError> = {\n [AppCheckError.USE_BEFORE_ACTIVATION]:\n 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +\n 'Call activate() before instantiating other Firebase services.'\n};\n\ninterface ErrorParams {\n [AppCheckError.USE_BEFORE_ACTIVATION]: { appName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<AppCheckError, ErrorParams>(\n 'appCheck',\n 'AppCheck',\n ERRORS\n);\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AppCheckProvider,\n AppCheckTokenResult,\n FirebaseAppCheck\n} from '@firebase/app-check-types';\nimport { _FirebaseService, FirebaseApp } from '@firebase/app-compat';\nimport {\n AppCheck as AppCheckServiceExp,\n CustomProvider,\n initializeAppCheck,\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n setTokenAutoRefreshEnabled as setTokenAutoRefreshEnabledExp,\n getToken as getTokenExp,\n onTokenChanged as onTokenChangedExp\n} from '@firebase/app-check';\nimport { PartialObserver, Unsubscribe } from '@firebase/util';\nimport { ERROR_FACTORY, AppCheckError } from './errors';\n\nexport class AppCheckService\n implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'>\n{\n _delegate?: AppCheckServiceExp;\n constructor(public app: FirebaseApp) {}\n\n activate(\n siteKeyOrProvider: string | AppCheckProvider,\n isTokenAutoRefreshEnabled?: boolean\n ): void {\n let provider:\n | ReCaptchaV3Provider\n | CustomProvider\n | ReCaptchaEnterpriseProvider;\n if (typeof siteKeyOrProvider === 'string') {\n provider = new ReCaptchaV3Provider(siteKeyOrProvider);\n } else if (\n siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||\n siteKeyOrProvider instanceof ReCaptchaV3Provider ||\n siteKeyOrProvider instanceof CustomProvider\n ) {\n provider = siteKeyOrProvider;\n } else {\n provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });\n }\n this._delegate = initializeAppCheck(this.app, {\n provider,\n isTokenAutoRefreshEnabled\n });\n }\n\n setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n setTokenAutoRefreshEnabledExp(this._delegate, isTokenAutoRefreshEnabled);\n }\n\n getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return getTokenExp(this._delegate, forceRefresh);\n }\n\n onTokenChanged(\n onNextOrObserver:\n | PartialObserver<AppCheckTokenResult>\n | ((tokenResult: AppCheckTokenResult) => void),\n onError?: (error: Error) => void,\n onCompletion?: () => void\n ): Unsubscribe {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return onTokenChangedExp(\n this._delegate,\n /**\n * Exp onTokenChanged() will handle both overloads but we need\n * to specify one to not confuse TypeScript.\n */\n onNextOrObserver as (tokenResult: AppCheckTokenResult) => void,\n onError,\n onCompletion\n );\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport firebase, {\n _FirebaseNamespace,\n FirebaseApp\n} from '@firebase/app-compat';\nimport { name, version } from '../package.json';\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { AppCheckService } from './service';\nimport { FirebaseAppCheck } from '@firebase/app-check-types';\nimport {\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n CustomProvider\n} from '@firebase/app-check';\n\nconst factory: InstanceFactory<'appCheck-compat'> = (\n container: ComponentContainer\n) => {\n // Dependencies\n const app = container.getProvider('app-compat').getImmediate();\n\n return new AppCheckService(app as FirebaseApp);\n};\n\nexport function registerAppCheck(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'appCheck-compat',\n factory,\n ComponentType.PUBLIC\n ).setServiceProps({\n ReCaptchaEnterpriseProvider,\n ReCaptchaV3Provider,\n CustomProvider\n })\n );\n}\n\nregisterAppCheck();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerAppCheck`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n appCheck(app?: FirebaseApp): FirebaseAppCheck;\n }\n interface FirebaseApp {\n appCheck(): FirebaseAppCheck;\n }\n}\n"],"names":["setTokenAutoRefreshEnabledExp","getTokenExp","onTokenChangedExp"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAQH,MAAM,MAAM,GAA4B;AACtC,IAAA,CAAA,uBAAA,6CACE,kFAAkF;QAClF,+DAA+D;CAClE,CAAC;AAMK,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C,UAAU,EACV,UAAU,EACV,MAAM,CACP;;ACrCD;;;;;;;;;;;;;;;AAeG;MAqBU,eAAe,CAAA;AAI1B,IAAA,WAAA,CAAmB,GAAgB,EAAA;QAAhB,IAAG,CAAA,GAAA,GAAH,GAAG,CAAa;KAAI;IAEvC,QAAQ,CACN,iBAA4C,EAC5C,yBAAmC,EAAA;AAEnC,QAAA,IAAI,QAG2B,CAAC;AAChC,QAAA,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;AACzC,YAAA,QAAQ,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.esm2017.js","sources":["../../src/errors.ts","../../src/service.ts","../../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum AppCheckError {\n USE_BEFORE_ACTIVATION = 'use-before-activation'\n}\n\nconst ERRORS: ErrorMap<AppCheckError> = {\n [AppCheckError.USE_BEFORE_ACTIVATION]:\n 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +\n 'Call activate() before instantiating other Firebase services.'\n};\n\ninterface ErrorParams {\n [AppCheckError.USE_BEFORE_ACTIVATION]: { appName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<AppCheckError, ErrorParams>(\n 'appCheck',\n 'AppCheck',\n ERRORS\n);\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AppCheckProvider,\n AppCheckTokenResult,\n FirebaseAppCheck\n} from '@firebase/app-check-types';\nimport { _FirebaseService, FirebaseApp } from '@firebase/app-compat';\nimport {\n AppCheck as AppCheckServiceExp,\n CustomProvider,\n initializeAppCheck,\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n setTokenAutoRefreshEnabled as setTokenAutoRefreshEnabledExp,\n getToken as getTokenExp,\n onTokenChanged as onTokenChangedExp\n} from '@firebase/app-check';\nimport { PartialObserver, Unsubscribe } from '@firebase/util';\nimport { ERROR_FACTORY, AppCheckError } from './errors';\n\nexport class AppCheckService\n implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'>\n{\n _delegate?: AppCheckServiceExp;\n constructor(public app: FirebaseApp) {}\n\n activate(\n siteKeyOrProvider: string | AppCheckProvider,\n isTokenAutoRefreshEnabled?: boolean\n ): void {\n let provider:\n | ReCaptchaV3Provider\n | CustomProvider\n | ReCaptchaEnterpriseProvider;\n if (typeof siteKeyOrProvider === 'string') {\n provider = new ReCaptchaV3Provider(siteKeyOrProvider);\n } else if (\n siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||\n siteKeyOrProvider instanceof ReCaptchaV3Provider ||\n siteKeyOrProvider instanceof CustomProvider\n ) {\n provider = siteKeyOrProvider;\n } else {\n provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });\n }\n this._delegate = initializeAppCheck(this.app, {\n provider,\n isTokenAutoRefreshEnabled\n });\n }\n\n setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n setTokenAutoRefreshEnabledExp(this._delegate, isTokenAutoRefreshEnabled);\n }\n\n getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return getTokenExp(this._delegate, forceRefresh);\n }\n\n onTokenChanged(\n onNextOrObserver:\n | PartialObserver<AppCheckTokenResult>\n | ((tokenResult: AppCheckTokenResult) => void),\n onError?: (error: Error) => void,\n onCompletion?: () => void\n ): Unsubscribe {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return onTokenChangedExp(\n this._delegate,\n /**\n * Exp onTokenChanged() will handle both overloads but we need\n * to specify one to not confuse TypeScript.\n */\n onNextOrObserver as (tokenResult: AppCheckTokenResult) => void,\n onError,\n onCompletion\n );\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport firebase, {\n _FirebaseNamespace,\n FirebaseApp\n} from '@firebase/app-compat';\nimport { name, version } from '../package.json';\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { AppCheckService } from './service';\nimport { FirebaseAppCheck } from '@firebase/app-check-types';\nimport {\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n CustomProvider\n} from '@firebase/app-check';\n\nconst factory: InstanceFactory<'appCheck-compat'> = (\n container: ComponentContainer\n) => {\n // Dependencies\n const app = container.getProvider('app-compat').getImmediate();\n\n return new AppCheckService(app as FirebaseApp);\n};\n\nexport function registerAppCheck(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'appCheck-compat',\n factory,\n ComponentType.PUBLIC\n ).setServiceProps({\n ReCaptchaEnterpriseProvider,\n ReCaptchaV3Provider,\n CustomProvider\n })\n );\n}\n\nregisterAppCheck();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerAppCheck`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n appCheck(app?: FirebaseApp): FirebaseAppCheck;\n }\n interface FirebaseApp {\n appCheck(): FirebaseAppCheck;\n }\n}\n"],"names":["setTokenAutoRefreshEnabledExp","getTokenExp","onTokenChangedExp"],"mappings":"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"}
|
package/dist/esm/src/errors.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { ErrorFactory } from '@firebase/util';
|
|
18
|
-
export declare const enum AppCheckError {
|
|
19
|
-
USE_BEFORE_ACTIVATION = "use-before-activation"
|
|
20
|
-
}
|
|
21
|
-
interface ErrorParams {
|
|
22
|
-
[AppCheckError.USE_BEFORE_ACTIVATION]: {
|
|
23
|
-
appName: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export declare const ERROR_FACTORY: ErrorFactory<AppCheckError, ErrorParams>;
|
|
27
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { ErrorFactory } from '@firebase/util';
|
|
18
|
+
export declare const enum AppCheckError {
|
|
19
|
+
USE_BEFORE_ACTIVATION = "use-before-activation"
|
|
20
|
+
}
|
|
21
|
+
interface ErrorParams {
|
|
22
|
+
[AppCheckError.USE_BEFORE_ACTIVATION]: {
|
|
23
|
+
appName: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const ERROR_FACTORY: ErrorFactory<AppCheckError, ErrorParams>;
|
|
27
|
+
export {};
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
-
export declare function registerAppCheck(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Define extension behavior of `registerAppCheck`
|
|
21
|
-
*/
|
|
22
|
-
declare module '@firebase/app-compat' {
|
|
23
|
-
interface FirebaseNamespace {
|
|
24
|
-
appCheck(app?: FirebaseApp): FirebaseAppCheck;
|
|
25
|
-
}
|
|
26
|
-
interface FirebaseApp {
|
|
27
|
-
appCheck(): FirebaseAppCheck;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
+
export declare function registerAppCheck(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Define extension behavior of `registerAppCheck`
|
|
21
|
+
*/
|
|
22
|
+
declare module '@firebase/app-compat' {
|
|
23
|
+
interface FirebaseNamespace {
|
|
24
|
+
appCheck(app?: FirebaseApp): FirebaseAppCheck;
|
|
25
|
+
}
|
|
26
|
+
interface FirebaseApp {
|
|
27
|
+
appCheck(): FirebaseAppCheck;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { AppCheckProvider, AppCheckTokenResult, FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
-
import { _FirebaseService, FirebaseApp } from '@firebase/app-compat';
|
|
19
|
-
import { AppCheck as AppCheckServiceExp } from '@firebase/app-check';
|
|
20
|
-
import { PartialObserver, Unsubscribe } from '@firebase/util';
|
|
21
|
-
export declare class AppCheckService implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'> {
|
|
22
|
-
app: FirebaseApp;
|
|
23
|
-
_delegate?: AppCheckServiceExp;
|
|
24
|
-
constructor(app: FirebaseApp);
|
|
25
|
-
activate(siteKeyOrProvider: string | AppCheckProvider, isTokenAutoRefreshEnabled?: boolean): void;
|
|
26
|
-
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
27
|
-
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
28
|
-
onTokenChanged(onNextOrObserver: PartialObserver<AppCheckTokenResult> | ((tokenResult: AppCheckTokenResult) => void), onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { AppCheckProvider, AppCheckTokenResult, FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
+
import { _FirebaseService, FirebaseApp } from '@firebase/app-compat';
|
|
19
|
+
import { AppCheck as AppCheckServiceExp } from '@firebase/app-check';
|
|
20
|
+
import { PartialObserver, Unsubscribe } from '@firebase/util';
|
|
21
|
+
export declare class AppCheckService implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'> {
|
|
22
|
+
app: FirebaseApp;
|
|
23
|
+
_delegate?: AppCheckServiceExp;
|
|
24
|
+
constructor(app: FirebaseApp);
|
|
25
|
+
activate(siteKeyOrProvider: string | AppCheckProvider, isTokenAutoRefreshEnabled?: boolean): void;
|
|
26
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
27
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
28
|
+
onTokenChanged(onNextOrObserver: PartialObserver<AppCheckTokenResult> | ((tokenResult: AppCheckTokenResult) => void), onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -12,128 +12,128 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
13
13
|
|
|
14
14
|
const name = "@firebase/app-check-compat";
|
|
15
|
-
const version = "0.3.16-canary.
|
|
15
|
+
const version = "0.3.16-canary.e577a408c";
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* @license
|
|
19
|
-
* Copyright 2021 Google LLC
|
|
20
|
-
*
|
|
21
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
-
* you may not use this file except in compliance with the License.
|
|
23
|
-
* You may obtain a copy of the License at
|
|
24
|
-
*
|
|
25
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
-
*
|
|
27
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
-
* See the License for the specific language governing permissions and
|
|
31
|
-
* limitations under the License.
|
|
32
|
-
*/
|
|
33
|
-
const ERRORS = {
|
|
34
|
-
["use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */]: 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +
|
|
35
|
-
'Call activate() before instantiating other Firebase services.'
|
|
36
|
-
};
|
|
17
|
+
/**
|
|
18
|
+
* @license
|
|
19
|
+
* Copyright 2021 Google LLC
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
const ERRORS = {
|
|
34
|
+
["use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */]: 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +
|
|
35
|
+
'Call activate() before instantiating other Firebase services.'
|
|
36
|
+
};
|
|
37
37
|
const ERROR_FACTORY = new util.ErrorFactory('appCheck', 'AppCheck', ERRORS);
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* @license
|
|
41
|
-
* Copyright 2021 Google LLC
|
|
42
|
-
*
|
|
43
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
44
|
-
* you may not use this file except in compliance with the License.
|
|
45
|
-
* You may obtain a copy of the License at
|
|
46
|
-
*
|
|
47
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
48
|
-
*
|
|
49
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
50
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
51
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
52
|
-
* See the License for the specific language governing permissions and
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
*/
|
|
55
|
-
class AppCheckService {
|
|
56
|
-
constructor(app) {
|
|
57
|
-
this.app = app;
|
|
58
|
-
}
|
|
59
|
-
activate(siteKeyOrProvider, isTokenAutoRefreshEnabled) {
|
|
60
|
-
let provider;
|
|
61
|
-
if (typeof siteKeyOrProvider === 'string') {
|
|
62
|
-
provider = new appCheck.ReCaptchaV3Provider(siteKeyOrProvider);
|
|
63
|
-
}
|
|
64
|
-
else if (siteKeyOrProvider instanceof appCheck.ReCaptchaEnterpriseProvider ||
|
|
65
|
-
siteKeyOrProvider instanceof appCheck.ReCaptchaV3Provider ||
|
|
66
|
-
siteKeyOrProvider instanceof appCheck.CustomProvider) {
|
|
67
|
-
provider = siteKeyOrProvider;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
provider = new appCheck.CustomProvider({ getToken: siteKeyOrProvider.getToken });
|
|
71
|
-
}
|
|
72
|
-
this._delegate = appCheck.initializeAppCheck(this.app, {
|
|
73
|
-
provider,
|
|
74
|
-
isTokenAutoRefreshEnabled
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled) {
|
|
78
|
-
if (!this._delegate) {
|
|
79
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
80
|
-
appName: this.app.name
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
appCheck.setTokenAutoRefreshEnabled(this._delegate, isTokenAutoRefreshEnabled);
|
|
84
|
-
}
|
|
85
|
-
getToken(forceRefresh) {
|
|
86
|
-
if (!this._delegate) {
|
|
87
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
88
|
-
appName: this.app.name
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
return appCheck.getToken(this._delegate, forceRefresh);
|
|
92
|
-
}
|
|
93
|
-
onTokenChanged(onNextOrObserver, onError, onCompletion) {
|
|
94
|
-
if (!this._delegate) {
|
|
95
|
-
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
96
|
-
appName: this.app.name
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return appCheck.onTokenChanged(this._delegate,
|
|
100
|
-
/**
|
|
101
|
-
* Exp onTokenChanged() will handle both overloads but we need
|
|
102
|
-
* to specify one to not confuse TypeScript.
|
|
103
|
-
*/
|
|
104
|
-
onNextOrObserver, onError, onCompletion);
|
|
105
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
* @license
|
|
41
|
+
* Copyright 2021 Google LLC
|
|
42
|
+
*
|
|
43
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
44
|
+
* you may not use this file except in compliance with the License.
|
|
45
|
+
* You may obtain a copy of the License at
|
|
46
|
+
*
|
|
47
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
48
|
+
*
|
|
49
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
50
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
51
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
52
|
+
* See the License for the specific language governing permissions and
|
|
53
|
+
* limitations under the License.
|
|
54
|
+
*/
|
|
55
|
+
class AppCheckService {
|
|
56
|
+
constructor(app) {
|
|
57
|
+
this.app = app;
|
|
58
|
+
}
|
|
59
|
+
activate(siteKeyOrProvider, isTokenAutoRefreshEnabled) {
|
|
60
|
+
let provider;
|
|
61
|
+
if (typeof siteKeyOrProvider === 'string') {
|
|
62
|
+
provider = new appCheck.ReCaptchaV3Provider(siteKeyOrProvider);
|
|
63
|
+
}
|
|
64
|
+
else if (siteKeyOrProvider instanceof appCheck.ReCaptchaEnterpriseProvider ||
|
|
65
|
+
siteKeyOrProvider instanceof appCheck.ReCaptchaV3Provider ||
|
|
66
|
+
siteKeyOrProvider instanceof appCheck.CustomProvider) {
|
|
67
|
+
provider = siteKeyOrProvider;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
provider = new appCheck.CustomProvider({ getToken: siteKeyOrProvider.getToken });
|
|
71
|
+
}
|
|
72
|
+
this._delegate = appCheck.initializeAppCheck(this.app, {
|
|
73
|
+
provider,
|
|
74
|
+
isTokenAutoRefreshEnabled
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled) {
|
|
78
|
+
if (!this._delegate) {
|
|
79
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
80
|
+
appName: this.app.name
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
appCheck.setTokenAutoRefreshEnabled(this._delegate, isTokenAutoRefreshEnabled);
|
|
84
|
+
}
|
|
85
|
+
getToken(forceRefresh) {
|
|
86
|
+
if (!this._delegate) {
|
|
87
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
88
|
+
appName: this.app.name
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return appCheck.getToken(this._delegate, forceRefresh);
|
|
92
|
+
}
|
|
93
|
+
onTokenChanged(onNextOrObserver, onError, onCompletion) {
|
|
94
|
+
if (!this._delegate) {
|
|
95
|
+
throw ERROR_FACTORY.create("use-before-activation" /* AppCheckError.USE_BEFORE_ACTIVATION */, {
|
|
96
|
+
appName: this.app.name
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return appCheck.onTokenChanged(this._delegate,
|
|
100
|
+
/**
|
|
101
|
+
* Exp onTokenChanged() will handle both overloads but we need
|
|
102
|
+
* to specify one to not confuse TypeScript.
|
|
103
|
+
*/
|
|
104
|
+
onNextOrObserver, onError, onCompletion);
|
|
105
|
+
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/**
|
|
109
|
-
* @license
|
|
110
|
-
* Copyright 2021 Google LLC
|
|
111
|
-
*
|
|
112
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
113
|
-
* you may not use this file except in compliance with the License.
|
|
114
|
-
* You may obtain a copy of the License at
|
|
115
|
-
*
|
|
116
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
117
|
-
*
|
|
118
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
119
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
120
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
121
|
-
* See the License for the specific language governing permissions and
|
|
122
|
-
* limitations under the License.
|
|
123
|
-
*/
|
|
124
|
-
const factory = (container) => {
|
|
125
|
-
// Dependencies
|
|
126
|
-
const app = container.getProvider('app-compat').getImmediate();
|
|
127
|
-
return new AppCheckService(app);
|
|
128
|
-
};
|
|
129
|
-
function registerAppCheck() {
|
|
130
|
-
firebase__default["default"].INTERNAL.registerComponent(new component.Component('appCheck-compat', factory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps({
|
|
131
|
-
ReCaptchaEnterpriseProvider: appCheck.ReCaptchaEnterpriseProvider,
|
|
132
|
-
ReCaptchaV3Provider: appCheck.ReCaptchaV3Provider,
|
|
133
|
-
CustomProvider: appCheck.CustomProvider
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
registerAppCheck();
|
|
108
|
+
/**
|
|
109
|
+
* @license
|
|
110
|
+
* Copyright 2021 Google LLC
|
|
111
|
+
*
|
|
112
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
113
|
+
* you may not use this file except in compliance with the License.
|
|
114
|
+
* You may obtain a copy of the License at
|
|
115
|
+
*
|
|
116
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
117
|
+
*
|
|
118
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
119
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
120
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
121
|
+
* See the License for the specific language governing permissions and
|
|
122
|
+
* limitations under the License.
|
|
123
|
+
*/
|
|
124
|
+
const factory = (container) => {
|
|
125
|
+
// Dependencies
|
|
126
|
+
const app = container.getProvider('app-compat').getImmediate();
|
|
127
|
+
return new AppCheckService(app);
|
|
128
|
+
};
|
|
129
|
+
function registerAppCheck() {
|
|
130
|
+
firebase__default["default"].INTERNAL.registerComponent(new component.Component('appCheck-compat', factory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps({
|
|
131
|
+
ReCaptchaEnterpriseProvider: appCheck.ReCaptchaEnterpriseProvider,
|
|
132
|
+
ReCaptchaV3Provider: appCheck.ReCaptchaV3Provider,
|
|
133
|
+
CustomProvider: appCheck.CustomProvider
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
registerAppCheck();
|
|
137
137
|
firebase__default["default"].registerVersion(name, version);
|
|
138
138
|
|
|
139
139
|
exports.registerAppCheck = registerAppCheck;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/errors.ts","../src/service.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum AppCheckError {\n USE_BEFORE_ACTIVATION = 'use-before-activation'\n}\n\nconst ERRORS: ErrorMap<AppCheckError> = {\n [AppCheckError.USE_BEFORE_ACTIVATION]:\n 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +\n 'Call activate() before instantiating other Firebase services.'\n};\n\ninterface ErrorParams {\n [AppCheckError.USE_BEFORE_ACTIVATION]: { appName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<AppCheckError, ErrorParams>(\n 'appCheck',\n 'AppCheck',\n ERRORS\n);\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AppCheckProvider,\n AppCheckTokenResult,\n FirebaseAppCheck\n} from '@firebase/app-check-types';\nimport { _FirebaseService, FirebaseApp } from '@firebase/app-compat';\nimport {\n AppCheck as AppCheckServiceExp,\n CustomProvider,\n initializeAppCheck,\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n setTokenAutoRefreshEnabled as setTokenAutoRefreshEnabledExp,\n getToken as getTokenExp,\n onTokenChanged as onTokenChangedExp\n} from '@firebase/app-check';\nimport { PartialObserver, Unsubscribe } from '@firebase/util';\nimport { ERROR_FACTORY, AppCheckError } from './errors';\n\nexport class AppCheckService\n implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'>\n{\n _delegate?: AppCheckServiceExp;\n constructor(public app: FirebaseApp) {}\n\n activate(\n siteKeyOrProvider: string | AppCheckProvider,\n isTokenAutoRefreshEnabled?: boolean\n ): void {\n let provider:\n | ReCaptchaV3Provider\n | CustomProvider\n | ReCaptchaEnterpriseProvider;\n if (typeof siteKeyOrProvider === 'string') {\n provider = new ReCaptchaV3Provider(siteKeyOrProvider);\n } else if (\n siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||\n siteKeyOrProvider instanceof ReCaptchaV3Provider ||\n siteKeyOrProvider instanceof CustomProvider\n ) {\n provider = siteKeyOrProvider;\n } else {\n provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });\n }\n this._delegate = initializeAppCheck(this.app, {\n provider,\n isTokenAutoRefreshEnabled\n });\n }\n\n setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n setTokenAutoRefreshEnabledExp(this._delegate, isTokenAutoRefreshEnabled);\n }\n\n getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return getTokenExp(this._delegate, forceRefresh);\n }\n\n onTokenChanged(\n onNextOrObserver:\n | PartialObserver<AppCheckTokenResult>\n | ((tokenResult: AppCheckTokenResult) => void),\n onError?: (error: Error) => void,\n onCompletion?: () => void\n ): Unsubscribe {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return onTokenChangedExp(\n this._delegate,\n /**\n * Exp onTokenChanged() will handle both overloads but we need\n * to specify one to not confuse TypeScript.\n */\n onNextOrObserver as (tokenResult: AppCheckTokenResult) => void,\n onError,\n onCompletion\n );\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport firebase, {\n _FirebaseNamespace,\n FirebaseApp\n} from '@firebase/app-compat';\nimport { name, version } from '../package.json';\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { AppCheckService } from './service';\nimport { FirebaseAppCheck } from '@firebase/app-check-types';\nimport {\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n CustomProvider\n} from '@firebase/app-check';\n\nconst factory: InstanceFactory<'appCheck-compat'> = (\n container: ComponentContainer\n) => {\n // Dependencies\n const app = container.getProvider('app-compat').getImmediate();\n\n return new AppCheckService(app as FirebaseApp);\n};\n\nexport function registerAppCheck(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'appCheck-compat',\n factory,\n ComponentType.PUBLIC\n ).setServiceProps({\n ReCaptchaEnterpriseProvider,\n ReCaptchaV3Provider,\n CustomProvider\n })\n );\n}\n\nregisterAppCheck();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerAppCheck`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n appCheck(app?: FirebaseApp): FirebaseAppCheck;\n }\n interface FirebaseApp {\n appCheck(): FirebaseAppCheck;\n }\n}\n"],"names":["ErrorFactory","ReCaptchaV3Provider","ReCaptchaEnterpriseProvider","CustomProvider","initializeAppCheck","setTokenAutoRefreshEnabledExp","getTokenExp","onTokenChangedExp","firebase","Component"],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAQH,MAAM,MAAM,GAA4B;AACtC,IAAA,CAAA,uBAAA,6CACE,kFAAkF;QAClF,+DAA+D;CAClE,CAAC;AAMK,MAAM,aAAa,GAAG,IAAIA,iBAAY,CAC3C,UAAU,EACV,UAAU,EACV,MAAM,CACP;;ACrCD;;;;;;;;;;;;;;;AAeG;MAqBU,eAAe,CAAA;AAI1B,IAAA,WAAA,CAAmB,GAAgB,EAAA;QAAhB,IAAG,CAAA,GAAA,GAAH,GAAG,CAAa;KAAI;IAEvC,QAAQ,CACN,iBAA4C,EAC5C,yBAAmC,EAAA;AAEnC,QAAA,IAAI,QAG2B,CAAC;AAChC,QAAA,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;AACzC,YAAA,QAAQ,GAAG,IAAIC,4BAAmB,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/errors.ts","../src/service.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum AppCheckError {\n USE_BEFORE_ACTIVATION = 'use-before-activation'\n}\n\nconst ERRORS: ErrorMap<AppCheckError> = {\n [AppCheckError.USE_BEFORE_ACTIVATION]:\n 'App Check is being used before activate() is called for FirebaseApp {$appName}. ' +\n 'Call activate() before instantiating other Firebase services.'\n};\n\ninterface ErrorParams {\n [AppCheckError.USE_BEFORE_ACTIVATION]: { appName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<AppCheckError, ErrorParams>(\n 'appCheck',\n 'AppCheck',\n ERRORS\n);\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n AppCheckProvider,\n AppCheckTokenResult,\n FirebaseAppCheck\n} from '@firebase/app-check-types';\nimport { _FirebaseService, FirebaseApp } from '@firebase/app-compat';\nimport {\n AppCheck as AppCheckServiceExp,\n CustomProvider,\n initializeAppCheck,\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n setTokenAutoRefreshEnabled as setTokenAutoRefreshEnabledExp,\n getToken as getTokenExp,\n onTokenChanged as onTokenChangedExp\n} from '@firebase/app-check';\nimport { PartialObserver, Unsubscribe } from '@firebase/util';\nimport { ERROR_FACTORY, AppCheckError } from './errors';\n\nexport class AppCheckService\n implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'>\n{\n _delegate?: AppCheckServiceExp;\n constructor(public app: FirebaseApp) {}\n\n activate(\n siteKeyOrProvider: string | AppCheckProvider,\n isTokenAutoRefreshEnabled?: boolean\n ): void {\n let provider:\n | ReCaptchaV3Provider\n | CustomProvider\n | ReCaptchaEnterpriseProvider;\n if (typeof siteKeyOrProvider === 'string') {\n provider = new ReCaptchaV3Provider(siteKeyOrProvider);\n } else if (\n siteKeyOrProvider instanceof ReCaptchaEnterpriseProvider ||\n siteKeyOrProvider instanceof ReCaptchaV3Provider ||\n siteKeyOrProvider instanceof CustomProvider\n ) {\n provider = siteKeyOrProvider;\n } else {\n provider = new CustomProvider({ getToken: siteKeyOrProvider.getToken });\n }\n this._delegate = initializeAppCheck(this.app, {\n provider,\n isTokenAutoRefreshEnabled\n });\n }\n\n setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n setTokenAutoRefreshEnabledExp(this._delegate, isTokenAutoRefreshEnabled);\n }\n\n getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult> {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return getTokenExp(this._delegate, forceRefresh);\n }\n\n onTokenChanged(\n onNextOrObserver:\n | PartialObserver<AppCheckTokenResult>\n | ((tokenResult: AppCheckTokenResult) => void),\n onError?: (error: Error) => void,\n onCompletion?: () => void\n ): Unsubscribe {\n if (!this._delegate) {\n throw ERROR_FACTORY.create(AppCheckError.USE_BEFORE_ACTIVATION, {\n appName: this.app.name\n });\n }\n return onTokenChangedExp(\n this._delegate,\n /**\n * Exp onTokenChanged() will handle both overloads but we need\n * to specify one to not confuse TypeScript.\n */\n onNextOrObserver as (tokenResult: AppCheckTokenResult) => void,\n onError,\n onCompletion\n );\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport firebase, {\n _FirebaseNamespace,\n FirebaseApp\n} from '@firebase/app-compat';\nimport { name, version } from '../package.json';\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { AppCheckService } from './service';\nimport { FirebaseAppCheck } from '@firebase/app-check-types';\nimport {\n ReCaptchaV3Provider,\n ReCaptchaEnterpriseProvider,\n CustomProvider\n} from '@firebase/app-check';\n\nconst factory: InstanceFactory<'appCheck-compat'> = (\n container: ComponentContainer\n) => {\n // Dependencies\n const app = container.getProvider('app-compat').getImmediate();\n\n return new AppCheckService(app as FirebaseApp);\n};\n\nexport function registerAppCheck(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'appCheck-compat',\n factory,\n ComponentType.PUBLIC\n ).setServiceProps({\n ReCaptchaEnterpriseProvider,\n ReCaptchaV3Provider,\n CustomProvider\n })\n );\n}\n\nregisterAppCheck();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerAppCheck`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n appCheck(app?: FirebaseApp): FirebaseAppCheck;\n }\n interface FirebaseApp {\n appCheck(): FirebaseAppCheck;\n }\n}\n"],"names":["ErrorFactory","ReCaptchaV3Provider","ReCaptchaEnterpriseProvider","CustomProvider","initializeAppCheck","setTokenAutoRefreshEnabledExp","getTokenExp","onTokenChangedExp","firebase","Component"],"mappings":"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"}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { ErrorFactory } from '@firebase/util';
|
|
18
|
-
export declare const enum AppCheckError {
|
|
19
|
-
USE_BEFORE_ACTIVATION = "use-before-activation"
|
|
20
|
-
}
|
|
21
|
-
interface ErrorParams {
|
|
22
|
-
[AppCheckError.USE_BEFORE_ACTIVATION]: {
|
|
23
|
-
appName: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export declare const ERROR_FACTORY: ErrorFactory<AppCheckError, ErrorParams>;
|
|
27
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { ErrorFactory } from '@firebase/util';
|
|
18
|
+
export declare const enum AppCheckError {
|
|
19
|
+
USE_BEFORE_ACTIVATION = "use-before-activation"
|
|
20
|
+
}
|
|
21
|
+
interface ErrorParams {
|
|
22
|
+
[AppCheckError.USE_BEFORE_ACTIVATION]: {
|
|
23
|
+
appName: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const ERROR_FACTORY: ErrorFactory<AppCheckError, ErrorParams>;
|
|
27
|
+
export {};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,39 +1,107 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
-
export declare function registerAppCheck(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Define extension behavior of `registerAppCheck`
|
|
21
|
-
*/
|
|
22
|
-
declare module '@firebase/app-compat' {
|
|
23
|
-
interface FirebaseNamespace {
|
|
24
|
-
appCheck(app?: FirebaseApp): FirebaseAppCheck;
|
|
25
|
-
}
|
|
26
|
-
interface FirebaseApp {
|
|
27
|
-
appCheck(): FirebaseAppCheck;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
+
export declare function registerAppCheck(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Define extension behavior of `registerAppCheck`
|
|
21
|
+
*/
|
|
22
|
+
declare module '@firebase/app-compat' {
|
|
23
|
+
interface FirebaseNamespace {
|
|
24
|
+
appCheck(app?: FirebaseApp): FirebaseAppCheck;
|
|
25
|
+
}
|
|
26
|
+
interface FirebaseApp {
|
|
27
|
+
appCheck(): FirebaseAppCheck;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
import { FirebaseApp as FirebaseAppCompat } from "@firebase/app-compat";
|
|
32
32
|
import { type AppCheckTokenResult, type PartialObserver, type Unsubscribe } from "@firebase/app-check";
|
|
33
33
|
declare module "@firebase/app-check" {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Requests a Firebase App Check token. This method should be used
|
|
36
|
+
* only if you need to authorize requests to a non-Firebase backend.
|
|
37
|
+
*
|
|
38
|
+
* Returns limited-use tokens that are intended for use with your
|
|
39
|
+
* non-Firebase backend endpoints that are protected with
|
|
40
|
+
* <a href="https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection">
|
|
41
|
+
* Replay Protection</a>. This method
|
|
42
|
+
* does not affect the token generation behavior of the
|
|
43
|
+
* #getAppCheckToken() method.
|
|
44
|
+
*
|
|
45
|
+
* @param appCheckInstance - The App Check service instance.
|
|
46
|
+
* @returns The limited use token.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function getLimitedUseToken(appCheckInstance: FirebaseAppCheck): Promise<AppCheckTokenResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current App Check token. If `forceRefresh` is false, this function first
|
|
52
|
+
* checks for a valid token in memory, then local persistence (IndexedDB).
|
|
53
|
+
* If not found, or if `forceRefresh` is true, it makes a request to the
|
|
54
|
+
* App Check endpoint for a fresh token. That request attaches
|
|
55
|
+
* to the most recent in-flight request if one is present.
|
|
56
|
+
*
|
|
57
|
+
* @param appCheckInstance - The App Check service instance.
|
|
58
|
+
* @param forceRefresh - If true, will always try to fetch a fresh token.
|
|
59
|
+
* If false, will use a cached token if found in storage.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare function getToken(appCheckInstance: FirebaseAppCheck, forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a listener to changes in the token state. There can be more
|
|
65
|
+
* than one listener registered at the same time for one or more
|
|
66
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
67
|
+
* the current token associated with this App Check instance changes.
|
|
68
|
+
*
|
|
69
|
+
* @param appCheckInstance - The App Check service instance.
|
|
70
|
+
* @param observer - An object with `next`, `error`, and `complete`
|
|
71
|
+
* properties. `next` is called with an
|
|
72
|
+
* {@link AppCheckTokenResult}
|
|
73
|
+
* whenever the token changes. `error` is optional and is called if an
|
|
74
|
+
* error is thrown by the listener (the `next` function). `complete`
|
|
75
|
+
* is unused, as the token stream is unending.
|
|
76
|
+
*
|
|
77
|
+
* @returns A function that unsubscribes this listener.
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare function onTokenChanged(appCheckInstance: FirebaseAppCheck, observer: PartialObserver<AppCheckTokenResult>): Unsubscribe;
|
|
81
|
+
/**
|
|
82
|
+
* Registers a listener to changes in the token state. There can be more
|
|
83
|
+
* than one listener registered at the same time for one or more
|
|
84
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
85
|
+
* the current token associated with this App Check instance changes.
|
|
86
|
+
*
|
|
87
|
+
* @param appCheckInstance - The App Check service instance.
|
|
88
|
+
* @param onNext - When the token changes, this function is called with an
|
|
89
|
+
* {@link AppCheckTokenResult}.
|
|
90
|
+
* @param onError - Optional. Called if there is an error thrown by the
|
|
91
|
+
* listener (the `onNext` function).
|
|
92
|
+
* @param onCompletion - Currently unused, as the token stream is unending.
|
|
93
|
+
* @returns A function that unsubscribes this listener.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare function onTokenChanged(appCheckInstance: FirebaseAppCheck, onNext: (tokenResult: AppCheckTokenResult) => void, onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;
|
|
97
|
+
/**
|
|
98
|
+
* Set whether App Check will automatically refresh tokens as needed.
|
|
99
|
+
*
|
|
100
|
+
* @param appCheckInstance - The App Check service instance.
|
|
101
|
+
* @param isTokenAutoRefreshEnabled - If true, the SDK automatically
|
|
102
|
+
* refreshes App Check tokens as needed. This overrides any value set
|
|
103
|
+
* during `initializeAppCheck()`.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare function setTokenAutoRefreshEnabled(appCheckInstance: FirebaseAppCheck, isTokenAutoRefreshEnabled: boolean): void;
|
|
39
107
|
}
|
package/dist/src/service.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 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
|
-
import { AppCheckProvider, AppCheckTokenResult, FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
-
import { _FirebaseService, FirebaseApp } from '@firebase/app-compat';
|
|
19
|
-
import { AppCheck as AppCheckServiceExp } from '@firebase/app-check';
|
|
20
|
-
import { PartialObserver, Unsubscribe } from '@firebase/util';
|
|
21
|
-
export declare class AppCheckService implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'> {
|
|
22
|
-
app: FirebaseApp;
|
|
23
|
-
_delegate?: AppCheckServiceExp;
|
|
24
|
-
constructor(app: FirebaseApp);
|
|
25
|
-
activate(siteKeyOrProvider: string | AppCheckProvider, isTokenAutoRefreshEnabled?: boolean): void;
|
|
26
|
-
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
27
|
-
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
28
|
-
onTokenChanged(onNextOrObserver: PartialObserver<AppCheckTokenResult> | ((tokenResult: AppCheckTokenResult) => void), onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;
|
|
29
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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
|
+
import { AppCheckProvider, AppCheckTokenResult, FirebaseAppCheck } from '@firebase/app-check-types';
|
|
18
|
+
import { _FirebaseService, FirebaseApp } from '@firebase/app-compat';
|
|
19
|
+
import { AppCheck as AppCheckServiceExp } from '@firebase/app-check';
|
|
20
|
+
import { PartialObserver, Unsubscribe } from '@firebase/util';
|
|
21
|
+
export declare class AppCheckService implements FirebaseAppCheck, Omit<_FirebaseService, '_delegate'> {
|
|
22
|
+
app: FirebaseApp;
|
|
23
|
+
_delegate?: AppCheckServiceExp;
|
|
24
|
+
constructor(app: FirebaseApp);
|
|
25
|
+
activate(siteKeyOrProvider: string | AppCheckProvider, isTokenAutoRefreshEnabled?: boolean): void;
|
|
26
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
27
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
28
|
+
onTokenChanged(onNextOrObserver: PartialObserver<AppCheckTokenResult> | ((tokenResult: AppCheckTokenResult) => void), onError?: (error: Error) => void, onCompletion?: () => void): Unsubscribe;
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/app-check-compat",
|
|
3
|
-
"version": "0.3.16-canary.
|
|
3
|
+
"version": "0.3.16-canary.e577a408c",
|
|
4
4
|
"description": "A compat App Check package for new firebase packages",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -31,25 +31,25 @@
|
|
|
31
31
|
"add-compat-overloads": "ts-node-script ../../scripts/build/create-overloads.ts -i ../app-check/dist/app-check-public.d.ts -o dist/src/index.d.ts -a -r AppCheck:FirebaseAppCheck -r FirebaseApp:FirebaseAppCompat --moduleToEnhance @firebase/app-check"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@firebase/app-compat": "0.2.
|
|
34
|
+
"@firebase/app-compat": "0.2.45-canary.e577a408c"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@firebase/app-check": "0.8.9-canary.
|
|
38
|
-
"@firebase/app-check-types": "0.5.2-canary.
|
|
39
|
-
"@firebase/logger": "0.4.3-canary.
|
|
40
|
-
"@firebase/util": "1.10.1-canary.
|
|
41
|
-
"@firebase/component": "0.6.10-canary.
|
|
37
|
+
"@firebase/app-check": "0.8.9-canary.e577a408c",
|
|
38
|
+
"@firebase/app-check-types": "0.5.2-canary.e577a408c",
|
|
39
|
+
"@firebase/logger": "0.4.3-canary.e577a408c",
|
|
40
|
+
"@firebase/util": "1.10.1-canary.e577a408c",
|
|
41
|
+
"@firebase/component": "0.6.10-canary.e577a408c",
|
|
42
42
|
"tslib": "^2.1.0"
|
|
43
43
|
},
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@firebase/app-compat": "0.2.
|
|
46
|
+
"@firebase/app-compat": "0.2.45-canary.e577a408c",
|
|
47
47
|
"rollup": "2.79.1",
|
|
48
48
|
"@rollup/plugin-commonjs": "21.1.0",
|
|
49
49
|
"@rollup/plugin-json": "4.1.0",
|
|
50
50
|
"@rollup/plugin-node-resolve": "13.3.0",
|
|
51
51
|
"rollup-plugin-typescript2": "0.31.2",
|
|
52
|
-
"typescript": "
|
|
52
|
+
"typescript": "5.5.4"
|
|
53
53
|
},
|
|
54
54
|
"repository": {
|
|
55
55
|
"directory": "packages/app-check",
|