You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@automata-network/safe-authmodule-sdk

Package Overview
Dependencies
1
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automata-network/safe-authmodule-sdk


Version published
Maintainers
0
Created

Readme

Source

Automata 2.0 Attestation SDK

This SDK includes the following modules:

  • setup.ts: Provides a method that deploys a SafeWallet, which enables AuthModule and creates an attestation of the user's device upon the initial setup of the wallet.

  • challenge.ts: Deterministically pre-computes the address of a SafeWallet prior to its deployment. This address is included as a challenge data for the initial attestation.


To install the SDK, do the following:

NPM:

npm install --save-dev @automata-network/safe-authmodule-sdk

YARN:

yarn add --dev @automata-network/safe-authmodule-sdk

To use the SDK, you must first import the two essential functions.

import { 
  computeSafeAddress, 
  createNewWallet, 
  AUTH_MODULE_ADDRESS,
  ANDROID_SAFETYNET_ATTESTATION_ADDRESS // this varies by the user's device
} from @automata-network/safe-authmodule-sdk;

// Step 1: Define a random nonce to generate a unique Safe wallet address.

// generates a random number from 0 to MAX_NUMBER - 1
const nonce = Math.floor(Math.random()) * MAX_NUMBER;

// This is OPTIONAL, but recommended. This would assign the provided address as the owner of the SafeWallet.
// SafeWallet is a multi-sig wallet, therefore ownership can be assigned to one or more addresses.
const ownerAddress = await signer.getAddress();

// This is OPTIONAL, but recommended. Some arbitrary number of signatures to execute a transaction (not via device attestation with AuthModule)
// as long as it is less than the number of owners.
const threshold = 5;

// Step 2: Computes the challenge
const safeAddress = await computeSafeAddress(nonce, [ownerAddress], threshold);

// Step 3: Sends a request to the Relayer to create a SafeWallet on chain.
// This step is performed after getting a response from creating a WebAuthn credential.

const response = await createNewWallet(
  nonce,
  {
    authDataBytes,
    clientDataJSONBytes // utf8 encoded
  },
  attStmt,
  ANDROID_SAFETYNET_ATTESTATION_ADDRESS,
  threshold,
  [ownerAddress],
  provider // OPTIONAL Web3 provider to overwrite default configurations. This is only used for reading on-chain data.
);

All contract deployment addresses can be found in constants.ts.

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc