New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/data-connect

Package Overview
Dependencies
Maintainers
0
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/data-connect - npm Package Compare versions

Comparing version 0.0.3-dataconnect-preview.d986d4bf2 to 0.1.0-20240930164710

dist/node-esm/src/core/AppCheckTokenProvider.d.ts

147

dist/index.cjs.js

@@ -11,3 +11,3 @@ 'use strict';

const name = "@firebase/data-connect";
const version = "0.0.3-dataconnect-preview.d986d4bf2";
const version = "0.1.0-20240930164710";

@@ -56,2 +56,56 @@ /**

*/
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
class AppCheckTokenProvider {
constructor(appName_, appCheckProvider) {
this.appName_ = appName_;
this.appCheckProvider = appCheckProvider;
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
if (!this.appCheck) {
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch());
}
}
getToken(forceRefresh) {
if (!this.appCheck) {
return new Promise((resolve, reject) => {
// Support delayed initialization of FirebaseAppCheck. This allows our
// customers to initialize the RTDB SDK before initializing Firebase
// AppCheck and ensures that all requests are authenticated if a token
// becomes available before the timoeout below expires.
setTimeout(() => {
if (this.appCheck) {
this.getToken(forceRefresh).then(resolve, reject);
}
else {
resolve(null);
}
}, 0);
});
}
return this.appCheck.getToken(forceRefresh);
}
addTokenChangeListener(listener) {
var _a;
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener)));
}
}
/**
* @license
* Copyright 2024 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 Code = {

@@ -131,2 +185,3 @@ OTHER: 'other',

*/
// @internal
class FirebaseAuthProvider {

@@ -415,3 +470,3 @@ constructor(_appName, _options, _authProvider) {

}
return `${baseUrl}/v1alpha/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
}

@@ -451,3 +506,3 @@ function addToken(url, apiKey) {

}
function dcFetch(url, body, { signal }, accessToken, _isUsingGen) {
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) {
if (!connectFetch) {

@@ -463,2 +518,8 @@ throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');

}
if (appId) {
headers['x-firebase-gmpid'] = appId;
}
if (appCheckToken) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
const bodyStr = JSON.stringify(body);

@@ -526,6 +587,8 @@ logDebug(`Making request out to ${url} with body: ${bodyStr}`);

class RESTTransport {
constructor(options, apiKey, authProvider, transportOptions, _isUsingGen = false) {
var _a;
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) {
var _a, _b;
this.apiKey = apiKey;
this.appId = appId;
this.authProvider = authProvider;
this.appCheckProvider = appCheckProvider;
this._isUsingGen = _isUsingGen;

@@ -538,3 +601,3 @@ this._host = '';

this._accessToken = null;
this._authInitialized = false;
this._appCheckToken = null;
this._lastToken = null;

@@ -550,3 +613,3 @@ // TODO(mtewani): Update U to include shape of body defined in line 13.

}, // TODO(mtewani): This is a patch, fix this.
abortController, this._accessToken, this._isUsingGen));
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen));
return {

@@ -564,3 +627,3 @@ then: withAuth.then.bind(withAuth),

variables: body
}, abortController, this._accessToken, this._isUsingGen);
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen);
});

@@ -599,2 +662,7 @@ return {

});
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => {
const { token } = result;
logDebug(`New App Check Token Available: ${token}`);
this._appCheckToken = token;
});
}

@@ -621,20 +689,22 @@ get endpointUrl() {

}
getWithAuth(forceToken = false) {
async getWithAuth(forceToken = false) {
var _a;
let starterPromise = new Promise(resolve => resolve(this._accessToken));
if (!this._authInitialized) {
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
if (this.appCheckProvider) {
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token;
}
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
return starterPromise;

@@ -764,10 +834,12 @@ }

class DataConnect {
// @internal
constructor(app,
// TODO(mtewani): Replace with _dataConnectOptions in the future
dataConnectOptions, _authProvider) {
dataConnectOptions, _authProvider, _appCheckProvider) {
this.app = app;
this.dataConnectOptions = dataConnectOptions;
this._authProvider = _authProvider;
this._appCheckProvider = _appCheckProvider;
this.isEmulator = false;
this.initialized = false;
this._initialized = false;
this._isUsingGeneratedSdk = false;

@@ -783,5 +855,3 @@ if (typeof process !== 'undefined' && process.env) {

}
/*
@internal
*/
// @internal
_useGeneratedSdk() {

@@ -796,2 +866,3 @@ if (!this._isUsingGeneratedSdk) {

}
// @internal
getSettings() {

@@ -802,4 +873,5 @@ const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));

}
// @internal
setInitialized() {
if (this.initialized) {
if (this._initialized) {
return;

@@ -814,4 +886,7 @@ }

}
this.initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._appCheckProvider) {
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app.name, this._appCheckProvider);
}
this._initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._transportOptions) {

@@ -823,4 +898,5 @@ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);

}
// @internal
enableEmulator(transportOptions) {
if (this.initialized) {
if (this._initialized) {
logError('enableEmulator called after initialization');

@@ -925,2 +1001,3 @@ throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');

const authProvider = container.getProvider('auth-internal');
const appCheckProvider = container.getProvider('app-check-internal');
let newOpts = options;

@@ -933,3 +1010,3 @@ if (settings) {

}
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider);
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));

@@ -1099,4 +1176,2 @@ app.registerVersion(name, version, variant);

exports.DataConnect = DataConnect;
exports.FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR;
exports.FirebaseAuthProvider = FirebaseAuthProvider;
exports.MUTATION_STR = MUTATION_STR;

@@ -1103,0 +1178,0 @@ exports.MutationManager = MutationManager;

@@ -7,3 +7,3 @@ import { _removeServiceInstance, getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';

const name = "@firebase/data-connect";
const version = "0.0.3-dataconnect-preview.d986d4bf2";
const version = "0.1.0-20240930164710";

@@ -52,2 +52,56 @@ /**

*/
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
class AppCheckTokenProvider {
constructor(appName_, appCheckProvider) {
this.appName_ = appName_;
this.appCheckProvider = appCheckProvider;
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
if (!this.appCheck) {
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch());
}
}
getToken(forceRefresh) {
if (!this.appCheck) {
return new Promise((resolve, reject) => {
// Support delayed initialization of FirebaseAppCheck. This allows our
// customers to initialize the RTDB SDK before initializing Firebase
// AppCheck and ensures that all requests are authenticated if a token
// becomes available before the timoeout below expires.
setTimeout(() => {
if (this.appCheck) {
this.getToken(forceRefresh).then(resolve, reject);
}
else {
resolve(null);
}
}, 0);
});
}
return this.appCheck.getToken(forceRefresh);
}
addTokenChangeListener(listener) {
var _a;
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener)));
}
}
/**
* @license
* Copyright 2024 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 Code = {

@@ -127,2 +181,3 @@ OTHER: 'other',

*/
// @internal
class FirebaseAuthProvider {

@@ -411,3 +466,3 @@ constructor(_appName, _options, _authProvider) {

}
return `${baseUrl}/v1alpha/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
}

@@ -447,3 +502,3 @@ function addToken(url, apiKey) {

}
function dcFetch(url, body, { signal }, accessToken, _isUsingGen) {
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) {
if (!connectFetch) {

@@ -459,2 +514,8 @@ throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');

}
if (appId) {
headers['x-firebase-gmpid'] = appId;
}
if (appCheckToken) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
const bodyStr = JSON.stringify(body);

@@ -522,6 +583,8 @@ logDebug(`Making request out to ${url} with body: ${bodyStr}`);

class RESTTransport {
constructor(options, apiKey, authProvider, transportOptions, _isUsingGen = false) {
var _a;
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) {
var _a, _b;
this.apiKey = apiKey;
this.appId = appId;
this.authProvider = authProvider;
this.appCheckProvider = appCheckProvider;
this._isUsingGen = _isUsingGen;

@@ -534,3 +597,3 @@ this._host = '';

this._accessToken = null;
this._authInitialized = false;
this._appCheckToken = null;
this._lastToken = null;

@@ -546,3 +609,3 @@ // TODO(mtewani): Update U to include shape of body defined in line 13.

}, // TODO(mtewani): This is a patch, fix this.
abortController, this._accessToken, this._isUsingGen));
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen));
return {

@@ -560,3 +623,3 @@ then: withAuth.then.bind(withAuth),

variables: body
}, abortController, this._accessToken, this._isUsingGen);
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen);
});

@@ -595,2 +658,7 @@ return {

});
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => {
const { token } = result;
logDebug(`New App Check Token Available: ${token}`);
this._appCheckToken = token;
});
}

@@ -617,20 +685,22 @@ get endpointUrl() {

}
getWithAuth(forceToken = false) {
async getWithAuth(forceToken = false) {
var _a;
let starterPromise = new Promise(resolve => resolve(this._accessToken));
if (!this._authInitialized) {
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
if (this.appCheckProvider) {
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token;
}
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
return starterPromise;

@@ -760,10 +830,12 @@ }

class DataConnect {
// @internal
constructor(app,
// TODO(mtewani): Replace with _dataConnectOptions in the future
dataConnectOptions, _authProvider) {
dataConnectOptions, _authProvider, _appCheckProvider) {
this.app = app;
this.dataConnectOptions = dataConnectOptions;
this._authProvider = _authProvider;
this._appCheckProvider = _appCheckProvider;
this.isEmulator = false;
this.initialized = false;
this._initialized = false;
this._isUsingGeneratedSdk = false;

@@ -779,5 +851,3 @@ if (typeof process !== 'undefined' && process.env) {

}
/*
@internal
*/
// @internal
_useGeneratedSdk() {

@@ -792,2 +862,3 @@ if (!this._isUsingGeneratedSdk) {

}
// @internal
getSettings() {

@@ -798,4 +869,5 @@ const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));

}
// @internal
setInitialized() {
if (this.initialized) {
if (this._initialized) {
return;

@@ -810,4 +882,7 @@ }

}
this.initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._appCheckProvider) {
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app.name, this._appCheckProvider);
}
this._initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._transportOptions) {

@@ -819,4 +894,5 @@ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);

}
// @internal
enableEmulator(transportOptions) {
if (this.initialized) {
if (this._initialized) {
logError('enableEmulator called after initialization');

@@ -921,2 +997,3 @@ throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');

const authProvider = container.getProvider('auth-internal');
const appCheckProvider = container.getProvider('app-check-internal');
let newOpts = options;

@@ -929,3 +1006,3 @@ if (settings) {

}
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider);
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));

@@ -1094,3 +1171,3 @@ registerVersion(name, version, variant);

export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
export { DataConnect, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
//# sourceMappingURL=index.esm2017.js.map

@@ -8,3 +8,3 @@ import { __extends, __assign, __awaiter, __generator } from 'tslib';

var name = "@firebase/data-connect";
var version = "0.0.3-dataconnect-preview.d986d4bf2";
var version = "0.1.0-20240930164710";

@@ -53,2 +53,59 @@ /**

*/
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
var AppCheckTokenProvider = /** @class */ (function () {
function AppCheckTokenProvider(appName_, appCheckProvider) {
var _this = this;
this.appName_ = appName_;
this.appCheckProvider = appCheckProvider;
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
if (!this.appCheck) {
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch());
}
}
AppCheckTokenProvider.prototype.getToken = function (forceRefresh) {
var _this = this;
if (!this.appCheck) {
return new Promise(function (resolve, reject) {
// Support delayed initialization of FirebaseAppCheck. This allows our
// customers to initialize the RTDB SDK before initializing Firebase
// AppCheck and ensures that all requests are authenticated if a token
// becomes available before the timoeout below expires.
setTimeout(function () {
if (_this.appCheck) {
_this.getToken(forceRefresh).then(resolve, reject);
}
else {
resolve(null);
}
}, 0);
});
}
return this.appCheck.getToken(forceRefresh);
};
AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) {
var _a;
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); }));
};
return AppCheckTokenProvider;
}());
/**
* @license
* Copyright 2024 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.
*/
var Code = {

@@ -131,2 +188,3 @@ OTHER: 'other',

*/
// @internal
var FirebaseAuthProvider = /** @class */ (function () {

@@ -420,3 +478,3 @@ function FirebaseAuthProvider(_appName, _options, _authProvider) {

}
return "".concat(baseUrl, "/v1alpha/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector);
return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector);
}

@@ -456,3 +514,3 @@ function addToken(url, apiKey) {

}
function dcFetch(url, body, _a, accessToken, _isUsingGen) {
function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) {
var _this = this;

@@ -470,2 +528,8 @@ var signal = _a.signal;

}
if (appId) {
headers['x-firebase-gmpid'] = appId;
}
if (appCheckToken) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
var bodyStr = JSON.stringify(body);

@@ -544,8 +608,10 @@ logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr));

var RESTTransport = /** @class */ (function () {
function RESTTransport(options, apiKey, authProvider, transportOptions, _isUsingGen) {
function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) {
if (_isUsingGen === void 0) { _isUsingGen = false; }
var _this = this;
var _a;
var _a, _b;
this.apiKey = apiKey;
this.appId = appId;
this.authProvider = authProvider;
this.appCheckProvider = appCheckProvider;
this._isUsingGen = _isUsingGen;

@@ -558,3 +624,3 @@ this._host = '';

this._accessToken = null;
this._authInitialized = false;
this._appCheckToken = null;
this._lastToken = null;

@@ -571,3 +637,3 @@ // TODO(mtewani): Update U to include shape of body defined in line 13.

}, // TODO(mtewani): This is a patch, fix this.
abortController, _this._accessToken, _this._isUsingGen);
abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
});

@@ -586,3 +652,3 @@ return {

variables: body
}, abortController, _this._accessToken, _this._isUsingGen);
}, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
});

@@ -621,2 +687,7 @@ return {

});
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) {
var token = result.token;
logDebug("New App Check Token Available: ".concat(token));
_this._appCheckToken = token;
});
}

@@ -648,24 +719,38 @@ Object.defineProperty(RESTTransport.prototype, "endpointUrl", {

RESTTransport.prototype.getWithAuth = function (forceToken) {
var _this = this;
var _a;
if (forceToken === void 0) { forceToken = false; }
var starterPromise = new Promise(function (resolve) {
return resolve(_this._accessToken);
return __awaiter(this, void 0, void 0, function () {
var starterPromise, _b;
var _this = this;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
starterPromise = new Promise(function (resolve) {
return resolve(_this._accessToken);
});
if (!this.appCheckProvider) return [3 /*break*/, 2];
_b = this;
return [4 /*yield*/, this.appCheckProvider.getToken()];
case 1:
_b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token;
_c.label = 2;
case 2:
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(function (data) {
if (!data) {
return null;
}
_this._accessToken = data.accessToken;
return _this._accessToken;
});
}
else {
starterPromise = new Promise(function (resolve) { return resolve(''); });
}
return [2 /*return*/, starterPromise];
}
});
});
if (!this._authInitialized) {
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(function (data) {
if (!data) {
return null;
}
_this._accessToken = data.accessToken;
return _this._accessToken;
});
}
else {
starterPromise = new Promise(function (resolve) { return resolve(''); });
}
}
return starterPromise;
};

@@ -801,10 +886,12 @@ RESTTransport.prototype._setLastToken = function (lastToken) {

var DataConnect = /** @class */ (function () {
// @internal
function DataConnect(app,
// TODO(mtewani): Replace with _dataConnectOptions in the future
dataConnectOptions, _authProvider) {
dataConnectOptions, _authProvider, _appCheckProvider) {
this.app = app;
this.dataConnectOptions = dataConnectOptions;
this._authProvider = _authProvider;
this._appCheckProvider = _appCheckProvider;
this.isEmulator = false;
this.initialized = false;
this._initialized = false;
this._isUsingGeneratedSdk = false;

@@ -820,5 +907,3 @@ if (typeof process !== 'undefined' && process.env) {

}
/*
@internal
*/
// @internal
DataConnect.prototype._useGeneratedSdk = function () {

@@ -833,2 +918,3 @@ if (!this._isUsingGeneratedSdk) {

};
// @internal
DataConnect.prototype.getSettings = function () {

@@ -839,4 +925,5 @@ var copy = JSON.parse(JSON.stringify(this.dataConnectOptions));

};
// @internal
DataConnect.prototype.setInitialized = function () {
if (this.initialized) {
if (this._initialized) {
return;

@@ -851,4 +938,7 @@ }

}
this.initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._appCheckProvider) {
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app.name, this._appCheckProvider);
}
this._initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._transportOptions) {

@@ -860,4 +950,5 @@ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);

};
// @internal
DataConnect.prototype.enableEmulator = function (transportOptions) {
if (this.initialized) {
if (this._initialized) {
logError('enableEmulator called after initialization');

@@ -949,2 +1040,3 @@ throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');

var authProvider = container.getProvider('auth-internal');
var appCheckProvider = container.getProvider('app-check-internal');
var newOpts = options;

@@ -957,3 +1049,3 @@ if (settings) {

}
return new DataConnect(app, __assign(__assign({}, newOpts), { projectId: app.options.projectId }), authProvider);
return new DataConnect(app, __assign(__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));

@@ -1122,3 +1214,3 @@ registerVersion(name, version, variant);

export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
export { DataConnect, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
//# sourceMappingURL=index.esm5.js.map

@@ -141,3 +141,3 @@ 'use strict';

}
function dcFetch(url, body, _a, accessToken, _isUsingGen) {
function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) {
var _this = this;

@@ -155,2 +155,8 @@ var signal = _a.signal;

}
if (appId) {
headers['x-firebase-gmpid'] = appId;
}
if (appCheckToken) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
var bodyStr = JSON.stringify(body);

@@ -213,3 +219,3 @@ logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr));

var name = "@firebase/data-connect";
var version = "0.0.3-dataconnect-preview.d986d4bf2";
var version = "0.1.0-20240930164710";

@@ -232,2 +238,60 @@ /**

*/
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
var AppCheckTokenProvider = /** @class */ (function () {
function AppCheckTokenProvider(appName_, appCheckProvider) {
var _this = this;
this.appName_ = appName_;
this.appCheckProvider = appCheckProvider;
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
if (!this.appCheck) {
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch());
}
}
AppCheckTokenProvider.prototype.getToken = function (forceRefresh) {
var _this = this;
if (!this.appCheck) {
return new Promise(function (resolve, reject) {
// Support delayed initialization of FirebaseAppCheck. This allows our
// customers to initialize the RTDB SDK before initializing Firebase
// AppCheck and ensures that all requests are authenticated if a token
// becomes available before the timoeout below expires.
setTimeout(function () {
if (_this.appCheck) {
_this.getToken(forceRefresh).then(resolve, reject);
}
else {
resolve(null);
}
}, 0);
});
}
return this.appCheck.getToken(forceRefresh);
};
AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) {
var _a;
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); }));
};
return AppCheckTokenProvider;
}());
/**
* @license
* Copyright 2024 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.
*/
// @internal
var FirebaseAuthProvider = /** @class */ (function () {

@@ -521,3 +585,3 @@ function FirebaseAuthProvider(_appName, _options, _authProvider) {

}
return "".concat(baseUrl, "/v1alpha/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector);
return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector);
}

@@ -550,8 +614,10 @@ function addToken(url, apiKey) {

var RESTTransport = /** @class */ (function () {
function RESTTransport(options, apiKey, authProvider, transportOptions, _isUsingGen) {
function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) {
if (_isUsingGen === void 0) { _isUsingGen = false; }
var _this = this;
var _a;
var _a, _b;
this.apiKey = apiKey;
this.appId = appId;
this.authProvider = authProvider;
this.appCheckProvider = appCheckProvider;
this._isUsingGen = _isUsingGen;

@@ -564,3 +630,3 @@ this._host = '';

this._accessToken = null;
this._authInitialized = false;
this._appCheckToken = null;
this._lastToken = null;

@@ -577,3 +643,3 @@ // TODO(mtewani): Update U to include shape of body defined in line 13.

}, // TODO(mtewani): This is a patch, fix this.
abortController, _this._accessToken, _this._isUsingGen);
abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
});

@@ -592,3 +658,3 @@ return {

variables: body
}, abortController, _this._accessToken, _this._isUsingGen);
}, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
});

@@ -627,2 +693,7 @@ return {

});
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) {
var token = result.token;
logDebug("New App Check Token Available: ".concat(token));
_this._appCheckToken = token;
});
}

@@ -654,24 +725,38 @@ Object.defineProperty(RESTTransport.prototype, "endpointUrl", {

RESTTransport.prototype.getWithAuth = function (forceToken) {
var _this = this;
var _a;
if (forceToken === void 0) { forceToken = false; }
var starterPromise = new Promise(function (resolve) {
return resolve(_this._accessToken);
return tslib.__awaiter(this, void 0, void 0, function () {
var starterPromise, _b;
var _this = this;
return tslib.__generator(this, function (_c) {
switch (_c.label) {
case 0:
starterPromise = new Promise(function (resolve) {
return resolve(_this._accessToken);
});
if (!this.appCheckProvider) return [3 /*break*/, 2];
_b = this;
return [4 /*yield*/, this.appCheckProvider.getToken()];
case 1:
_b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token;
_c.label = 2;
case 2:
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(function (data) {
if (!data) {
return null;
}
_this._accessToken = data.accessToken;
return _this._accessToken;
});
}
else {
starterPromise = new Promise(function (resolve) { return resolve(''); });
}
return [2 /*return*/, starterPromise];
}
});
});
if (!this._authInitialized) {
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(function (data) {
if (!data) {
return null;
}
_this._accessToken = data.accessToken;
return _this._accessToken;
});
}
else {
starterPromise = new Promise(function (resolve) { return resolve(''); });
}
}
return starterPromise;
};

@@ -807,10 +892,12 @@ RESTTransport.prototype._setLastToken = function (lastToken) {

var DataConnect = /** @class */ (function () {
// @internal
function DataConnect(app,
// TODO(mtewani): Replace with _dataConnectOptions in the future
dataConnectOptions, _authProvider) {
dataConnectOptions, _authProvider, _appCheckProvider) {
this.app = app;
this.dataConnectOptions = dataConnectOptions;
this._authProvider = _authProvider;
this._appCheckProvider = _appCheckProvider;
this.isEmulator = false;
this.initialized = false;
this._initialized = false;
this._isUsingGeneratedSdk = false;

@@ -826,5 +913,3 @@ if (typeof process !== 'undefined' && process.env) {

}
/*
@internal
*/
// @internal
DataConnect.prototype._useGeneratedSdk = function () {

@@ -839,2 +924,3 @@ if (!this._isUsingGeneratedSdk) {

};
// @internal
DataConnect.prototype.getSettings = function () {

@@ -845,4 +931,5 @@ var copy = JSON.parse(JSON.stringify(this.dataConnectOptions));

};
// @internal
DataConnect.prototype.setInitialized = function () {
if (this.initialized) {
if (this._initialized) {
return;

@@ -857,4 +944,7 @@ }

}
this.initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._appCheckProvider) {
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app.name, this._appCheckProvider);
}
this._initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._transportOptions) {

@@ -866,4 +956,5 @@ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);

};
// @internal
DataConnect.prototype.enableEmulator = function (transportOptions) {
if (this.initialized) {
if (this._initialized) {
logError('enableEmulator called after initialization');

@@ -955,2 +1046,3 @@ throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');

var authProvider = container.getProvider('auth-internal');
var appCheckProvider = container.getProvider('app-check-internal');
var newOpts = options;

@@ -963,3 +1055,3 @@ if (settings) {

}
return new DataConnect(app, tslib.__assign(tslib.__assign({}, newOpts), { projectId: app.options.projectId }), authProvider);
return new DataConnect(app, tslib.__assign(tslib.__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));

@@ -1141,4 +1233,2 @@ app.registerVersion(name, version, variant);

exports.DataConnect = DataConnect;
exports.FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR;
exports.FirebaseAuthProvider = FirebaseAuthProvider;
exports.MUTATION_STR = MUTATION_STR;

@@ -1145,0 +1235,0 @@ exports.MutationManager = MutationManager;

@@ -7,2 +7,5 @@ /**

import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { FirebaseApp } from '@firebase/app';

@@ -12,9 +15,21 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';

import { FirebaseError } from '@firebase/util';
import { FirebaseOptions } from '@firebase/app-types';
import { LogLevelString } from '@firebase/logger';
import { Provider } from '@firebase/component';
export declare type AuthTokenListener = (token: string | null) => void;
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
declare class AppCheckTokenProvider {
private appName_;
private appCheckProvider?;
private appCheck?;
constructor(appName_: string, appCheckProvider?: Provider<AppCheckInternalComponentName>);
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
addTokenChangeListener(listener: AppCheckTokenListener): void;
}
export declare interface AuthTokenProvider {
declare type AuthTokenListener = (token: string | null) => void;
declare interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;

@@ -55,6 +70,7 @@ addTokenChangeListener(listener: AuthTokenListener): void;

private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
initialized: boolean;
_initialized: boolean;
private _transport;

@@ -65,3 +81,4 @@ private _transportClass;

_isUsingGeneratedSdk: boolean;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
private _appCheckTokenProvider?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
_useGeneratedSdk(): void;

@@ -120,2 +137,5 @@ _delete(): Promise<void>;

/**
* @internal
*/
export declare interface DataConnectTransport {

@@ -150,15 +170,2 @@ invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{

export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
export declare class FirebaseAuthProvider implements AuthTokenProvider {
private _appName;
private _options;
private _authProvider;
private _auth;
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
removeTokenChangeListener(listener: (token: string | null) => void): void;
}
/**

@@ -214,5 +221,2 @@ * Initialize DataConnect instance

export declare interface MutationResponse<T> extends CancellableOperation<T> {
}
/**

@@ -308,5 +312,2 @@ * Mutation Result from `executeMutation`

export declare interface QueryResponse<T> extends CancellableOperation<T> {
}
/**

@@ -336,7 +337,2 @@ * Result of `executeQuery`

export declare interface Sender<T> {
abort: () => void;
send: () => Promise<T>;
}
/**

@@ -403,3 +399,6 @@ * Serialized Ref as a result of `QueryResult.toJSON()`

export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
/**
* @internal
*/
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;

@@ -406,0 +405,0 @@ /**

@@ -133,3 +133,3 @@ import { FirebaseError } from '@firebase/util';

}
function dcFetch(url, body, { signal }, accessToken, _isUsingGen) {
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) {
if (!connectFetch) {

@@ -145,2 +145,8 @@ throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');

}
if (appId) {
headers['x-firebase-gmpid'] = appId;
}
if (appCheckToken) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
const bodyStr = JSON.stringify(body);

@@ -192,3 +198,3 @@ logDebug(`Making request out to ${url} with body: ${bodyStr}`);

const name = "@firebase/data-connect";
const version = "0.0.3-dataconnect-preview.d986d4bf2";
const version = "0.1.0-20240930164710";

@@ -211,2 +217,57 @@ /**

*/
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
class AppCheckTokenProvider {
constructor(appName_, appCheckProvider) {
this.appName_ = appName_;
this.appCheckProvider = appCheckProvider;
this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
if (!this.appCheck) {
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch());
}
}
getToken(forceRefresh) {
if (!this.appCheck) {
return new Promise((resolve, reject) => {
// Support delayed initialization of FirebaseAppCheck. This allows our
// customers to initialize the RTDB SDK before initializing Firebase
// AppCheck and ensures that all requests are authenticated if a token
// becomes available before the timoeout below expires.
setTimeout(() => {
if (this.appCheck) {
this.getToken(forceRefresh).then(resolve, reject);
}
else {
resolve(null);
}
}, 0);
});
}
return this.appCheck.getToken(forceRefresh);
}
addTokenChangeListener(listener) {
var _a;
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener)));
}
}
/**
* @license
* Copyright 2024 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.
*/
// @internal
class FirebaseAuthProvider {

@@ -495,3 +556,3 @@ constructor(_appName, _options, _authProvider) {

}
return `${baseUrl}/v1alpha/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
}

@@ -524,6 +585,8 @@ function addToken(url, apiKey) {

class RESTTransport {
constructor(options, apiKey, authProvider, transportOptions, _isUsingGen = false) {
var _a;
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) {
var _a, _b;
this.apiKey = apiKey;
this.appId = appId;
this.authProvider = authProvider;
this.appCheckProvider = appCheckProvider;
this._isUsingGen = _isUsingGen;

@@ -536,3 +599,3 @@ this._host = '';

this._accessToken = null;
this._authInitialized = false;
this._appCheckToken = null;
this._lastToken = null;

@@ -548,3 +611,3 @@ // TODO(mtewani): Update U to include shape of body defined in line 13.

}, // TODO(mtewani): This is a patch, fix this.
abortController, this._accessToken, this._isUsingGen));
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen));
return {

@@ -562,3 +625,3 @@ then: withAuth.then.bind(withAuth),

variables: body
}, abortController, this._accessToken, this._isUsingGen);
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen);
});

@@ -597,2 +660,7 @@ return {

});
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => {
const { token } = result;
logDebug(`New App Check Token Available: ${token}`);
this._appCheckToken = token;
});
}

@@ -619,20 +687,22 @@ get endpointUrl() {

}
getWithAuth(forceToken = false) {
async getWithAuth(forceToken = false) {
var _a;
let starterPromise = new Promise(resolve => resolve(this._accessToken));
if (!this._authInitialized) {
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
if (this.appCheckProvider) {
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token;
}
if (this.authProvider) {
starterPromise = this.authProvider
.getToken(/*forceToken=*/ forceToken)
.then(data => {
if (!data) {
return null;
}
this._accessToken = data.accessToken;
return this._accessToken;
});
}
else {
starterPromise = new Promise(resolve => resolve(''));
}
return starterPromise;

@@ -762,10 +832,12 @@ }

class DataConnect {
// @internal
constructor(app,
// TODO(mtewani): Replace with _dataConnectOptions in the future
dataConnectOptions, _authProvider) {
dataConnectOptions, _authProvider, _appCheckProvider) {
this.app = app;
this.dataConnectOptions = dataConnectOptions;
this._authProvider = _authProvider;
this._appCheckProvider = _appCheckProvider;
this.isEmulator = false;
this.initialized = false;
this._initialized = false;
this._isUsingGeneratedSdk = false;

@@ -781,5 +853,3 @@ if (typeof process !== 'undefined' && process.env) {

}
/*
@internal
*/
// @internal
_useGeneratedSdk() {

@@ -794,2 +864,3 @@ if (!this._isUsingGeneratedSdk) {

}
// @internal
getSettings() {

@@ -800,4 +871,5 @@ const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));

}
// @internal
setInitialized() {
if (this.initialized) {
if (this._initialized) {
return;

@@ -812,4 +884,7 @@ }

}
this.initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._appCheckProvider) {
this._appCheckTokenProvider = new AppCheckTokenProvider(this.app.name, this._appCheckProvider);
}
this._initialized = true;
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this.app.options.appId, this._authTokenProvider, this._appCheckTokenProvider, undefined, this._isUsingGeneratedSdk);
if (this._transportOptions) {

@@ -821,4 +896,5 @@ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);

}
// @internal
enableEmulator(transportOptions) {
if (this.initialized) {
if (this._initialized) {
logError('enableEmulator called after initialization');

@@ -923,2 +999,3 @@ throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');

const authProvider = container.getProvider('auth-internal');
const appCheckProvider = container.getProvider('app-check-internal');
let newOpts = options;

@@ -931,3 +1008,3 @@ if (settings) {

}
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider);
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));

@@ -1108,3 +1185,3 @@ registerVersion(name, version, variant);

export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
export { DataConnect, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef, validateArgs, validateDCOptions };
//# sourceMappingURL=index.node.esm.js.map

@@ -18,2 +18,3 @@ /**

import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';

@@ -39,3 +40,2 @@ import { Provider } from '@firebase/component';

}
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
/**

@@ -61,6 +61,7 @@ *

private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
initialized: boolean;
_initialized: boolean;
private _transport;

@@ -71,3 +72,4 @@ private _transportClass;

_isUsingGeneratedSdk: boolean;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
private _appCheckTokenProvider?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
_useGeneratedSdk(): void;

@@ -74,0 +76,0 @@ _delete(): Promise<void>;

@@ -18,5 +18,5 @@ /**

export declare function initializeFetch(fetchImpl: typeof fetch): void;
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, accessToken: string | null, _isUsingGen: boolean): Promise<{
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, appId: string | null, accessToken: string | null, appCheckToken: string | null, _isUsingGen: boolean): Promise<{
data: T;
errors: Error[];
}>;

@@ -18,3 +18,7 @@ /**

import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
/**
* @internal
*/
export interface DataConnectTransport {

@@ -37,11 +41,5 @@ invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{

}
export interface QueryResponse<T> extends CancellableOperation<T> {
}
export interface MutationResponse<T> extends CancellableOperation<T> {
}
export interface Sender<T> {
abort: () => void;
send: () => Promise<T>;
}
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
export * from '../../core/FirebaseAuthProvider';
/**
* @internal
*/
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;

@@ -18,2 +18,3 @@ /**

import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';

@@ -23,3 +24,5 @@ import { DataConnectTransport } from '.';

private apiKey?;
private appId?;
private authProvider?;
private appCheckProvider?;
private _isUsingGen;

@@ -34,5 +37,5 @@ private _host;

private _accessToken;
private _authInitialized;
private _appCheckToken;
private _lastToken;
constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
get endpointUrl(): string;

@@ -39,0 +42,0 @@ useEmulator(host: string, port?: number, isSecure?: boolean): void;

@@ -7,2 +7,5 @@ /**

import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { FirebaseApp } from '@firebase/app';

@@ -12,9 +15,10 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';

import { FirebaseError } from '@firebase/util';
import { FirebaseOptions } from '@firebase/app-types';
import { LogLevelString } from '@firebase/logger';
import { Provider } from '@firebase/component';
export declare type AuthTokenListener = (token: string | null) => void;
/* Excluded from this release type: AppCheckTokenProvider */
export declare interface AuthTokenProvider {
declare type AuthTokenListener = (token: string | null) => void;
declare interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;

@@ -55,6 +59,7 @@ addTokenChangeListener(listener: AuthTokenListener): void;

private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
initialized: boolean;
_initialized: boolean;
private _transport;

@@ -65,3 +70,4 @@ private _transportClass;

_isUsingGeneratedSdk: boolean;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
private _appCheckTokenProvider?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
_useGeneratedSdk(): void;

@@ -120,14 +126,3 @@ _delete(): Promise<void>;

export declare interface DataConnectTransport {
invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
data: T;
errors: Error[];
}>;
invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
data: T;
errors: Error[];
}>;
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
onTokenChanged: (token: string | null) => void;
}
/* Excluded from this release type: DataConnectTransport */

@@ -150,15 +145,2 @@ export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;

export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
export declare class FirebaseAuthProvider implements AuthTokenProvider {
private _appName;
private _options;
private _authProvider;
private _auth;
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
removeTokenChangeListener(listener: (token: string | null) => void): void;
}
/**

@@ -206,5 +188,2 @@ * Initialize DataConnect instance

export declare interface MutationResponse<T> extends CancellableOperation<T> {
}
/**

@@ -294,5 +273,2 @@ * Mutation Result from `executeMutation`

export declare interface QueryResponse<T> extends CancellableOperation<T> {
}
/**

@@ -322,7 +298,2 @@ * Result of `executeQuery`

export declare interface Sender<T> {
abort: () => void;
send: () => Promise<T>;
}
/**

@@ -389,3 +360,3 @@ * Serialized Ref as a result of `QueryResult.toJSON()`

export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
/* Excluded from this release type: TransportClass */

@@ -392,0 +363,0 @@ /**

@@ -7,5 +7,4 @@ /**

import { FirebaseApp } from '@firebase/app';
import { FirebaseOptions } from '@firebase/app-types';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';

@@ -15,7 +14,3 @@ import { LogLevelString } from '@firebase/logger';

export declare type AuthTokenListener = (token: string | null) => void;
export declare interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
}
export declare interface CancellableOperation<T> extends PromiseLike<{

@@ -49,4 +44,3 @@ data: T;

isEmulator: boolean;
initialized: boolean;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
getSettings(): ConnectorConfig;

@@ -73,14 +67,3 @@ setInitialized(): void;

}
export declare interface DataConnectTransport {
invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
data: T;
errors: Error[];
}>;
invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
data: T;
errors: Error[];
}>;
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
onTokenChanged: (token: string | null) => void;
}
/* Excluded from this release type: DataConnectTransport */
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;

@@ -99,9 +82,2 @@ /**

export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
export declare class FirebaseAuthProvider implements AuthTokenProvider {
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
removeTokenChangeListener(listener: (token: string | null) => void): void;
}
/**

@@ -141,4 +117,2 @@ * Initialize DataConnect instance

export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
export declare interface MutationResponse<T> extends CancellableOperation<T> {
}
/**

@@ -201,4 +175,2 @@ * Mutation Result from `executeMutation`

export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
export declare interface QueryResponse<T> extends CancellableOperation<T> {
}
/**

@@ -224,6 +196,2 @@ * Result of `executeQuery`

}
export declare interface Sender<T> {
abort: () => void;
send: () => Promise<T>;
}
/**

@@ -274,3 +242,3 @@ * Serialized Ref as a result of `QueryResult.toJSON()`

export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
/* Excluded from this release type: TransportClass */
/**

@@ -277,0 +245,0 @@ * Options to connect to emulator

@@ -18,2 +18,3 @@ /**

import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';

@@ -39,3 +40,2 @@ import { Provider } from '@firebase/component';

}
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
/**

@@ -61,6 +61,7 @@ *

private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
initialized: boolean;
_initialized: boolean;
private _transport;

@@ -71,3 +72,4 @@ private _transportClass;

_isUsingGeneratedSdk: boolean;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
private _appCheckTokenProvider?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
_useGeneratedSdk(): void;

@@ -74,0 +76,0 @@ _delete(): Promise<void>;

@@ -18,5 +18,5 @@ /**

export declare function initializeFetch(fetchImpl: typeof fetch): void;
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, accessToken: string | null, _isUsingGen: boolean): Promise<{
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, appId: string | null, accessToken: string | null, appCheckToken: string | null, _isUsingGen: boolean): Promise<{
data: T;
errors: Error[];
}>;

@@ -18,3 +18,7 @@ /**

import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
/**
* @internal
*/
export interface DataConnectTransport {

@@ -37,11 +41,5 @@ invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{

}
export interface QueryResponse<T> extends CancellableOperation<T> {
}
export interface MutationResponse<T> extends CancellableOperation<T> {
}
export interface Sender<T> {
abort: () => void;
send: () => Promise<T>;
}
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
export * from '../../core/FirebaseAuthProvider';
/**
* @internal
*/
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;

@@ -18,2 +18,3 @@ /**

import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';

@@ -23,3 +24,5 @@ import { DataConnectTransport } from '.';

private apiKey?;
private appId?;
private authProvider?;
private appCheckProvider?;
private _isUsingGen;

@@ -34,5 +37,5 @@ private _host;

private _accessToken;
private _authInitialized;
private _appCheckToken;
private _lastToken;
constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
get endpointUrl(): string;

@@ -39,0 +42,0 @@ useEmulator(host: string, port?: number, isSecure?: boolean): void;

{
"name": "@firebase/data-connect",
"version": "0.0.3-dataconnect-preview.d986d4bf2",
"version": "0.1.0-20240930164710",
"description": "",

@@ -38,3 +38,3 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",

"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
"test:all": "npm run test:node",
"test:all": "run-p --npm-path npm lint test:unit",
"test:browser": "karma start --single-run",

@@ -51,13 +51,13 @@ "test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",

"peerDependencies": {
"@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2"
"@firebase/app": "0.10.12-20240930164710"
},
"dependencies": {
"@firebase/auth-interop-types": "0.2.3-dataconnect-preview.d986d4bf2",
"@firebase/component": "0.6.8-dataconnect-preview.d986d4bf2",
"@firebase/logger": "0.4.2-dataconnect-preview.d986d4bf2",
"@firebase/util": "1.9.7-dataconnect-preview.d986d4bf2",
"@firebase/auth-interop-types": "0.2.3",
"@firebase/component": "0.6.9",
"@firebase/logger": "0.4.2",
"@firebase/util": "1.10.0",
"tslib": "^2.1.0"
},
"devDependencies": {
"@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2",
"@firebase/app": "0.10.12-20240930164710",
"rollup": "2.79.1",

@@ -64,0 +64,0 @@ "rollup-plugin-typescript2": "0.31.2",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc