Skip to content
DogeJS-DevPublic

About

Sign in with Doge: prove ownership of a Dogecoin address by signing a challenge. Element, server verifier and wallet adapters.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

DogeJS

Sign in with Doge

One button: the visitor signs a short text with their Dogecoin wallet and is signed in. No passwords, and no coins move.

Live demo · Documentation · All DogeJS projects

The Sign in with Doge button and its wallet window

What it does

  • Gives your page one button: the visitor picks a wallet, approves in the window that pops up, and is signed in. No forms and no passwords.
  • Nothing moves and nothing costs anything: the visitor only signs a short text that names your site, a nonce and an expiry time.
  • Works with MyDoge, the DogeJS Wallet or any wallet that can sign a message (the visitor can also paste a signature).
  • Includes a server-side verifier (@dogejs/signin/verify) that checks the domain, nonce, network, time and address, and refuses anything else.
  • You can add your own wallet row with walletAdapter.

Try it

Click the button on the live demo and choose Demo wallet: two clicks to the green check. https://dogejs.com/signin/

Add it to a page with two lines:

<script src="signin.js" defer></script>
<doge-signin mode="button" statement="Sign in to Example."></doge-signin>

Screenshots

The wallet list: a demo wallet, MyDoge, the DogeJS Wallet or any other wallet.

The wallet list: a demo wallet, MyDoge, the DogeJS Wallet or any other wallet.

Approved: the green check, and the address that signed.

Approved: the green check, and the address that signed.

Install

Nothing is on npm yet, so install straight from this repository (it needs a public repository, or a GitHub login that can read it). The prepare script builds dist as part of the install. For a plain page, copy dist/signin.js to your own static host and load it with a script tag, as above.

npm install github:DogeJS-Dev/sign-in#v0.7.2

Once the package is on npm this becomes npm install @dogejs/signin. This runs a whole sign-in on the server side, with a throwaway key standing in for the visitor's wallet:

import { generatePrivateKey, getPublicKey, encodeWif, p2pkhAddress, signMessage } from '@dogejs/core';
import { createSignInMessage, generateNonce, verifySignIn } from '@dogejs/signin/verify';

// Server: make a challenge. (Keep the nonce server-side and use it once.)
const nonce = generateNonce();
const priv = generatePrivateKey(); // stands in for the visitor's wallet
const address = p2pkhAddress(getPublicKey(priv));
const message = createSignInMessage({
  domain: 'example.com', address, uri: 'https://example.com/login', network: 'mainnet',
  nonce, issuedAt: new Date(), expirationTime: new Date(Date.now() + 10 * 60 * 1000),
});

// Wallet: sign it (here with @dogejs/core; a real wallet does this for you).
const signature = signMessage(message, encodeWif(priv));

// Server: verify.
const result = verifySignIn({ message, signature, expected: { domain: 'example.com', nonce } });
console.log(result.ok, result.ok && result.address === address); // true true

How it works

The button checks the signature in the browser, but to protect anything you must check it again on your server, with a nonce your server issued (pass it in the nonce attribute). The signed text is a fixed, human-readable message modelled on EIP-4361 and parsed by one strict grammar. The DogeJS Wallet opens in a pop-up, shows the site's name, and refuses requests that name another site. Signing and verification come from core.

The full reference, including every attribute and event, is in docs/REFERENCE.md.

Works with

  • Built on core.
  • The wallet answers sign-in requests (protocol: docs/SIGNIN-REQUEST.md in that repository).
  • Pairs with the pay-button for sites that want to sign people in and take payment.

Status

Version 0.7.2. It is not published to npm yet, so you install it from git. It has had no external security review. No real wallet and no real Dogecoin node has been used to test it; signing and verification rely on core, which is also unreviewed.

Contributing

Bug reports, ideas and pull requests are welcome. Read the contributing guide first: small, tested, explained.

npm install
npm run build
npm run typecheck
npm test

Report a security problem privately to hello@dogejs.com, never in a public issue. See SECURITY.md.

The maintainers keep one combined development workspace for all DogeJS projects and publish each project from it as a repository of its own. An accepted pull request is applied there and appears here with the next release.

Licence

MIT, see LICENSE. Bundled third-party code, where there is any, is listed in THIRD_PARTY_LICENSES.

About

Sign in with Doge: prove ownership of a Dogecoin address by signing a challenge. Element, server verifier and wallet adapters.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages