<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harshita Kashyap on Medium]]></title>
        <description><![CDATA[Stories by Harshita Kashyap on Medium]]></description>
        <link>https://medium.com/@hrsa.kshyp?source=rss-dfa11f861853------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Harshita Kashyap on Medium</title>
            <link>https://medium.com/@hrsa.kshyp?source=rss-dfa11f861853------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:52:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hrsa.kshyp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Architecture of Invisibility: A Deep Dive into Instagram’s Story Hiding Logic]]></title>
            <link>https://medium.com/@hrsa.kshyp/the-architecture-of-invisibility-a-deep-dive-into-instagrams-story-hiding-logic-7f5f6bbf8d63?source=rss-dfa11f861853------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f5f6bbf8d63</guid>
            <category><![CDATA[instagram-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[privacy-by-design]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Harshita Kashyap]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 14:56:07 GMT</pubDate>
            <atom:updated>2025-12-28T14:56:07.116Z</atom:updated>
            <content:encoded><![CDATA[<p>How permissions, real-time sync, and “Silent 404s” create a seamless privacy layer at scale.</p><h3>The Engineering Challenge of Ephemeral Privacy</h3><p>When a user posts a Story on Instagram, it isn’t just a file upload; it’s a broadcast to a dynamic set of “Authorized Viewers.” The real complexity arises when that set of viewers changes <strong>after</strong> the broadcast has started.</p><p>If a user hides a Story from a follower five minutes after posting, the system must transition from a state of “Publicly Available” to “Selectively Invisible” in milliseconds across global edge servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*E1PjpW1sYl0t6CTwCRTCwQ.jpeg" /><figcaption>Figure 1: Sequence diagram of the Filtered Fetch logic during a Story Tray request</figcaption></figure><h3>1. The Relationship-Based Access Control (ReBAC)</h3><p>At its core, Instagram doesn’t use simple “Public/Private” flags. Instead, it likely utilizes a <strong>ReBAC</strong> model.</p><p>When you request a list of stories (the “Tray”), the backend doesn’t just look for your friends. It performs a <strong>Filter-on-Fetch</strong> operation.</p><ul><li><strong>The Query:</strong> The system queries the Stories table but joins it with a Privacy_Exclusions table.</li><li><strong>The Logic:</strong> If viewer_id exists in author.hidden_list, that specific story_id is omitted from the JSON payload.</li></ul><p><strong>Key Technical Finding:</strong> This check happens at the <strong>API Gateway or Edge level</strong>. It is cheaper to strip the data during the initial fetch than to have the client handle the logic.</p><h3>2. Dealing with the Active Client: Real-Time Invalidation</h3><p>The hardest part of “hiding” content is dealing with the user who is <strong>already active</strong>. If User B has the app open, your story bubble is already rendered on their screen.</p><p>Instagram solves this using <strong>Long-lived WebSockets (specifically MQTT)</strong>.</p><ol><li>User A hits “Hide.”</li><li>The backend updates the database.</li><li>A <strong>Push Event</strong> is triggered via the Real-time service.</li><li>The client app for User B receives a “Silent Invalidation” packet.</li><li>The app triggers a local UI state change to remove the bubble.</li></ol><p>This is why the bubble “vanishes” without a refresh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*ykVnvMScS40YFbWR" /><figcaption>The Real-time Pipeline: How Instagram synchronizes privacy states across global WebSocket nodes.</figcaption></figure><h3>3. The “Silent 404” (Security by Obscurity)</h3><p>One of the most fascinating parts of this system is how it handles direct access.</p><p>If you try to access a hidden story via a direct URL or a notification deep-link, the server returns a 404 Not Found.</p><ul><li><strong>Why not 403 Forbidden?</strong> In security, a 403 confirms the resource exists but you&#39;re blocked. A 404 suggests the resource doesn&#39;t exist at all.</li><li><strong>The UX Goal:</strong> By returning a 404, Instagram protects the author’s social privacy. The hidden user assumes the story was deleted or simply expired.</li></ul><h3>5. Global Impact: Highlights and Archives</h3><p>The “Hide Story” list is a <strong>Global Filter</strong>. Because the exclusion check is a middleware layer in the Media API, it automatically cascades to:</p><ol><li><strong>Highlights:</strong> If you hide someone, they can no longer see your Highlights on your profile.</li><li><strong>Live Notifications:</strong> They are automatically unsubscribed from “User X is Live” push notifications.</li></ol><h3>5. The One Edge Case: The Race Condition</h3><p>Can someone <em>ever</em> see a hidden story? <strong>Yes.</strong> If a user has a very slow connection and the story video file (the actual .mp4) has already been cached in their device’s temporary storage <em>before</em> you hit hide, they may be able to play that specific video once.</p><p>However, any interaction — like a Heart or a Reply — will fail, because the <strong>Interaction API</strong> re-verifies permissions before committing to the database.</p><h3>Final Thoughts</h3><p>Instagram’s hiding logic proves that <strong>Privacy &gt; Cache</strong>. In a choice between showing stale data and enforcing a new privacy rule, the system is designed to favor the creator’s current state instantly.</p><p>For developers, the takeaway is clear: <strong>Never trust the client to filter data. Always enforce permissions at the API Edge.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f5f6bbf8d63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t Waste the Wait: How a Client Blocker Saved My OAuth Integration]]></title>
            <link>https://medium.com/@hrsa.kshyp/dont-waste-the-wait-how-a-client-blocker-saved-my-oauth-integration-7c8250ed9dab?source=rss-dfa11f861853------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c8250ed9dab</guid>
            <category><![CDATA[quickbooks]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[freelancing-tips]]></category>
            <dc:creator><![CDATA[Harshita Kashyap]]></dc:creator>
            <pubDate>Sun, 14 Dec 2025 16:40:19 GMT</pubDate>
            <atom:updated>2025-12-14T16:40:19.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why<strong> constraint-driven work</strong> is the secret weapon for developers (plus a critical QuickBooks Node.js fix)</h3><p>Freelance projects are rarely linear. We like to imagine a straight line: <strong>Discovery → Development → Deployment.</strong></p><p>In reality, it’s usually: <strong>Discovery → Dev… → Wait for Admin Access → Wait some more → Rush to Deploy.</strong></p><p>I hit this exact wall this week. I’m building a custom QuickBooks integration for a client using the MERN stack. The app logic is ready, the UI is clean, but I hit a hard stop: <strong>I need Production Admin access to test with live data.</strong></p><p>While waiting for that email invitation, I had two choices:</p><ol><li>Do nothing and wait.</li><li>Use the “downtime” to stress-test existing features.</li></ol><p>I chose option 2. I call this <strong>Constraint-Driven Work</strong>. When you can’t move <em>forward</em>, you move <em>deeper</em>. I polished the UI, fixed some pagination bugs, and decided to audit my backend authentication flow.</p><p>And I’m glad I did. I found a “silent killer” in my code that would have broken the production app within 24 hours of launch.</p><h3>The Trap: QuickBooks OAuth &amp; Token Rotation</h3><p>If you’ve worked with OAuth 2.0 (Google, Facebook, etc.), you know the drill:</p><ol><li>User grants access.</li><li>You get an access_token (short-lived) and a refresh_token (long-lived).</li><li>When the access token expires, you use the refresh token to get a new one.</li></ol><p><strong>The Mistake:</strong> In many APIs, the refresh_token is static. It doesn&#39;t change often. You can store it in your MongoDB user document and reference it for months.</p><p><strong>The Reality (Intuit/QuickBooks):</strong> QuickBooks uses <strong>Refresh Token Rotation</strong>. Every time you request a new access token, the API <em>may</em> invalidate your old refresh token and hand you a brand new one.</p><p>If your Node.js backend throws this new value away and tries to use the old one tomorrow, the handshake fails. Your user gets kicked out. Your client calls you in a panic.</p><h3>The Fix: Treat Auth as a Write Operation</h3><p>I had to rewrite my server-side token logic to ensure I was capturing this rotation.</p><p>Here is the pattern I implemented (using Node.js and Mongoose):</p><p>// <strong>THE RISKY WAY</strong><br>// Many tutorials suggest this simple flow:<br>/* async function refreshMyToken() {<br> const authResponse = await oauthClient.refresh();<br> return authResponse.access_token; <br>}<br>*/<br>// The problem? If ‘authResponse’ contained a new refresh token, <br>// you just lost it.</p><p>// <strong>THE SAFE WAY</strong><br>async function refreshAndSaveToken(user) {<br> try {<br> const authResponse = await oauthClient.refresh();<br> <br> // 1. Check if a new refresh token was issued (Rotation)<br> // If not, keep using the one we already have.<br> const newRefreshToken = authResponse.refresh_token || user.refreshToken;</p><p>// 2. FORCE a database update immediately<br> // Never treat refresh as read-only.<br> user.accessToken = authResponse.access_token;<br> user.refreshToken = newRefreshToken; // CRITICAL UPDATE<br> user.tokenTimestamp = new Date();<br> <br> await user.save();<br> <br> return user.accessToken;</p><p>} catch (error) {<br> console.error(“OAuth Refresh Failed:”, error);<br> // Handle re-auth flow here<br> throw error;<br> }<br>}</p><h3>Why “Constraint-Driven Work” Matters</h3><p>If I had received admin access on Day 1, I would have rushed to fetch the data. I would have deployed the app using my original, flawed auth logic. The app would have worked perfectly… for 24 hours.</p><p>Then, the refresh token would have rotated, my database would have held the old key, and the integration would have crashed.</p><p>By being “blocked,” I was forced to look at my code with a critical eye rather than a feature-shipping eye.</p><p><strong>The Takeaway:</strong> When you are stuck waiting on approvals, keys, or feedback, don’t just idle. Use that constraint to harden your foundation.</p><p>Your future self (and your client) will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c8250ed9dab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>