Skip to content

Commit

Permalink
feat: private content feature complete
Browse files Browse the repository at this point in the history
  • Loading branch information
vighnesh153 committed Dec 24, 2024
1 parent d62a28b commit 4e65deb
Show file tree
Hide file tree
Showing 35 changed files with 476 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"ekAHm4gvpTBjoSmvINUnt638btaM","createdAt":"1734187406426","lastLoginAt":"1734882450193","displayName":"Vighnesh Raut","photoUrl":"https://i.imgur.com/npqtdBu.png","providerUserInfo":[{"providerId":"google.com","rawId":"5762999240917570257694699278672391745578","federatedId":"5762999240917570257694699278672391745578","displayName":"Vighnesh Raut","photoUrl":"https://i.imgur.com/npqtdBu.png","email":"vighnesh.raut13@gmail.com","screenName":"vighnesh153"}],"validSince":"1734881873","email":"vighnesh.raut13@gmail.com","emailVerified":true,"disabled":false,"lastRefreshAt":"2024-12-22T17:33:39.253Z"},{"localId":"iWtBCmoWRTXg6UTQCV7ncLJPxcNO","displayName":"Pikachu","photoUrl":"https://i.imgur.com/npqtdBu.png","screenName":"Pikachu","email":"pikachu@pokemon.com","emailVerified":true,"createdAt":"1734882413806","lastLoginAt":"1734882416118","providerUserInfo":[{"providerId":"google.com","rawId":"7759237076568892792428913761032108656749","federatedId":"7759237076568892792428913761032108656749","displayName":"Pikachu","photoUrl":"https://i.imgur.com/npqtdBu.png","email":"pikachu@pokemon.com","screenName":"Pikachu"}],"lastRefreshAt":"2024-12-22T15:46:56.118Z"}]}
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"ekAHm4gvpTBjoSmvINUnt638btaM","createdAt":"1734187406426","lastLoginAt":"1734979688327","displayName":"Vighnesh Raut","photoUrl":"https://i.imgur.com/npqtdBu.png","providerUserInfo":[{"providerId":"google.com","rawId":"5762999240917570257694699278672391745578","federatedId":"5762999240917570257694699278672391745578","displayName":"Vighnesh Raut","photoUrl":"https://i.imgur.com/npqtdBu.png","email":"vighnesh.raut13@gmail.com","screenName":"vighnesh153"}],"validSince":"1735046053","email":"vighnesh.raut13@gmail.com","emailVerified":true,"disabled":false,"lastRefreshAt":"2024-12-24T13:16:43.826Z"},{"localId":"iWtBCmoWRTXg6UTQCV7ncLJPxcNO","createdAt":"1734882413806","lastLoginAt":"1734882416118","displayName":"Pikachu","photoUrl":"https://i.imgur.com/npqtdBu.png","providerUserInfo":[{"providerId":"google.com","rawId":"7759237076568892792428913761032108656749","federatedId":"7759237076568892792428913761032108656749","displayName":"Pikachu","photoUrl":"https://i.imgur.com/npqtdBu.png","email":"pikachu@pokemon.com","screenName":"Pikachu"}],"validSince":"1735046053","email":"pikachu@pokemon.com","emailVerified":true,"disabled":false}]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--boundary
Content-Type: application/json

{"contentType":"text/plain"}
--boundary
Content-Type: text/plain

--boundary--
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "private_content/",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734965083632,
"contentType": "application/octet-stream",
"storageClass": "STANDARD",
"downloadTokens": [],
"etag": "ihM3MT4PR3n8tM/lSFLMe8byZns",
"timeCreated": "2024-12-23T14:44:43.632Z",
"updated": "2024-12-23T14:44:43.632Z",
"size": 130,
"md5Hash": "iUpceipDkyQhwwUflucD5w==",
"crc32c": "3108464614"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/cute-gray-cat-kitten-looking-600nw-2386006989.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901036,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"51504da9-99c8-47e7-a735-3025ecd8bfb9"
],
"etag": "jjYA4cA08jdkw864wXU+KsgDx7U",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.036Z",
"updated": "2024-12-23T16:55:01.036Z",
"size": 44234,
"md5Hash": "t2mnbZvVpYDr8Pnk15P/ZA==",
"crc32c": "2173746191"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/happy-labrador-dog-water-splashes-600nw-2470403137.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972873209,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"a085943a-d91f-4273-994a-1ddad9152ac3"
],
"etag": "mRDoId0vzZPncDZlhVqReRNQjek",
"customMetadata": {},
"timeCreated": "2024-12-23T16:54:33.209Z",
"updated": "2024-12-23T16:54:33.209Z",
"size": 77390,
"md5Hash": "+LyrUtEgh70ouPvpY/8l1A==",
"crc32c": "3407295130"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/adorable-ragdoll-cat-beautiful-blue-600nw-1992318023.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901045,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"7a13b0ea-ee65-416a-9603-9077559a6be5"
],
"etag": "gb9WQa5RHDOBJOGN7WUo2AjmN2Y",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.045Z",
"updated": "2024-12-23T16:55:01.045Z",
"size": 38852,
"md5Hash": "EttE8U4lbuS+MMBAM8ZZGw==",
"crc32c": "2119935361"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/sphynx-cat-naked-600nw-1058785700.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901040,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"391e7ff2-32b1-4172-806f-be6e662a07d8"
],
"etag": "ZoDwFGER1WR1X3LV4m/gisIf8Dw",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.040Z",
"updated": "2024-12-23T16:55:01.040Z",
"size": 33350,
"md5Hash": "84WCkhORK871LUYJbIi9Fw==",
"crc32c": "995158010"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/tabby-cat-169-ratio-600nw-44442067.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901042,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"7080bd8a-28ea-4471-975a-6c80a0d6c433"
],
"etag": "Q/XEYDasm0Omie3tkx0wpPhfhU0",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.042Z",
"updated": "2024-12-23T16:55:01.042Z",
"size": 36496,
"md5Hash": "sFPuKijTz2GDEA1OfRuJBQ==",
"crc32c": "764008526"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/happy-dog-running-blossoming-flower-600nw-2458562695.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972868065,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"c632353e-eae1-4cd7-8324-93cb35fa1ad2"
],
"etag": "Z/MIzl8lrMGKD346mUb71mK7DHo",
"customMetadata": {},
"timeCreated": "2024-12-23T16:54:28.065Z",
"updated": "2024-12-23T16:54:28.065Z",
"size": 55358,
"md5Hash": "l0qwErxhQ9gs4kXKmK/DRQ==",
"crc32c": "1634826027"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/adult-fluffy-ragdoll-cat-outside-600nw-1467863648.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901047,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"9cb8ce7c-e820-4619-8502-fbb3cc4dc492"
],
"etag": "6TqN9ijExE+tGLs3sz0qRsnfdJI",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.047Z",
"updated": "2024-12-23T16:55:01.047Z",
"size": 53922,
"md5Hash": "92CXebKvweV9nBnZxfzTWA==",
"crc32c": "499067176"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/young-cute-bengal-cat-sitting-600nw-2238825697.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901030,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"bce26425-9a90-4ccd-87c5-c936dedab26c"
],
"etag": "XGnoPf8dxosbmKHIdlxKP941C4U",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.030Z",
"updated": "2024-12-23T16:55:01.030Z",
"size": 42916,
"md5Hash": "IGjn5gEg6JV58QUZvGL/PA==",
"crc32c": "2725626091"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "private_content/savannah-cat-beautiful-spotted-striped-600nw-589366805.webp",
"bucket": "demo-vighnesh153-app.appspot.com",
"metageneration": 1,
"generation": 1734972901023,
"contentType": "image/webp",
"storageClass": "STANDARD",
"contentDisposition": "inline",
"downloadTokens": [
"43b67554-1b3e-403d-ab1e-9f4ecb55c41e"
],
"etag": "hjuaot9+RQJogsdvZJZxs+devwI",
"customMetadata": {},
"timeCreated": "2024-12-23T16:55:01.024Z",
"updated": "2024-12-23T16:55:01.024Z",
"size": 66148,
"md5Hash": "yxQMlJWFBENVTEK09AHr9g==",
"crc32c": "4282025506"
}
73 changes: 73 additions & 0 deletions tools-nodejs/vighnesh153-astro/functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools-nodejs/vighnesh153-astro/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"main": "lib/functions/src/index.js",
"dependencies": {
"@vighnesh153/tools": "npm:@jsr/vighnesh153__tools@^0.1.17",
"firebase-admin": "^13.0.1",
"firebase-functions": "^6.1.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ async function createReadSignedUrl(
internalPath: string,
): Promise<string | null> {
const file = storage.bucket().file(internalPath);
const expirationDate = new Date(Date.now() + 2 * dayInMs);
const expirationDate = new Date(Date.now() + dayInMs * 2);

// https://github.com/firebase/firebase-tools/issues/3400#issuecomment-847916638
if (process.env.FUNCTIONS_EMULATOR) {
return file.publicUrl();
return internalPath.startsWith("http") ? internalPath : file.publicUrl();
}

try {
const urls = await file.getSignedUrl({
version: "v4",
action: "read",
expires: expirationDate,
extensionHeaders: {
"cache-control": `max-age=${dayInMs * 365 / 1000}`,
},
});
return urls[0];
} catch (e) {
Expand Down
Loading

0 comments on commit 4e65deb

Please sign in to comment.