test-sveltekit-web-auth
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

2077 Auth

A sveltekit library for handling authentication for web3 and web2 providers.

Installation

// TODO: add actual package name once published
npm install @2077/auth

Usage

The library provides three methods of authentication:

  1. Browser wallet: connect to a wallet provider
  2. SIWE + JWT: generates a JWT based on a signature created from a SIWE message
  3. Web2 providers: Google, X, Github

Browser Wallet

This method connects to a wallet provider and returns the wallet address and chainId.

<script>
  import { Auth } from '$lib/index';
</script>

{#snippet header()}
  <h4>Connect wallet</h4>
{/snippet}
<Auth
  header={header}
  walletLoginCallback={(walletInfo) => /*Do something with walletInfo*/}
/>

SIWE + JWT

This method generates a JWT based on a signature created from a SIWE message.

@2077/auth provides the request handlers that will create a SIWE-style messages, forward them to the client, sign the message, and send it back to the server in order to validate and generate a JWT.

// +page.svelte
<script>
  import { Auth } from '$lib/index';
  export let data;
</script>

{#snippet header()}
  <h4>SIWE + JWT</h4>
{/snippet}
<Auth
  header={header}
  enableSocial={true}
  walletLoginCallback={(walletInfo) => /*Do something with walletInfo*/}
  signatureEndpoint="/"
  authenticationEndpoint="/"
/>
// TODO: rename import to actual package name when published
import { getSignatureMessage, authenticate } from '@2077/auth';

export const GET = getSignatureMessage;
export const POST = authenticate({ jwtSecret: 'secret' });

Web2 Providers

TODO

Readme

Keywords

none

Package Sidebar

Install

npm i test-sveltekit-web-auth

Weekly Downloads

0

Version

0.0.1

License

none

Unpacked Size

11.3 kB

Total Files

10

Last publish

Collaborators

  • iankressin