@tempoxyz/auth 0.0.0-pr-87.sha-cf6fb2e → 0.0.0-pr-91.sha-bdc606a
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/dist/Actions.d.ts +1 -7
- package/dist/Actions.js +0 -2
- package/dist/Auth.d.ts +1 -1
- package/dist/Decorator.d.ts +1 -5
- package/dist/Decorator.js +1 -4
- package/dist/Step.d.ts +1 -13
- package/dist/TempoAccount.d.ts +1 -13
- package/dist/TempoAccount.js +1 -5
- package/dist/actions/device.d.ts +1 -1
- package/dist/actions/email.d.ts +4 -7
- package/dist/actions/email.js +3 -14
- package/dist/actions/passkey.d.ts +3 -10
- package/dist/actions/passkey.js +0 -7
- package/dist/actions/redirect.d.ts +1 -1
- package/dist/actions/tempoAccount.d.ts +5 -13
- package/dist/actions/tempoAccount.js +17 -9
- package/dist/internal/api.d.ts +0 -26
- package/dist/internal/api.js +0 -8
- package/dist/internal/request.d.ts +0 -2
- package/dist/internal/request.js +1 -3
- package/package.json +1 -1
- package/dist/actions/realm.d.ts +0 -26
- package/dist/actions/realm.js +0 -15
package/dist/Actions.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export * as email from './actions/email.ts';
|
|
|
14
14
|
export * as oauth from './actions/oauth.ts';
|
|
15
15
|
export * as passkey from './actions/passkey.ts';
|
|
16
16
|
export * as provider from './actions/provider.ts';
|
|
17
|
-
export * as realm from './actions/realm.ts';
|
|
18
17
|
export * as redirect from './actions/redirect.ts';
|
|
19
18
|
export * as tempoAccount from './actions/tempoAccount.ts';
|
|
20
19
|
/**
|
|
@@ -33,14 +32,9 @@ export declare namespace authorize {
|
|
|
33
32
|
type Options<chainId extends number = number> = {
|
|
34
33
|
/**
|
|
35
34
|
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
36
|
-
* defaults to the
|
|
35
|
+
* defaults to the user's first. Defaults to a new key.
|
|
37
36
|
*/
|
|
38
37
|
accessKey?: Account.Account | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* The address of the user's Tempo Account the key acts for, such as the one the user chose from
|
|
41
|
-
* a sign-in's account step. Takes the place of `accessKey`'s `access`.
|
|
42
|
-
*/
|
|
43
|
-
account?: `0x${string}` | undefined;
|
|
44
38
|
/**
|
|
45
39
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
46
40
|
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
package/dist/Actions.js
CHANGED
|
@@ -6,7 +6,6 @@ export * as email from './actions/email.js';
|
|
|
6
6
|
export * as oauth from './actions/oauth.js';
|
|
7
7
|
export * as passkey from './actions/passkey.js';
|
|
8
8
|
export * as provider from './actions/provider.js';
|
|
9
|
-
export * as realm from './actions/realm.js';
|
|
10
9
|
export * as redirect from './actions/redirect.js';
|
|
11
10
|
export * as tempoAccount from './actions/tempoAccount.js';
|
|
12
11
|
/**
|
|
@@ -31,7 +30,6 @@ export async function authorize(auth, options = {}) {
|
|
|
31
30
|
const response = await Api.post(auth, '/v1/authorize', {
|
|
32
31
|
json: request(auth, {
|
|
33
32
|
accessKey: key.accessKey,
|
|
34
|
-
account: options.account,
|
|
35
33
|
challenge: options.challenge,
|
|
36
34
|
permissions: options.permissions,
|
|
37
35
|
}),
|
package/dist/Auth.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export declare namespace RequestError {
|
|
|
87
87
|
uri?: string | undefined;
|
|
88
88
|
};
|
|
89
89
|
/** Each refusal's stable name. `docs/errors.md` explains each one. */
|
|
90
|
-
type Reason = 'already_decided' | 'approval_pending' | 'body_too_large' | 'challenge_not_permitted' | 'cross_site_request' | 'device_code_expired' | 'duplicate_limit' | 'empty_limits' | 'empty_scopes' | 'expiry_exceeds_maximum' | 'expiry_passed' | 'foreign_account' | 'foreign_origin' | 'invalid_chain' | 'invalid_code' | 'invalid_expiry' | 'invalid_field' | 'invalid_origin' | 'invalid_period' | 'invalid_public_key' | 'limit_exceeds_maximum' | 'malformed_body' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | '
|
|
90
|
+
type Reason = 'already_decided' | 'approval_pending' | 'body_too_large' | 'challenge_not_permitted' | 'cross_site_request' | 'device_code_expired' | 'duplicate_limit' | 'empty_limits' | 'empty_scopes' | 'expiry_exceeds_maximum' | 'expiry_passed' | 'foreign_account' | 'foreign_origin' | 'invalid_chain' | 'invalid_code' | 'invalid_expiry' | 'invalid_field' | 'invalid_origin' | 'invalid_period' | 'invalid_public_key' | 'limit_exceeds_maximum' | 'malformed_body' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | 'polling_too_fast' | 'rate_limited' | 'rejected' | 'request_denied' | 'scope_without_limit' | 'session_required' | 'unexpected' | 'unknown_code' | 'unknown_endpoint' | 'unsupported_call' | 'unsupported_step' | 'unsupported_token' | 'upstream_unavailable' | 'webauthn_rejected' | 'webauthn_required';
|
|
91
91
|
}
|
|
92
92
|
/** A client's {@link Account} read before a sign-in set it, or after sign-out emptied it. */
|
|
93
93
|
export declare class SignedOutError extends Error {
|
package/dist/Decorator.d.ts
CHANGED
|
@@ -111,10 +111,6 @@ export declare namespace tempoAuth {
|
|
|
111
111
|
/** `Actions.provider.signIn`. */
|
|
112
112
|
signIn: (options: Actions.provider.signIn.Options) => void;
|
|
113
113
|
};
|
|
114
|
-
realm: {
|
|
115
|
-
/** `Actions.realm.list`. */
|
|
116
|
-
list: () => Promise<Actions.realm.list.ReturnType>;
|
|
117
|
-
};
|
|
118
114
|
redirect: {
|
|
119
115
|
/** `Actions.redirect.complete`, which sets the client's account. */
|
|
120
116
|
complete: (options?: Actions.redirect.complete.Options) => Promise<Actions.redirect.complete.ReturnType>;
|
|
@@ -144,7 +140,7 @@ export declare namespace tempoAuth {
|
|
|
144
140
|
signOut: () => Promise<void>;
|
|
145
141
|
tempoAccount: {
|
|
146
142
|
/** `Actions.tempoAccount.create`. */
|
|
147
|
-
create: (
|
|
143
|
+
create: () => Promise<Actions.tempoAccount.create.ReturnType>;
|
|
148
144
|
/** `Actions.tempoAccount.list`. */
|
|
149
145
|
list: () => Promise<Actions.tempoAccount.list.ReturnType>;
|
|
150
146
|
};
|
package/dist/Decorator.js
CHANGED
|
@@ -156,9 +156,6 @@ export function tempoAuth(options) {
|
|
|
156
156
|
list: () => Actions.provider.list(auth),
|
|
157
157
|
signIn: (options) => Actions.provider.signIn(auth, options),
|
|
158
158
|
},
|
|
159
|
-
realm: {
|
|
160
|
-
list: () => Actions.realm.list(auth),
|
|
161
|
-
},
|
|
162
159
|
redirect: {
|
|
163
160
|
async complete(options = {}) {
|
|
164
161
|
const change = begin();
|
|
@@ -195,7 +192,7 @@ export function tempoAuth(options) {
|
|
|
195
192
|
await Actions.signOut(auth);
|
|
196
193
|
},
|
|
197
194
|
tempoAccount: {
|
|
198
|
-
create: (
|
|
195
|
+
create: () => Actions.tempoAccount.create(auth),
|
|
199
196
|
list: () => Actions.tempoAccount.list(auth),
|
|
200
197
|
},
|
|
201
198
|
},
|
package/dist/Step.d.ts
CHANGED
|
@@ -2,20 +2,8 @@
|
|
|
2
2
|
* A step a sign-in needs before it finishes, such as the SSO connection an address requires.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A step a sign-in needs before it finishes: the SSO connection an address requires, or the choice
|
|
8
|
-
* of account for a user with more than one Tempo Account.
|
|
9
|
-
*/
|
|
5
|
+
/** A step a sign-in needs before it finishes, such as the SSO connection an address requires. */
|
|
10
6
|
export type Step = {
|
|
11
|
-
/** The user's Tempo Accounts: the one the browser selected before first, then oldest first. */
|
|
12
|
-
accounts: readonly TempoAccount[];
|
|
13
|
-
/**
|
|
14
|
-
* The kind of step. The user is signed in, and chooses an account, whose `address`
|
|
15
|
-
* `Actions.authorize` takes as `account`.
|
|
16
|
-
*/
|
|
17
|
-
type: 'account';
|
|
18
|
-
} | {
|
|
19
7
|
/** The kind of step. */
|
|
20
8
|
type: 'sso';
|
|
21
9
|
/** Where `Actions.provider.signIn` sends the browser to take the step. */
|
package/dist/TempoAccount.d.ts
CHANGED
|
@@ -12,25 +12,13 @@ export type TempoAccount = {
|
|
|
12
12
|
* that may refuse a key authorization.
|
|
13
13
|
*/
|
|
14
14
|
owner: 'privy' | 'webAuthn' | (string & {});
|
|
15
|
-
/**
|
|
16
|
-
* The realm the account belongs to: `default`, or one the app's settings name, such as
|
|
17
|
-
* `tempo-cash`, with its display name. An app reaches only the accounts of its realms.
|
|
18
|
-
*/
|
|
19
|
-
realm: {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
15
|
};
|
|
24
16
|
/**
|
|
25
17
|
* Instantiates a {@link TempoAccount}.
|
|
26
18
|
*
|
|
27
19
|
* @example
|
|
28
20
|
* ```ts
|
|
29
|
-
* const tempoAccount = TempoAccount.from({
|
|
30
|
-
* address: '0x…',
|
|
31
|
-
* owner: 'privy',
|
|
32
|
-
* realm: { id: 'default', name: 'Tempo' },
|
|
33
|
-
* })
|
|
21
|
+
* const tempoAccount = TempoAccount.from({ address: '0x…', owner: 'privy' })
|
|
34
22
|
* ```
|
|
35
23
|
*/
|
|
36
24
|
export declare function from(value: TempoAccount): TempoAccount;
|
package/dist/TempoAccount.js
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* ```ts
|
|
6
|
-
* const tempoAccount = TempoAccount.from({
|
|
7
|
-
* address: '0x…',
|
|
8
|
-
* owner: 'privy',
|
|
9
|
-
* realm: { id: 'default', name: 'Tempo' },
|
|
10
|
-
* })
|
|
6
|
+
* const tempoAccount = TempoAccount.from({ address: '0x…', owner: 'privy' })
|
|
11
7
|
* ```
|
|
12
8
|
*/
|
|
13
9
|
export function from(value) {
|
package/dist/actions/device.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare namespace authorize {
|
|
|
18
18
|
type Options<chainId extends number = number> = {
|
|
19
19
|
/**
|
|
20
20
|
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
21
|
-
* defaults to the
|
|
21
|
+
* defaults to the user's first. Defaults to a new key.
|
|
22
22
|
*/
|
|
23
23
|
accessKey?: Account.Account | undefined;
|
|
24
24
|
/**
|
package/dist/actions/email.d.ts
CHANGED
|
@@ -24,15 +24,12 @@ export declare namespace sendCode {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Signs the user in with the code they were emailed, and authorizes the app in the same call.
|
|
27
|
-
* Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues
|
|
28
|
-
* or when the user has more than one Tempo Account, whose chosen `address` `Actions.authorize` takes
|
|
29
|
-
* as `account`.
|
|
27
|
+
* Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues.
|
|
30
28
|
*
|
|
31
29
|
* @example
|
|
32
30
|
* ```ts
|
|
33
31
|
* const result = await Actions.email.signIn(auth, { code, email })
|
|
34
|
-
* if ('step' in result
|
|
35
|
-
* Actions.provider.signIn(auth, { url: result.step.url })
|
|
32
|
+
* if ('step' in result) Actions.provider.signIn(auth, { url: result.step.url })
|
|
36
33
|
* ```
|
|
37
34
|
*/
|
|
38
35
|
export declare function signIn<const chainId extends number = number>(auth: Auth, options: signIn.Options<chainId>): Promise<signIn.ReturnType<chainId>>;
|
|
@@ -40,7 +37,7 @@ export declare namespace signIn {
|
|
|
40
37
|
type Options<chainId extends number = number> = {
|
|
41
38
|
/**
|
|
42
39
|
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
43
|
-
* defaults to the
|
|
40
|
+
* defaults to the user's first. Defaults to a new key.
|
|
44
41
|
*/
|
|
45
42
|
accessKey?: Account.Account | undefined;
|
|
46
43
|
/**
|
|
@@ -63,7 +60,7 @@ export declare namespace signIn {
|
|
|
63
60
|
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
|
64
61
|
permissions?: Permissions<chainId> | undefined;
|
|
65
62
|
};
|
|
66
|
-
/** The authorization, or the step the address
|
|
63
|
+
/** The authorization, or the step the address requires first. */
|
|
67
64
|
type ReturnType<chainId extends number = number> = Authorization<chainId> | {
|
|
68
65
|
step: Step;
|
|
69
66
|
};
|
package/dist/actions/email.js
CHANGED
|
@@ -15,15 +15,12 @@ export async function sendCode(auth, options) {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Signs the user in with the code they were emailed, and authorizes the app in the same call.
|
|
18
|
-
* Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues
|
|
19
|
-
* or when the user has more than one Tempo Account, whose chosen `address` `Actions.authorize` takes
|
|
20
|
-
* as `account`.
|
|
18
|
+
* Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues.
|
|
21
19
|
*
|
|
22
20
|
* @example
|
|
23
21
|
* ```ts
|
|
24
22
|
* const result = await Actions.email.signIn(auth, { code, email })
|
|
25
|
-
* if ('step' in result
|
|
26
|
-
* Actions.provider.signIn(auth, { url: result.step.url })
|
|
23
|
+
* if ('step' in result) Actions.provider.signIn(auth, { url: result.step.url })
|
|
27
24
|
* ```
|
|
28
25
|
*/
|
|
29
26
|
export async function signIn(auth, options) {
|
|
@@ -49,17 +46,9 @@ export async function signIn(auth, options) {
|
|
|
49
46
|
// rather than discard the authorization.
|
|
50
47
|
if (kept && link)
|
|
51
48
|
await Link.release(auth, { link }).catch(() => undefined);
|
|
52
|
-
if ('step' in body)
|
|
53
|
-
if (body.step.type === 'account')
|
|
54
|
-
return {
|
|
55
|
-
step: {
|
|
56
|
-
accounts: body.step.accounts.map(Api.tempoAccount),
|
|
57
|
-
type: 'account',
|
|
58
|
-
},
|
|
59
|
-
};
|
|
49
|
+
if ('step' in body)
|
|
60
50
|
return {
|
|
61
51
|
step: { ...body.step, url: new URL(body.step.url, auth.url).href },
|
|
62
52
|
};
|
|
63
|
-
}
|
|
64
53
|
return Api.authorization(body.authorization, key);
|
|
65
54
|
}
|
|
@@ -9,7 +9,6 @@ import type { Account } from 'viem/tempo';
|
|
|
9
9
|
import type { Auth } from '../Auth.ts';
|
|
10
10
|
import type { Authorization } from '../Authorization.ts';
|
|
11
11
|
import type { Permissions } from '../Permissions.ts';
|
|
12
|
-
import type { Step } from '../Step.ts';
|
|
13
12
|
/**
|
|
14
13
|
* Signs the user in with a passkey, and authorizes the app in the same call. On a page, the
|
|
15
14
|
* passkey's one assertion also signs the app's key when that passkey owns the Tempo Account, since
|
|
@@ -34,7 +33,7 @@ export declare namespace signIn {
|
|
|
34
33
|
type Options<chainId extends number = number> = {
|
|
35
34
|
/**
|
|
36
35
|
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
37
|
-
* defaults to the
|
|
36
|
+
* defaults to the user's first. Defaults to a new key.
|
|
38
37
|
*/
|
|
39
38
|
accessKey?: Account.Account | undefined;
|
|
40
39
|
/**
|
|
@@ -75,14 +74,8 @@ export declare namespace signIn {
|
|
|
75
74
|
/** The kind of step. */
|
|
76
75
|
type: 'email';
|
|
77
76
|
};
|
|
78
|
-
/**
|
|
79
|
-
* The authorization, the email step, or the account step of a user with more than one Tempo
|
|
80
|
-
* Account. A passkey that owns one of the user's accounts selects it, so only a passkey that owns
|
|
81
|
-
* none returns the account step.
|
|
82
|
-
*/
|
|
77
|
+
/** The authorization, or the email step. */
|
|
83
78
|
type ReturnType<chainId extends number = number> = Authorization<chainId> | {
|
|
84
|
-
step: EmailStep
|
|
85
|
-
type: 'account';
|
|
86
|
-
}>;
|
|
79
|
+
step: EmailStep;
|
|
87
80
|
};
|
|
88
81
|
}
|
package/dist/actions/passkey.js
CHANGED
|
@@ -54,13 +54,6 @@ export async function signIn(auth, options = {}) {
|
|
|
54
54
|
json: native ? { assertion, authorize } : { assertion },
|
|
55
55
|
}));
|
|
56
56
|
if ('step' in body) {
|
|
57
|
-
if (body.step.type === 'account')
|
|
58
|
-
return {
|
|
59
|
-
step: {
|
|
60
|
-
accounts: body.step.accounts.map(Api.tempoAccount),
|
|
61
|
-
type: 'account',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
57
|
// The emailed-code sign-in that sends the link returns this key's authorization, so a key the
|
|
65
58
|
// library generated waits for it in `storage`.
|
|
66
59
|
if (body.step.signed && !options.accessKey)
|
|
@@ -42,7 +42,7 @@ export declare namespace createUrl {
|
|
|
42
42
|
type Options = {
|
|
43
43
|
/**
|
|
44
44
|
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
45
|
-
* defaults to the
|
|
45
|
+
* defaults to the user's first. Defaults to a new key, whose material `pending` keeps.
|
|
46
46
|
*/
|
|
47
47
|
accessKey?: Account.Account | undefined;
|
|
48
48
|
/**
|
|
@@ -5,32 +5,24 @@
|
|
|
5
5
|
import type { Auth } from '../Auth.ts';
|
|
6
6
|
import type { TempoAccount } from '../TempoAccount.ts';
|
|
7
7
|
/**
|
|
8
|
-
* Creates another Tempo Account for the signed-in user,
|
|
9
|
-
*
|
|
8
|
+
* Creates another Tempo Account for the signed-in user, and returns it. Pass its `address` as the
|
|
9
|
+
* `access` of an access key to authorize keys on it.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth
|
|
13
|
+
* const tempoAccount = await Actions.tempoAccount.create(auth)
|
|
14
14
|
* await Actions.authorize(auth, {
|
|
15
15
|
* accessKey: { ...accessKey, account: tempoAccount.address },
|
|
16
16
|
* })
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function create(auth: Auth
|
|
19
|
+
export declare function create(auth: Auth): Promise<create.ReturnType>;
|
|
20
20
|
export declare namespace create {
|
|
21
|
-
type Options = {
|
|
22
|
-
/**
|
|
23
|
-
* The realm that holds the account, one that `Actions.realm.list` returns. Defaults to the app's
|
|
24
|
-
* first realm.
|
|
25
|
-
*/
|
|
26
|
-
realm?: string | undefined;
|
|
27
|
-
};
|
|
28
21
|
/** The new account. */
|
|
29
22
|
type ReturnType = TempoAccount;
|
|
30
23
|
}
|
|
31
24
|
/**
|
|
32
|
-
* Lists the signed-in user's Tempo Accounts
|
|
33
|
-
* one they selected at sign-in, or else their oldest.
|
|
25
|
+
* Lists the signed-in user's Tempo Accounts, their default first.
|
|
34
26
|
*
|
|
35
27
|
* @example
|
|
36
28
|
* ```ts
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import * as Api from '../internal/api.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates another Tempo Account for the signed-in user,
|
|
4
|
-
*
|
|
3
|
+
* Creates another Tempo Account for the signed-in user, and returns it. Pass its `address` as the
|
|
4
|
+
* `access` of an access key to authorize keys on it.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth
|
|
8
|
+
* const tempoAccount = await Actions.tempoAccount.create(auth)
|
|
9
9
|
* await Actions.authorize(auth, {
|
|
10
10
|
* accessKey: { ...accessKey, account: tempoAccount.address },
|
|
11
11
|
* })
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export async function create(auth
|
|
15
|
-
return
|
|
14
|
+
export async function create(auth) {
|
|
15
|
+
return toTempoAccount(await Api.json(await Api.post(auth, '/v1/account/tempo', { json: {} })));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Lists the signed-in user's Tempo Accounts
|
|
19
|
-
* one they selected at sign-in, or else their oldest.
|
|
18
|
+
* Lists the signed-in user's Tempo Accounts, their default first.
|
|
20
19
|
*
|
|
21
20
|
* @example
|
|
22
21
|
* ```ts
|
|
@@ -24,6 +23,15 @@ export async function create(auth, options = {}) {
|
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
export async function list(auth) {
|
|
27
|
-
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL(
|
|
28
|
-
|
|
26
|
+
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL('/v1/account', auth.url), {
|
|
27
|
+
credentials: 'include',
|
|
28
|
+
}));
|
|
29
|
+
return tempo.map(toTempoAccount);
|
|
30
|
+
}
|
|
31
|
+
/** Reads the account's address and the type of its owner, which the API lists first. */
|
|
32
|
+
function toTempoAccount(account) {
|
|
33
|
+
return {
|
|
34
|
+
address: account.address,
|
|
35
|
+
owner: account.config.owners[0].type,
|
|
36
|
+
};
|
|
29
37
|
}
|
package/dist/internal/api.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { Account } from 'viem/tempo';
|
|
|
3
3
|
import { type Auth, RequestError } from '../Auth.ts';
|
|
4
4
|
import type { Authorization } from '../Authorization.ts';
|
|
5
5
|
import * as Key from '../Key.ts';
|
|
6
|
-
import type { TempoAccount } from '../TempoAccount.ts';
|
|
7
6
|
import type { Tokens } from '../Tokens.ts';
|
|
8
7
|
/**
|
|
9
8
|
* Builds an authorization from what Tempo Auth returned and the sign-in's key: the material the
|
|
@@ -14,14 +13,6 @@ export declare function authorization<chainId extends number = number>(body: Hea
|
|
|
14
13
|
accessKey?: Account.Account | undefined;
|
|
15
14
|
material: Key.Material;
|
|
16
15
|
}): Authorization<chainId>;
|
|
17
|
-
/**
|
|
18
|
-
* A sign-in's account step as the API returns it: the accounts of a user with more than one, who
|
|
19
|
-
* selects one before a key is authorized.
|
|
20
|
-
*/
|
|
21
|
-
export type AccountStep = {
|
|
22
|
-
accounts: readonly TempoAccountResponse[];
|
|
23
|
-
type: 'account';
|
|
24
|
-
};
|
|
25
16
|
/** What the headless API returns for an authorization. */
|
|
26
17
|
export type Headless = {
|
|
27
18
|
account: Key.Key['account'];
|
|
@@ -52,23 +43,6 @@ export declare function post(auth: Auth, path: string, options: {
|
|
|
52
43
|
* OAuth form posts to WorkOS.
|
|
53
44
|
*/
|
|
54
45
|
export declare function token(auth: Auth, body: Record<string, string>): Promise<TokenResponse>;
|
|
55
|
-
/** Reads the account's address, the type of its owner, which the API lists first, and its realm. */
|
|
56
|
-
export declare function tempoAccount(account: TempoAccountResponse): TempoAccount;
|
|
57
|
-
/** A Tempo Account as the API returns it, with the fields the package reads. */
|
|
58
|
-
export type TempoAccountResponse = {
|
|
59
|
-
address: `0x${string}`;
|
|
60
|
-
config: {
|
|
61
|
-
owners: readonly [{
|
|
62
|
-
type: string;
|
|
63
|
-
}, ...{
|
|
64
|
-
type: string;
|
|
65
|
-
}[]];
|
|
66
|
-
};
|
|
67
|
-
realm: {
|
|
68
|
-
id: string;
|
|
69
|
-
name: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
46
|
/** What Tempo Auth's token endpoint returns. Redeeming a redirect's code adds its key authorization. */
|
|
73
47
|
export type TokenResponse = {
|
|
74
48
|
access_token: string;
|
package/dist/internal/api.js
CHANGED
|
@@ -71,14 +71,6 @@ export async function token(auth, body) {
|
|
|
71
71
|
method: 'POST',
|
|
72
72
|
}));
|
|
73
73
|
}
|
|
74
|
-
/** Reads the account's address, the type of its owner, which the API lists first, and its realm. */
|
|
75
|
-
export function tempoAccount(account) {
|
|
76
|
-
return {
|
|
77
|
-
address: account.address,
|
|
78
|
-
owner: account.config.owners[0].type,
|
|
79
|
-
realm: { id: account.realm.id, name: account.realm.name },
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
74
|
/** Reads a token response into `Tokens`. */
|
|
83
75
|
export function tokens(response) {
|
|
84
76
|
return {
|
|
@@ -7,8 +7,6 @@ import type { Permissions } from '../Permissions.ts';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function request(auth: Auth, options: {
|
|
9
9
|
accessKey: Account.Account;
|
|
10
|
-
/** The user's Tempo Account the key acts for, in place of the one `accessKey` names. */
|
|
11
|
-
account?: `0x${string}` | undefined;
|
|
12
10
|
/** A message the key's witness binds. */
|
|
13
11
|
challenge?: string | undefined;
|
|
14
12
|
permissions?: Permissions | undefined;
|
package/dist/internal/request.js
CHANGED
|
@@ -10,13 +10,11 @@ import { Hex } from 'ox';
|
|
|
10
10
|
*/
|
|
11
11
|
export function request(auth, options) {
|
|
12
12
|
const { accessKey, challenge, permissions = {} } = options;
|
|
13
|
-
const account = options.account ??
|
|
14
|
-
(accessKey.accessKeyAddress ? accessKey.address : undefined);
|
|
15
13
|
return {
|
|
16
14
|
...(challenge === undefined ? {} : { challenge }),
|
|
17
15
|
client_id: auth.clientId,
|
|
18
16
|
key_authorization: {
|
|
19
|
-
...(
|
|
17
|
+
...(accessKey.accessKeyAddress ? { account: accessKey.address } : {}),
|
|
20
18
|
address: accessKey.accessKeyAddress ?? accessKey.address,
|
|
21
19
|
chainId: Hex.fromNumber(permissions.chainId ?? auth.chainId),
|
|
22
20
|
expiry: permissions.expiry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempoxyz/auth",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-91.sha-bdc606a",
|
|
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": {
|
package/dist/actions/realm.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lists the realms the app reaches: the sets of Tempo Accounts its settings name.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type { Auth } from '../Auth.ts';
|
|
6
|
-
/**
|
|
7
|
-
* Lists the realms the app reaches, in its settings' order. The first holds the accounts
|
|
8
|
-
* `Actions.tempoAccount.create` adds unless it names another.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const realms = await Actions.realm.list(auth)
|
|
13
|
-
* // [{ id: 'default', name: 'Tempo', passkeys: true }]
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function list(auth: Auth): Promise<list.ReturnType>;
|
|
17
|
-
export declare namespace list {
|
|
18
|
-
type ReturnType = readonly {
|
|
19
|
-
/** The realm ID, such as `default` or `tempo-cash`, which `Actions.tempoAccount.create` takes. */
|
|
20
|
-
id: string;
|
|
21
|
-
/** The realm's display name, such as `Tempo Cash`. */
|
|
22
|
-
name: string;
|
|
23
|
-
/** Whether passkeys own accounts in the realm. Only the default realm holds them. */
|
|
24
|
-
passkeys: boolean;
|
|
25
|
-
}[];
|
|
26
|
-
}
|
package/dist/actions/realm.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as Api from '../internal/api.js';
|
|
2
|
-
/**
|
|
3
|
-
* Lists the realms the app reaches, in its settings' order. The first holds the accounts
|
|
4
|
-
* `Actions.tempoAccount.create` adds unless it names another.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const realms = await Actions.realm.list(auth)
|
|
9
|
-
* // [{ id: 'default', name: 'Tempo', passkeys: true }]
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export async function list(auth) {
|
|
13
|
-
const { realms } = await Api.json(await (auth.fetch ?? fetch)(new URL(`/v1/realms?${new URLSearchParams({ client_id: auth.clientId })}`, auth.url)));
|
|
14
|
-
return realms;
|
|
15
|
-
}
|