@tempoxyz/auth 0.0.0-pr-87.sha-e2f2851 → 0.0.0-pr-87.sha-36a8c57
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 -1
- package/dist/Actions.js +1 -1
- package/dist/Auth.d.ts +1 -1
- package/dist/Decorator.d.ts +4 -6
- package/dist/Decorator.js +3 -4
- package/dist/actions/account.d.ts +22 -0
- package/dist/actions/account.js +17 -0
- package/dist/actions/realm.d.ts +2 -3
- package/dist/actions/realm.js +1 -2
- package/package.json +1 -1
- package/dist/actions/tempoAccount.d.ts +0 -44
- package/dist/actions/tempoAccount.js +0 -29
package/dist/Actions.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { Auth } from './Auth.ts';
|
|
|
9
9
|
import type { Authorization } from './Authorization.ts';
|
|
10
10
|
import type { Permissions } from './Permissions.ts';
|
|
11
11
|
import type { Tokens } from './Tokens.ts';
|
|
12
|
+
export * as account from './actions/account.ts';
|
|
12
13
|
export * as device from './actions/device.ts';
|
|
13
14
|
export * as email from './actions/email.ts';
|
|
14
15
|
export * as oauth from './actions/oauth.ts';
|
|
@@ -16,7 +17,6 @@ export * as passkey from './actions/passkey.ts';
|
|
|
16
17
|
export * as provider from './actions/provider.ts';
|
|
17
18
|
export * as realm from './actions/realm.ts';
|
|
18
19
|
export * as redirect from './actions/redirect.ts';
|
|
19
|
-
export * as tempoAccount from './actions/tempoAccount.ts';
|
|
20
20
|
/**
|
|
21
21
|
* Authorizes the app for a user already signed in to Tempo Auth, from any app. Returns
|
|
22
22
|
* `undefined` without a session, so the app shows sign-in. The key must fit Tempo Auth's headless
|
package/dist/Actions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as AccessKey from './internal/accessKey.js';
|
|
2
2
|
import * as Api from './internal/api.js';
|
|
3
3
|
import { request } from './internal/request.js';
|
|
4
|
+
export * as account from './actions/account.js';
|
|
4
5
|
export * as device from './actions/device.js';
|
|
5
6
|
export * as email from './actions/email.js';
|
|
6
7
|
export * as oauth from './actions/oauth.js';
|
|
@@ -8,7 +9,6 @@ export * as passkey from './actions/passkey.js';
|
|
|
8
9
|
export * as provider from './actions/provider.js';
|
|
9
10
|
export * as realm from './actions/realm.js';
|
|
10
11
|
export * as redirect from './actions/redirect.js';
|
|
11
|
-
export * as tempoAccount from './actions/tempoAccount.js';
|
|
12
12
|
/**
|
|
13
13
|
* Authorizes the app for a user already signed in to Tempo Auth, from any app. Returns
|
|
14
14
|
* `undefined` without a session, so the app shows sign-in. The key must fit Tempo Auth's headless
|
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' | 'passkey_not_permitted' | 'polling_too_fast' | 'rate_limited' | '
|
|
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' | 'passkey_not_permitted' | '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
|
@@ -70,6 +70,10 @@ export declare namespace tempoAuth {
|
|
|
70
70
|
type Decorator<chainId extends number> = {
|
|
71
71
|
/** Tempo Auth's actions, with the extension's instance. */
|
|
72
72
|
auth: {
|
|
73
|
+
account: {
|
|
74
|
+
/** `Actions.account.get`. */
|
|
75
|
+
get: () => Promise<Actions.account.get.ReturnType>;
|
|
76
|
+
};
|
|
73
77
|
/**
|
|
74
78
|
* `Actions.authorize`, which sets the client's account, or empties it when the user has no
|
|
75
79
|
* session.
|
|
@@ -142,12 +146,6 @@ export declare namespace tempoAuth {
|
|
|
142
146
|
* fails, and discards any sign-in still pending.
|
|
143
147
|
*/
|
|
144
148
|
signOut: () => Promise<void>;
|
|
145
|
-
tempoAccount: {
|
|
146
|
-
/** `Actions.tempoAccount.create`. */
|
|
147
|
-
create: (options?: Actions.tempoAccount.create.Options) => Promise<Actions.tempoAccount.create.ReturnType>;
|
|
148
|
-
/** `Actions.tempoAccount.list`. */
|
|
149
|
-
list: () => Promise<Actions.tempoAccount.list.ReturnType>;
|
|
150
|
-
};
|
|
151
149
|
};
|
|
152
150
|
};
|
|
153
151
|
}
|
package/dist/Decorator.js
CHANGED
|
@@ -98,6 +98,9 @@ export function tempoAuth(options) {
|
|
|
98
98
|
};
|
|
99
99
|
return {
|
|
100
100
|
auth: {
|
|
101
|
+
account: {
|
|
102
|
+
get: () => Actions.account.get(auth),
|
|
103
|
+
},
|
|
101
104
|
async authorize(options = {}) {
|
|
102
105
|
const change = begin();
|
|
103
106
|
const authorization = await Actions.authorize(auth, options);
|
|
@@ -194,10 +197,6 @@ export function tempoAuth(options) {
|
|
|
194
197
|
signedOut = version;
|
|
195
198
|
await Actions.signOut(auth);
|
|
196
199
|
},
|
|
197
|
-
tempoAccount: {
|
|
198
|
-
create: (options) => Actions.tempoAccount.create(auth, options),
|
|
199
|
-
list: () => Actions.tempoAccount.list(auth),
|
|
200
|
-
},
|
|
201
200
|
},
|
|
202
201
|
};
|
|
203
202
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the signed-in user's Tempo Account for the app, with its realm.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import type { Auth } from '../Auth.ts';
|
|
6
|
+
import type { TempoAccount } from '../TempoAccount.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Returns the signed-in user's Tempo Account for the app: the one they selected at sign-in, or else
|
|
9
|
+
* their oldest in the app's realms, with its `realm`. A user with no account in the app's realms
|
|
10
|
+
* receives one in its first.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const tempoAccount = await Actions.account.get(auth)
|
|
15
|
+
* // { address: '0x…', owner: 'privy', realm: { id: 'tempo-cash', name: 'Tempo Cash' } }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function get(auth: Auth): Promise<get.ReturnType>;
|
|
19
|
+
export declare namespace get {
|
|
20
|
+
/** The user's Tempo Account for the app. */
|
|
21
|
+
type ReturnType = TempoAccount;
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as Api from '../internal/api.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the signed-in user's Tempo Account for the app: the one they selected at sign-in, or else
|
|
4
|
+
* their oldest in the app's realms, with its `realm`. A user with no account in the app's realms
|
|
5
|
+
* receives one in its first.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const tempoAccount = await Actions.account.get(auth)
|
|
10
|
+
* // { address: '0x…', owner: 'privy', realm: { id: 'tempo-cash', name: 'Tempo Cash' } }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export async function get(auth) {
|
|
14
|
+
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL(`/v1/account?${new URLSearchParams({ client_id: auth.clientId })}`, auth.url), { credentials: 'include' }));
|
|
15
|
+
// Tempo Auth lists the account the app uses first, and always lists one.
|
|
16
|
+
return Api.tempoAccount(tempo[0]);
|
|
17
|
+
}
|
package/dist/actions/realm.d.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Auth } from '../Auth.ts';
|
|
6
6
|
/**
|
|
7
|
-
* Lists the realms the app reaches, in its settings' order. The first holds
|
|
8
|
-
* `Actions.tempoAccount.create` adds unless it names another.
|
|
7
|
+
* Lists the realms the app reaches, in its settings' order. The first holds a user's first account.
|
|
9
8
|
*
|
|
10
9
|
* @example
|
|
11
10
|
* ```ts
|
|
@@ -16,7 +15,7 @@ import type { Auth } from '../Auth.ts';
|
|
|
16
15
|
export declare function list(auth: Auth): Promise<list.ReturnType>;
|
|
17
16
|
export declare namespace list {
|
|
18
17
|
type ReturnType = readonly {
|
|
19
|
-
/** The realm ID, such as `default` or `tempo-cash
|
|
18
|
+
/** The realm ID, such as `default` or `tempo-cash`. */
|
|
20
19
|
id: string;
|
|
21
20
|
/** The realm's display name, such as `Tempo Cash`. */
|
|
22
21
|
name: string;
|
package/dist/actions/realm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Api from '../internal/api.js';
|
|
2
2
|
/**
|
|
3
|
-
* Lists the realms the app reaches, in its settings' order. The first holds
|
|
4
|
-
* `Actions.tempoAccount.create` adds unless it names another.
|
|
3
|
+
* Lists the realms the app reaches, in its settings' order. The first holds a user's first account.
|
|
5
4
|
*
|
|
6
5
|
* @example
|
|
7
6
|
* ```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempoxyz/auth",
|
|
3
|
-
"version": "0.0.0-pr-87.sha-
|
|
3
|
+
"version": "0.0.0-pr-87.sha-36a8c57",
|
|
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": {
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages the signed-in user's Tempo Accounts.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type { Auth } from '../Auth.ts';
|
|
6
|
-
import type { TempoAccount } from '../TempoAccount.ts';
|
|
7
|
-
/**
|
|
8
|
-
* Creates another Tempo Account for the signed-in user, in `realm` or the app's first realm, and
|
|
9
|
-
* returns it. Pass its `address` as the `access` of an access key to authorize keys on it.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth, { realm: 'tempo-cash' })
|
|
14
|
-
* await Actions.authorize(auth, {
|
|
15
|
-
* accessKey: { ...accessKey, account: tempoAccount.address },
|
|
16
|
-
* })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function create(auth: Auth, options?: create.Options): Promise<create.ReturnType>;
|
|
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
|
-
/** The new account. */
|
|
29
|
-
type ReturnType = TempoAccount;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Lists the signed-in user's Tempo Accounts that the app's settings include, their default first: the
|
|
33
|
-
* one they selected at sign-in, or else their oldest.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const [account, ...others] = await Actions.tempoAccount.list(auth)
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function list(auth: Auth): Promise<list.ReturnType>;
|
|
41
|
-
export declare namespace list {
|
|
42
|
-
/** The user's accounts, their default first. */
|
|
43
|
-
type ReturnType = readonly TempoAccount[];
|
|
44
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as Api from '../internal/api.js';
|
|
2
|
-
/**
|
|
3
|
-
* Creates another Tempo Account for the signed-in user, in `realm` or the app's first realm, and
|
|
4
|
-
* returns it. Pass its `address` as the `access` of an access key to authorize keys on it.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth, { realm: 'tempo-cash' })
|
|
9
|
-
* await Actions.authorize(auth, {
|
|
10
|
-
* accessKey: { ...accessKey, account: tempoAccount.address },
|
|
11
|
-
* })
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export async function create(auth, options = {}) {
|
|
15
|
-
return Api.tempoAccount(await Api.json(await Api.post(auth, `/v1/account/tempo?${new URLSearchParams({ client_id: auth.clientId })}`, { json: options.realm ? { realm: options.realm } : {} })));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Lists the signed-in user's Tempo Accounts that the app's settings include, their default first: the
|
|
19
|
-
* one they selected at sign-in, or else their oldest.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* const [account, ...others] = await Actions.tempoAccount.list(auth)
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export async function list(auth) {
|
|
27
|
-
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL(`/v1/account?${new URLSearchParams({ client_id: auth.clientId })}`, auth.url), { credentials: 'include' }));
|
|
28
|
-
return tempo.map(Api.tempoAccount);
|
|
29
|
-
}
|