npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

passkeyme-ionic-cap-plugin

v0.0.1

Published

SDK for Passkeye - Passkeys for Ionic Apps

Downloads

2

Readme

alt text

ionic-passkeys

Passkeyme for Ionic Apps

Install

npm install passkeyme-ionic-cap-plugin
npx cap sync

API

passkeyRegister(...)

passkeyRegister(options: { challenge: string; }) => Promise<{ credential: string; }>

| Param | Type | | ------------- | ----------------------------------- | | options | { challenge: string; } |

Returns: Promise<{ credential: string; }>


passkeyAuthenticate(...)

passkeyAuthenticate(options: { challenge: string; }) => Promise<{ credential: string; }>

| Param | Type | | ------------- | ----------------------------------- | | options | { challenge: string; } |

Returns: Promise<{ credential: string; }>


Example

Here is a full working example.

To get it working, first, go to Passkeyme, register, create an app and grab the AppID and API Key, and populate in your env as:

VITE_APP_UUID=
VITE_API_KEY=

Then, create the app:

npx create-react-app passkeyme-react-demo
npm install passkeyme-web-sdk axios styled-components
npm start

You'll need to run it behind an addressible domain for Passkeys to work. You can host it, or use ngrok to serve it.

import { IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader, IonInput, IonItem, IonList, IonMenuButton, IonPage, IonTitle, IonToolbar } from '@ionic/react';
import { useParams } from 'react-router';
import ExploreContainer from '../components/ExploreContainer';
import { PasskeymeSDK } from 'passkeyme-ionic-cap-plugin';

import axios from "axios";
import { useState } from 'react';

const API_URL = "https://passkeyme.com";
const APP_UUID = import.meta.env.VITE_APP_UUID;
const API_KEY = import.meta.env.VITE_API_KEY;

const client = axios.create({
   baseURL: `${API_URL}/webauthn/${APP_UUID}`, 
   headers: {
     'x-api-key': API_KEY,
     'Content-Type': 'application/json'
   }});

const Page: React.FC = () => {

  const [result, setResult] = useState<any>("");
  const [username, setUsername] = useState<any>("");
  const [displayName, setDisplayName] = useState<any>("");

  const appuuid = APP_UUID;
  const apikey = API_KEY;

  async function registerPasskey() {
    try {

      const response = await client.post(`/start_registration`, {username, displayName});

      const { credential } = await PasskeymeSDK.passkeyRegister({ challenge: response.data.challenge });

      let completionresponse = await client.post(`/complete_registration`, { username, credential });

      setResult(JSON.stringify(completionresponse.data));
    } catch (error) {
      console.log('passkeyme: reg: error:', JSON.stringify(error))
      setResult(JSON.stringify(error));
    }
  };

  async function authenticatePasskey() {
    try {

      let response = await client.post(`/start_authentication`, { username });

      const { credential } = await PasskeymeSDK.passkeyAuthenticate({ challenge: response.data.challenge });

      let completionresponse = await client.post(`/complete_authentication`, { credential });

      setResult(JSON.stringify(completionresponse.data));

    } catch (error) {
      console.log('passkeyme: error:', JSON.stringify(error))
      setResult(JSON.stringify(error));
    }
  }

  const { name } = useParams<{ name: string; }>();

  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonButtons slot="start">
            <IonMenuButton />
          </IonButtons>
          <IonTitle>{name}</IonTitle>
        </IonToolbar>
      </IonHeader>

      <IonContent fullscreen>
        <IonHeader collapse="condense">
          <IonToolbar>
            <IonTitle size="large">{name}</IonTitle>
          </IonToolbar>
        </IonHeader>
        <ExploreContainer name={name} />
        <IonCard>
          <IonCardHeader>
            <IonCardTitle>
            <IonList>
              <IonItem>
                <IonInput label="username" placeholder="Enter a username" value={username}
                  onIonChange={(e: any) => setUsername(e.target.value)}               
                  ></IonInput>
              </IonItem>

              <IonItem>
                <IonInput label="displayName" placeholder="Enter a display name" value={displayName}
                onIonChange={(e: any) => setDisplayName(e.target.value)}
                ></IonInput>
              </IonItem>
            </IonList>
                
            <IonButton 
                onClick={() => {
                  registerPasskey()
                }}
            >Register Passkey
            </IonButton>
            <IonButton 
                onClick={() => {
                  authenticatePasskey()
                }}
            >Login Passkey
            </IonButton>

            </IonCardTitle>
          </IonCardHeader>

          <IonCardContent>{result}</IonCardContent>
        </IonCard>

      </IonContent>
    </IonPage>
  );
};

export default Page;