<?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[Paul Ardeleanu’s Blog - Medium]]></title>
        <description><![CDATA[Geekery in public - Medium]]></description>
        <link>https://medium.com/paul-ardeleanu?source=rss----1554d945a89f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Paul Ardeleanu’s Blog - Medium</title>
            <link>https://medium.com/paul-ardeleanu?source=rss----1554d945a89f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 07:49:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/paul-ardeleanu" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AI-enabled XR glasses are having their Pebble moment]]></title>
            <link>https://medium.com/paul-ardeleanu/ai-enabled-xr-glasses-are-having-their-pebble-moment-735fbc334897?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/735fbc334897</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[smart-glass]]></category>
            <category><![CDATA[wearables]]></category>
            <category><![CDATA[xr]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 21:19:32 GMT</pubDate>
            <atom:updated>2026-07-11T21:19:33.497Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally published at </em><a href="https://www.pardel.dev/2026/05/02/xr-glasses-pebble-moment.html"><em>https://www.pardel.dev</em></a><em> on May 2, 2026.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpGLLEUX0VMrE-JBPNRKMw.png" /></figure><p>I had the opportunity to try Even Realities’ new G2 glasses this week. I went in half-expecting an iPhone moment, given the form factor and the marketing, and walked out with something different. It felt familiar, but not in the way I’d predicted. It felt like a Pebble moment.</p><p>I mean that as the highest compliment.</p><h3>Why Pebble</h3><p>The Pebble smartwatch landed in 2013, two years ahead of the Apple Watch, with a black &amp; white e-paper display at 144x168 resolution, a battery that lasted a week and a peculiar charging connector. By the time Apple shipped, Pebble had built a community, an app store, a developer culture and a fiercely loyal audience.</p><p>The product was rudimentary. Things people would later call essential were missing. There was no proper health tracking, no real fitness story, no LTE, no app gating. The display couldn’t render anything richer than a notification and a glanceable workout. The hardware quietly broadcast that this was the early days of a new category.</p><p>And yet, Pebble shipped early enough to define what people wanted next: notifications on your wrist, music control without pulling your phone out, a timer you could glance at without looking rude in a meeting. It pioneered the idea that a watch could be a peripheral to your phone rather than a replacement for it. By the time the Apple Watch launched, the consumer use cases were already understood, the third-party developer instinct was already trained, and the basic shape of “smart” watch was already in collective memory. Pebble lost the market and shaped the category.</p><p>That’s worth dwelling on: Pebble was a forerunner, not a winner. It didn’t survive as a business in its original form. It still sells today (now rebooted) to an audience that knows exactly what it wants from it, but the market crown went to incumbents who arrived late with more capital, more scale, and more polish. The forerunner role is unglamorous, but it is the thing that makes the category legible in the first place.</p><p>That’s where AI-enabled XR glasses are now. Clearly early but at the start of something real.</p><h3>The form factor breakthrough</h3><p>Here’s the part that surprised me most: the G2 is the first pair of XR glasses that actually look and feel like glasses.</p><p>That sentence sounds modest. It isn’t. The category has been trying to clear this bar for a decade and it has, until now, looked like one of these:</p><ul><li>Apple Vision Pro: a beautiful piece of engineering, but unmistakably a pair of ski goggles strapped to your face.</li><li>Snap Spectacles (2024 dev kit): a developer kit. Worn by developers. At developer events.</li><li>Magic Leap: a cyberpunk visor with an external compute pack.</li><li>Google Glass: the uncanny-valley headline, fairly or not, that taught a generation of consumers what they didn’t want.</li><li>Meta Ray-Ban: the closest precedent for getting the silhouette right, but with a camera trade-off I’ll come back to.</li></ul><p>Not ski goggles, not a visor, not a developer kit strapped to your face. Pebble looked like a watch; the G2 looks like eyewear. That’s not a small thing; it’s the difference between something you’d wear and something you’d demo. It’s the bar that decides whether a product gets shown off in a shop window or zipped back into a backpack the moment the press demo ends.</p><p>Once the form factor is right, everything else gets to be evaluated on its merits. Until then, every feature is competing with the social cost of looking like you’ve borrowed your goggles from a chemistry lab.</p><h3>What I liked</h3><h4>No camera</h4><p>The Even Realities products ship without a camera, and I think that’s the right call.</p><p>I don’t want one on my face and I don’t want one on anyone else’s. That’s the social argument, and it’s a real one. Cameras on glasses are perceived as intrusive in a way that cameras on phones are not, because phones telegraph their intent (you have to lift it, point it, frame the shot) and glasses don’t. Google Glass discovered this, expensively, in 2013. Snap Spectacles discovered it less expensively but no less clearly across multiple generations. Meta Ray-Ban has rehabilitated the camera-on-glasses idea somewhat but mostly because the camera is conspicuously visible and the form factor is so familiar that people read the device as a known quantity.</p><p>There’s a pragmatic point too: a camera on glasses is never going to rival the one already in your pocket. Phone cameras are now multi-lens, computationally enhanced systems backed by gigabytes of model weights and hundreds of milliamp-hours of dedicated battery. A glasses camera is, given the obvious physical constraints, smaller, with worse optics, less compute, and less power. It’s a worse camera than the one you already own, attached to a more socially uncomfortable form factor. It’s the wrong place to put a camera.</p><p>The smartwatch market told us this story already. The Apple Watch shipped cameraless while early Samsung rivals had cameras built in, and the market quietly settled on no-camera as the norm. Discretion won. Same gravity applies here.</p><h4>The R1 ring is part of the product</h4><p>You can buy the glasses on their own. You shouldn’t. The R1 ring is what turns them from glasses-with-AI into a usable input loop. I want to flag this because it’s the right answer to a question the category has been getting wrong for years: how do you control glasses without looking strange?</p><p>The candidate input paradigms are all problematic on their own:</p><ul><li><strong>Voice</strong> is what most assistants default to, but talking to your glasses in public still reads as eccentric.</li><li><strong>Touch on the temple</strong> works for one or two gestures but doesn’t scale. You also look like you’re swatting a fly :)</li><li><strong>Gesture in mid-air</strong> is what Vision Pro is selling and is, to put it gently, a work in progress. Watching someone pinch-and-flick at thin air is the most demoware-coded thing in current consumer tech.</li><li><strong>Phone-as-controller</strong> defeats the point. If I have to pull my phone out, why am I wearing the glasses?</li></ul><p>A ring is a different answer. The input is invisible to anyone watching and the gestures map to glanceable actions rather than full keyboard equivalents, which is what glasses need. Together, the glasses and ring give you a control surface that doesn’t need a phone in your hand or a voice in thin air. The combination is what makes the experience work.</p><p>Treating the ring as part of the product (rather than an upsell accessory) is a quietly important design decision.</p><h4>The AI on-device experience</h4><p>The AI is on point: dictation, live conversation summaries, quick lookups. Not demoware, but the things I’d reach for daily.</p><p>This is the part that separates the G2 from the Pebble analogy slightly. Pebble’s killer feature was the notification, which is a passive surface. The G2’s killer feature is the AI, which is an active one. The product is at its best when it’s giving you a useful response to something you’ve just done: captured a thought, finished a meeting, glanced at a sign in a foreign language. The use cases that work are the ones where you’d otherwise have pulled out your phone, opened an app, waited, and broken the moment. The glasses collapse that loop.</p><p>Where the AI doesn’t work YET is anywhere it would on a laptop: long-form reasoning, multi-turn conversations, deep research. That’s fine. That’s not what glasses are for. The trap most XR products fall into is trying to be a full computer on your face. The G2 doesn’t try, and that’s part of why it works.</p><h3>What I didn’t like</h3><p>There were two things, both structural rather than product flaws.</p><ul><li>The first is the price. Even’s products are firmly in early-adopter territory, which is, again, exactly where Pebble was. Tooling, low volumes, premium components, retail margin: they all push the first generation of any new device class out of mainstream price ranges. The G2 is no different, and complaining about it is essentially complaining about being early. And when you consider the G2 + R1 “package” that makes the product tick… well, it’s getting pretty expensive.</li><li>The second is limited availability. Only a handful of opticians stock them today. Distributing a pair of glasses through opticians (rather than through Apple Stores, electronics retailers, or direct online sales) is a deliberate choice that pulls the product back into an eyewear retail channel. It means real people fitting them to your face, real prescriptions cut to order, real after-sales service. It also means the product can’t scale at consumer-electronics speed. You can ship phones in a launch week. You can’t ship prescription glasses through a small network of opticians at the same pace.</li></ul><p>This is going to be a constraint on how fast Even can scale, and it’s also going to be a moat against competitors who don’t think about distribution this way. Whether that trade-off survives contact with mass-market demand is one of the more interesting open questions about the company.</p><h3>What comes next</h3><p>Two predictions.</p><h4><strong>1. AI-enabled XR glasses are coming. Not in five years. The loop is closing now.</strong></h4><p>The G2 is not the device that wins this category. The device that wins this category will be made by a company with the scale to manufacture at consumer-electronics volume, the brand to clear retail shelves and the AI infrastructure to deliver the on-device experience without lag. The candidates are obvious: Apple, Meta, Google, possibly Samsung. None of them have shipped this product yet. Apple is heavy on hardware and light on shipping pressure and AI. Meta has Ray-Ban scale but a camera trade-off the market may eventually punish. Google is on its third or fourth attempt at this category and may finally have learned. Samsung has the supply chain but rarely the product taste.</p><p>The wildcard is whether a smaller player like Even can ride the early-adopter market long enough to scale into the mainstream before an incumbent copies the form factor. Pebble couldn’t, and that’s the cautionary tale. But the form factor advantage Even has is real, and the optician distribution channel is harder to replicate than it looks. They have a runway. Whether it’s long enough is the question.</p><h4><strong>2. The winning form factor will look more like the G2 than like anything with a camera array bolted to it.</strong></h4><p>This is a longer-term prediction/wish/hope: discretion will matter more than capability. The history of consumer wearables is the history of devices that quietly faded into the background of daily life: wristbands became watches, watches became phones-on-the-wrist, earphones became invisible. The form factors evolved differently, but the same thing happened underneath each one: more capability, more software, more sensors, all hidden inside a device the wearer wanted to keep wearing.</p><p>The G2 isn’t the endpoint of that trajectory. But it’s the first product in this category that’s pointed in the right direction. That’s the Pebble moment. Not the device that wins, but the device that makes everyone else realise what winning looks like.</p><p><em>Originally published at </em><a href="https://www.pardel.dev/2026/05/02/xr-glasses-pebble-moment.html"><em>https://www.pardel.dev</em></a><em> on May 2, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=735fbc334897" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/ai-enabled-xr-glasses-are-having-their-pebble-moment-735fbc334897">AI-enabled XR glasses are having their Pebble moment</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Opening Pandora’s Box: A Developer’s Guide to AI Agents]]></title>
            <link>https://medium.com/paul-ardeleanu/opening-pandoras-box-a-developer-s-guide-to-ai-agents-8be2f23e590d?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/8be2f23e590d</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dev-talk]]></category>
            <category><![CDATA[public-speaking]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 21:19:17 GMT</pubDate>
            <atom:updated>2026-07-11T21:19:19.306Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>This is the long-form version of a talk I gave at </em><a href="https://www.devtalks.ro/11-devtalks-2026"><em>DevTalks Romania 2026</em></a><em> in Bucharest. The talk was not recorded, so consider this its replacement. </em><a href="https://github.com/pardel/presentations/blob/main/2026%20-%20DevTalks%20-%20Opening%20Pandora&#39;s%20Box/slides%20-%20DevTalks%202026%20-%20Opening%20Pandora&#39;s%20Box.pdf"><em>The slides are available on GitHub</em></a><em>.</em></blockquote><p><em>Originally published at </em><a href="https://www.pardel.dev/2026/06/12/opening-pandoras-box.html"><em>https://www.pardel.dev</em></a><em> on June 12, 2026.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U_eo9m5TRTCHCqVL.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aEdwAWwoKTWQXjtA.jpeg" /></figure><p><strong>Pandora was given a box</strong>. Well, a jar, really: “box” is a mistranslation that stuck.</p><p>She was given a jar <strong>with a single instruction, never open it</strong>, and you already know how this goes: <strong>curiosity won</strong>.</p><p>She lifted the lid, and bad things the world did not yet know flew out: sickness, toil, despair. She forced the lid back down, but far too late for almost everything was already gone. One thing stayed inside: <strong>Hope</strong>.</p><p>That’s the myth, and we’re living it today. You see, we’ve opened a box of our own.</p><p>Twelve months ago, AI coding agents were cool demos. Today they’re in your editor, your terminal, your pipeline. And most of us opened the box exactly the way Pandora did: quickly, and with curiosity. <strong>But</strong> without understanding what came with it.</p><p>So here is the plan for this talk: not hype, not fear, just a walk through what flew out, what is still inside, and what turns it from a threat into an advantage.</p><p>Before we get started, I just want to make sure it’s understood that <strong>this is not a talk for senior engineers</strong>. It’s for everyone willing to listen and try! Anyone can peek inside these tools and see what they’re actually doing. That’s not about seniority; it’s about curiosity.</p><h3>1. The arc every developer is on</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f-kmk4ZbSy-FHTsL.jpeg" /></figure><p>Every developer is somewhere on this seven-step AI Adoption Arc, left to right and rising:</p><p>It starts at the bottom, with the <strong>Anxious Prompter</strong>: you type something and hope.</p><p>One step up is the <strong>Fluent Prompter</strong>, where you’ve become good at this and you’re genuinely productive. But it’s still magic.</p><p>From step four onwards, the same skill reaches further each time:</p><ul><li>you shape the tool</li><li>you design workflows</li><li>you bring your team along</li><li>and at the top you grow the practice across a whole organisation.</li></ul><p>We’re going to walk this arc together, and by the end you’ll know two things: <strong>which step you’re standing on, and where it leads next.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VVQzNoBtjhMSDVTC.jpeg" /></figure><p><em>The seven-step developer arc, from anxious prompter to platform thinker.</em></p><ol><li><strong>Anxious prompter</strong>: you type something and hope.</li><li><strong>Fluent prompter</strong>: you’re genuinely productive, but it’s still magic.</li><li><strong>Harness reader</strong>: you stop guessing and look inside.</li><li><strong>Harness shaper</strong>: you treat the tool as yours to change.</li><li><strong>Workflow designer</strong>: you design the workflows the agent runs, and build the thing that runs them.</li><li><strong>Team enabler</strong>: you teach the discipline to a team.</li><li><strong>Platform thinker</strong>: you scale the practice across a whole organisation.</li></ol><p>Those bottom two steps share something: on both, <strong>the tool is a black box</strong>. On step one you’re afraid of it; on step two you’re productive with it, but either way the box is closed, and you can’t see inside.</p><p>And honestly, <strong>most of our industry stays on those bottom two steps</strong>. We’re all fluent prompters now, and that’s a huge step forward, but it’s still a box we don’t understand.</p><p>Step three is where that changes: <strong>we stop guessing and look in</strong>.</p><h3>2. The loop is boring</h3><p>And here’s the first thing we notice: <strong>it’s boring</strong>. This is the agent, the whole thing, roughly seven lines.</p><pre>while not done:<br>    reply = model(conversation)<br><br>    if reply.wants_tool:<br>        result = run_tool(reply.tool_call)<br>        conversation.append(result)<br>    else:<br>        done = True</pre><p>It sends the conversation so far to the model, and the model answers in one of two ways:</p><ol><li>Either it <strong>wants to use a tool</strong>, be that reading a file or running a test, in which case the harness runs it and loops.</li><li>Or it says <strong>it’s done, and the loop stops</strong>.</li></ol><p>Let me repeat that! The engine inside the technology that thrills and terrifies our industry <strong>is a while-loop</strong>! The kind you wrote when you first learned to program.</p><p>So why is Claude Code hundreds of thousands of lines of code?</p><p>Remember when, a couple of months ago, the Claude Code source code got released publicly by mistake?!</p><p>A community study found that only about 1.6% of it is what we could fairly call AI decision logic: the clever part, the bit that talks to the model. The other 98.4% is operational infrastructure: be that permissions, tool definitions, state management, error handling, sandboxing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*05MfGvjgN3tSQ3ng.jpeg" /></figure><p>So what we call artificial intelligence is, by volume, 98% ordinary software engineering. The magic is a rounding error, and that’s genuinely good news, because ordinary software engineering is something we already know how to read.</p><p>The “Dive into Claude Code” paper is available at <a href="https://arxiv.org/pdf/2604.14228">https://arxiv.org/pdf/2604.14228</a> if you’d like to read it.</p><p>Liu and colleagues also decomposed the production harness into seven parts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d3PVOrXvMReO19qB.jpeg" /></figure><ul><li>It starts with you on the left, and your interfaces, be that terminal, editor, CI.</li><li>They all feed one agent loop.</li><li>Around that loop sit the permission system, the tools, state and persistence, and the execution environment.</li><li>Every entry point feeds the same loop, and that loop reaches its tools only through the same permission gate. Seven components, one loop in the middle, and the shape is legible.</li></ul><p>That’s no accident: its architecture is driven by five values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*247AedGCLfeZwdmW.jpeg" /></figure><ol><li><strong>Human decision authority</strong>: humans (not the model) make the calls that matter.</li><li><strong>Safety, security and privacy</strong>: protect the user, the system, and data from harm.</li><li><strong>Reliable execution</strong>: what the agent says it will do, the harness validates and dispatches faithfully.</li><li><strong>Capability amplification</strong>: extend what the developer can do, not just automate what they already do.</li><li><strong>Contextual adaptability</strong>: the harness fits different developers, projects, and contexts.</li></ol><p>These are the 5 values. The first one is <strong>what the architecture revolves around.</strong> The other four are <strong>how the harness honours it</strong>.</p><p>You can watch this in a real session. Ask the agent to fix a failing test, and it reads the test, reads the code, and runs the test to verify it fails: each is just a tool call, and <strong>reads are safe, so the harness lets them straight through</strong>. Then the model wants to change a file, and that pause is the permission system, because reading your code was free but changing it isn’t. The agent asks, a human says yes, and nothing is written that a human hadn’t cleared. That’s the loop, start to finish: not magic, <strong>just a while-loop with good engineering around it</strong> and human checkpoints at the right moments. In Claude Code you can open any of those tool calls and read the whole trace with Cmd+O.</p><p>Prompt, model, tool, result, turning again and again until the work is done, with human checkpoints at the right moments. <strong>Boring and legible.</strong></p><p>So we opened the box, found the loop, and watched it turn. And just like that, we’ve climbed step three on the arc: the harness reader. This is the step everything else is built on, because we cannot shape what we cannot read.</p><p>Before moving to the next step in the arc, we have to ask the hard question: <strong>now that the box is open, what flew out?</strong></p><h3>3. What flew out: the six ills</h3><p>Six things that flew out. However, none of them is a reason to put the lid back on; <strong>in fact, we can’t close the box</strong>.</p><p>It’s open, and we have to deal with what flew out.</p><p>But the good news is that every one of these six is something we can build against. They’re not vibes, they’re work, and work is something we know how to do.</p><h3>3.1. Opacity</h3><p>You might have reviewed an agent’s work this week. You open the PR, read the diff. What you can’t read is <strong>why</strong>.</p><p>The agent had reasons. But all that reasoning lived inside a session, and when the session ends, it’s gone. The diff is the only thing that survived.</p><p><strong>And the diff is the what, never the why.</strong></p><p>For a human teammate, you’d have the commit message, the PR description, or a Confluence page. For an agent, by default, you get a diff and a shrug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nWW9izuwrVx20W3i.jpeg" /></figure><p><em>Opacity: a diff tells you what changed, but the reasoning leaves with the session.</em></p><h4>However, it’s fixable</h4><p>Take the git log of an agent-assisted project: it’s agent-assisted work, with standard commit messages but the <em>why</em> is missing.</p><p>To the right in the screenshot below, is the same work again: same three commits, same messages. But this time, <strong>a hook fired</strong> during each session and attached the reasoning to history, so every commit now carries a <strong>Checkpoint</strong>. The Checkpoint itself is just a pointer: short, generic, and machine-readable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XhxPFYg0b4_3yyId.jpeg" /></figure><p>The log file contains every session, every meaningful event, the whole thing. We can filter the log by the session id:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xo75pbxTnSVarjGz.jpeg" /></figure><p>On that session, the agent made two changes and the hook captured each one with a short rationale. That sentence is the <strong>why</strong>, and 6 months from now anybody reading that commit will be able to retrieve the reasoning behind it.</p><p>This is how we fix opacity. The <em>why</em> isn’t lost because agents are mysterious; it’s lost because, by default, nothing wrote it down.</p><h3>3.2. Misalignment</h3><p>Three months ago, OpenAI published how they run their own internal coding agents, and they don’t trust them to run unwatched.</p><p>A separate model, GPT-5.4 Thinking at maximum reasoning effort, watches them: it reviews the chain-of-thought and tool usage for every session. Categorises each one and assigns a severity level, all within thirty minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0oYq8yiZMhRedIep.jpeg" /></figure><p>And that monitor caught every misalignment OpenAI’s own engineers had independently escalated. In fact, it flagged more that the humans had missed.</p><p><strong>The company at the frontier of this technology is afraid of its own tools, in production, today</strong>. That’s not a science-fiction problem; it’s an operational one, and has operational answers.</p><p>OpenAI’s answer is a monitor.</p><p>Now, you’re not OpenAI, but the shape is the same: when an agent acts on your behalf, something should be watching it. That’s engineering we can build.</p><h3>3.3. Displacement</h3><p>The headline version is “AI takes developer jobs”, and the honest version is yes and no.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GhSPf_0APqADmERZ.jpeg" /></figure><p><em>Displacement is two numbers pulling opposite ways: more novel tasks, less code comprehension.</em></p><ul><li>Last year, Anthropic surveyed its own engineers and found about 27% of Claude-Code-assisted tasks were work that would not have been attempted otherwise. The ceiling rises, and the things that were too expensive, too fiddly or too far down the backlog, are now getting done.</li><li>In another study completed this year, a team of researchers gave developers code-comprehension tests, and the ones working in AI-assisted conditions scored 17% lower at understanding the code.</li></ul><p>The ceiling rises, but the floor drops too.</p><ul><li><strong>Do more and understand more</strong>, and we’re lifted with the ceiling.</li><li><strong>Do more and understand less</strong>, and we sink with the floor.</li></ul><p>Displacement doesn’t come for developers who are willing to understand their tools and their limitations.</p><h3>3.4. Three more ills</h3><p>On top of those three, three more flew out:</p><ul><li><strong>Accountability vacuum</strong>: our current business models of who’s responsible for what, always assumed a human pressed the merge button. For an agentic world, most orgs have no clean answer for who owns what.</li><li><strong>Amplified dysfunction</strong>: AI is an amplifier, not a fixer. A mature team gets a real lift. An immature one gets more defects, bigger PRs nobody can review, and faster wrong decisions. <strong>AI multiplies your team, including the problems you already have.</strong></li><li><strong>Prompt injection at agent scale</strong>: this has two routes.</li><li>A tool can be poisoned when you install it, via hidden instructions in its description.</li><li>Or poisoned whilst it runs, through hidden instructions in what it sends back.</li></ul><p>The MCP ecosystem has already shipped vulnerable servers by the thousand. The fixes differ: a vetted registry for what you install and a sanitising hook for what comes back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1auvFv9JtL8grVCS.jpeg" /></figure><p>So that’s what flew out: six ills. Not one was magic. Not one is a reason to panic, or to pretend we can close the box again.</p><p><strong>Every one is shaped like engineering</strong>: a hook for opacity, a monitor for misalignment, a reading habit for displacement, or a fix for each injection route. This isn’t vibes, it’s work.</p><p>OK. Now, if that’s what flew out, what’s still inside?</p><h3>4. What is still inside: the safety primitives</h3><p>Going back to the myth for a moment, when Pandora closed the lid, the box wasn’t empty: one thing was still inside, and that thing was hope.</p><p>For us, the hope that stayed in the box is engineering: the safety primitives that ship in a production harness today, whether or not anyone reads them.</p><p>Let’s look into the box.</p><h3>4.1. Permissions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0MAqKmxh483NUdfK.jpeg" /></figure><p>When our box opened, the first thing we were all met with was <strong>the approval prompt</strong>: the agent wants to act, so it stops and asks. Reads are free but anything that changes the world waits for us to confirm it.</p><p>When Anthropic measured how people actually used it, it found that we approve about 93% of those per-action prompts. 93! <strong>A control we say yes to nine times in ten is not a control; it is a speed bump</strong> we will stop noticing and mindlessly approve.</p><p>What Anthropic did next wasn’t to add more warnings but to restructure around permission boundaries. Instead of a hundred prompts a session, we define once what the agent may do: which tools are allowed, which denied, which gated. Deny-first and only escalating to a human when one is genuinely needed. So, the per-action triage that used to interrupt us, is now code.</p><p>In that Claude Code leaked repo, there was a file called yoloClassifier.ts, about 1500 lines of TypeScript, that scores how risky each action is and decides whether to let it through, block it, or ask a human. That&#39;s the permission system, and it&#39;s a boundary we set once and can audit, not a prompt we rubber-stamp a hundred times.</p><h3>4.2. Hooks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6LuSNzOUzoyZDsGB.jpeg" /></figure><p>Permissions decide what the agent is allowed to do. And unlike everything we put in AGENTS.md (which the model can choose to ignore), hooks are code that runs. Instructions can be ignored. Hooks cannot.</p><p>That Claude Code study counted 27 hook event types: 5 safety events, and 22 for lifecycle and orchestration, like before a tool runs, after it runs, or when a session starts or ends. At each of those events you can run your own code, and it can do one of three things:</p><ul><li>block the action</li><li>rewrite it before it happens</li><li>or annotate it, attaching something to the record.</li></ul><p><strong>A hook is how we address the opacity we encountered before.</strong> Attach one on the after-an-edit event, and every change carries your metadata: the task, the reasoning, the trail. <strong>The why stays welded to the what</strong>, automatically, because you wired it that way.</p><p>Let’s watch one fire. Same harness as before. This time, we’re watching a hook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*saika0XGo5hNhipR.png" /></figure><p>We are asking the agent to perform a simple docs task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_4pDtEZ0lnpkWJt5.png" /></figure><p>The Agent attempts to make an edit — we gave it permission to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MLNd7299RiDbFLSn.png" /></figure><p>And the hook fires immediately after that edit, writing the reasoning into the session’s lineage record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OEKtRiK0jy5bcUGm.png" /></figure><p>The hook captures every change the instant it happens; and when the work is committed, that record becomes the Session-Checkpoint we saw earlier: the line that carries the reasoning.</p><p>Nobody typed that, and nobody approved that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WGwZsi-T9V-Elv93.png" /></figure><p><strong>It’s policy, running as code, on the after-an-edit event</strong>.</p><p>So the <em>what</em> is logged automatically, and the <em>why</em> is welded on at commit time. The opacity we worried about in the last section, resolved by wiring a hook.</p><h3>4.3. The quieter primitives</h3><p>Let’s cover 3 more primitives, already in the box.</p><ul><li><strong>MCP boundaries</strong>: MCP has become the official protocol a harness uses to reach external tools and data. It extends the agent NOT at the reasoning layer BUT at the protocol layer. When your team ships an MCP server for an internal API, the agent gets to see exactly what every engineer on that team sees through it, no more, no less. <strong>We’re NOT widening what the model can think, we’re defining what it can reach.</strong></li><li><strong>Subagent isolation</strong>: When the harness spins up a subagent, it runs the same loop again, but with a fresh context window of its own. It does its work, and hands back just a summary. Nothing leaks across that line: not the context, not the permissions. It’s a sealed box, by design.</li><li><strong>Append-only sessions</strong>: As the session runs, the harness writes it to disk: an append-only log you can resume, fork, and rewind. So the session isn’t a black box that vanishes when you close the terminal. It’s a record. And you can audit it.</li></ul><p>So the hope stayed in the box BUT hope was never a feeling. It was these primitives all along, and across all five they share one trait: governance you can open and shape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6N58VmfQZdFMg4wx.jpeg" /></figure><p>In most organisations, governance is a whitepaper: a document on a shared drive that everyone ignores. In a production harness, governance is running code.</p><p>But before we go on, one piece of honest pushback.</p><h3>5. A contrarian beat: single-agent by default</h3><p>The loudest advice in the industry right now isn’t <strong>shape your harness</strong>. It’s <strong>build a swarm</strong>.</p><p>So let me swim against the current for a minute. The thinking goes like this: if one agent is good, a <em>team</em> of agents must be better. A planner, an architect, a coder, a reviewer, a tester, all talking to each other, orchestrating the swarm. It looks like an org chart. And we trust org charts.</p><p>Earlier this year, a Stanford team finally ran the comparison fairly by holding one thing equal: the <em>thinking budget</em>, i.e. the tokens an agent gets to reason before it answers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k2Pl2TxEzqPyfIn5.jpeg" /></figure><p>Turns out: <strong>the single agent matches or beats the swarm at any serious budget.</strong> So where did all those swarm <em>wins</em> come from? Compute nobody counted. The swarm didn’t win; it just spent more, 4.7 times the compute, and took the credit.</p><p>Why? Because <strong>one agent sees the whole problem at once</strong>. A swarm can’t; each agent only gets a short summary of what the others did, and every summary loses something. So more agents don’t add understanding; they add telephone-game distortion.</p><p>There’s really only one time a swarm pulls ahead: when the information is so messy and noisy that a single agent gets lost in it, and that situation is becoming more common.</p><p>So, decompose deliberately. A swarm carries a hidden cost: the coordination tax.</p><ul><li>Every extra agent burns tokens, time, and money.</li><li>Every hand-off is another chance to drop or distort information.</li></ul><p>We pay that tax whether or not the swarm earns it back.</p><p>So: <strong>single agent by default</strong>. <strong>A swarm is the exception</strong> that should only be triggered if:</p><ul><li>context is too long <em>and</em> genuinely corrupted.</li><li>sub-tasks that truly don’t need to talk to each other</li><li>sub-tasks reaching for completely different tools</li></ul><p>One focused agent with good tools will always beat six confused agents arguing.</p><h3>6. Agency is your job-safety strategy</h3><p>OK, something else we’ve been circling deserves to be named. <strong>AI is closing the skill gap</strong>: the distance between a junior developer and a senior engineer, the distance that used to take a decade to cross, is getting shorter.</p><p>If your value was <em>“I can write the code that most people cannot”</em>, that moat is draining.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*coDyImVN0RgHfFqG.jpeg" /></figure><p>Max Schoening, who runs product at Notion, put it cleanly: <strong>“the first ten per cent of every project is now free”</strong>. We can spin up ten agents and explore ten rough versions before lunch. But the last ten per cent is still ninety per cent of the work. Exploration got cheap but shipping something real didn’t.</p><p>So if the skill is flattening, the honest question is: what’s left? What’s the thing that still separates the developers who compound from the developers who stall?</p><p><strong>What’s left is agency</strong>! Not skill. Agency!</p><blockquote><em>Agency is a disposition to treat the world around us as malleable. Something we are allowed to reach into and change.</em></blockquote><p>AI-native isn’t about having an LLM open on your screen all the time; <strong>it’s about how you think about the value of your work</strong>.</p><p>If you don’t know what matters, what good looks like, or where to focus, <strong>AI just helps you do the wrong thing faster</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bYIvRqWK1Z5ZCZxT.jpeg" /></figure><p>Most developers are still on steps one and two of our arc: the anxious and the fluent prompter. They accept the harness exactly as it shipped: they type into the box, and they take whatever the box was configured to give them.</p><p>The harness shaper, step four, does the opposite. You look at the harness the way a potter looks at clay: all of it is malleable, all of it is yours to throw.</p><p>So shape your harness. Don’t just prompt it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9MWx55qqkD46oz4S.png" /></figure><p>“Shape your harness” might sound like a slogan, but it’s not.</p><p>Here is the harness we saw earlier. We have:</p><ul><li>a project-memory file</li><li>a permissions file</li><li>and the hooks that wire your policy into every edit and every commit.</li></ul><p><strong>That’s not a manifesto. It’s a directory listing</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RV2bwcfShE_Y3Pd0.png" /></figure><p>And every one of those is a plain text file, and every one of them is yours to edit.</p><p><strong>Agency is the disposition; these files are the artefact</strong>. Which means shaping your harness isn’t aspirational: it’s just opening files. And that’s exactly what you can do on Monday.</p><h3>The Monday-morning checklist</h3><p>Here are 5 moves for your Monday morning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yA7myIcKfPPNuvR8.jpeg" /></figure><ol><li><strong>Write your </strong><strong>AGENTS.md like a system contract.</strong></li><li>Most teams treat the project-memory file as a README: a few notes, mostly stale. It’s not a README. It’s the contract the agent reads before every task. Treat it like load-bearing code: precise, current, reviewed. Whatever your harness calls it, be that AGENTS.md, CLAUDE.md, .cursorrules, the discipline is the same.</li><li><strong>Ship one MCP server</strong>.</li><li>Find that one thing your team reaches for every day but that the agent currently can’t see, be that your deployment status, your internal docs, your ticketing. Make it a tool, instead of a paragraph of instructions. <strong>Start with one single server.</strong></li><li><strong>Install one hook for lineage.</strong></li><li>Pick the smallest hook that captures the why alongside the what in your history, so that six months from now the diff still explains itself. <strong>Smallest one that works</strong>.</li><li><strong>Run a permissions audit.</strong></li><li>Open your harness’s permission rules and actually read them, then tighten one and maybe loosen another, both deliberately. <strong>Stop treating permissions as someone else’s default.</strong></li><li><strong>Run the single-agent default.</strong></li><li>Resist the swarm. One focused agent with good tools, until you hit a real trigger for decomposition, not before.</li></ol><p>These are the 5. And one thing rings true of all of them. They don’t need a budget, a meeting, or a platform team.</p><p>They’re all things you can do on Monday morning, with the tools you already have, and the permissions you already have.</p><p>To help you remember all five, I’ve put together a <a href="https://h301.dev/devtalks-checklist">PDF with the checklist</a>, and the engineering primitives. It contains every move on that checklist, as ready-to-paste starting points.</p><p>Now, the checklist is the easy part. The hardest part is the mindset shift.</p><p>The developers who thrive in the next decade will <strong>not</strong> be the ones who memorise the cleverest prompts. They’ll be the ones who shape their harness, who treat the permissions, the hooks, the project memory, the tools, all of it, as clay on a wheel.</p><p>And the best part? You don’t need to wait for someone to hand you a mandate.</p><h3>7. Build the thing itself</h3><p>The checklist is the harness-shaper’s move. The next step up is to build the thing all of that wraps around: <strong>the loop itself</strong>. Yes, you’re perfectly capable of building an agent yourself today.</p><p>Remember the harness loop we saw earlier?</p><pre>while not done:<br>    reply = model(conversation)<br><br>    if reply.wants_tool:<br>        result = run_tool(reply.tool_call)<br>        conversation.append(result)<br>    else:<br>        done = True</pre><p>Let’s remind ourselves what it does:</p><ul><li>it calls the model.</li><li>if the reply asks for a tool, run the tool and feed the result back.</li><li>if it doesn’t, we’re done.</li></ul><p>That’s it!</p><p>Here are the same lines but in JavaScript, and they’re about to grow.</p><pre>let done = false;<br>while (!done) {<br>  const reply = await model(conversation);<br><br>  if (reply.wantsTool) {<br>    const result = await runTool(reply.toolCall);<br>    conversation.push(result);<br>  } else {<br>    done = true;<br>  }<br>}</pre><p>Everything we add from here is pure engineering. And each thing we bolt on is a safety primitive we’ve already spoken about. Watch the code grow one move at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*epRYSqB9QloGM5ds.png" /></figure><ol><li>First move: before we let the loop run a tool, we <strong>check against a permission ruleset</strong>, so the agent can’t run a destructive command without our say-so. That’s the safety primitive we named earlier, and it’s 4 extra lines.</li><li>Second move: After the tool returns, <strong>a hook fires</strong> and writes the result and the reason to a log, so the <em>why</em> is captured at the moment it exists. And that’s the <strong>opacity fix</strong>; one single extra line.</li><li>Third move: the prompt-injection. In two halves. Because the threat has two routes.</li></ol><ul><li>Before the dispatcher runs a tool, it <strong>checks the tool’s source against a list of trusted MCP servers</strong>: that closes the schema route, the case where the tool’s own description was poisoned at install.</li><li>And after the tool returns, <strong>a small sanitiser strips instruction-shaped strings</strong> from the result before the loop reads it back: that closes the response route, the case where the tool’s output is carrying instructions for the agent.</li></ul><p>And that’s it!</p><p>We designed a workflow!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mUnJEtJGqKD5ri1O.jpeg" /></figure><p><em>The whole hardened harness on one screen: the artefact is small, but the discipline scales.</em></p><p>That was <strong>Step five</strong> on our AI adoption arc.</p><p><strong>Step six</strong> is the enabler: the same discipline taught to a team. The senior engineers in this room have done this already, almost certainly, without naming it.</p><p>And <strong>Step seven</strong>, the platform thinker, is where the practice scales beyond your team.</p><h3>8. Where the practice scales</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cSN3z-kJ2YSw-koN.jpeg" /></figure><p>As we mentioned earlier, <strong>AI amplifies whatever system it runs on</strong>. Amplify a good system and you compound. But amplify a broken one and you compound the breakage.</p><p>We can do everything on that checklist and become genuinely good at shaping our harness, and our organisations still gain nothing. The literature has a name for it: <strong>the AI Productivity Paradox</strong>.</p><p><strong>Individual lift, no organisational gain</strong>: more tasks completed, more PRs merged, but delivery measured at the level of the whole team is dead flat.</p><p>So, if individual agency alone doesn’t scale, what does?</p><p>What scales is an operating model, a new paradigm-shift operating model. At Vonage, we’re building a paradigm-shift operating model; we call it the AI-Native Software Factory and it’s something I’ve spent my last half a year on.</p><p>It embeds AI assistants, automation, and intelligent tooling into every phase of software delivery, from requirements and architecture through to testing, deployment, and operations.</p><p><strong>It rests on four pillars.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d5yqqxXqxIUXPvdP.jpeg" /></figure><p><em>The AI-Native Software Factory: four pillars wired from inputs through to deployment.</em></p><ol><li>The first is a <strong>Context Graph</strong>: a governed, queryable model of the code, architecture and previous decisions, tickets, runtime, so an agent reasons over a real picture of the system instead of reading files and hoping.</li><li>The second is an <strong>Intent Engine</strong>: a system that captures the intent behind every change, so the <em>why</em> is always available to the agent, and to the humans who review it. Specifications are the source of truth, testable and executable.</li><li>The third pillar is the <strong>Agentic Assembly Line</strong>: receives Units of Work from the Intent Engine and decomposes them into tasks for specialised agents executing in parallel (not a swarm).</li><li>The fourth is a <strong>Governance Gate</strong>: a system that enforces the rules of the organisation, so the agent can’t act outside of them, and every action is logged and auditable.</li></ol><p>Those four pillars are the answers to the ills we named: opacity is what the Context Graph closes, by making the <em>why</em> a durable, queryable record rather than a session detail that vanishes, and the accountability vacuum is what the Governance Gate combats, the same problems solved structurally rather than heroically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3nGvBHnJINCJ7Csu.jpeg" /></figure><p>So here’s the whole climb. We’ve walked the entirety of it, from the anxious prompter, all the way to the platform thinker at the top. Reading became shaping, shaping became designing and building. And building, taught to a team, becomes the platform thinking the factory runs on. <strong>That’s the climb, and all of it is ours to make</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iHpX6afHTh4QyDyT.jpeg" /></figure><p><em>On the AI Stage at DevTalks Romania, Bucharest, June 2026.</em></p><p><em>Originally published at </em><a href="https://www.pardel.dev/2026/06/12/opening-pandoras-box.html"><em>https://www.pardel.dev</em></a><em> on June 12, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8be2f23e590d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/opening-pandoras-box-a-developer-s-guide-to-ai-agents-8be2f23e590d">Opening Pandora’s Box: A Developer’s Guide to AI Agents</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passkeys from first principles: what they are and how they work]]></title>
            <link>https://medium.com/paul-ardeleanu/passkeys-from-first-principles-what-they-are-and-how-they-work-b5409910bb26?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/b5409910bb26</guid>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[first-principles-thinking]]></category>
            <category><![CDATA[webauthn]]></category>
            <category><![CDATA[passkey]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 21:06:10 GMT</pubDate>
            <atom:updated>2026-07-11T21:06:11.435Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally published at </em><a href="https://www.pardel.dev/2026/06/28/passkeys-from-first-principles.html"><em>https://www.pardel.dev</em></a><em> on June 28, 2026.</em></p><blockquote><strong><em>Passwords are the oldest unfixed bug in software</em></strong><em>. We have spent thirty years adding layers around them and moving them about, and passkeys are the first widely deployed change that removes the shared secret rather than relocating it. This is a tour of where passkeys sit in the authentication landscape, and how the two ceremonies behind them work; a follow-up post builds them from scratch in Ruby on Rails.</em></blockquote><p><strong>The password</strong> has a structural problem that no amount of policy can patch. It <strong>is a shared secret</strong>: you know it, and the server knows it. Every shared secret is something that can be guessed, reused across sites, leaked in a breach, or handed to the wrong person by a convincing email. We have spent decades building defences around that one weakness, and most of them treat the symptom rather than the cause.</p><p><strong>Passkeys are different because they stop sharing the secret at all</strong>. The aim of this post is to make that idea concrete: first by placing passkeys properly within the authentication ecosystem, and then by walking through the two ceremonies that make them work.</p><h3>The authentication ladder</h3><p>It helps to see passkeys as the next step on an authentication ladder we have been climbing for years, because each step was an attempt to fix the step below it:</p><figure><img alt="A staircase of five authentication methods rising by year. Each step shows where its reusable secret lives and whether it can be phished: passwords (1961, the server database, phishable); passwords plus a one-time code (1986, database and device, phishable); federated identity (late 2000s, the identity provider, phishable); magic links (mid-2010s, the email inbox, phishable); and passkeys (2022, no shared secret, unphishable)." src="https://cdn-images-1.medium.com/max/1024/1*FI3nVQGaV4WwYpbtO8U_oQ.png" /></figure><h3>1961: Passwords alone</h3><p>A single shared secret, an idea that goes back to MIT’s CTSS in 1961. If it is guessed, reused, or phished, the account is gone. Every other step exists because this one leaks.</p><h3>1986: Passwords plus a one-time code</h3><p>Hardware tokens such as RSA’s SecurID landed in 1986, and TOTP apps and SMS codes later carried the idea into everyday use, adding a second factor: something you have, on top of something you know. This genuinely raises the cost of an attack, yet it does not close the most common door. A user who can be tricked into typing their password into a lookalike site can just as easily be tricked into typing the six-digit code straight after it. The phishing page simply relays both to the real site in real time. SMS adds its own weakness on top, since numbers can be ported away from their owner.</p><h3>Late 2000s: Federated identity</h3><p>The “Sign in with Google” button lets users authenticate through a provider such as Google, Apple, or GitHub, which genuinely removes the password from your application: you never store one and never check one, because you delegate the whole question to an identity provider. Strictly this is OpenID Connect, the authentication layer built on top of OAuth 2.0, the framework finalised in 2012, even though almost everyone calls the bundle OAuth. The catch is that it removes the password from your app without removing the shared secret from the system: it centralises it. The user still proves themselves to the provider, and usually still does so with a password, so the phishing target moves to the provider’s login page rather than disappearing. Every account a user federates then rests on the security of that one provider account, the provider gets to see everywhere its users sign in, and it becomes a single point of lockout.</p><h3>Mid-2010s: Magic links</h3><p>Popularised by the SaaS boom of the mid-2010s, sending a sign-in link by email removes the password from the user’s head, which is a real improvement, but it makes the same move as federated identity, relocating the secret rather than removing it. The link is now a bearer token sitting in an inbox, and that inbox is itself usually protected by a password. It is also exposed on the way there: the link crosses mail servers and relays you do not control, over connections where TLS (the encryption that protects data in transit, the “S” in HTTPS) is only opportunistic between mail servers and can be stripped, so a token that grants account access spends its first moments on infrastructure outside anyone’s security guarantees. The security of the account collapses back onto the security of the mailbox.</p><h3>2022: Passkeys</h3><p>Instead of proving you know a secret, you prove you hold a private key, and you never reveal that key to anyone. The server keeps only the matching public half. There is nothing in the database for an attacker to steal and replay, and, as we will see, the browser refuses to use the key on the wrong site, so phishing stops working by design.</p><blockquote><em>Two patterns show up at every step of the authentication ladder:</em></blockquote><blockquote>* The first is phishability: almost every step except the last can be defeated by a user who is fooled into cooperating with the attacker, and passkeys are the first step where cooperation is not enough, because the user is no longer the one checking that the site is genuine.</blockquote><blockquote>* The second is more fundamental: every step except passkeys keeps a shared secret somewhere, whether in the user’s head, in an inbox, or in a provider’s database, and the entire history of the ladder is really the story of moving that secret to ever better-defended locations.</blockquote><p>Federated identity is the high point of that strategy rather than an exception to it: it does not abolish the secret, it hands it to a provider who can guard it better than you can. Passkeys are the first widely deployed step that stops there being a shared secret to move at all.</p><h3>What a passkey actually is</h3><p>Strip away the branding and a passkey is a public/private key pair created for one website.</p><p>When you register, your device generates a fresh key pair. The private key is written into a protected store: the secure enclave on a phone, a TPM on a laptop, or the chip inside a hardware security key. It is designed never to leave that store in usable form. The public key, which is useless on its own, is sent to the website and saved against your account.</p><p>From then on, signing in means the website sends a random challenge, your device signs it with the private key, and the website checks the signature against the public key it stored. Possession of the private key is proven without the key ever crossing the wire.</p><figure><img alt="A two-phase diagram of a passkey key pair. Registration: your device generates a key pair; the private key stays locked in the device’s secure store and never leaves, while only the public key travels across the network and is saved against your account on the website. Signing in: the website sends a random challenge, the device unlocks with a biometric or PIN and signs the challenge with the private key inside the secure store, the signature travels back, and the website verifies it against the" src="https://cdn-images-1.medium.com/max/1024/1*1XTsRD2LCie7gXLGpp3g2A.png" /></figure><p>Two consequences fall straight out of this design, and they are the whole reason passkeys matter:</p><ul><li>The first is that a database breach stops being catastrophic for authentication. A stolen password table is a list of secrets that unlock accounts, often reusable on other sites because people repeat passwords. A stolen passkey table is a list of public keys, and a public key cannot sign anything. There is nothing there to replay.</li><li>The second is that a single passkey gesture is already multi-factor. To use the private key, the authenticator first checks the user with a biometric or a PIN. That combines something you have, the device holding the key, with something you are or something you know, the gesture that unlocks it. The clumsy “password plus separate app” dance collapses into one fingerprint.</li></ul><h3>Naming the standards correctly</h3><p>The terminology around passkeys is a small thicket, and getting it right makes the rest of the field readable.</p><ul><li><strong>WebAuthn</strong> is the browser API. It is a W3C standard, exposed in JavaScript as navigator.credentials. When the code below calls navigator.credentials.create() or navigator.credentials.get(), that is WebAuthn.</li><li><strong>CTAP</strong>, the Client to Authenticator Protocol, is how a client such as a browser talks to a roaming authenticator such as a phone or a security key, typically over USB, NFC, or Bluetooth.</li><li><strong>FIDO2</strong> is the umbrella term for the two together: WebAuthn plus CTAP. The <strong>FIDO Alliance</strong>, working with the W3C, is the body behind the standards.</li><li><strong>Passkey</strong> is the consumer-friendly name for a WebAuthn credential, and in practice it usually means a <em>discoverable</em> one, a distinction we will come to shortly. The word was chosen so that nobody has to say “discoverable FIDO2 credential” at a dinner party.</li></ul><h3>The taxonomy that trips people up</h3><p>Three distinctions cause most of the confusion when teams first adopt passkeys.</p><p><strong>Platform versus roaming authenticators.</strong> A platform authenticator is built into the device you are using: Touch ID on a Mac, Windows Hello, the secure enclave on a phone. A roaming authenticator is a separate object you carry between devices, almost always a hardware security key such as a YubiKey. Your app does not usually need to care which is which, but the choice shapes the user’s recovery story.</p><p>You might expect a platform authenticator to trap a passkey on one machine, since the private key is generated inside that device’s secure hardware. In practice it usually does not, because the operating system’s credential manager copies the passkey between all the devices signed into the same account. Create a passkey with Touch ID on a Mac that shares an iCloud account with your iPhone, and iCloud Keychain syncs it to the phone, so you can sign in there without registering separately; Google Password Manager does the same across your Android and Chrome devices. The private key still never leaves secure storage on each device; the credential manager moves an encrypted copy, end-to-end encrypted so Apple or Google cannot read it. Whether a passkey travels this way is the <em>synced versus device-bound</em> distinction, next.</p><p><strong>Synced versus device-bound.</strong> This is the distinction that made passkeys usable for ordinary people. A device-bound passkey lives and dies on one piece of hardware: lose the device and you lose the key. A synced passkey is backed up and shared across a user’s devices by a credential manager such as iCloud Keychain or Google Password Manager, so a new phone arrives already holding the user’s passkeys. Synced passkeys trade a little theoretical hardware-level assurance for an enormous gain in practicality, and they are why passkeys finally crossed into the mainstream. One side effect is that synced passkeys often report a signature counter of zero, a detail that matters when we verify signature counters in part two.</p><p><strong>Discoverable versus non-discoverable credentials.</strong> A non-discoverable credential, historically called a non-resident key, stores nothing on the authenticator itself. The server has to remind the authenticator which credentials exist by sending a list, which means the user has to identify themselves first, typically by typing a username. A discoverable credential, the resident key, stores enough on the authenticator that it can present the user’s accounts without being told who they are in advance. Discoverable credentials are what make truly usernameless, passwordless sign-in possible: the user lands on the page, taps a button, picks an account, and authenticates. That is the experience this post builds.</p><h3>Where your email fits in</h3><p>Passkeys remove the password, but they do not remove the need to say <em>who</em> a key belongs to, and this is where the email address quietly re-enters the story. When the server starts registration, the creation options it sends to the browser include a user object with three fields, and each has a different job:</p><ul><li><strong>user.id</strong> is the <em>user handle</em>: an opaque identifier for the account, generated once by the server, ideally just random bytes. With a discoverable credential the authenticator stores it next to the private key and hands it back during sign-in, and that is the whole mechanism behind usernameless login: the server learns who is authenticating from the handle the authenticator presents, not from anything the user types.</li><li><strong>user.name</strong> is the human-readable account identifier, and in practice this is almost always the email address, though the spec is just as happy with a username or a phone number: its own examples list all three. Its consumer is not your server but the account picker: when a user holds passkeys for more than one account on your site, this is the string the browser shows so they can tell the accounts apart.</li><li><strong>user.displayName</strong> is a friendlier label still, a full name rather than an address, shown alongside user.name where the interface has room for it.</li></ul><p>Three things follow from this split, and each one surprises people the first time.</p><p><strong>The email is a label, not a credential.</strong> Nothing in either ceremony signs it, checks it, or proves the user controls the inbox behind it. Registering a passkey with user.name set to paul@example.com proves possession of a private key and nothing whatsoever about that mailbox. If your application relies on email for recovery or notifications, verifying ownership is a separate, ordinary application concern, exactly as it was with passwords.</p><p><strong>The email must not be the user handle.</strong> The WebAuthn specification is explicit that user.id must not contain personally identifying information such as an email or username. Partly this is privacy: the handle is not guarded the way the private key is, so it should be worthless to anyone who reads it. Partly it is lifecycle: the handle is copied onto authenticators you may never see again, so it has to outlive an email change; an account is not the address it was created with. The follow-up post generates it with a one-line helper from the webauthn-ruby gem and stores it as a separate column on the user.</p><p><strong>The picker text lives on the authenticator, not on your server.</strong> A discoverable credential stores user.name and user.displayName at creation time so the picker can render without asking your server anything. Change the email on the account later and every existing passkey keeps showing the old address; browsers are only now gaining an API that lets a site push updated details back to the credential manager.</p><p><strong>And a worry worth defusing: a tampered label cannot cross accounts.</strong> If the server never validates the email, could a user change the address on a passkey and sign in to someone else’s account? No, because the label never makes the return journey. The authentication response carries the credential ID, the signature, and the user handle; user.name and user.displayName are write-only, handed to the authenticator at registration for the picker&#39;s benefit and never sent back. Editing the email on a stored passkey changes what your own picker displays and nothing else.</p><p>The handle does return, and it is the field an attacker would want to swap, but a response presenting someone else’s handle fails twice over. The server looks the credential up among <em>that</em> account’s registered credentials, where the attacker’s credential does not appear, and the signature only verifies against the public key stored at registration, which is not the attacker’s. The specification makes the first of these an explicit verification step, checking that the user identified by the handle actually owns the credential presented, and the second is the entire point of the design. Where the label genuinely can be abused is before any of this, at account creation: an application that creates accounts from an unverified email lets anyone claim victim@example.com and attach a passkey to it before the victim ever signs up. That is the classic pre-account-takeover problem, it exists just as much with passwords, and it is exactly the &quot;separate, ordinary application concern&quot; from a paragraph ago.</p><p>There is a pleasing demotion hiding in all this. On the authentication ladder, the email address had been climbing: magic links made the inbox the place the secret actually lived. With passkeys the email drops off the security path entirely. It is a caption in a picker and a channel for receipts, and the last home of the shared secret ends up holding no secret at all.</p><h3>Why passkeys cannot be phished</h3><p>This is the part worth slowing down on, because it is where passkeys earn their reputation.</p><p>When a credential is created, it is bound to a <strong>Relying Party ID</strong>, the RP ID, which is essentially your site’s domain. When the user later tries to authenticate, the browser will only offer credentials whose RP ID matches the origin of the page actually being viewed. A passkey created for pardel.dev is invisible on parde1.dev, and the user is never asked to make that judgement.</p><p>That last clause is the crucial one. With passwords, the human is the component checking that the site is genuine, and humans are not reliable at spotting a swapped letter in a domain under time pressure. With passkeys, the browser performs the check, mechanically, every time, using the real origin rather than the one the user thinks they are on. The signed payload that comes back to your server includes the origin the browser saw and the exact challenge you issued, so even a man-in-the-middle relaying messages in real time cannot produce a valid signature for your domain. The thing that defeats classic phishing is moved out of the user’s hands entirely.</p><h3>The two ceremonies</h3><p>Everything in WebAuthn reduces to two flows, and they are pleasingly symmetrical. The specification calls them ceremonies:</p><ul><li><strong>Registration</strong> (the attestation ceremony) creates a new key pair and hands the public key to your server.</li><li><strong>Authentication</strong> (the assertion ceremony) proves the user still holds the matching private key.</li></ul><p>Both follow the same shape: the server issues a random challenge, the authenticator produces a signature over it, and the server verifies that signature. Hold that round-trip in your head and the code below is mostly plumbing.</p><h3>Registration</h3><ol><li>The browser asks the server to start registration.</li><li>The server generates a random challenge, remembers it, and returns the creation options, including the user object: the account&#39;s handle and its email label.</li><li>The browser calls navigator.credentials.create(), which prompts the user for a biometric or PIN and generates the key pair. The authenticator keeps the private key and stores the handle and email beside it, ready for the account picker.</li><li>The browser sends the new public key and a signature back to the server.</li><li>The server verifies the response against the stored challenge and saves the public key against the account.</li></ol><figure><img alt="Sequence diagram of the registration ceremony between the browser and the server. Step 1: the browser asks the server to start registration. Step 2: the server generates and remembers a random challenge and returns the creation options, which include the user object: the account’s user handle and its email label. Step 3: on the browser, navigator.credentials.create() prompts the user for a biometric or PIN and generates the key pair; the private key stays on the device, and the handle and email" src="https://cdn-images-1.medium.com/max/1024/1*O93hsq4OCuzsXDcCaA3tvA.png" /></figure><h3>Authentication</h3><ol><li>The browser asks the server to start sign-in.</li><li>The server generates a fresh challenge, remembers it, and returns the request options. Nothing in them identifies the user: the passkey is about to say who is signing in.</li><li>The browser calls navigator.credentials.get(), the user picks a passkey from a list labelled by email, and confirms with a gesture.</li><li>The browser sends a signature over the challenge back to the server, along with the user handle.</li><li>The server finds the account by the handle, verifies the signature against its stored public key, and opens a session.</li></ol><figure><img alt="Sequence diagram of the authentication ceremony between the browser and the server. Step 1: the browser asks the server to start sign-in. Step 2: the server generates and remembers a fresh challenge and returns the request options; nothing in them identifies the user, because the passkey will say who is signing in. Step 3: on the browser, navigator.credentials.get() shows a picker that labels each account with its email; the user picks one and confirms with a gesture, signing the challenge with" src="https://cdn-images-1.medium.com/max/1024/1*ZVXfQJXvJyGZFFPe6GaOlw.png" /></figure><h3>What’s next: building it in Rails</h3><p>The two ceremonies above are the entire protocol: a challenge out, a signature back, a verification. Everything else is plumbing. In the follow-up post, <a href="https://www.pardel.dev/2026/07/04/passkeys-in-ruby-on-rails.html"><strong>Building passkeys in Ruby on Rails from scratch</strong></a>, we turn these diagrams into a working passwordless, usernameless login: the server-side options and verification with the webauthn-ruby gem, the browser calls, the parts a from-scratch demo tends to skip, and a small gem that packages the whole thing.</p><h3>References</h3><ol><li><a href="https://news.mit.edu/2019/mit-professor-emeritus-fernando-corby-corbato-computing-pioneer-dies-0715">Professor Emeritus Fernando Corbató, MIT computing pioneer, dies at 93</a>, MIT News (the CTSS password, 1961).</li><li><a href="https://www.rsa.com/products/securid/">RSA SecurID</a>, RSA (the SecurID one-time-password hardware token).</li><li><a href="https://datatracker.ietf.org/doc/html/rfc6238">RFC 6238: TOTP: Time-Based One-Time Password Algorithm</a>, IETF (2011).</li><li><a href="https://pages.nist.gov/800-63-3/sp800-63b.html">NIST SP 800–63B: Digital Identity Guidelines — Authentication and Lifecycle Management</a>, NIST (2017; §5.1.3.3 restricts SMS one-time codes).</li><li><a href="https://openid.net/specs/openid-connect-core-1_0.html">OpenID Connect Core 1.0</a>, OpenID Foundation.</li><li><a href="https://datatracker.ietf.org/doc/html/rfc6749">RFC 6749: The OAuth 2.0 Authorization Framework</a>, IETF (2012).</li><li><a href="https://www.w3.org/TR/webauthn-2/">Web Authentication (WebAuthn) Level 2</a>, W3C Recommendation.</li><li><a href="https://fidoalliance.org/passkeys/">Passkeys</a>, FIDO Alliance.</li><li><a href="https://www.apple.com/newsroom/2022/05/apple-google-and-microsoft-commit-to-expanded-support-for-fido-standard/">Apple, Google and Microsoft commit to expanded support for FIDO standard</a>, Apple Newsroom, May 2022 (passkeys).</li><li><a href="https://www.w3.org/TR/webauthn-2/#dictionary-user-credential-params">Web Authentication (WebAuthn) Level 2, §5.4.3: User Account Parameters for Credential Generation</a>, W3C (the PublicKeyCredentialUserEntity dictionary: id, name, and displayName).</li></ol><p><em>Originally published at </em><a href="https://www.pardel.dev/2026/06/28/passkeys-from-first-principles.html"><em>https://www.pardel.dev</em></a><em> on June 28, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5409910bb26" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/passkeys-from-first-principles-what-they-are-and-how-they-work-b5409910bb26">Passkeys from first principles: what they are and how they work</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building passkeys in Ruby on Rails from scratch]]></title>
            <link>https://medium.com/paul-ardeleanu/building-passkeys-in-ruby-on-rails-from-scratch-db5d2a64cf1f?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/db5d2a64cf1f</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[passkey]]></category>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 21:03:59 GMT</pubDate>
            <atom:updated>2026-07-11T21:04:00.636Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally published at </em><a href="https://www.pardel.dev/2026/07/04/passkeys-in-ruby-on-rails.html"><em>https://www.pardel.dev</em></a><em> on July 4, 2026.</em></p><blockquote><em>This is the second half of a two-part series. </em><a href="https://www.pardel.dev/2026/06/28/passkeys-from-first-principles.html"><em>Part one</em></a><em> covers where passkeys sit in the authentication landscape, what a passkey actually is, and the two ceremonies at the heart of WebAuthn. Here we turn those ceremonies into working code.</em></blockquote><blockquote><em>If you would rather not hand-roll any of it, </em><a href="https://www.pardel.dev/2026/07/04/passkeys-in-ruby-on-rails.html#a-gem-that-packages-this"><em>a small gem further down</em></a><em> packages this exact approach — but building it once first is the best way to understand what that gem is doing for you.</em></blockquote><h3>What we’re building</h3><p>We will build this from scratch: no Devise, no authentication engine, just the <a href="https://github.com/cedarcode/webauthn-ruby">webauthn-ruby</a> gem for the server-side cryptography and the browser&#39;s native API on the front end. The goal is transparency rather than a drop-in solution, so the snippets below are the load-bearing parts rather than a complete application. We are building passwordless, usernameless sign-in, which means discoverable credentials throughout.</p><h3>1. A new Rails app</h3><p>Start from an empty application. Any recent version will do; these examples target Rails 8. We pass --css=tailwind so the handful of views at the end get some styling without any custom CSS.</p><pre>rails new passkeys_demo --css=tailwind<br>cd passkeys_demo</pre><h3>2. The user model</h3><p>We need a User for credentials to hang off. In a usernameless flow the only field that truly matters is a stable identifier, but an email gives us something human to show when a user manages their keys. We add the webauthn_id column now too: it is the <em>user handle</em> the authenticator stores alongside a discoverable credential, and the piece that later lets the server tell who is signing in without a typed username.</p><pre>bin/rails generate model User email:string:uniq webauthn_id:string<br>bin/rails db:migrate</pre><p>With the app and the User in place, we can add WebAuthn itself.</p><h3>3. Setup</h3><p>Add the gem and configure it. The configuration tells the library who you are and which origins it should trust.</p><pre># Gemfile gem <br>&quot;webauthn&quot;</pre><pre>## config/initializers/webauthn.rb<br>WebAuthn.configure do |config|<br>  config.allowed_origins = [&quot;https://your.domain.dev&quot;]<br>  config.rp_name = &quot;Your Domain&quot;<br>  # rp_id defaults to the origin&#39;s domain; set it explicitly if you<br>  # serve auth from a subdomain but want credentials to cover the apex.<br>  config.rp_id = &quot;your.domain.dev&quot;<br>end</pre><p>A quick note on the browser side before the controllers. WebAuthn passes binary data, and JSON cannot carry raw bytes, so challenges and IDs travel as base64url strings that the browser has to turn into ArrayBuffers and back. Modern browsers handle that conversion for us: PublicKeyCredential.parseCreationOptionsFromJSON() and parseRequestOptionsFromJSON() turn the server&#39;s JSON into the structures the API expects, and a credential&#39;s .toJSON() turns the result back into something we can POST. These methods are now supported in every major browser, so we use them directly and add no JavaScript dependency at all. (Until recently you needed a small helper such as @github/webauthn-json to fill this gap.)</p><h3>4. The credential model</h3><p>We need somewhere to keep the public keys. A user has many credentials, because a person will register more than one device, and each credential stores three things: the credential’s own identifier, the public key, and a signature counter. Generate the model the same way we did the user:</p><pre>bin/rails generate model Credential \<br>  user:references \<br>  external_id:string:uniq \<br>  public_key:text \<br>  sign_count:integer \<br>  nickname:string</pre><p>The generator gets us most of the way: user:references adds the foreign key, and external_id:string:uniq adds a unique index. We ask for sign_count:integer because the generator does not accept bigint as a field type; we widen it to bigint in the migration below. Open the migration it wrote and tighten the columns that must always be present, plus a default for the counter:</p><pre># db/migrate/XXXXXX_create_credentials.rb<br>create_table :credentials do |t|<br>  t.references :user, null: false, foreign_key: true<br>  t.string  :external_id, null: false   # the credential ID, base64url<br>  t.text    :public_key,  null: false   # COSE key, base64url<br>  t.bigint  :sign_count,  null: false, default: 0<br>  t.string  :nickname                   # &quot;Work laptop&quot;, so users can manage keys<br>  t.timestamps<br>end<br>add_index :credentials, :external_id, unique: true</pre><p>Then run:</p><pre>bin/rails db:migrate</pre><p>The public key is a text column rather than a string: an RSA authenticator&#39;s key, base64url-encoded, overflows the default varchar(255) on MySQL and would be truncated, breaking every later signature check for that credential.</p><p>We call this column external_id, deliberately not webauthn_id, to keep it distinct from the <em>user handle</em> we added to User earlier: the two are otherwise easy to confuse. The handle identifies the person, the credential ID identifies one key they registered. The handle needs a value once, when the account is created, and it should never expose anything sensitive.</p><pre># When creating a user:<br>user.update!(webauthn_id: WebAuthn.generate_user_id)</pre><h3>5. Linking users to credentials</h3><p>The generated Credential already belongs_to :user; add the other side so current_user.credentials works:</p><pre># app/models/user.rb<br>class User &lt; ApplicationRecord<br>  has_many :credentials, dependent: :destroy<br>end</pre><h3>6. Registration on the server</h3><p>A reminder of the ceremony we are now writing, server half on the right:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*560xtTd8HCyebg9b.png" /></figure><p>Both halves live in a RegistrationsController, so generate it first:</p><pre>bin/rails generate controller Registrations</pre><p>Starting registration means generating options, with two settings that turn an ordinary credential into a passkey. Requiring a resident key asks the authenticator to store a <em>discoverable</em> credential, and requiring user verification asks for the biometric or PIN gesture that makes the result multi-factor.</p><pre># app/controllers/registrations_controller.rb<br>class RegistrationsController &lt; ApplicationController<br>  # POST /registration/options<br>  def options<br>    options = WebAuthn::Credential.options_for_create(<br>      user: { id: current_user.webauthn_id, name: current_user.email },<br>      exclude: current_user.credentials.pluck(:external_id),<br>      authenticator_selection: {<br>        resident_key: &quot;required&quot;,<br>        user_verification: &quot;required&quot;<br>      }<br>    )<br><br>    session[:creation_challenge] = options.challenge<br>    render json: options<br>  end<br>end</pre><p>The current_user here is the ordinary Rails session helper, nothing WebAuthn-specific: registering a passkey assumes the person is already signed in, so this endpoint runs for an authenticated user adding a key to their account. We define current_user (and the start_session_for used later) in <a href="https://www.pardel.dev/2026/07/04/passkeys-in-ruby-on-rails.html#11-the-application-controller">step 11</a>, next to the sign-up that bootstraps that first account.</p><p>The exclude list stops a user registering the same authenticator twice. Notice that the challenge is stashed in the session: it must survive the round-trip so we can confirm the device signed <em>our</em> challenge and not a replayed one.</p><p>The other action in the same controller verifies the result. The browser posts back the new credential, and the gem checks the signature and the challenge for us. If verify does not raise, we persist the public key.</p><pre># app/controllers/registrations_controller.rb (same controller)<br># POST /registration<br>def create<br>  webauthn_credential = WebAuthn::Credential.from_create(params[:credential])<br><br>  webauthn_credential.verify(<br>    session.delete(:creation_challenge),<br>    user_verification: true<br>  )<br><br>  current_user.credentials.create!(<br>    external_id: webauthn_credential.id,<br>    public_key:  webauthn_credential.public_key,<br>    sign_count:  webauthn_credential.sign_count,<br>    nickname:    params[:nickname]<br>  )<br><br>  render json: { status: &quot;ok&quot; }<br>rescue WebAuthn::Error =&gt; e<br>  render json: { error: e.message }, status: :unprocessable_entity<br>end</pre><p>Deleting the challenge from the session as we read it is deliberate: a challenge is single-use, and leaving it lying around invites replay.</p><p>That user_verification: true argument earns its place. Requiring user verification in the <em>options</em> only asks the browser for the gesture; it is the verify call that actually checks the User-Verified flag the authenticator returns. Leave it off and a tampered client can skip the biometric and still be accepted, quietly demoting your multi-factor login to a single factor. The same argument belongs on the authentication verify below.</p><h3>7. Registration in the browser</h3><p>The front end fetches the options, turns them into the binary structures the API expects with PublicKeyCredential.parseCreationOptionsFromJSON(), hands those to navigator.credentials.create(), and posts the result back, serialised with the credential&#39;s own .toJSON(). It lives in a small browser module, app/javascript/passkeys.js, and is exported so the views can import it later:</p><pre>// app/javascript/passkeys.js<br>function csrfToken() {<br>  return document.querySelector(&#39;meta[name=&quot;csrf-token&quot;]&#39;).content;<br>}<br><br>export async function registerPasskey(nickname) {<br>  const optionsJSON = await (await fetch(&quot;/registration/options&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;X-CSRF-Token&quot;: csrfToken() },<br>  })).json();<br><br>  // Turn the server&#39;s JSON into the binary structures the API expects.<br>  const options = PublicKeyCredential.parseCreationOptionsFromJSON(optionsJSON);<br><br>  // This line is where the OS prompts for Touch ID / Windows Hello / a PIN<br>  // and the key pair is generated inside the secure hardware.<br>  const credential = await navigator.credentials.create({ publicKey: options });<br><br>  await fetch(&quot;/registration&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;Content-Type&quot;: &quot;application/json&quot;, &quot;X-CSRF-Token&quot;: csrfToken() },<br>    body: JSON.stringify({ credential: credential.toJSON(), nickname }),<br>  });<br>}</pre><p>Every fetch carries Rails&#39;s CSRF token in the X-CSRF-Token header, read from the &lt;meta name=&quot;csrf-token&quot;&gt; tag that csrf_meta_tags renders in the default layout. Leave it out and Rails rejects each POST with 422 Unprocessable Content ( Can&#39;t verify CSRF token authenticity), so no ceremony ever runs.</p><p>The single most important line is the call to create(). That is the moment the operating system takes over, asks the user for their gesture, and mints a key pair whose private half never becomes visible to your JavaScript, your server, or the network.</p><h3>8. Authentication on the server</h3><p>The mirror-image ceremony, once more before we implement it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O2eWd-M24Zrf41kz.png" /></figure><p>Sign-in gets its own SessionsController, so generate that too:</p><pre>bin/rails generate controller Sessions</pre><p>Now the symmetry pays off. To begin sign-in we generate options again, but this time we deliberately send no allow-list. An empty allow-list tells the browser to offer whatever discoverable passkeys it holds for this site, which is what produces the usernameless “pick an account” prompt.</p><pre># app/controllers/sessions_controller.rb<br>class SessionsController &lt; ApplicationController<br>  # POST /session/options<br>  def options<br>    options = WebAuthn::Credential.options_for_get(<br>      user_verification: &quot;required&quot;<br>    )<br><br>    session[:authentication_challenge] = options.challenge<br>    render json: options<br>  end<br>end</pre><p>When the signed assertion comes back, it carries two useful things: the credential’s ID, and the <em>user handle</em> we stored at registration. The handle tells us which user is signing in, with no username typed anywhere. The create action, in the same controller, does the verifying.</p><pre># app/controllers/sessions_controller.rb (same controller)<br># POST /session<br>def create<br>  webauthn_credential = WebAuthn::Credential.from_get(params[:credential])<br><br>  user = User.find_by!(webauthn_id: webauthn_credential.user_handle)<br>  stored = user.credentials.find_by!(external_id: webauthn_credential.id)<br><br>  webauthn_credential.verify(<br>    session.delete(:authentication_challenge),<br>    public_key:  stored.public_key,<br>    sign_count:  stored.sign_count,<br>    user_verification: true<br>  )<br><br>  stored.update!(sign_count: webauthn_credential.sign_count)<br>  start_session_for(user)<br><br>  render json: { status: &quot;ok&quot; }<br>rescue WebAuthn::Error, ActiveRecord::RecordNotFound<br>  render json: { error: &quot;Authentication failed&quot; }, status: :unauthorized<br>end</pre><p>The verify call is the heart of the whole system. It confirms the signature was produced by the private key matching our stored public key, that it covered our challenge, and that the origin the browser reported is one we allow. Only when all of that holds do we open a session.</p><p>The sign_count deserves a word. Each authenticator keeps a counter that it increments on every signature, and by storing the last value we have seen we can spot a counter that goes backwards, which would suggest a cloned device. Because we pass sign_count to verify, the gem enforces this for us automatically: it raises WebAuthn::SignCountVerificationError whenever a previously non-zero counter fails to strictly increase, the classic cloned-authenticator signal. Synced passkeys, the iCloud and Google variety, frequently report zero on both sides and are exempt, so they never trip it; the only way to opt out entirely is to pass sign_count: 0 every time, which can never regress.</p><h3>9. Authentication in the browser</h3><p>The front end mirrors registration. No username field appears anywhere. The sign-in half goes in the same app/javascript/passkeys.js module:</p><pre>// app/javascript/passkeys.js (same csrfToken helper as above)<br>export async function signIn() {<br>  const optionsJSON = await (await fetch(&quot;/session/options&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;X-CSRF-Token&quot;: csrfToken() },<br>  })).json();<br>  const options = PublicKeyCredential.parseRequestOptionsFromJSON(optionsJSON);<br><br>  // The browser shows the account picker and asks for the user&#39;s gesture.<br>  const assertion = await navigator.credentials.get({ publicKey: options });<br><br>  const result = await fetch(&quot;/session&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: { &quot;Content-Type&quot;: &quot;application/json&quot;, &quot;X-CSRF-Token&quot;: csrfToken() },<br>    body: JSON.stringify({ credential: assertion.toJSON() }),<br>  });<br><br>  if (result.ok) window.location.assign(&quot;/dashboard&quot;);<br>}</pre><p>That is a complete passwordless login. There is no password field, no one-time code, no email round-trip, and nothing on the server that a breach could turn into account access.</p><h3>10. Routes</h3><p>So far we have controllers and two JavaScript functions but no pages to click. Three small views turn them into a working app, and because we created the project with --css=tailwind, a few utility classes give us something tidy without writing any CSS. The two functions from steps 7 and 9 already live in app/javascript/passkeys.js and are exported, so the views can import them.</p><p>Rails 8 wires JavaScript through import maps, and a file at the top of app/javascript is not pinned automatically, so add one line to config/importmap.rb; otherwise import { ... } from &quot;passkeys&quot; fails to resolve in the browser and the buttons do nothing:</p><pre># config/importmap.rb<br>pin &quot;passkeys&quot;</pre><p>The routes tie the endpoints and pages together:</p><pre># config/routes.rb<br>Rails.application.routes.draw do<br>  root &quot;sessions#new&quot;<br><br>  get  &quot;signup&quot;,               to: &quot;registrations#new&quot;<br>  post &quot;users&quot;,                to: &quot;users#create&quot;          # bootstrap the account<br>  post &quot;registration/options&quot;, to: &quot;registrations#options&quot;<br>  post &quot;registration&quot;,         to: &quot;registrations#create&quot;<br><br>  get  &quot;signin&quot;,               to: &quot;sessions#new&quot;<br>  post &quot;session/options&quot;,      to: &quot;sessions#options&quot;<br>  post &quot;session&quot;,              to: &quot;sessions#create&quot;<br><br>  get  &quot;dashboard&quot;,            to: &quot;dashboard#show&quot;<br>end</pre><h3>11. The application controller</h3><p>A passwordless site still has to create the very first account somehow, the bootstrap problem the next section returns to. There is no password anywhere in this chain. Being <em>signed in</em> just means session[:user_id] is set, and only two things ever set it. For a brand-new user, account creation does: submitting an email runs UsersController#create, which creates the User and opens a session on the spot. Now that current_user exists, the registration ceremony from step 7 can bind their first passkey to that account. From then on the other path takes over: signing in with that passkey verifies a signature and calls the same start_session_for, opening a session with no password and no account-creation step. So the full chain for a new user is sign up → session opened → first passkey registered, and every visit after that is pick passkey → signature verified → session opened. The current_user and start_session_for helpers the earlier controllers assumed go in ApplicationController, which rails new already created, so we just add them:</p><pre># app/controllers/application_controller.rb<br>class ApplicationController &lt; ActionController::Base<br>  private<br><br>  def current_user<br>    @current_user ||= User.find_by(id: session[:user_id])<br>  end<br><br>  def start_session_for(user)<br>    session[:user_id] = user.id<br>  end<br>end</pre><h3>12. The users controller</h3><p>Generate the controller that creates accounts:</p><pre>bin/rails generate controller Users</pre><pre># app/controllers/users_controller.rb<br>class UsersController &lt; ApplicationController<br>  def create<br>    user = User.create!(email: params[:email], webauthn_id: WebAuthn.generate_user_id)<br>    start_session_for(user)<br>    render json: { status: &quot;ok&quot; }<br>  end<br>end</pre><p>The sign-up page takes an email, creates the account, then runs the registration ceremony from step 7:</p><pre>&lt;%# app/views/registrations/new.html.erb %&gt;<br>&lt;div class=&quot;min-h-screen flex items-center justify-center bg-slate-50&quot;&gt;<br>  &lt;div class=&quot;w-full max-w-sm rounded-xl bg-white p-8 shadow&quot;&gt;<br>    &lt;h1 class=&quot;text-xl font-semibold text-slate-800&quot;&gt;Create your account&lt;/h1&gt;<br>    &lt;input id=&quot;email&quot; type=&quot;email&quot; placeholder=&quot;you@example.com&quot;<br>           class=&quot;mt-4 w-full rounded-lg border border-slate-300 px-3 py-2&quot;&gt;<br>    &lt;button id=&quot;signup&quot;<br>            class=&quot;mt-4 w-full rounded-lg bg-teal-600 px-3 py-2 font-medium text-white hover:bg-teal-700&quot;&gt;<br>      Create account &amp;amp; add passkey<br>    &lt;/button&gt;<br>    &lt;p class=&quot;mt-4 text-center text-sm text-slate-500&quot;&gt;<br>      Already have one? &lt;a href=&quot;/signin&quot; class=&quot;text-teal-600&quot;&gt;Sign in&lt;/a&gt;<br>    &lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br><br>&lt;script type=&quot;module&quot;&gt;<br>  import { registerPasskey } from &quot;passkeys&quot;;<br><br>  document.getElementById(&quot;signup&quot;).addEventListener(&quot;click&quot;, async () =&gt; {<br>    await fetch(&quot;/users&quot;, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;,<br>        &quot;X-CSRF-Token&quot;: document.querySelector(&#39;meta[name=&quot;csrf-token&quot;]&#39;).content,<br>      },<br>      body: JSON.stringify({ email: document.getElementById(&quot;email&quot;).value }),<br>    });<br>    await registerPasskey(&quot;This device&quot;);<br>    window.location.assign(&quot;/dashboard&quot;);<br>  });<br>&lt;/script&gt;</pre><p>The sign-in page is just a button; the account picker does the rest:</p><pre>&lt;%# app/views/sessions/new.html.erb %&gt;<br>&lt;div class=&quot;min-h-screen flex items-center justify-center bg-slate-50&quot;&gt;<br>  &lt;div class=&quot;w-full max-w-sm rounded-xl bg-white p-8 shadow text-center&quot;&gt;<br>    &lt;h1 class=&quot;text-xl font-semibold text-slate-800&quot;&gt;Welcome back&lt;/h1&gt;<br>    &lt;button id=&quot;signin&quot;<br>            class=&quot;mt-6 w-full rounded-lg bg-teal-600 px-3 py-2 font-medium text-white hover:bg-teal-700&quot;&gt;<br>      Sign in with a passkey<br>    &lt;/button&gt;<br>    &lt;p class=&quot;mt-4 text-sm text-slate-500&quot;&gt;<br>      New here? &lt;a href=&quot;/signup&quot; class=&quot;text-teal-600&quot;&gt;Create an account&lt;/a&gt;<br>    &lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br><br>&lt;script type=&quot;module&quot;&gt;<br>  import { signIn } from &quot;passkeys&quot;;<br>  document.getElementById(&quot;signin&quot;).addEventListener(&quot;click&quot;, signIn);<br>&lt;/script&gt;</pre><h3>13. The dashboard controller</h3><p>And the dashboard the ceremony redirects to:</p><pre>&lt;%# app/views/dashboard/show.html.erb %&gt;<br>&lt;div class=&quot;min-h-screen flex items-center justify-center bg-slate-50&quot;&gt;<br>  &lt;div class=&quot;rounded-xl bg-white p-8 shadow text-center&quot;&gt;<br>    &lt;h1 class=&quot;text-2xl font-semibold text-slate-800&quot;&gt;You&#39;re in&lt;/h1&gt;<br>    &lt;p class=&quot;mt-2 text-slate-500&quot;&gt;Signed in with a passkey, no password anywhere.&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Generate the dashboard controller, whose one job is to guard the page:</p><pre>bin/rails generate controller Dashboard</pre><pre># app/controllers/dashboard_controller.rb<br>class DashboardController &lt; ApplicationController<br>  def show<br>    redirect_to &quot;/signin&quot; unless current_user<br>  end<br>end</pre><p>That is the whole app: create an account with Touch ID or a security key, sign out, and sign back in by picking the passkey, with no password field anywhere.</p><h3>The parts a from-scratch demo skips</h3><p>A tutorial earns trust by being honest about what it left out. A real deployment has to deal with several things the snippets above glossed over.</p><p><strong>Account recovery and the bootstrap problem.</strong> A passkey proves possession of a device, so the hardest question is what happens before the first passkey exists, or after the last one is lost. You still need a recovery path, often an emailed link or a backup code, and that path tends to become the weakest link in the whole system. Synced passkeys soften this, because losing a phone no longer loses the credential, but you cannot assume every user has sync enabled.</p><p><strong>The second-passkey problem.</strong> A user with exactly one device-bound passkey is one dropped phone away from being locked out. Good products nudge people to register a second authenticator early, which is why the nickname column above matters: users need to see and manage the keys they hold.</p><p><strong>Cross-device sign-in.</strong> Authenticating on a desktop using the passkey on your phone uses the <em>hybrid</em> transport, the QR-code-and-Bluetooth flow. The good news is that it is handled by the platform and the same navigator.credentials.get() call, so your code does not change, but it is worth testing because the user experience is unfamiliar to many people.</p><p><strong>Attestation.</strong> We quietly ignored the attestation statement that registration can return, which lets a server demand cryptographic proof of <em>what kind</em> of authenticator was used. Most consumer sites neither need nor want this, since it adds friction and privacy concerns, but regulated environments sometimes require it.</p><p><strong>Encoding discipline.</strong> Almost every integration bug in WebAuthn is a base64url-versus-base64 mismatch, or a string that should have been bytes. Leaning on a small, well-tested serialisation helper on each side, as we did, removes the category of bug that costs the most debugging time.</p><h3>A gem that packages this</h3><p>Everything above is hand-rolled on purpose, so the ceremonies stay in plain sight. If you would rather not carry that code yourself, I have packaged exactly this approach as a small gem, ( <a href="https://github.com/pardel/passkeyed">source</a>). It keeps the same from-scratch shape, with nothing hidden behind a mountable engine: a model concern, a controller concern that exposes the four ceremony methods, the Stimulus controller, and an install generator.</p><pre># Gemfile <br>gem &quot;passkeyed&quot;</pre><pre>bin/rails generate passkeyed:install<br>bin/rails db:migrate</pre><p>The migration also backfills a user handle for every account you already have, so existing users can register a passkey the moment it runs — the awkward bootstrap case a from-scratch demo quietly skips.</p><p>The controller side then becomes the four methods we built by hand:</p><pre>class SessionsController &lt; ApplicationController<br>  include Passkeyed::Ceremonies<br><br>  def options<br>    render json: passkey_authentication_options<br>  end<br><br>  def create<br>    user = passkey_authenticate!(params[:credential])<br>    session[:user_id] = user.id<br>    render json: { status: &quot;ok&quot; }<br>  rescue Passkeyed::Error<br>    render json: { error: &quot;Authentication failed&quot; }, status: :unauthorized<br>  end<br>endThe gem wires in the same server-side user-verification check we just added, and validates its own configuration at boot: a mistyped user-verification level, or the generated localhost origin left in a deployed app, raises rather than silently advertising a requirement to the browser while skipping the server-side check. It keeps its settings off webauthn-ruby’s global configuration too — every call is handed an isolated relying party — so an app already using webauthn-ruby directly is never clobbered. And its challenges are single-use and time-limited: one consumed hours later, from a stale tab, is rejected rather than honoured.</pre><p>Several of the edges the last section flagged are handled as well. The nickname column becomes a small management API on the owner model - current_user.passkeyed_credentials, rename_passkey, revoke_passkey, each scoped so one user can never touch another&#39;s key - which is exactly what the <em>second-passkey problem</em> needs: somewhere to see and label the devices you hold. Each credential also records whether it is a synced or device-bound passkey, how the authenticator talks to clients, and a last-used timestamp, for a richer management screen. The bundled Stimulus controller treats a cancelled or timed-out prompt as a normal outcome rather than an error, and will offer passkeys through the browser&#39;s autofill (conditional UI) when you opt in. For everything else - audit logging, a &quot;new device&quot; email, watching for failed sign-in attempts - there are after-ceremony hooks and ActiveSupport::Notifications events that, unlike the hooks, also fire on failure.</p><p>A runnable Rails 8 demo using Hotwire and Tailwind, covering sign-up, passwordless sign-in, and managing passkeys, lives alongside it in <a href="https://github.com/pardel/passkeyed-demo">passkeyed-demo</a>.</p><h3>Where this leaves us</h3><p>Every step on the authentication ladder before passkeys left the secret somewhere it could be taken: in the user’s head, in a database, in an inbox, in a text message. Each new layer made the secret a little harder to reach without ever changing the fact that a reachable secret existed.</p><p>Passkeys change that fact. The private key stays inside the user’s hardware, the server holds only a public key worth nothing to a thief, and the browser, not the human, decides whether the site asking for a signature is the real one. That is why a passkey login cannot be phished and why a stolen database yields nothing to replay. The secret has finally moved to the one place an attacker cannot reach, and that is the whole point.</p><h3>References</h3><ol><li><a href="https://github.com/cedarcode/webauthn-ruby">cedarcode/webauthn-ruby</a>, the server-side WebAuthn gem.</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential">PublicKeyCredential</a>, MDN (the native parseCreationOptionsFromJSON, parseRequestOptionsFromJSON, and toJSON methods, with browser-support tables).</li></ol><p><em>Originally published at </em><a href="https://www.pardel.dev/2026/07/04/passkeys-in-ruby-on-rails.html"><em>https://www.pardel.dev</em></a><em> on July 4, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db5d2a64cf1f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/building-passkeys-in-ruby-on-rails-from-scratch-db5d2a64cf1f">Building passkeys in Ruby on Rails from scratch</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Credentials-free authentication (part 2)]]></title>
            <link>https://medium.com/paul-ardeleanu/credentials-free-authentication-part-2-c9b25a5d236f?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/c9b25a5d236f</guid>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Sat, 24 Nov 2018 12:12:44 GMT</pubDate>
            <atom:updated>2018-11-24T12:12:43.541Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Showing a simple way to authenticate your users without exposing yourself to data breaches.</blockquote><h3>Part 2: The iOS app (native, using Swift)</h3><h3>Table of Contents</h3><h4>I. Intro</h4><p>1.1 The APIs<br>1.2 New iOS App</p><h4>II. The Verify Service</h4><p>2.1 Constants<br>2.2 VerifyServiceError<br>2.3 URLSession<br>2.4 Requesting a Verification<br>2.5 The Verification Check<br>2.6 Cancelling a verification<br>2.7 All together now</p><h4>III. The Login Screen</h4><p>3.1 Login Storyboard<br>3.2 The Router<br>3.3 Navigation using the Router<br>3.4 The Login Screen<br>3.5 Activity Indicator<br>3.6 Starting the Verification<br>3.7 Main Screen</p><h3>I. Intro</h3><p>In Part 1, we built a Vapor app that we deployed to Heroku. This was needed to secure the Nexmo credentials (and not include them inside the iOS app).</p><p>In this second part, we’re going to build an iOS app that will authenticate the user without storing their credentials. It will do this by checking the ownership of a phone number using the APIs we’ve build.</p><h4>1.1 The APIs</h4><p>Here is quick summary of the live APIs we built:</p><ol><li><strong>Start verification request</strong>:<br>URL: https://[appname].herokuapp.com/verify/request<br>Method: POST<br>Parameters: api_key, number</li><li><strong>Fulfil verification</strong>:<br>URL: https://[appname].herokuapp.com/verify/check<br>Method: POST<br>Parameters: api_key, request_id, code</li><li><strong>Cancel verification</strong>:<br>URL: https://[appname].herokuapp.com/verify/check<br>Method: POST<br>Parameters: api_key, request_id</li></ol><h4>1.2 New iOS App</h4><p>We are building an app named “Notes” using the Single View App template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35eAEyhdinNYq7Hwfj_9ZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6sbkGA6hwGRvJFxj4agug.png" /></figure><h3>II. The Verify Service</h3><p>Let’s start by creating a simple utility class that will be responsible for the interactions with the server — we’ll name it VerifyService and create a singleton for it to avoid duplicates:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac7bd1d38d2570d2797fb14f14e20eeb/href">https://medium.com/media/ac7bd1d38d2570d2797fb14f14e20eeb/href</a></iframe><h4>2.1 Constants</h4><p>To store all the hardcoded values we’ll need, we’ll define the following constants:</p><ul><li><strong>UserDefault</strong> — for the default variable names (we’ll use them later)</li><li><strong>Auth</strong> — for the length of an authenticated session</li><li><strong>API</strong> — host and apiKey values</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d53eb258651d74c0b3f7ee4e658bd674/href">https://medium.com/media/d53eb258651d74c0b3f7ee4e658bd674/href</a></iframe><p>If you are unsure of why enums are used here, <a href="https://www.natashatherobot.com/swift-enum-no-cases/">see this blogpost</a>. <strong>TLDR: </strong>enums with no cases are perfect for namespaced constants.</p><h4>2.2 VerifyServiceError</h4><p>We’ll also add, at the top of the VerifyService.swift file, a VerifyServiceError enum that we’ll use to express errors:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62814c9d34fc8319bba00bd3d903fd2b/href">https://medium.com/media/62814c9d34fc8319bba00bd3d903fd2b/href</a></iframe><h4>2.3 URLSession</h4><p>An URLSession is also required to ensure that all calls are being sent on a background thread — create a new Swift file named ApiSession.swift for it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b155cc1c2147f6814676bf6b6889d7a3/href">https://medium.com/media/b155cc1c2147f6814676bf6b6889d7a3/href</a></iframe><h4>2.4 Requesting a Verification</h4><p>Let’s go back to our VerifyService and continue building it by adding a couple of utility methods. They are going to used to create the URLRequests for each of the API calls.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f580c29b9a35073e94500c7cd6f2597/href">https://medium.com/media/0f580c29b9a35073e94500c7cd6f2597/href</a></iframe><p>Here is the request call:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb749438ce9450743fd411bfb9325362/href">https://medium.com/media/cb749438ce9450743fd411bfb9325362/href</a></iframe><h4>2.5 The Verification Check</h4><p>The verification check follows the same logic: we’re sending a request to /verify/check with the api_key, request_id and code as parameters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24038bca75a456cd00ce6bddf012f305/href">https://medium.com/media/24038bca75a456cd00ce6bddf012f305/href</a></iframe><h4>2.6 Cancelling a verification</h4><p>To cancel a verification in progress, we’ll need to send a request to /verify/cancel with the api_key and request_id as parameters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d525f4fe0ac844fe9180f81205b9bd9/href">https://medium.com/media/2d525f4fe0ac844fe9180f81205b9bd9/href</a></iframe><h4>2.7 All together now</h4><p>To make sure we’re on the same page, a better indented, more legible and complete version the VerifyService.swift file is available at: <a href="https://gist.github.com/pardel/9ccf5c418d58257f3e2b30299cc5cc8e">https://gist.github.com/pardel/9ccf5c418d58257f3e2b30299cc5cc8e</a></p><h3>III. The Login Screen</h3><p>Now that we have the service the deals with the network calls to the APIs, let’s start building the interface of our app. This will consists of mainly 2 parts, one containing the authentication screen and, the other, the rest of the app.</p><p>I always find it easier to split these parts into 2 separate storyboards — we’ll use the one we already have (Main.storyboard) for the app and create a new one for the authentication.</p><h4>3.1 Login Storyboard</h4><p>We’ll therefore create a new storyboard named Login.storyboard. I also find it easier (and more enjoyable to use) when these app “parts” as arranged in groups:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*R1io4SL--7MBSw7n9IPL2w.png" /></figure><p>Let’s start building the storyboard:</p><ul><li>add a UIViewController from the Libray (it is now, in Xcode 10, launched from the toolbar)</li><li>embed the view controller into a navigation controller (from the menu: Editor &gt; Embed in… &gt; Navigation Controller</li><li>set the navigation controller as the entry point for the storyboard ( Is Initial View Controller checkbox in the Attributes Inspector)</li><li>add a second View Controller</li><li>add a “Show” segue from the first view controller to the second so it can be pushed onto the navigation stack — name the segue: “showCode”</li><li>create two Cocoa Touch Class files, subclasses of UIViewController, called LoginViewController.swift and CodeViewController.swift</li><li>assign LoginViewController class to the root (first) view controller and CodeViewController to the second one</li></ul><p>This is how our storyboard looks now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7kH3uUpYYuYvjjmMXHFXdA.png" /></figure><h4>3.2 The Router</h4><p>The flow between the authentication part and the main part will be handled by a rudimentary router. Let’s create a new Swift file named Router.swift and define a Route as a closure that takes no parameters and returns nothing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0844e920ab45e8ac8106c38b1ecda33f/href">https://medium.com/media/0844e920ab45e8ac8106c38b1ecda33f/href</a></iframe><p>We’ll also define a Router class as a singleton, since we’re going to only need one router:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/220e73775009fa379e9c8de9b51559ae/href">https://medium.com/media/220e73775009fa379e9c8de9b51559ae/href</a></iframe><p>Our router needs to be able to store routes and navigate to them; so, we’ll add a property routes that stores a dictionary of named routes as well as methods to add and navigate to a route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37c3a24fd7d0f11a91862d6a4cff0475/href">https://medium.com/media/37c3a24fd7d0f11a91862d6a4cff0475/href</a></iframe><p>Notice the the add and navigateTo methods are static; also,we are using a preconditionFailure for when a route is not found.</p><h4>3.3 Navigation using the Router</h4><p>Let’s now use our Router to in the AppDelegate and add routes for navigating to home, login and logout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c237eddfc1d47f914530e99efe2e61be/href">https://medium.com/media/c237eddfc1d47f914530e99efe2e61be/href</a></iframe><p>We’ll then call addRoutes in application:didFinishLaunchingWithOptions and navigate to either home or login depending on the current state:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33f82a402c7f8880731e69a5ae34c499/href">https://medium.com/media/33f82a402c7f8880731e69a5ae34c499/href</a></iframe><p>We’ve used a property on the VerifyService, hasBeenVerified, defined as a check for the time when we last verified the user:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/615f1c2880e23b5207718cc951f6164e/href">https://medium.com/media/615f1c2880e23b5207718cc951f6164e/href</a></iframe><p>Everything should be operational now so let’s Build &amp; Run; you’ll see an empty screen with a navigation bar at the top — our Login view controller. Let’s add some “color” to it!</p><h4>3.4 The Login Screen</h4><p>Our login screen should contain just one text field to ask the user for their number. Let’s add just that, as well as a button to start the verification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*CaY4-QZFtG7sZIul6b1Zig.png" /></figure><p>We’ll connect the text field to an IBOutlet in LoginViewController and the button to an IBAction:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f0a9763ff1d4fd7e65d890a0d421e50/href">https://medium.com/media/8f0a9763ff1d4fd7e65d890a0d421e50/href</a></iframe><p>We’ve also added a title for the screen and set the phoneTextField to any value previously entered (and stored in UserDefaults). If phoneTextField is empty when the login is display, we’ll also make it the first responder.</p><h4>3.5 Activity Indicator</h4><p>As the API calls will be done asynchronously, we’ll need to show the progress to the user whilst preventing her from move to another screen. For this we’ll use the <a href="https://github.com/icanzilb/SwiftSpinner">SwiftSpinner</a> library from the prolific <a href="https://twitter.com/icanzilb">Marin Todorov</a>. All you need to do is download the <a href="https://raw.githubusercontent.com/icanzilb/SwiftSpinner/master/SwiftSpinner/SwiftSpinner.swift">SwiftSpinner.swift</a> file and add it to the Xcode project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4s1f0Dhj12fJ_dgX7F8fg.png" /></figure><h4>3.6 Starting the Verification</h4><p>The login action will:</p><ul><li>save number to UserDefaults</li><li>show the SwiftSpinner</li><li>and start a verification process</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/820aa3c8fa68df3241a8a8173de1905a/href">https://medium.com/media/820aa3c8fa68df3241a8a8173de1905a/href</a></iframe><p>There is just one more thing we need to do before we move to the next screen — if a verification is in progress, we should automatically advance to the next screen. We can achieve this in viewDidLoad by checking if the requestId UserDefault is set. Here is the complete listing of LoginViewController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fff692af73c0a737b4e8922d0cc3c1c1/href">https://medium.com/media/fff692af73c0a737b4e8922d0cc3c1c1/href</a></iframe><h4>3.7 Fulfilling the Verification</h4><p>Once the number is submitted, we should receive an SMS with a 4-digit code that we’ll use to confirm our number.</p><p>To submit this, let’s build the interface for the CodeViewController — as before, we’ll need a TextField but no submit button as we’ll send the code once 4 digits are entered. We’ll also add an IBOutlet for it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*NW8IxbjH-R9E92OWPhnDSg.png" /></figure><p>We’ll also need to disable the navbar back button and replace it with a cancel button that is displayed 30 seconds later. NB: <a href="https://developer.nexmo.com/api/verify#verify-control">Nexmo verification requests</a> can’t be cancelled in the first 30 seconds.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/033d601324c3a9cb6380dbc9d039fcb3/href">https://medium.com/media/033d601324c3a9cb6380dbc9d039fcb3/href</a></iframe><p>The cancellation is straight-forward — a call to VerifyService cancel and going back for either success or error:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e554a16ba755f923ab23b7fcbbc58dbb/href">https://medium.com/media/e554a16ba755f923ab23b7fcbbc58dbb/href</a></iframe><p>Let’s now handle the code submission — we’ll need to add an IBAction for the “Editing Changed” event of the codeTextField (the Connections Inspector is your friend).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5915eaab387943c958ad81d20bc9bb62/href">https://medium.com/media/5915eaab387943c958ad81d20bc9bb62/href</a></iframe><p>That’s it for the CodeViewController — a complete listing can be found at: <a href="https://gist.github.com/pardel/c28eecec05239ce5efbc5c3058ae503e">https://gist.github.com/pardel/c28eecec05239ce5efbc5c3058ae503e</a></p><h4>3.7 Main Screen</h4><p>Once verified, our app is showing a blank white screen. Let’s change that a bit to reflect the authenticated status.</p><p>Let’s open the Main.storyboard and embed the ViewController into a Navigation Controller just like we did in section 3.1.</p><p>Let’s also add, in ViewController.swift, a title and a logout button:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c3e291a9d85da9143cbcbc9a922e3bd/href">https://medium.com/media/4c3e291a9d85da9143cbcbc9a922e3bd/href</a></iframe><p>Build &amp; Run and we’re off to the races!</p><blockquote>And here we have it! A complete iOS app that doesn’t require user credentials to authenticate its users!</blockquote><p>A complete copy of the project is available at: <a href="https://github.com/pardel/NexmoVerify-iOS">https://github.com/pardel/NexmoVerify-iOS</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9b25a5d236f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/credentials-free-authentication-part-2-c9b25a5d236f">Credentials-free authentication (part 2)</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Credentials-free authentication — Part 1: The web server]]></title>
            <link>https://medium.com/paul-ardeleanu/credentials-free-authentication-part-1-the-web-server-c1ab952ef126?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/c1ab952ef126</guid>
            <category><![CDATA[nexmo]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[vaporswift]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Fri, 09 Nov 2018 11:51:38 GMT</pubDate>
            <atom:updated>2018-11-09T11:50:00.006Z</atom:updated>
            <content:encoded><![CDATA[<h3>Credentials-free authentication (part 1)</h3><blockquote>Showing a simple way to authenticate your users without exposing yourself to data breaches.</blockquote><h3>Part 1: The web server (using Swift &amp; Vapor)</h3><h3>Table of Contents</h3><h4>I. Intro</h4><p>1.1 “Social Authentication”<br>1.2 The Better Alternative<br>1.3 Nexmo Verify<br>1.4 Vapor</p><h4>II. Vapor Server</h4><p>2.1 New Vapor app<br>2.2 Routes<br>2.3 Consuming APIs using Postman</p><h4>III. Building our APIs</h4><p>3.1 verify/request<br>3.2 Reading input parameters<br>3.3 The Output</p><h4>IV. Nexmo service</h4><p>4.1 Nexmo Credentials<br>4.2 Xcode Environment Variables<br>4.3 Start the Verification<br>4.4 The HTTP Request<br>4.5 Nexmo Session<br>4.6 (cont) Verify Request<br>4.7 Check Verification<br>4.8 Cancel Verification<br>4.9 Summary</p><h4>V. Vapor Routes</h4><p>5.1 verify/request<br>5.2 verify/check<br>5.3 verify/cancel<br>5.4 Testing using Postman</p><h4>VI. Deployment to Heroku</h4><p>6.1 The Heroku CLI<br>6.2 New app<br>6.3 Heroku config vars<br>6.4 Procfile<br>6.5 Deploy</p><blockquote><strong>NB: </strong>In Part 2, we’re going to build an iOS app that consumes the APIs we’re constructing in this article.</blockquote><h3>I. Intro</h3><p>Another day, another data breach. Nobody seems to understand that loosing users’ credentials has a bad impact on user trust and revenue — maybe they should ask “the business formally knows as” Yahoo about that.<br>And what’s even more disturbing is that businesses are suffering because of others’ inability to secure shared data.</p><h4>1.1 “Social authentication”</h4><p>Developers are delegating authentication to 3rd parties (Google, Facebook, Twitter, Github, etc.) is order to avoid the headaches of dealing with sensitive data. Like all bad ideas, it sounded good at the time.<br>I’ve been saying this for a long time now: one should never lock their house with someone else’s key unless it’s your mum. The trust must be complete or the whole exercise becomes futile.</p><h4>1.2 The Better Alternative</h4><p>What if I told you there is a very simple way to authenticate your users without storing credentials or delegating to 3rd parties?!<br> You get to rely on an omnipresent resource: virtually everyone has a phone number; and instead of asking for a password that you check against the version you hold, you send them a short-lived SMS containing a code they need to send back to you.</p><p>Here is a list of technologies we’re going to use:</p><ul><li><strong>Nexmo</strong>’s <strong>Verify</strong> APIs — will allow us to send SMS’</li><li><strong>Vapor</strong> — the most used web framework for Swift — we’ll build a simple web server (we’ll discuss below the need for a web server)</li><li><strong>iOS</strong> — we’re going to build an app that consumes this authentication</li></ul><p>The only downside (if you can call it that) is that it costs money, but balancing the need for authentication with good security can bring those costs down. <br>Plus, you <strong>are</strong> building a profitable business where you charge users for services, right?! 🤨</p><h4>1.3 Nexmo Verify</h4><p><a href="https://www.nexmo.com/">Nexmo</a> is a business unit of Vonage that <a href="https://developer.nexmo.com/">develops and markets communication APIs</a>. One of their first available APIs is <a href="https://developer.nexmo.com/verify/overview">Verify</a> which allows you to send a PIN (by SMS and phone) to prove a user can be reached at a specific number.</p><p>We’re going to be using the <a href="https://developer.nexmo.com/api/verify">Verify APIs</a> directly so we’ll need to authenticate via an <a href="https://developer.nexmo.com/concepts/guides/authentication">API key and Secret</a>. As we don’t want to include the key and secret into our iOS app, we’ll create a simple web app that will act as the intermediary — a great opportunity to use Vapor and <a href="http://www.swift.org/">one language for everything</a> :).</p><p>A good description of the flow we’ll need to follow can be found here: <a href="https://developer.nexmo.com/verify/guides/verify-a-user">https://developer.nexmo.com/verify/guides/verify-a-user</a>:</p><ol><li>Send a phone verification code and receive a request_id</li><li>User receives code on their phone via a text message or text-to-speech</li><li>User enters verification code.</li><li>We check the phone verification code using code and request_id</li></ol><h4>1.4 Vapor</h4><p><a href="https://vapor.codes/">Vapor</a> is the most used web framework for Swift — it’s not really production ready yet (as of v3) but lots of developers are using it for small projects.</p><p>Before we start, make sure you have a relatively recent version of Swift installed on your Mac — mine is 4.2:</p><blockquote>$ <strong><em>swift --version</em></strong><br>Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)<br>Target: x86_64-apple-darwin18.0.0</blockquote><p>We’re going to install Vapor via <a href="https://brew.sh/">Homebrew</a>:</p><blockquote>$ <strong><em>brew install vapor/tap/vapor</em><br>…<br></strong>🍺 /usr/local/Cellar/vapor/3.1.10: 4 files, 15.6MB, built in 2 seconds</blockquote><blockquote>$ <strong><em>vapor --version</em></strong><br>Vapor Toolbox: 3.1.10</blockquote><h3>II. Vapor Server</h3><h4>2.1 New Vapor app</h4><p>We’re now ready to create our web app:</p><blockquote>$ <strong><em>vapor new Verify --template=api</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tyxyt3AxUsKuAJT6RubCLg.png" /></figure><p>Go into the project folder and generate an Xcode project — this will take a bit of time as all dependencies are being pulled in (-y option is open Xcode automatically):</p><blockquote>$ <strong><em>cd Verify</em></strong><br>$ <strong><em>vapor xcode -y</em><br></strong>Generating Xcode Project [Done]<br>Select the `Run` scheme to run.<br>Open Xcode project?<br>y/n&gt; yes<br>Opening Xcode project…</blockquote><p>We now have a Xcode project ready to use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DXv3QUL7cIRECfL8mnV8w.png" /></figure><p>Make sure you’ve selected the “Run” scheme and “MyMac” as the Target:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ltH-jMS5Kmt_KGj90pPsOw.png" /></figure><p>… and press ⌘R to run the server. You should now see a “<strong>Server starting on http://localhost:8080</strong>” message in the Console.</p><p>Navigating to that URL, you’ll get to see the server in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBjT6MojvHnEQwvn9FIXFw.png" /></figure><h4>2.2 The Routes</h4><p>Routing is the process of finding the appropriate response to an incoming request and, in Vapor, we define our routes in the Sources &gt; App &gt; routes.swift file.</p><p>By default, Vapor includes some a sample Controller and Model together with their routes — let’s get rid of them and only leave the root route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/243282d17266658e3d7ba3ee06277c66/href">https://medium.com/media/243282d17266658e3d7ba3ee06277c66/href</a></iframe><p>We’ll now add our 3 routes:</p><ul><li>verify/request — we’ll use this to kickstart a number verification process</li><li>verify/check — we’ll use this to send back the code received</li><li>verify/cancel — allows us to cancel an ongoing request</li></ul><p>As we’re going to be sending data, we’ll define them as POST requests:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a574379a58a4ae891843569764d9528/href">https://medium.com/media/0a574379a58a4ae891843569764d9528/href</a></iframe><p>Build and Run your Xcode project again to make those routes available. Now, since we’re using POST we won’t be able to use the browser anymore, so we’ll use a free tool called Postman.</p><h4>2.3 Consuming APIs using Postman</h4><p><a href="https://www.getpostman.com/">Postman</a> is an extensive collection of tools that makes it easy to consume APIs. We’re going to be using their Mac app available <a href="https://www.getpostman.com/apps">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZOierUSGTUgUGpf0yaMUvA.png" /></figure><p>We’ll start by creating a Request — I’ve named mine Request and stored in under a Verify collection. Use the following parameters:</p><ul><li>method: POST</li><li>url: <a href="http://localhost:8080/verify/request">http://localhost:8080/verify/request</a></li></ul><p>Once you hit Send, a “request verification” response should be received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_jPaQkSX1UBu8UTmCRssQ.png" /></figure><h3>III. Building our APIs</h3><h4>3.1 verify/request</h4><p>It will come to no surprise that the first API we’re going to build is the one were we initiate a verification. The parameter our API would need to accept is the number to verify.</p><p>In addition to that, we’ll add another parameter, called api_key. This is a very simple security measure in case someone inadvertently discovers our APIs — we don’t want people to spam or empty our Nexmo balance 🤓. It could also be used to remove access if required later on.</p><p>So the parameters we’ll send are:</p><ul><li><strong>number —</strong> string containing the phone number in international format. eg: 447xxxxxxxxx. Goes without say that you should use your own number here to receive verification codes.</li><li><strong>api_key —</strong> string containing an unique identifier — I’m gonna to use ‘b6AK9o8kVx3n’ but feel free to pick any random value.</li></ul><p>Let’s update our Postman request to include them in the body of the HTTP request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kh3Eiu4fOCGQEYBLhd957Q.png" /></figure><h4>3.2 Reading input parameters</h4><p>Handling the input parameters in Vapor is <a href="https://docs.vapor.codes/3.0/multipart/overview/">pretty easy</a>: we’ll need to create a Codable struct that represents our input. We’ll call it VerifyRequestParameters and we’re going to use it to decode the request’s content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24e10d8a27a43e19a9eb68ebc5ad4eee/href">https://medium.com/media/24e10d8a27a43e19a9eb68ebc5ad4eee/href</a></iframe><p>Build&amp;Run and send that request again. You’ll notice that the params inside the route is a Future:</p><blockquote>request verification with NIO.<strong>EventLoopFuture</strong>&lt;App.(unknown context at 0x10050e510).VerifyRequestParameters&gt;</blockquote><p>If you are not familiar with the concept of Futures and Promises, the prolific <a href="https://twitter.com/johnsundell">John Sundell</a> wrote a <a href="https://www.swiftbysundell.com/posts/under-the-hood-of-futures-and-promises-in-swift">great article explaining the concepts behind them</a>.</p><p>Vapor contains an <a href="https://docs.vapor.codes/3.0/async/overview/">Async library</a> that makes using Futures relatively easy.</p><h4>3.3 The Output</h4><p>We’ll send back a JSON response that includes:</p><ul><li><strong>request_id </strong>— string containing the request_id from Nexmo, if the call was successful.</li><li><strong>error </strong>— string containing an error description, if call was unsuccessful.</li></ul><p><strong>NB:</strong> both request_id and error are optional as they depend on the call’s</p><p>Vapor makes sending JSON output easy — all we have to do is to send back a Codable struct. We’ll name it VerifyRequestResponse (I know the naming can be confusing here).</p><p>We’ll also have to send back a future if we want to consume the input parameters. In the listing below, I’m sending back the number as the request_id — this is a stopgap solution until we build the service that talks to the Nexmo APIs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5206bef493361d835d15ab1c3710121/href">https://medium.com/media/b5206bef493361d835d15ab1c3710121/href</a></iframe><p>Build&amp;Run and check the response in Postman.</p><h3>IV. Nexmo Service</h3><p>Let’s add a simple class that handles all the communication with Verify - we’ll name it NexmoService and include couple of properties we’ll need.</p><h4>4.1 Nexmo Credentials</h4><p>Let’s create a file inside the App group and name it NexmoService.swift:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ccfee00c0215bcb944e25d1c542b826/href">https://medium.com/media/2ccfee00c0215bcb944e25d1c542b826/href</a></iframe><p>The api_key, api_secret and myapp_api_key will be set as environment variables (we’ll see how to do this later in Heroku). I’ve decided to add them as static non-optional to make our life easier.</p><p>NEXMO_API_KEY and NEXMO_API_SECRET are the Nexmo credentials unique to your app. You can retrieve yours from your Nexmo dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXoTDOZr6C77duHAlgA9dg.png" /></figure><h4>4.2 Xcode Environment Variables</h4><p>For our local development, we’re going to inject those credentials inside the Xcode scheme as Environment Variables for the Run stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAZ18R7DxxcEw9MSGVe_Fg.png" /></figure><p>Now, you might think there is a security issue here but our project’s .gitignore contains the project so it won’t be committed to version control. You’re using version control, right?!</p><p>For MYAPP_API_KEY, add a random string — this is unique to our Vapor app and we’ll be using it later when consuming the APIs.</p><p>The only downside is:</p><blockquote>You’ll need to re-add the credentials if you regenerate the project.</blockquote><h4>4.3 Start the Verification</h4><p>The first Nexmo API we’re going to consume is the verify request: <a href="https://developer.nexmo.com/api/verify#request">https://developer.nexmo.com/api/verify#request</a></p><p>For this, inside the NexmoVerify class, we’ll add a method that takes a phone number as the input and returns either a request_id or an error. As the API call will happen asynchronously, we’re gonna employ escaping closures.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c708d217d8f507998352165ff518c208/href">https://medium.com/media/c708d217d8f507998352165ff518c208/href</a></iframe><p>We can define NexmoServiceErroris an enum that conforms to the Error protocol. I went ahead and added all error cases we’re going to deal with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/769a45488eaea74203079808cd63f59c/href">https://medium.com/media/769a45488eaea74203079808cd63f59c/href</a></iframe><p>Now, let’s go back to our verify method — we’re going to start by creating an URLRequest.</p><h4>4.4 The HTTP request</h4><p>We’ll write a simple private method called httpRequest that takes in a path and a list of parameters and returns an URLRequest?.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9050e491635a43a2fa793d651fbe0466/href">https://medium.com/media/9050e491635a43a2fa793d651fbe0466/href</a></iframe><p>We’ve also used it inside the startVerification method to create a URLRequest to “verify/json” endpoing.</p><h4>4.5 NexmoSession</h4><p>Now that we have the request, let’s use it to run a dataTask. In order to ensure that our requests are always sent on the background thread, we’ll create a custom URLSession.</p><p>Add a new Swift file to the project and name it NexmoSession.swift:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7290f72a6884a78c2202db83073c0221/href">https://medium.com/media/7290f72a6884a78c2202db83073c0221/href</a></iframe><p>The code above is pretty straightforward — we use a standard URLSessionConfiguration and a background OperationQueue to construct a shared URLSession to be used for all calls.</p><h4>4.6 (cont) Start Verification</h4><p>We’re now ready to send the request to Verify:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1028e384e709ad777425a4a062f9e6a/href">https://medium.com/media/b1028e384e709ad777425a4a062f9e6a/href</a></iframe><p>Let’s go through the code line by line:</p><ul><li><em>lines 11–15: </em>create the URLRequest for ‘verify/json’ with the number and brand as parameters</li><li><em>lines 16–17</em>: create a data task on the shared NexmoSession</li><li><em>lines 18–20</em>: handling any errors we encounter on performing the data task</li><li><em>line 22</em>: create the JSON decoder for the returned data</li><li><em>lines 23–27</em>: create a decodable entity that defines the response received</li><li><em>lines 28–32</em>: check for returned data in a valid JSON format</li><li><em>lines 33–43</em>: handle various scenarios — we only return success if the status response is either 0 or 10 and a request_id is present</li></ul><h4>4.7 Check Verification</h4><p>Following the same flow as above, and reusing the httpRequest method, here is how the verification check looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59b8734ce979cd2a6209fced22952f13/href">https://medium.com/media/59b8734ce979cd2a6209fced22952f13/href</a></iframe><p>This time, we’re sending a request to ‘verify/check/json’ with the request_id (received on the previous call) and the code received via SMS.</p><p>The response returned includes the status of the check, our request_id as well as pricing information.</p><h4>4.8 Cancel Verification</h4><p>The last call to send is the cancellation — the parameters required are the request_id and a cancel cmd:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bb5527d84f8464b6aaa2d2232c15222/href">https://medium.com/media/7bb5527d84f8464b6aaa2d2232c15222/href</a></iframe><h4>4.9 Summary</h4><p>We’re now ready to “consume” our NexmoService inside the Vapor routes.</p><p>To make it easier to understand and use, here is our NexmoService “signature”:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abd48480e91b2406fa006b93e92003f4/href">https://medium.com/media/abd48480e91b2406fa006b93e92003f4/href</a></iframe><h3>V. Vapor Routes</h3><p>Back in section 3.3, in routes.swift, we’ve defined this promise that we’re now ready to fulfil :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5206bef493361d835d15ab1c3710121/href">https://medium.com/media/b5206bef493361d835d15ab1c3710121/href</a></iframe><h4>5.1 verify/request</h4><p>The verify/request route is going to start the verification process by using the startVerification method of our NexmoService.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f43e04a2683a883ca2193e842a3fefe/href">https://medium.com/media/1f43e04a2683a883ca2193e842a3fefe/href</a></iframe><p>In lines 7-10 , we’re checking our service api_key against the provided parameters.</p><p>Word of warning — make sure you build the next 2 routes before trying to use this one. The Nexmo service will call your number to relay the code by voice if you don’t confirm it within the first couple of minutes. This can become a nuisance if you’re still building the check or cancel calls.</p><h4>5.2 verify/check</h4><p>The verify/check route is going to fulfil the verification process by using the checkVerification method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69377dbd6f538b9cf63cd4f7afcdf29a/href">https://medium.com/media/69377dbd6f538b9cf63cd4f7afcdf29a/href</a></iframe><h4>5.3 verify/cancel</h4><p>Finally, verify/cancel will send the cancellation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/041366f5dbe000072316995079d5fb48/href">https://medium.com/media/041366f5dbe000072316995079d5fb48/href</a></iframe><p>That’s it! We now have a fully operational Vapor server that uses the Nexmo’s Verify to provide an API to authenticate users.</p><p>Build&amp;Run, and we’re ready to test it!</p><p>For reference, a complete copy of the project is available at: <a href="https://github.com/pardel/NexmoVerify-Vapor">https://github.com/pardel/NexmoVerify-Vapor</a></p><h4>5.4 Testing using Postman</h4><p>Let’s test the service by using Postman as shown in section 2.3.</p><p>In addition to the call we’re already built, let’s add 2 more. One for the verify/check:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa0VR8UuujRMKrXDnEypIw.png" /></figure><p>and one for verify/cancel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K01AA0HYxHF25TQOJpiajA.png" /></figure><p>Make sure the right api_key value is added as defined in the Xcode schema run parameters (section 4.2).</p><p>We’re now ready to try it. Make sure you have your phone handy and ready to receive text messages — this is how they look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Un9lcJAYv4CTJUzsI_xHQg.png" /></figure><p>Here are couple of scenarios we should try (make sure you copy the request_id returned in the first step, into the subsequent calls):</p><ul><li><em>Success scenario: </em>Request, Check</li><li><em>Success scenario: </em>Request, Cancel (NB: there is a 30 seconds delay before a request can be cancelled).</li><li><em>Success scenario: </em>Request, Request, Check (2nd call will not return an error but the same request_id as 1st call)</li><li><em>Error scenario: </em>Request, Check, Cancel (3rd call will return error — verification already checked)</li><li><em>Error scenario: </em>Request, Cancel, Cancel(3rd call will return error — verification already cancelled)</li></ul><h3>VI. Deployment to Heroku</h3><p>We’re now ready to deploy to a live server. Before you proceed any further, make sure you’ve <a href="https://git-scm.com/docs/git-commit">committed</a> all your changes:</p><blockquote>$ <strong>git add .</strong><br>…<br>$ <strong>git commit -m ‘Verify server operational’</strong></blockquote><h4>6.1 The Heroku CLI</h4><p>The simplest way for us to deploy is using the Heroku CLI which makes it easy to create and manage your Heroku apps directly from the terminal.</p><p>The CLI can be install using a MacOS Installer or via brew — instructions are available at: <a href="https://devcenter.heroku.com/articles/heroku-cli">https://devcenter.heroku.com/articles/heroku-cli</a></p><p>Once that’s completed, we have access to a heroku command:</p><blockquote>$ <strong>heroku -- version</strong><br>heroku/7.18.2 darwin-x64 node-v10.12.0</blockquote><p>We’ll also need to login into our account:</p><blockquote>$ <strong>heroku login</strong><br>Enter your Heroku credentials.<br>Email: <strong>paul@example.com</strong><br>Password (typing will be hidden):<br>Authentication successful.</blockquote><p>Vapor includes a command that, in theory, would allow anyone to deploy to Heroku easily:</p><blockquote><strong>vapor heroku init</strong></blockquote><p>This creates a Heroku app using their latest stack, <a href="https://devcenter.heroku.com/articles/heroku-18-stack">Heroku-1</a>8, which is based on Ubuntu 18.04. Unfortunately, “<a href="https://github.com/vapor/documentation/issues/359">Vapor does not support OpenSSL 1.1</a> — the new default on 18.04 — on the source level, so it is not compatible with Ubuntu 18.04 in the end”. This issues<a href="https://github.com/vapor/crypto/pull/75"> has already been fixed</a> but not released yet.</p><p>Until <a href="https://github.com/vapor/crypto/milestone/24?closed=1">that release</a> happens, we’ll need to deploy using the Heroku CLI.</p><h4>6.2 New app</h4><p>Heroku servers support lots of programming language but unfortunately, Swift is not on the official list yet. Fret not — Heroku allows us to add our own scripts that are run when your app is deployed, called <a href="https://elements.heroku.com/buildpacks"><strong>Buildpacks</strong></a>. They are used to install dependencies for your app and configure your environment.</p><p>We’ll use the heroku-16 stack and the Vapor buildpack to create our app:</p><blockquote>$ <strong>heroku create --stack=heroku-16 --buildpack=</strong><a href="https://github.com/vapor-community/heroku-buildpack"><strong>https://github.com/vapor-community/heroku-buildpack</strong></a><br>Creating app… done, ⬢ stark-mesa-11992, stack is heroku-16<br>Setting buildpack to <a href="https://github.com/vapor-community/heroku-buildpack">https://github.com/vapor-community/heroku-buildpack</a>... done<br><a href="https://stark-mesa-11992.herokuapp.com/">https://stark-mesa-11992.herokuapp.com/</a> | <a href="https://git.heroku.com/stark-mesa-11992.git">https://git.heroku.com/stark-mesa-11992.git</a></blockquote><p>We now have a Heroku app called stark-mesa-11992 (you will get a different name) which can be seen in your Heroku control panel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKSLYZvW3PRGoYHvjSv1mA.png" /></figure><p>Let’s add the newly created app to our repository — this will allow us to deploy directly to the Heroku app:</p><blockquote>$ <strong>heroku git:remote -a stark-mesa-11992</strong><br>set git remote heroku to <a href="https://git.heroku.com/stark-mesa-11992.git">https://git.heroku.com/stark-mesa-11992.git</a></blockquote><p>There are 2 more things we need to do before we can deploy to it — setting the Heroku config vars and adding a Procfile.</p><h4>6.3 Heroku config vars</h4><p>Seting the config vars can be done via the command line using the CLI (make sure you use your Nexmo credentials):</p><blockquote>$ <strong>heroku config:set MYAPP_API_KEY=b6AK9o8kVx3n</strong><br>Setting MYAPP_API_KEY and restarting ⬢ stark-mesa-11992… done, v3<br>MYAPP_API_KEY: b6AK9o8kVx3n<br>$ <strong>heroku config:set NEXMO_API_KEY=xxx</strong><br>Setting NEXMO_API_KEY and restarting ⬢ stark-mesa-11992… done, v4<br>NEXMO_API_KEY: xxx<br>$ <strong>heroku config:set NEXMO_API_SECRET=xxx</strong><br>Setting NEXMO_API_SECRET and restarting ⬢ stark-mesa-11992… done, v5<br>NEXMO_API_SECRET: xxx</blockquote><p>These config var values could also be set or changed using the app’s Settings panel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bbkf0_XPL8WsmhfG9wZoaw.png" /></figure><h4>6.4 Procfile</h4><p>The last thing we need to do before we can deploy is adding a Procfile to the project so Heroku will know how to run the app:</p><blockquote>$ <strong>echo ‘web: Run serve --env production --hostname 0.0.0.0 --port $PORT’ &gt; Procfile<br></strong>$ <strong>git add Procfile</strong><br>$ <strong>git commit -m ‘adds Procfile’</strong><br>[master 71bba1e] adds Procfile<br> 1 file changed, 1 insertion(+)<br> create mode 100644 Procfile</blockquote><p>And with that, we’re ready!</p><h4>6.5 Deploy</h4><p>It’s all gonna come together now :). Make sure you use your own Heroku app name below:</p><blockquote>$ <strong>git push heroku master</strong><br>Counting objects: 56, done.<br>…<br>remote: — — -&gt; Installing dynamic libraries<br>remote: — — -&gt; Installing binaries<br>remote: — — -&gt; Cleaning up after build<br>remote: — — -&gt; Discovering process types<br>remote: Procfile declares types -&gt; web<br>remote:<br>remote: — — -&gt; Compressing…<br>remote: Done: 8.5M<br>remote: — — -&gt; Launching…<br>remote: Released v6<br>remote: <a href="https://stark-mesa-11992.herokuapp.com/">https://stark-mesa-11992.herokuapp.com/</a> deployed to Heroku<br>remote:<br>remote: Verifying deploy… done.<br>To <a href="https://git.heroku.com/stark-mesa-11992.git">https://git.heroku.com/stark-mesa-11992.git</a><br> * [new branch] master -&gt; master</blockquote><p>The app is now deployed — let’s add a web dyno to run the app:</p><blockquote>$ <strong>heroku ps:scale web=1</strong><br>Scaling dynos… done, now running web at 1:Free</blockquote><p>And we can now open the app either by typing the URL in a browser or using:</p><blockquote>$ <strong>heroku open</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ez-zx_hpihEVN42ihyliEg.png" /></figure><p><strong>Congratulations</strong>! You’ve now deployed a Vapor app to Heroku!</p><p>We can now use Postman to test the calls — all we have to do is replace <a href="http://localhost:8080/">http://localhost:8080</a> with <a href="https://stark-mesa-11992.herokuapp.com/">https://stark-mesa-11992.herokuapp.com</a> (make sure you use your own app name).</p><blockquote>That’s it for this tutorial! In the next one we’re going to build an iOS app that will use this Heroku app to authenticate users without requiring a password.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1ab952ef126" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/credentials-free-authentication-part-1-the-web-server-c1ab952ef126">Credentials-free authentication — Part 1: The web server</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React and Bootstrap 4 —Setup & Navigation]]></title>
            <link>https://medium.com/paul-ardeleanu/react-and-bootstrap-4-part-1-setup-navigation-d4767e2ed9f0?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/d4767e2ed9f0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bootstrap-4]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Wed, 20 Dec 2017 22:18:56 GMT</pubDate>
            <atom:updated>2018-08-23T20:47:15.948Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Published in: December 2017. Last update: August 2018</em></p><blockquote>I’ve only started learning React couple of weeks ago and I would love your feedback - please use the form at the end of this article.</blockquote><p><a href="https://reactjs.org/">React</a> and <a href="http://getbootstrap.com/">Bootstrap</a> are 2 web frameworks often used together. However, their integration is not that straight-forward — whilst the CSS part is easy to add, the JS part of Bootstrap contradicts with the core React principle of “unidirectional” data flow.</p><p>The <a href="https://react-bootstrap.github.io/">React-Bootstrap library</a> is an attempt to solve this issue, but it’s based on an old version of Bootstrap (version 3).</p><p>However, adding Bootstrap and creating our own ‘components’ is pretty straightforward and good exercise ;)</p><h3>Table of contents</h3><h4><strong>I. Setup</strong></h4><p>1.1 Creating a new React app<br>1.2 Adding the Bootstrap framework<br>1.3 Integrating the Bootstrap CSS<br>1.4 Adding a Bootstrap container<br>1.5 Starting the development server<br>1.6 Cleaning up</p><h4><strong>II. Implementing the Bootstrap navigation</strong></h4><p>2.1 Navigation React Component<br>2.2 Bootstrap navbar<br>2.3 Abstracting the NavItem<br>2.4 Active NavItem<br>2.5 Disabled NavItem<br>2.6 Using the NavItem<br>2.7 Adding a NavDropdown<br>2.8 Adding state to NavDropdown</p><h3>I. Setup</h3><h4>1.1 Creating a new React app</h4><p>The simplest way to create a React app is by using the official <a href="https://reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html">Create React App</a> (I’ve named my app blog):</p><pre>$ <strong>create-react-app blog</strong><br>...<br>$ <strong>cd blog</strong></pre><h4>1.2 Adding the Bootstrap framework</h4><p>We’re now going to add the <a href="https://www.npmjs.com/package/bootstrap">Bootstrap framework via npm</a>:</p><pre>$ <strong>npm install --save </strong>bootstrap<br>...<br>+ bootstrap@4.1.3<br>added 1 package in 7.617s</pre><blockquote>NB: As version 4 is out of beta, a version doesn’t need to be included for bootstrap.</blockquote><h4>1.3 Integrating the Bootstrap CSS</h4><p>Part of the libraries install under node_modules, we have bootstrap, containing a distribution folder with the CSS we’ll need:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsKBjgKSIpnN2ie2kCG9Rw.png" /></figure><p>We’ll link this file inside our index.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cHu9YKzGiJ-KENF6FbpRqQ.png" /></figure><h4>1.4 Adding a Bootstrap container</h4><p>As we’re now using Bootstrap, we’ll add a container as the main div for our app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWYqrThXV1hLzT9sa-_4tA.png" /></figure><h4>1.5 Starting the development server</h4><p>Let’s see how things work together now; run npm start in the project folder:</p><pre>$ npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebX-GIimOQ1tX5i9Do_J0Q.png" /></figure><h4>1.6 Cleaning up</h4><p>Before we proceed to the next step, let’s tidy things up a bit:</p><ul><li>in App.js, remove the reference to the logo — i.e. the line:</li></ul><pre>import logo from ‘./logo.svg’;</pre><ul><li>remove the logo source file: src/logo.svg</li><li>remove the existing css from App.css</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9fzd9fJ_GG-nBqfzpE4nA.png" /></figure><h3>II. Implementing the Bootstrap navigation</h3><p>Let’s add the <a href="http://getbootstrap.com/docs/4.0/components/navbar/">Bootstrap navbar component</a> to our app.</p><h4>2.1 Navigation React Component</h4><p>Create a components folders inside src and a new Navigation.js file. We’ll create a simple React Component which we’ll reference from our App:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8dR8pi3A7N28aJ2LqkVxA.png" /></figure><p>And the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFhgYmAg15KbmoqTBGDOtw.png" /></figure><h4>2.2 Bootstrap navbar</h4><p>From here onwards, we’re going to be working exclusively inside the Navigation.js file. To start with, let’s replace the current output with a navbar as found on the<a href="http://getbootstrap.com/docs/4.0/components/navbar/#supported-content"> Bootstrap documentation page</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Kh8hA7Yfh8envrAQRXZSg.png" /></figure><p>As we’re working with JSX, there are couple of things to change:</p><ul><li>the input tag on line 36 needs to be closed:</li></ul><pre>&lt;input class=&quot;form-control mr-sm-2&quot; type=&quot;search&quot; placeholder=&quot;Search&quot; aria-label=&quot;Search&quot; /&gt;</pre><ul><li>class attributes should be renamed to className (use find &amp; replace)</li><li>links should not point to # so replace that with /</li></ul><p>The end result is in the gist below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e41e639c7401be699dea31b1dccda7f0/href">https://medium.com/media/e41e639c7401be699dea31b1dccda7f0/href</a></iframe><p>And the result in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hE0j6dt5do8HSN4lshVe5A.png" /></figure><h4>2.3 Abstracting the NavItem</h4><p>We’re going to abstract the entries in the navbar into a component. The current HTML looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6392aee5183d80dd42776e6dc271c0d6/href">https://medium.com/media/6392aee5183d80dd42776e6dc271c0d6/href</a></iframe><p>In Navigation.js, above the Navigation component we’ll create a f<a href="https://reactjs.org/tutorial/tutorial.html#functional-components">unctional component</a> named NavItem that needs 2 props: name &amp; path.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be3f615508b7ad0288a13c65f42ff288/href">https://medium.com/media/be3f615508b7ad0288a13c65f42ff288/href</a></iframe><h4>2.4 Active NavItem</h4><p>The link for the current page differs from the others:</p><ul><li><strong>the li element gets an extra active class</strong></li></ul><p>We’ll compare [line 3] the current path [line 2] to the props.path and compose a liClassName constant that we’ll use as the className for the list element in the returned JSX:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/693ce506ff25359c988b6c762a40f544/href">https://medium.com/media/693ce506ff25359c988b6c762a40f544/href</a></iframe><ul><li><strong>the link ‘content’ has a current marker</strong></li></ul><p>We’ll add extra content if current path is equal to props path (line 8 below):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad866603d01f05bf5907f4bb38d818c5/href">https://medium.com/media/ad866603d01f05bf5907f4bb38d818c5/href</a></iframe><blockquote>NB: The span tag is inside brackets and not quotes so it gets treated as JSX code.</blockquote><h4>2.5 Disabled NavItem</h4><p>The disabled element has an extra class “disabled” in the a element of the list item. We’ll pass the disabled status as a prop and use it to compose a new aClassName constant [line 4] to use as className for the link [line 7]:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14a8f2edf26a74a0e00a9f882ff14028/href">https://medium.com/media/14a8f2edf26a74a0e00a9f882ff14028/href</a></iframe><h4>2.6 Using the NavItem</h4><p>We can now replace almost all li elements with NavItems (we’ll deal with the dropdown later on). Here is the Navigation.js file after replacement (notice lines 31–33):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93bee22e1226a75a4988a5d5c186bf32/href">https://medium.com/media/93bee22e1226a75a4988a5d5c186bf32/href</a></iframe><h4>2.7 Adding a NavDropdown</h4><p>Let’s now deal with the dropdown — notice that the dropdown content doesn’t show at the moment since we didn’t include any of the Bootstrap JS.</p><p>As the dropdown has state (open or closed) we can’t use a functional component. For props, we’ll need a name — we’ll also use any child element included. Belong the newly added NavItem but before the Navigation class, add:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38baca5e144a22f80b5fe1f12a85ed85/href">https://medium.com/media/38baca5e144a22f80b5fe1f12a85ed85/href</a></iframe><p>We can now use the component inside the Navigation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ca89da6f9b615035c2083175a98488c/href">https://medium.com/media/7ca89da6f9b615035c2083175a98488c/href</a></iframe><h4>2.8 Adding state to NavDropdown</h4><p>The dropdown is shown is a show class is added to the div with the dropdown-menu class. We’ll use the component constructor to set the initial state and add an extra show class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f93fa105808b9df8a446c2a1366016d1/href">https://medium.com/media/f93fa105808b9df8a446c2a1366016d1/href</a></iframe><blockquote>You can set the initial value of isToggleOn to true to see the menu expanded.</blockquote><p>We’ll next add an action to NavDropdown:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fac6e2970c701fffced6eba49f98a62/href">https://medium.com/media/8fac6e2970c701fffced6eba49f98a62/href</a></iframe><p>and use it for when the dropdown link is clicked. Here is the complete NavDropdown component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6545243fdf23b1c88b704dceebdeebca/href">https://medium.com/media/6545243fdf23b1c88b704dceebdeebca/href</a></iframe><h3>That’s all Folks!</h3><p>Now we have the dropdown working and the full navbar operational.</p><p>The code for the full project is available on Github: <a href="https://github.com/pardel/react-bootstrap4-part1">https://github.com/pardel/react-bootstrap4-part1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4767e2ed9f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/react-and-bootstrap-4-part-1-setup-navigation-d4767e2ed9f0">React and Bootstrap 4 —Setup &amp; Navigation</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Sass with React (without ejecting or running an extra process)]]></title>
            <link>https://medium.com/paul-ardeleanu/using-sass-with-react-without-ejecting-or-running-an-extra-process-de1e4ba4a442?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/de1e4ba4a442</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[create-react-app]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Mon, 18 Dec 2017 22:09:40 GMT</pubDate>
            <atom:updated>2017-12-17T04:42:58.979Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>I’ve started learning React couple of weeks ago and, whilst being in awe of how many open-source tools and libraries are out there, I’m still not comfortable with some of the complicated processes to get started. This is my first attempt at contributing to the simplification of those processes.</blockquote><h3>Scenario:</h3><p>The simplest way to create a React app is by using the official <a href="https://reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html">Create React App</a> — it allows a complete beginner to get up and running using a simple command:</p><pre>create-react-app hello-world</pre><p>whist avoiding going down the rabit hole that leads to <a href="https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4">Javascript fatigue</a>. To start the app one has to simply type:</p><pre>npm start</pre><p>… and you’re off to the races.</p><p>You also want to also use <a href="http://sass-lang.com/">Sass</a> in your app. There are 2 ways to do this:</p><ol><li><strong>Eject your React app</strong></li></ol><p>‘Ejecting’ is the process of removing some of the ‘magic’ of create-react-app by revealing all the build dependencies, configs, and scripts — they’re moved inside the project. This is great for advanced devs (allows better customisation) but is <a href="https://github.com/webpack-contrib/sass-loader">confusing for beginners</a>. You can <a href="https://medium.com/@Connorelsea/using-sass-with-create-react-app-7125d6913760">read more on this here</a>.</p><p>2. <strong>Use a separate process</strong> to run the Sass to CSS conversion</p><p>Sass is a Ruby gem so one could run a conversion to CSS using this gem and then include the CSS in the React app. Good news: this is a simple process since Ruby comes preinstalled on all modern OS’. Bad news: one needs to run a separate process to do conversion, parallel to the node server that is serving the React app. You can <a href="https://hackernoon.com/using-sass-with-create-react-app-without-ejecting-b5f4f827ed9e">read more on this here</a>.</p><h3>Problem:</h3><p>You want to continue using npm start to run your app and not worry about the internals.</p><h3>Solution:</h3><p>We’ll be using the Sass gem and ‘merge’ it inside the React app.</p><h4>1. Install the Sass ruby gem</h4><p>Refer to the <a href="http://sass-lang.com/install">instructions on the Sass website on how to install</a>. To check the installation, run:</p><pre>$ <strong>gem list | grep sass</strong><br>…<br>sass (3.5.1)<br>sass-listen (4.0.0)<br>…</pre><h4>2. Create the React app</h4><p>Let’s create a new app:</p><pre>$ create-react-app helloworld<br>...<br>$ cd helloworld</pre><p>You can now run the start script and see your React app:</p><pre>$ npm start</pre><h4>3. Sass source &amp; CSS destination</h4><p>We’ll now create the Sass source and CSS destination folders:</p><pre>mkdir -p src/styles/scss src/styles/css</pre><p><strong><em>NB:</em></strong><em> SCSS (Sassy CSS) is the main Sass implementation since Sass v.3. </em><a href="http://www.thesassway.com/editorial/sass-vs-scss-which-syntax-is-better"><em>Read more here</em></a><em>.</em></p><p>Let’s also create the source App SCSS file:</p><pre>touch src/styles/scss/App.scss</pre><p>The conversion process is simple enough — we’ll use the sass executable installed by the gem:</p><pre>$ which sass<br>/usr/local/bin/sass<br>$ sass — help<br>Usage: sass [options] [INPUT] [OUTPUT]</pre><pre>Description:<br> Converts SCSS or Sass files to CSS.<br>...</pre><p>Here is the conversion command — it will continuously watch for changes in the src/styles/scss folder and run the output to the src/styles/css folder.</p><pre>$ sass — watch src/styles/scss:src/styles/css<br>&gt;&gt;&gt; Sass is watching for changes. Press Ctrl-C to stop.<br> write src/styles/css/App.css<br> write src/styles/css/App.css.map</pre><h4>4. Use the converted App.css</h4><p>We’ll now instruct React to use the converted CSS file. At the moment App.js uses the App.css inside the src folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftcNA_XRnQN1fmEua94FUw.png" /></figure><p>We’ll delete that file and reference src/styles/css/App.css inside App.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGkYXgKOddQFZ9LiwisCCg.png" /></figure><p><em>NB: The initial CSS is now gone, so your React app will look ‘funny’.</em></p><h4>5. All together now!</h4><p>All that’s left is to add the sass conversion script as part of the React start process. This is done by changing the start script inside package.json:</p><pre>{<br> &quot;name&quot;: &quot;helloworld&quot;,<br> ...<br> &quot;start&quot;: &quot;sass — watch src/styles/scss:src/styles/css | react-scripts start&quot;,<br> ...<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1uV_EXBsj5alAxfKGIzBHA.png" /></figure><p>You can now start the server using npm start and start using Sass inside your React app.</p><h4>One more thing</h4><p>The Sass gem uses a temporary folder (.sass-cache) during the conversion process — add it to the project .gitignore file so it won’t be pushed to your VC server.</p><h3>That’s all folks!</h3><p>Hope this proves helpful to people. A copy of the project is available on <a href="https://github.com/pardel/sass-react">Github</a>. As ever, feel free to add a comment below with suggestions/criticism etc.</p><h3>Happy coding!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de1e4ba4a442" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/using-sass-with-react-without-ejecting-or-running-an-extra-process-de1e4ba4a442">Using Sass with React (without ejecting or running an extra process)</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resetting iOS Simulator for UI tests]]></title>
            <link>https://medium.com/paul-ardeleanu/resetting-ios-simulator-for-ui-tests-cd7fff57788e?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/cd7fff57788e</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[ui-testing]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Wed, 19 Apr 2017 17:26:41 GMT</pubDate>
            <atom:updated>2021-11-16T19:57:59.415Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>For updated instructions (Swift 5 and Xcode 11), please visit: </em><a href="https://www.pardel.dev/blog/resetting-ios-simulator-for-ui-tests">https://www.pardel.dev/blog/resetting-ios-simulator-for-ui-tests</a></blockquote><p>One of the major issues we encounter with UI tests in iOS is the simulator’s inability to completely clear its slate between runs. Here is an example.</p><h3>The problem we’re trying to solve</h3><p>Say, you’re implementing a login functionality and, like a good citizen, you’re storing the credentials in the keychain. Now, for unit and integration tests this won’t pose a problem as it can be easily mocked. But for UI tests, the app is tested as an entity, from outside, without access to internals. And the simulator doesn’t clear the keychain between tests.</p><p>Almost as bad as Xcode running tests in alphabetical order! 😱</p><h3>The Solution — app launch arguments</h3><p>When starting an app as part of the UI tests, one can pass in launch arguments:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eab93c7dda3736004823fba2e8630d5a/href">https://medium.com/media/eab93c7dda3736004823fba2e8630d5a/href</a></iframe><p>But for that to work we’re going to have a look at UIApplicationMain first.</p><h4>UIApplicationMain</h4><p>If you came to iOS Swift development from other languages, or even if you did iOS development with Obj-C before, you might have noticed that there is no <strong><em>main.x</em></strong> file that can be used as the entry point — e.g. <strong><em>main.m</em></strong> in Obj-C. There is a <strong><em>@UIApplicationMain</em></strong> marker in <strong><em>AppDelegate.swift</em></strong> that serves the same purpose and it’s actually possible to also use a “main” file.</p><p>To be able to observe the new launch parameter “ — Reset” we’ll need to change things a bit so we can react to it.</p><p>Let’s delete @UIApplicationMain and create a <strong><em>main.swift</em></strong> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9affc390e6efca2a370961564aee03f/href">https://medium.com/media/f9affc390e6efca2a370961564aee03f/href</a></iframe><p>This simply calls UIApplicationMain which is the entry point to create the application object and the application delegate and set up the event cycle.</p><p>This now gives us the opportunity to perform tasks before launching the app.</p><h4>The AppReset</h4><p>To reset the keychain I’ve created a simple resetKeychain() method, enclosed into an enum, simply for namespacing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ff0816ab4cf056cc884f689b27c94d5/href">https://medium.com/media/8ff0816ab4cf056cc884f689b27c94d5/href</a></iframe><h3>All together now</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYsLaWwF9Bt2qz47pL7mYQ.png" /></figure><p>The code is also available as a gist:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26fa0e817b130ab040a5bb6174ad7d98/href">https://medium.com/media/26fa0e817b130ab040a5bb6174ad7d98/href</a></iframe><h3>One more thing</h3><p>When using the reset in UI tests I tend to create helper methods to launch the app with different arguments:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a3e07f58fda519f15c81237c3511a3d/href">https://medium.com/media/9a3e07f58fda519f15c81237c3511a3d/href</a></iframe><h3>That’s it!</h3><p>Happy UI Testing! 🤓</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd7fff57788e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/resetting-ios-simulator-for-ui-tests-cd7fff57788e">Resetting iOS Simulator for UI tests</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TDD-ing your @Realm objects in Xcode Playgrounds]]></title>
            <link>https://medium.com/paul-ardeleanu/tdd-ing-your-realm-objects-in-xcode-playgrounds-de492fa69543?source=rss----1554d945a89f---4</link>
            <guid isPermaLink="false">https://medium.com/p/de492fa69543</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[realm]]></category>
            <category><![CDATA[swift-playgrounds]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Paul Ardeleanu]]></dc:creator>
            <pubDate>Wed, 05 Apr 2017 17:52:51 GMT</pubDate>
            <atom:updated>2017-04-05T22:48:06.534Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2 previous posts, I’ve shown <a href="https://m.pardel.net/tdd-in-xcode-playgrounds-544a95db11e2">how to TDD</a> and <a href="https://m.pardel.net/using-3rd-party-frameworks-in-swift-playgrounds-fd415f6dba10">how to use 3rd party frameworks in Xcode Playgrounds</a>. This one kinda ties them together.</p><p>If you’ve never used <a href="https://realm.io/products/realm-mobile-database/">Realm Mobile Database</a> before, head over to their <a href="https://realm.io/docs/swift/latest/">Swift documentation pages</a>. In short, it is a fast, open-source alternative to SQLite and CoreData — allows you to store your data fast in a cross-platform format. There is also a Realm Browser that can be downloaded from the <a href="https://itunes.apple.com/gb/app/realm-browser/id1007457278?mt=12">Mac App Store</a>.</p><h3>The Task object and TestCase</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZolCrQ7b_vz5D2Zr-FSKg.png" /></figure><p>Let’s go through this one step at a time.</p><h3>Import PlaygroundWrapper and RealmSwift</h3><p>As mentioned in <a href="https://m.pardel.net/using-3rd-party-frameworks-in-swift-playgrounds-fd415f6dba10">Using 3rd party frameworks in Xcode Playgrounds</a>, this technique allows us to bring Realm support into the playgrounds.</p><h3>Task realm object</h3><p>I’ve created a simple realm object with one property — realm objects must have at least one property. In my case this an uuid that gets a randomly generated string when created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef0c7a3e349a9ecae40f9bdc2c9b18ea/href">https://medium.com/media/ef0c7a3e349a9ecae40f9bdc2c9b18ea/href</a></iframe><h3>TaskTests</h3><p>As described in <a href="https://m.pardel.net/tdd-in-xcode-playgrounds-544a95db11e2">TDD in Xcode Playgrounds</a>, I’ve created a subclass of XCTestCase and run a test suite.</p><p>The class also contains 2 properties that will help with the testing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b076349df9ea3a597ba00824219c30e0/href">https://medium.com/media/b076349df9ea3a597ba00824219c30e0/href</a></iframe><h3>The setup</h3><p>The “magic” here is the use of <strong>in memory</strong> Realm databases with a <strong>random identifier</strong>. This ensures that a new fresh realm is created before each test.</p><p>Setting the Realm.Configuration.defaultConfiguration allows us to not having to store the configuration for later use — we can simply address the realm as Realm().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/598da4295c9605b6883ed0b3ec88184c/href">https://medium.com/media/598da4295c9605b6883ed0b3ec88184c/href</a></iframe><h3>The test: testSetup()</h3><p>Fairly straigtforward — we’re testing that we have one and only one realm objects of type Task.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ceb2eccb23176fc3267ebbf411e01fb6/href">https://medium.com/media/ceb2eccb23176fc3267ebbf411e01fb6/href</a></iframe><p>From here onwards, the world is your oyster…</p><p>The project can be found on github: <a href="https://github.com/pardel/tdd-realm-playgrounds">https://github.com/pardel/tdd-realm-playgrounds</a></p><h3>But is it fast?</h3><p>Oh yes, it’s fast: <a href="https://realm.io/news/introducing-realm/#fast">https://realm.io/news/introducing-realm/#fast</a>. Realm was designed and built for performance.</p><p>Last but not least, imagine TDD-ing with Core Data, Playgrounds or not. 🤓</p><h4>Update April 5th</h4><p>The Video of my “TDD in Xcode Playgrounds” lighthing talk at <a href="https://twitter.com/iOSConLondon">@iOSConLondon</a> can be found below. It covers the subject of this article as well as others.</p><p><a href="https://skillsmatter.com/skillscasts/10072-tdd-in-xcode-playgrounds">TDD in Xcode Playgrounds | SkillsCast | 30th March 2017</a></p><h4>Thank you!</h4><p><strong>Big thank you</strong> to <a href="https://medium.com/u/dcb7aa802f50">Marin Todorov</a> for catching a bad error.</p><p>If you found this tutorial useful, make sure you check out my upcoming <a href="https://leanpub.com/test-gtfo">LeanPub</a> book:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*IbtYe-XmOAPDX5Kt4lZdiQ.png" /><figcaption><a href="https://leanpub.com/test-gtfo">“<strong>Test or GTFO! </strong>— a guide to iOS Test Driven Development with Swift”</a>.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de492fa69543" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paul-ardeleanu/tdd-ing-your-realm-objects-in-xcode-playgrounds-de492fa69543">TDD-ing your @Realm objects in Xcode Playgrounds</a> was originally published in <a href="https://medium.com/paul-ardeleanu">Paul Ardeleanu’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>