forked from alchemyplatform/aa-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add docs for using the alchemy signer (alchemyplatform#445)
- Loading branch information
Showing
18 changed files
with
707 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • addPasskey | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.addPasskey method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.addPasskey method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • addPasskey | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.addPasskey method | ||
--- | ||
|
||
# addPasskey | ||
|
||
The `addPasskey` method is used to add a passkey as an auth method to an already logged in user. | ||
|
||
::: warning | ||
This method throws if there is no authenticated user. | ||
::: | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
await signer.addPasskey(); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`Promise<string[]>` -- on success returns an array of credential ids | ||
|
||
## Parameters | ||
|
||
`params?: CredentialCreationOptions` -- overrides for the WebAuthn credential creation options. For more info on the `CredentialCreationOptions` interface, see [here](https://microsoft.github.io/PowerBI-JavaScript/interfaces/_node_modules_typedoc_node_modules_typescript_lib_lib_dom_d_.credentialcreationoptions.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • authenticate | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.authenticate method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.authenticate method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • authenticate | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.authenticate method | ||
--- | ||
|
||
# authenticate | ||
|
||
The `authenticate` method is used to authenticate a user with the Alchemy Signer. | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
const bundlePromise = new Promise(async (resolve) => { | ||
// up to you define how you collect the OTP from the user | ||
const otpFromUser = await getOtpFromUser(); | ||
resolve(otpFromUser); | ||
}); | ||
|
||
const user = await signer.authenticate({ | ||
type: "email", | ||
email: "[email protected]", | ||
// the bundle is the OTP that the user will input from their email | ||
bundle: bundlePromise, | ||
}); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`Promise<User>` -- on success returns a `User` object representing the authenticated user. | ||
|
||
## Parameters | ||
|
||
`AuthParams` -- an object that contains the following properties: | ||
|
||
```ts | ||
export type AuthParams = | ||
| { type: "email"; email: string; bundle: Promise<string> } | ||
| { | ||
type: "passkey"; | ||
createNew: false; | ||
} | ||
| { | ||
type: "passkey"; | ||
createNew: true; | ||
username: string; | ||
creationOpts?: CredentialCreationOptionOverrides; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • disconnect | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.disconnect method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.disconnect method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • disconnect | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.disconnect method | ||
--- | ||
|
||
# disconnect | ||
|
||
The `disconnect` method is used to disconnect a user from the Alchemy Signer and clear the local session. | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
await signer.disconnect(); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • exportWallet | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.exportWallet method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.exportWallet method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • exportWallet | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.exportWallet method | ||
--- | ||
|
||
# exportWallet | ||
|
||
The `exportWallet` method is used to export the user's private key or seed phrase. | ||
|
||
If the user is authenticated with an Email, this will return a seed phrase | ||
If the user is authenticated with a Passkey, this will return a private key | ||
|
||
::: warning | ||
This method throws if there is no authenticated user. | ||
::: | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
await signer.exportWallet({ | ||
iframeContainerId: "my-export-wallet-container", | ||
}); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`Promise<boolean>` -- returns a boolean indicating the success of the export | ||
|
||
## Parameters | ||
|
||
`params: ExportWalletParams` | ||
|
||
- `iframeContainerId: string` -- the id of the container to render the export wallet iframe in | ||
- `iframeElementId?: string` -- the id given to the iframe element that will be injected into the DOM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • getAddress | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.getAddress method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.getAddress method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • getAddress | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.getAddress method | ||
--- | ||
|
||
# getAddress | ||
|
||
Returns the signer's public address. | ||
|
||
::: warning | ||
This method throws if there is no authenticated user. | ||
::: | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
const address = await signer.getAddress(); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`Promise<Address>` -- on success returns the signer's public address. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
outline: deep | ||
head: | ||
- - meta | ||
- property: og:title | ||
content: Alchemy Signer • getAuthDetails | ||
- - meta | ||
- name: description | ||
content: Learn how to use the AlchemySigner.getAuthDetails method | ||
- - meta | ||
- property: og:description | ||
content: Learn how to use the AlchemySigner.getAuthDetails method | ||
- - meta | ||
- name: twitter:title | ||
content: Alchemy Signer • getAuthDetails | ||
- - meta | ||
- name: twitter:description | ||
content: Learn how to use the AlchemySigner.getAuthDetails method | ||
--- | ||
|
||
# getAuthDetails | ||
|
||
The `getAuthDetails` method is used to get the details of the currently authenticated user. This method will also use session storage to get the user's details if they are already authenticated. | ||
|
||
::: warning | ||
This method throws if there is no authenticated user. | ||
::: | ||
|
||
## Usage | ||
|
||
::: code-group | ||
|
||
```ts | ||
import { signer } from "./signer"; | ||
|
||
const user = await signer.getAuthDetails(); | ||
``` | ||
|
||
<<< @/snippets/signers/alchemy/signer.ts | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`Promise<User>` -- on success returns a `User` object representing the authenticated user. |
Oops, something went wrong.