@tempoxyz/auth 0.0.0-pr-66.sha-846b1be → 0.0.0-pr-66.sha-480b2a0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,23 +5,20 @@ Signs users in to Tempo through [Tempo Auth](../../docs/README.md), and returns
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import {
|
|
8
|
+
import { Auth, tempoAuth } from '@tempoxyz/auth'
|
|
9
9
|
import { createClient, Expiry, Scopes } from 'viem/tempo'
|
|
10
10
|
import * as Tokens from 'viem/tokens'
|
|
11
11
|
|
|
12
|
-
const client = createClient()
|
|
12
|
+
const client = createClient({ account: Auth.account() }).extend(
|
|
13
|
+
tempoAuth({ clientId: 'client_…' }),
|
|
14
|
+
)
|
|
13
15
|
const ousd = Tokens.ousd(client.chain.id).address
|
|
14
16
|
|
|
15
|
-
const auth = Auth.create({
|
|
16
|
-
chainId: client.chain.id,
|
|
17
|
-
clientId: 'client_…',
|
|
18
|
-
})
|
|
19
|
-
|
|
20
17
|
// 1. Email the user a sign-in code.
|
|
21
|
-
await
|
|
18
|
+
await client.auth.email.sendCode({ email: 'user@example.com' })
|
|
22
19
|
|
|
23
|
-
// 2. Sign in with the code, and authorize an access key.
|
|
24
|
-
const result = await
|
|
20
|
+
// 2. Sign in with the code, and authorize an access key, which becomes the client's account.
|
|
21
|
+
const result = await client.auth.email.signIn({
|
|
25
22
|
code: '123456',
|
|
26
23
|
email: 'user@example.com',
|
|
27
24
|
permissions: {
|
|
@@ -35,14 +32,13 @@ if ('step' in result) throw new Error('This address signs in through SSO.')
|
|
|
35
32
|
|
|
36
33
|
// 3. Send a transaction with the access key.
|
|
37
34
|
await client.token.transferSync({
|
|
38
|
-
account: result.account,
|
|
39
35
|
amount: 10_000n,
|
|
40
36
|
to: '0x…',
|
|
41
37
|
token: ousd,
|
|
42
38
|
})
|
|
43
39
|
```
|
|
44
40
|
|
|
45
|
-
Every sign-in returns the same `Authorization
|
|
41
|
+
Every sign-in returns the same `Authorization` and sets the client's account. The client sends with the access key, and the `accessToken` calls Tempo APIs. Each action is also available without the extension, as `Actions`.
|
|
46
42
|
|
|
47
43
|
## Install
|
|
48
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempoxyz/auth",
|
|
3
|
-
"version": "0.0.0-pr-66.sha-
|
|
3
|
+
"version": "0.0.0-pr-66.sha-480b2a0",
|
|
4
4
|
"description": "Signs users in to Tempo through Tempo Auth, and returns Viem access key accounts on their Tempo Accounts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|