firebase-tools 15.30.0 → 15.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/gcp/iam.js CHANGED
@@ -155,23 +155,14 @@ async function generateManagedServiceAccountName(projectId, prefix) {
155
155
  }
156
156
  throw new error_1.FirebaseError("Failed to generate a unique service account name after 10 attempts.");
157
157
  }
158
- function computeRolesEtag(roles, existingSalt) {
158
+ function computeRolesEtag(roles) {
159
+ const ALPHA_CHARS = "abcdefghijklmnopqrstuvwxyz";
159
160
  const BASE38_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_";
160
- let salt = existingSalt;
161
- if (!salt) {
162
- salt = String.fromCharCode(97 + Math.floor(Math.random() * 26));
163
- for (let i = 0; i < 9; i++) {
164
- salt += BASE38_CHARS[Math.floor(Math.random() * 38)];
165
- }
166
- }
167
- const sorted = Array.from(roles).sort();
168
- const hashBuffer = crypto
169
- .createHash("sha256")
170
- .update(salt + sorted.join(","))
171
- .digest();
172
- let hashStr = "";
173
- for (const byte of hashBuffer) {
174
- hashStr += BASE38_CHARS[byte % 38];
161
+ const sorted = Array.from(new Set(roles)).sort();
162
+ const hashBuffer = crypto.createHash("sha256").update(sorted.join(",")).digest();
163
+ let hashStr = ALPHA_CHARS[hashBuffer[0] % ALPHA_CHARS.length];
164
+ for (let i = 1; i < hashBuffer.length; i++) {
165
+ hashStr += BASE38_CHARS[hashBuffer[i] % BASE38_CHARS.length];
175
166
  }
176
- return `${salt}-${hashStr.substring(0, 52)}`;
167
+ return hashStr;
177
168
  }