1.5.0 • Published 2 years ago

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

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years 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

2 years ago

1.5.0-alpha-1

2 years ago

1.5.0-alpha-2

2 years ago

1.5.0-alpha-3

2 years ago

1.5.0-alpha-4

2 years ago

1.5.0

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years 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

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.39

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.33

3 years ago

0.1.32

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago