@tempoxyz/auth 0.0.0-pr-87.sha-459d55d → 0.0.0-pr-87.sha-cf6fb2e
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 -0
- package/dist/Actions.js +1 -0
- package/dist/Auth.d.ts +1 -1
- package/dist/Decorator.d.ts +5 -1
- package/dist/Decorator.js +4 -1
- package/dist/actions/realm.d.ts +26 -0
- package/dist/actions/realm.js +15 -0
- package/dist/actions/tempoAccount.d.ts +11 -4
- package/dist/actions/tempoAccount.js +5 -5
- package/package.json +1 -1
package/dist/Actions.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ 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';
|
|
17
18
|
export * as redirect from './actions/redirect.ts';
|
|
18
19
|
export * as tempoAccount from './actions/tempoAccount.ts';
|
|
19
20
|
/**
|
package/dist/Actions.js
CHANGED
|
@@ -6,6 +6,7 @@ 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';
|
|
9
10
|
export * as redirect from './actions/redirect.js';
|
|
10
11
|
export * as tempoAccount from './actions/tempoAccount.js';
|
|
11
12
|
/**
|
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' | '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';
|
|
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' | 'realm_not_permitted' | '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,6 +111,10 @@ 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
|
+
};
|
|
114
118
|
redirect: {
|
|
115
119
|
/** `Actions.redirect.complete`, which sets the client's account. */
|
|
116
120
|
complete: (options?: Actions.redirect.complete.Options) => Promise<Actions.redirect.complete.ReturnType>;
|
|
@@ -140,7 +144,7 @@ export declare namespace tempoAuth {
|
|
|
140
144
|
signOut: () => Promise<void>;
|
|
141
145
|
tempoAccount: {
|
|
142
146
|
/** `Actions.tempoAccount.create`. */
|
|
143
|
-
create: () => Promise<Actions.tempoAccount.create.ReturnType>;
|
|
147
|
+
create: (options?: Actions.tempoAccount.create.Options) => Promise<Actions.tempoAccount.create.ReturnType>;
|
|
144
148
|
/** `Actions.tempoAccount.list`. */
|
|
145
149
|
list: () => Promise<Actions.tempoAccount.list.ReturnType>;
|
|
146
150
|
};
|
package/dist/Decorator.js
CHANGED
|
@@ -156,6 +156,9 @@ 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
|
+
},
|
|
159
162
|
redirect: {
|
|
160
163
|
async complete(options = {}) {
|
|
161
164
|
const change = begin();
|
|
@@ -192,7 +195,7 @@ export function tempoAuth(options) {
|
|
|
192
195
|
await Actions.signOut(auth);
|
|
193
196
|
},
|
|
194
197
|
tempoAccount: {
|
|
195
|
-
create: () => Actions.tempoAccount.create(auth),
|
|
198
|
+
create: (options) => Actions.tempoAccount.create(auth, options),
|
|
196
199
|
list: () => Actions.tempoAccount.list(auth),
|
|
197
200
|
},
|
|
198
201
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -5,19 +5,26 @@
|
|
|
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
|
-
* its `address` as the `access` of an access key to authorize keys on it.
|
|
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
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth)
|
|
13
|
+
* const tempoAccount = await Actions.tempoAccount.create(auth, { realm: 'tempo-cash' })
|
|
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): Promise<create.ReturnType>;
|
|
19
|
+
export declare function create(auth: Auth, options?: create.Options): 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
|
+
};
|
|
21
28
|
/** The new account. */
|
|
22
29
|
type ReturnType = TempoAccount;
|
|
23
30
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as Api from '../internal/api.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates another Tempo Account for the signed-in user
|
|
4
|
-
* its `address` as the `access` of an access key to authorize keys on it.
|
|
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
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* const tempoAccount = await Actions.tempoAccount.create(auth)
|
|
8
|
+
* const tempoAccount = await Actions.tempoAccount.create(auth, { realm: 'tempo-cash' })
|
|
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 Api.tempoAccount(await Api.json(await Api.post(auth, `/v1/account/tempo?${new URLSearchParams({ client_id: auth.clientId })}`, { json: {} })));
|
|
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
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Lists the signed-in user's Tempo Accounts that the app's settings include, their default first: the
|
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-cf6fb2e",
|
|
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": {
|