@firebase/app-check
Advanced tools
Comparing version 0.1.4-canary.5d31e2192 to 0.1.4-canary.ca857526b
@@ -925,7 +925,8 @@ 'use strict'; | ||
} | ||
function addTokenListener(app, platformLoggerProvider, listener, onError) { | ||
function addTokenListener(app, platformLoggerProvider, type, listener, onError) { | ||
var state = getState(app); | ||
var tokenListener = { | ||
next: listener, | ||
error: onError | ||
error: onError, | ||
type: type | ||
}; | ||
@@ -1021,14 +1022,12 @@ var newState = tslib.__assign(tslib.__assign({}, state), { tokenObservers: tslib.__spreadArray(tslib.__spreadArray([], state.tokenObservers), [tokenListener]) }); | ||
try { | ||
if (observer.error) { | ||
// If this listener has an error handler, handle errors differently | ||
// from successes. | ||
if (token.error) { | ||
observer.error(token.error); | ||
} | ||
else { | ||
observer.next(token); | ||
} | ||
if (observer.type === "EXTERNAL" /* EXTERNAL */ && token.error != null) { | ||
// If this listener was added by a 3P call, send any token error to | ||
// the supplied error handler. A 3P observer always has an error | ||
// handler. | ||
observer.error(token.error); | ||
} | ||
else { | ||
// Otherwise return the token, whether or not it has an error field. | ||
// If the token has no error field, always return the token. | ||
// If this is a 2P listener, return the token, whether or not it | ||
// has an error field. | ||
observer.next(token); | ||
@@ -1038,3 +1037,3 @@ } | ||
catch (ignored) { | ||
// If any handler fails, ignore and run next handler. | ||
// Errors in the listener function itself are always ignored. | ||
} | ||
@@ -1162,3 +1161,3 @@ } | ||
} | ||
addTokenListener(app, platformLoggerProvider, nextFn, errorFn); | ||
addTokenListener(app, platformLoggerProvider, "EXTERNAL" /* EXTERNAL */, nextFn, errorFn); | ||
return function () { return removeTokenListener(app, nextFn); }; | ||
@@ -1220,3 +1219,3 @@ } | ||
addTokenListener: function (listener) { | ||
return addTokenListener(app, platformLoggerProvider, listener); | ||
return addTokenListener(app, platformLoggerProvider, "INTERNAL" /* INTERNAL */, listener); | ||
}, | ||
@@ -1228,3 +1227,3 @@ removeTokenListener: function (listener) { return removeTokenListener(app, listener); } | ||
var name = "@firebase/app-check"; | ||
var version = "0.1.4-canary.5d31e2192"; | ||
var version = "0.1.4-canary.ca857526b"; | ||
@@ -1231,0 +1230,0 @@ /** |
@@ -919,7 +919,8 @@ import firebase from '@firebase/app'; | ||
} | ||
function addTokenListener(app, platformLoggerProvider, listener, onError) { | ||
function addTokenListener(app, platformLoggerProvider, type, listener, onError) { | ||
var state = getState(app); | ||
var tokenListener = { | ||
next: listener, | ||
error: onError | ||
error: onError, | ||
type: type | ||
}; | ||
@@ -1015,14 +1016,12 @@ var newState = __assign(__assign({}, state), { tokenObservers: __spreadArray(__spreadArray([], state.tokenObservers), [tokenListener]) }); | ||
try { | ||
if (observer.error) { | ||
// If this listener has an error handler, handle errors differently | ||
// from successes. | ||
if (token.error) { | ||
observer.error(token.error); | ||
} | ||
else { | ||
observer.next(token); | ||
} | ||
if (observer.type === "EXTERNAL" /* EXTERNAL */ && token.error != null) { | ||
// If this listener was added by a 3P call, send any token error to | ||
// the supplied error handler. A 3P observer always has an error | ||
// handler. | ||
observer.error(token.error); | ||
} | ||
else { | ||
// Otherwise return the token, whether or not it has an error field. | ||
// If the token has no error field, always return the token. | ||
// If this is a 2P listener, return the token, whether or not it | ||
// has an error field. | ||
observer.next(token); | ||
@@ -1032,3 +1031,3 @@ } | ||
catch (ignored) { | ||
// If any handler fails, ignore and run next handler. | ||
// Errors in the listener function itself are always ignored. | ||
} | ||
@@ -1156,3 +1155,3 @@ } | ||
} | ||
addTokenListener(app, platformLoggerProvider, nextFn, errorFn); | ||
addTokenListener(app, platformLoggerProvider, "EXTERNAL" /* EXTERNAL */, nextFn, errorFn); | ||
return function () { return removeTokenListener(app, nextFn); }; | ||
@@ -1214,3 +1213,3 @@ } | ||
addTokenListener: function (listener) { | ||
return addTokenListener(app, platformLoggerProvider, listener); | ||
return addTokenListener(app, platformLoggerProvider, "INTERNAL" /* INTERNAL */, listener); | ||
}, | ||
@@ -1222,3 +1221,3 @@ removeTokenListener: function (listener) { return removeTokenListener(app, listener); } | ||
var name = "@firebase/app-check"; | ||
var version = "0.1.4-canary.5d31e2192"; | ||
var version = "0.1.4-canary.ca857526b"; | ||
@@ -1225,0 +1224,0 @@ /** |
@@ -819,7 +819,8 @@ import firebase from '@firebase/app'; | ||
} | ||
function addTokenListener(app, platformLoggerProvider, listener, onError) { | ||
function addTokenListener(app, platformLoggerProvider, type, listener, onError) { | ||
const state = getState(app); | ||
const tokenListener = { | ||
next: listener, | ||
error: onError | ||
error: onError, | ||
type | ||
}; | ||
@@ -905,14 +906,12 @@ const newState = Object.assign(Object.assign({}, state), { tokenObservers: [...state.tokenObservers, tokenListener] }); | ||
try { | ||
if (observer.error) { | ||
// If this listener has an error handler, handle errors differently | ||
// from successes. | ||
if (token.error) { | ||
observer.error(token.error); | ||
} | ||
else { | ||
observer.next(token); | ||
} | ||
if (observer.type === "EXTERNAL" /* EXTERNAL */ && token.error != null) { | ||
// If this listener was added by a 3P call, send any token error to | ||
// the supplied error handler. A 3P observer always has an error | ||
// handler. | ||
observer.error(token.error); | ||
} | ||
else { | ||
// Otherwise return the token, whether or not it has an error field. | ||
// If the token has no error field, always return the token. | ||
// If this is a 2P listener, return the token, whether or not it | ||
// has an error field. | ||
observer.next(token); | ||
@@ -922,3 +921,3 @@ } | ||
catch (ignored) { | ||
// If any handler fails, ignore and run next handler. | ||
// Errors in the listener function itself are always ignored. | ||
} | ||
@@ -1037,3 +1036,3 @@ } | ||
} | ||
addTokenListener(app, platformLoggerProvider, nextFn, errorFn); | ||
addTokenListener(app, platformLoggerProvider, "EXTERNAL" /* EXTERNAL */, nextFn, errorFn); | ||
return () => removeTokenListener(app, nextFn); | ||
@@ -1085,3 +1084,3 @@ } | ||
getToken: forceRefresh => getToken$1(app, platformLoggerProvider, forceRefresh), | ||
addTokenListener: listener => addTokenListener(app, platformLoggerProvider, listener), | ||
addTokenListener: listener => addTokenListener(app, platformLoggerProvider, "INTERNAL" /* INTERNAL */, listener), | ||
removeTokenListener: listener => removeTokenListener(app, listener) | ||
@@ -1092,3 +1091,3 @@ }; | ||
const name = "@firebase/app-check"; | ||
const version = "0.1.4-canary.5d31e2192"; | ||
const version = "0.1.4-canary.ca857526b"; | ||
@@ -1095,0 +1094,0 @@ /** |
@@ -19,2 +19,3 @@ /** | ||
import { AppCheckTokenListener, AppCheckTokenResult } from '@firebase/app-check-interop-types'; | ||
import { ListenerType } from './state'; | ||
import { Provider } from '@firebase/component'; | ||
@@ -36,3 +37,3 @@ export declare const defaultTokenErrorData: { | ||
export declare function getToken(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>, forceRefresh?: boolean): Promise<AppCheckTokenResult>; | ||
export declare function addTokenListener(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>, listener: AppCheckTokenListener, onError?: (error: Error) => void): void; | ||
export declare function addTokenListener(app: FirebaseApp, platformLoggerProvider: Provider<'platform-logger'>, type: ListenerType, listener: AppCheckTokenListener, onError?: (error: Error) => void): void; | ||
export declare function removeTokenListener(app: FirebaseApp, listener: (token: AppCheckTokenResult) => void): void; |
@@ -28,3 +28,8 @@ /** | ||
next: AppCheckTokenListener; | ||
type: ListenerType; | ||
} | ||
export declare const enum ListenerType { | ||
'INTERNAL' = "INTERNAL", | ||
'EXTERNAL' = "EXTERNAL" | ||
} | ||
export interface AppCheckState { | ||
@@ -31,0 +36,0 @@ activated: boolean; |
{ | ||
"name": "@firebase/app-check", | ||
"version": "0.1.4-canary.5d31e2192", | ||
"version": "0.1.4-canary.ca857526b", | ||
"description": "The App Check component of the Firebase JS SDK", | ||
@@ -27,11 +27,11 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"peerDependencies": { | ||
"@firebase/app": "0.6.27-canary.5d31e2192", | ||
"@firebase/app-types": "0.6.2-canary.5d31e2192" | ||
"@firebase/app": "0.6.27-canary.ca857526b", | ||
"@firebase/app-types": "0.6.2-canary.ca857526b" | ||
}, | ||
"dependencies": { | ||
"@firebase/app-check-types": "0.1.0-canary.5d31e2192", | ||
"@firebase/app-check-interop-types": "0.1.0-canary.5d31e2192", | ||
"@firebase/util": "1.1.0-canary.5d31e2192", | ||
"@firebase/component": "0.5.3-canary.5d31e2192", | ||
"@firebase/logger": "0.2.6-canary.5d31e2192", | ||
"@firebase/app-check-types": "0.1.0-canary.ca857526b", | ||
"@firebase/app-check-interop-types": "0.1.0-canary.ca857526b", | ||
"@firebase/util": "1.1.0-canary.ca857526b", | ||
"@firebase/component": "0.5.3-canary.ca857526b", | ||
"@firebase/logger": "0.2.6-canary.ca857526b", | ||
"tslib": "^2.1.0" | ||
@@ -41,3 +41,3 @@ }, | ||
"devDependencies": { | ||
"@firebase/app": "0.6.27-canary.5d31e2192", | ||
"@firebase/app": "0.6.27-canary.ca857526b", | ||
"rollup": "2.52.2", | ||
@@ -44,0 +44,0 @@ "@rollup/plugin-json": "4.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
412426
4278
+ Added@firebase/app@0.6.27-canary.ca857526b(transitive)
+ Added@firebase/app-check-interop-types@0.1.0-canary.ca857526b(transitive)
+ Added@firebase/app-check-types@0.1.0-canary.ca857526b(transitive)
+ Added@firebase/app-types@0.6.2-canary.ca857526b(transitive)
+ Added@firebase/component@0.5.3-canary.ca857526b(transitive)
+ Added@firebase/logger@0.2.6-canary.ca857526b(transitive)
+ Added@firebase/util@1.1.0-canary.ca857526b(transitive)
- Removed@firebase/app@0.6.27-canary.5d31e2192(transitive)
- Removed@firebase/app-check-interop-types@0.1.0-canary.5d31e2192(transitive)
- Removed@firebase/app-check-types@0.1.0-canary.5d31e2192(transitive)
- Removed@firebase/app-types@0.6.2-canary.5d31e2192(transitive)
- Removed@firebase/component@0.5.3-canary.5d31e2192(transitive)
- Removed@firebase/logger@0.2.6-canary.5d31e2192(transitive)
- Removed@firebase/util@1.1.0-canary.5d31e2192(transitive)
Updated@firebase/app-check-interop-types@0.1.0-canary.ca857526b