1.5.0 • Published 12 months ago

@automata-network/safe-authmodule-sdk v1.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

Automata 2.0 Attestors 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_ATTESTOR_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_ATTESTOR_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.

1.5.0-alpha-0

1 year ago

1.5.0-alpha-1

1 year ago

1.5.0-alpha-2

1 year ago

1.5.0-alpha-3

12 months ago

1.5.0-alpha-4

12 months ago

1.5.0

12 months ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.39

2 years ago

0.1.38

2 years ago

0.1.37

2 years ago

0.1.36

2 years ago

0.1.35

2 years ago

0.1.34

2 years ago

0.1.33

2 years ago

0.1.32

2 years ago

0.1.31

2 years ago

0.1.30

2 years ago

0.1.29

2 years ago

0.1.28

2 years ago

0.1.27

2 years ago

0.1.26

2 years ago

0.1.25

2 years ago

0.1.24

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago