MCPcopy Create free account
hub / github.com/NativeScript/firebase / AppCheck

Class AppCheck

packages/firebase-app-check-debug/index.ios.ts:49–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48let provider;
49export class AppCheck implements IAppCheck {
50 _native: FIRAppCheck;
51 _nativeApp;
52 _app: FirebaseApp;
53 constructor(app?: FirebaseApp) {
54 if (app?.native) {
55 this._native = FIRAppCheck.appCheckWithApp(app.native);
56 this._nativeApp = app.native;
57 } else {
58 if (defaultAppCheck) {
59 return defaultAppCheck;
60 }
61 defaultAppCheck = this;
62 this._native = FIRAppCheck.appCheck();
63 this._nativeApp = FIRApp.defaultApp();
64 }
65 }
66
67 static setProviderFactory() {
68 if (!provider) {
69 provider = FIRAppCheckDebugProviderFactory.alloc().init();
70 }
71 FIRAppCheck.setAppCheckProviderFactory(provider);
72 }
73
74 activate(isTokenAutoRefreshEnabled: boolean) {
75 this.native.isTokenAutoRefreshEnabled = isTokenAutoRefreshEnabled;
76 }
77 getToken(forceRefresh: boolean): Promise<AppCheckToken> {
78 return new Promise((resolve, reject) => {
79 this.native.tokenForcingRefreshCompletion(forceRefresh, (token, error) => {
80 if (error) {
81 const err = FirebaseError.fromNative(error);
82 reject(err);
83 } else {
84 resolve(AppCheckToken.fromNative(token));
85 }
86 });
87 });
88 }
89 setTokenAutoRefreshEnabled(enabled: boolean) {
90 this.native.isTokenAutoRefreshEnabled = enabled;
91 }
92 get native() {
93 return this._native;
94 }
95 get ios() {
96 return this.native;
97 }
98 get app(): FirebaseApp {
99 if (!this._app) {
100 // @ts-ignore
101 this._app = FirebaseApp.fromNative(this._nativeApp);
102 }
103 return this._app;
104 }
105}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected