| 102 | |
| 103 | let customProvider: AppCheckProviderFactory; |
| 104 | export class AppCheck implements IAppCheck { |
| 105 | _native: com.google.firebase.appcheck.FirebaseAppCheck; |
| 106 | _nativeApp; |
| 107 | constructor(app?: FirebaseApp) { |
| 108 | if (app?.native) { |
| 109 | this._nativeApp = app.native; |
| 110 | this._native = com.google.firebase.appcheck.FirebaseAppCheck.getInstance(app.native); |
| 111 | } else { |
| 112 | if (defaultAppCheck) { |
| 113 | return defaultAppCheck; |
| 114 | } |
| 115 | defaultAppCheck = this; |
| 116 | this._nativeApp = (<any>com).google.firebase.FirebaseApp.getInstance(); |
| 117 | this._native = com.google.firebase.appcheck.FirebaseAppCheck.getInstance(); |
| 118 | } |
| 119 | } |
| 120 | static setProviderFactory(custom?: AppCheckProviderFactory) { |
| 121 | if (custom && custom instanceof AppCheckProviderFactory) { |
| 122 | customProvider = custom; |
| 123 | } else { |
| 124 | customProvider = undefined; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | activate(isTokenAutoRefreshEnabled: boolean) { |
| 129 | this.native.setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled); |
| 130 | if (customProvider) { |
| 131 | this.native.installAppCheckProviderFactory(customProvider.native); |
| 132 | } else { |
| 133 | this.native.installAppCheckProviderFactory(com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory.getInstance()); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | getToken(forceRefresh: boolean): Promise<AppCheckToken> { |
| 138 | return new Promise((resolve, reject) => { |
| 139 | NSAppCheck().getToken( |
| 140 | this.native, |
| 141 | forceRefresh, |
| 142 | new org.nativescript.firebase.app_check.FirebaseAppCheck.Callback({ |
| 143 | onSuccess(param0) { |
| 144 | resolve(AppCheckToken.fromNative(param0)); |
| 145 | }, |
| 146 | onError(param0) { |
| 147 | const err = FirebaseError.fromNative(param0); |
| 148 | reject(err); |
| 149 | }, |
| 150 | }) |
| 151 | ); |
| 152 | }); |
| 153 | } |
| 154 | setTokenAutoRefreshEnabled(enabled: boolean) { |
| 155 | this.native.setTokenAutoRefreshEnabled(enabled); |
| 156 | } |
| 157 | get native() { |
| 158 | return this._native; |
| 159 | } |
| 160 | get ios() { |
| 161 | return this.native; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…