You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issues filed here should be about a feature request for a specific extension in this repository. To file a feature request that affects multiple extensions or the Firebase Extensions platform, please reach out to Firebase support directly.
[REQUIRED] Step 2: Extension name
This feature request is for extension: firestore-counter
What feature would you like to see?
The current web client code is not safe for use in nodejs cloud function environment due to the reliance on document, specifically, document.cooke for the storage of the shard id.
How would you use it?
var sharded = require('sharded-counter')
...
I would expect that other folks have need to be able to update counters in a more secure fashion rather than exposed on the client. In my case, updating inventory counts.
Possible solution
I've already tested the below as a possible solution
change /extensions/firestore-counter/clients/web/src/index.ts to:
function getShardId(cookie: string): string {
const shardId = uuid.v4();
// make node env friendly...
if (typeof document !== 'undefined') {
const result = new RegExp(
"(?:^|; )" + encodeURIComponent(cookie) + "=([^;]*)"
).exec(document.cookie);
if (result) return result[1];
const date = new Date();
date.setTime(date.getTime() + 30 * 24 * 60 * 60 * 1000);
const expires = "; expires=" + date.toUTCString();
document.cookie =
encodeURIComponent(cookie) + "=" + shardId + expires + "; path=/";
}
return shardId;
}
I can make the above as a PR since I've already done this locally for my testing to use.
I wanted to ask about this before just submitting a PR since you all might have a really good reason not to have a node friendly option that I'm not aware of - for example is there a terrible thing not to re-use shardId's?
The text was updated successfully, but these errors were encountered:
[READ] Step 1: Are you in the right place?
Issues filed here should be about a feature request for a specific extension in this repository. To file a feature request that affects multiple extensions or the Firebase Extensions platform, please reach out to
Firebase support directly.
[REQUIRED] Step 2: Extension name
This feature request is for extension: firestore-counter
What feature would you like to see?
The current web client code is not safe for use in nodejs cloud function environment due to the reliance on
document
, specifically,document.cooke
for the storage of the shard id.How would you use it?
var sharded = require('sharded-counter')
...
I would expect that other folks have need to be able to update counters in a more secure fashion rather than exposed on the client. In my case, updating inventory counts.
Possible solution
I've already tested the below as a possible solution
change
/extensions/firestore-counter/clients/web/src/index.ts
to:change:
/extensions/firestore-counter/clients/web/webpack.config.js
:change:
libraryTarget: 'var',
to:
I can make the above as a PR since I've already done this locally for my testing to use.
I wanted to ask about this before just submitting a PR since you all might have a really good reason not to have a node friendly option that I'm not aware of - for example is there a terrible thing not to re-use
shardId
's?The text was updated successfully, but these errors were encountered: