@tempoxyz/auth 0.0.0-pr-73.sha-163f721 → 0.0.0-pr-72.sha-b9acf1a
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 +0 -1
- package/dist/Actions.js +0 -1
- package/dist/Auth.d.ts +1 -1
- package/dist/Decorator.d.ts +0 -4
- package/dist/Decorator.js +0 -9
- package/dist/Permissions.d.ts +2 -9
- package/dist/actions/email.d.ts +0 -5
- package/dist/actions/email.js +1 -2
- package/dist/internal/request.d.ts +0 -1
- package/dist/internal/request.js +0 -1
- package/package.json +1 -1
- package/dist/actions/passkey.d.ts +0 -53
- package/dist/actions/passkey.js +0 -41
package/dist/Actions.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ import type { Tokens } from './Tokens.ts';
|
|
|
12
12
|
export * as device from './actions/device.ts';
|
|
13
13
|
export * as email from './actions/email.ts';
|
|
14
14
|
export * as oauth from './actions/oauth.ts';
|
|
15
|
-
export * as passkey from './actions/passkey.ts';
|
|
16
15
|
export * as provider from './actions/provider.ts';
|
|
17
16
|
export * as redirect from './actions/redirect.ts';
|
|
18
17
|
export * as tempoAccount from './actions/tempoAccount.ts';
|
package/dist/Actions.js
CHANGED
|
@@ -4,7 +4,6 @@ import { request } from './internal/request.js';
|
|
|
4
4
|
export * as device from './actions/device.js';
|
|
5
5
|
export * as email from './actions/email.js';
|
|
6
6
|
export * as oauth from './actions/oauth.js';
|
|
7
|
-
export * as passkey from './actions/passkey.js';
|
|
8
7
|
export * as provider from './actions/provider.js';
|
|
9
8
|
export * as redirect from './actions/redirect.js';
|
|
10
9
|
export * as tempoAccount from './actions/tempoAccount.js';
|
package/dist/Auth.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare namespace RequestError {
|
|
|
86
86
|
uri?: string | undefined;
|
|
87
87
|
};
|
|
88
88
|
/** Each refusal's stable name. `docs/errors.md` explains each one. */
|
|
89
|
-
type Reason = 'already_decided' | 'approval_pending' | 'body_too_large' | '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_public_key' | 'limit_exceeds_maximum' | 'malformed_body' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | '
|
|
89
|
+
type Reason = 'already_decided' | 'approval_pending' | 'body_too_large' | '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';
|
|
90
90
|
}
|
|
91
91
|
/** A client's {@link Account} read before a sign-in set it, or after sign-out emptied it. */
|
|
92
92
|
export declare class SignedOutError extends Error {
|
package/dist/Decorator.d.ts
CHANGED
|
@@ -95,10 +95,6 @@ export declare namespace tempoAuth {
|
|
|
95
95
|
/** `Actions.oauth.userInfo`. */
|
|
96
96
|
userInfo: (options: Actions.oauth.userInfo.Options) => Promise<User>;
|
|
97
97
|
};
|
|
98
|
-
passkey: {
|
|
99
|
-
/** `Actions.passkey.signIn`, which sets the client's account unless it returns a step. */
|
|
100
|
-
signIn: <const id extends number = chainId>(options?: Actions.passkey.signIn.Options<id>) => Promise<Actions.passkey.signIn.ReturnType<id>>;
|
|
101
|
-
};
|
|
102
98
|
provider: {
|
|
103
99
|
/** `Actions.provider.list`. */
|
|
104
100
|
list: () => Promise<Actions.provider.list.ReturnType>;
|
package/dist/Decorator.js
CHANGED
|
@@ -111,15 +111,6 @@ export function tempoAuth(options) {
|
|
|
111
111
|
jwks: () => Actions.oauth.jwks(auth),
|
|
112
112
|
userInfo: (options) => Actions.oauth.userInfo(auth, options),
|
|
113
113
|
},
|
|
114
|
-
passkey: {
|
|
115
|
-
async signIn(options = {}) {
|
|
116
|
-
const apply = begin();
|
|
117
|
-
const result = await Actions.passkey.signIn(auth, options);
|
|
118
|
-
if (!('step' in result))
|
|
119
|
-
apply(result.account);
|
|
120
|
-
return result;
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
114
|
provider: {
|
|
124
115
|
list: () => Actions.provider.list(auth),
|
|
125
116
|
signIn: (options) => Actions.provider.signIn(auth, options),
|
package/dist/Permissions.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What an app's access key may do: its chain, expiry, spending limits, and call scopes
|
|
3
|
-
* witness its authorization binds.
|
|
2
|
+
* What an app's access key may do: its chain, expiry, spending limits, and call scopes.
|
|
4
3
|
* @module
|
|
5
4
|
*/
|
|
6
|
-
import type { Hex } from 'ox';
|
|
7
5
|
import type { KeyAuthorization } from 'ox/tempo';
|
|
8
6
|
/**
|
|
9
7
|
* What an app's access key may do, as Viem's `accessKey.authorize` takes it. Tempo Auth fills what
|
|
@@ -15,15 +13,10 @@ export type Permissions<chainId extends number = number> = {
|
|
|
15
13
|
chainId?: chainId | undefined;
|
|
16
14
|
/** Unix seconds. Viem's `Expiry` builds one, such as `Expiry.days(1)`. Defaults to a year from now. */
|
|
17
15
|
expiry?: number | undefined;
|
|
18
|
-
/** How much of each token the key may spend. Defaults to about $1,000 of each token it calls, or of OUSD. */
|
|
16
|
+
/** How much of each token the key may spend, in total or, with a `period` in seconds, per period. Defaults to about $1,000 of each token it calls, or of OUSD. */
|
|
19
17
|
limits?: KeyAuthorization.KeyAuthorization['limits'];
|
|
20
18
|
/** The calls the key may make. Defaults to transfers of each token it limits. */
|
|
21
19
|
scopes?: KeyAuthorization.KeyAuthorization['scopes'];
|
|
22
|
-
/**
|
|
23
|
-
* A 32-byte value the owner's signature binds (TIP-1053), such as `hashMessage(challenge)` for a
|
|
24
|
-
* challenge the app's backend issued. Only an app with the `tempo-auth:sign` scope may send one.
|
|
25
|
-
*/
|
|
26
|
-
witness?: Hex.Hex | undefined;
|
|
27
20
|
};
|
|
28
21
|
/**
|
|
29
22
|
* Instantiates a {@link Permissions}, keeping `chainId` as a literal type.
|
package/dist/actions/email.d.ts
CHANGED
|
@@ -44,11 +44,6 @@ export declare namespace signIn {
|
|
|
44
44
|
code: string;
|
|
45
45
|
/** The address the code was sent to. */
|
|
46
46
|
email: string;
|
|
47
|
-
/**
|
|
48
|
-
* The `link` from `Actions.passkey.signIn`'s email step, which links that wallet.tempo passkey
|
|
49
|
-
* to the user.
|
|
50
|
-
*/
|
|
51
|
-
link?: string | undefined;
|
|
52
47
|
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
|
53
48
|
permissions?: Permissions<chainId> | undefined;
|
|
54
49
|
};
|
package/dist/actions/email.js
CHANGED
|
@@ -23,14 +23,13 @@ export async function sendCode(auth, options) {
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export async function signIn(auth, options) {
|
|
26
|
-
const { code, email,
|
|
26
|
+
const { code, email, permissions } = options;
|
|
27
27
|
const key = await AccessKey.resolve(options.accessKey);
|
|
28
28
|
const body = await Api.json(await Api.post(auth, '/v1/auth/code/verify', {
|
|
29
29
|
json: {
|
|
30
30
|
authorize: request(auth, { accessKey: key.accessKey, permissions }),
|
|
31
31
|
code,
|
|
32
32
|
email,
|
|
33
|
-
...(link ? { link } : {}),
|
|
34
33
|
},
|
|
35
34
|
}));
|
|
36
35
|
if ('step' in body)
|
|
@@ -22,7 +22,6 @@ export declare function request(auth: Auth, options: {
|
|
|
22
22
|
token: `0x${string}`;
|
|
23
23
|
}[] | undefined;
|
|
24
24
|
scopes: readonly Account.z_KeyAuthorization.Scope<`0x${string}`>[] | undefined;
|
|
25
|
-
witness: `0x${string}` | undefined;
|
|
26
25
|
};
|
|
27
26
|
redirect_uri: string;
|
|
28
27
|
scope: string;
|
package/dist/internal/request.js
CHANGED
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-72.sha-b9acf1a",
|
|
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,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs the user in with a passkey from the app's own sign-in form. The browser offers every passkey
|
|
3
|
-
* it holds for Tempo's domain, so the app needs no email first.
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { Authentication } from 'ox/webauthn';
|
|
7
|
-
import type { Account } from 'viem/tempo';
|
|
8
|
-
import type { Auth } from '../Auth.ts';
|
|
9
|
-
import type { Authorization } from '../Authorization.ts';
|
|
10
|
-
import type { Permissions } from '../Permissions.ts';
|
|
11
|
-
/**
|
|
12
|
-
* Signs the user in with a passkey, and authorizes the app in the same call. Returns the email step
|
|
13
|
-
* for a wallet.tempo passkey whose account has no email: the app signs the user in with
|
|
14
|
-
* `Actions.email.signIn`, passing the step's `link`, which links the passkey. Throws a `RequestError` with reason
|
|
15
|
-
* `webauthn_required` when a passkey owns the Tempo Account the key acts for, since a passkey signs a
|
|
16
|
-
* key authorization only on Tempo Auth's pages. `Actions.redirect.start` authorizes it there, where
|
|
17
|
-
* the user is already signed in.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* const result = await Actions.passkey.signIn(auth)
|
|
22
|
-
* if ('step' in result) showEmailForm()
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare function signIn<const chainId extends number = number>(auth: Auth, options?: signIn.Options<chainId>): Promise<signIn.ReturnType<chainId>>;
|
|
26
|
-
export declare namespace signIn {
|
|
27
|
-
type Options<chainId extends number = number> = {
|
|
28
|
-
/**
|
|
29
|
-
* The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
|
|
30
|
-
* defaults to the user's first. Defaults to a new key.
|
|
31
|
-
*/
|
|
32
|
-
accessKey?: Account.Account | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Runs the WebAuthn ceremony in place of `navigator.credentials.get`, such as a native passkey
|
|
35
|
-
* module. Its assertion must report a web origin on the relying party's domain that the app
|
|
36
|
-
* registered, so an Android app's facet origin is refused.
|
|
37
|
-
*/
|
|
38
|
-
getFn?: Authentication.sign.Options['getFn'] | undefined;
|
|
39
|
-
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
|
40
|
-
permissions?: Permissions<chainId> | undefined;
|
|
41
|
-
};
|
|
42
|
-
/** The step a wallet.tempo passkey without an email needs: an emailed code, which links it. */
|
|
43
|
-
type EmailStep = {
|
|
44
|
-
/** Passed as `link` to `Actions.email.signIn`, which links the passkey to that user. */
|
|
45
|
-
link: string;
|
|
46
|
-
/** The kind of step. */
|
|
47
|
-
type: 'email';
|
|
48
|
-
};
|
|
49
|
-
/** The authorization, or the email step. */
|
|
50
|
-
type ReturnType<chainId extends number = number> = Authorization<chainId> | {
|
|
51
|
-
step: EmailStep;
|
|
52
|
-
};
|
|
53
|
-
}
|
package/dist/actions/passkey.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs the user in with a passkey from the app's own sign-in form. The browser offers every passkey
|
|
3
|
-
* it holds for Tempo's domain, so the app needs no email first.
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { Authentication } from 'ox/webauthn';
|
|
7
|
-
import * as AccessKey from '../internal/accessKey.js';
|
|
8
|
-
import * as Api from '../internal/api.js';
|
|
9
|
-
import { request } from '../internal/request.js';
|
|
10
|
-
/**
|
|
11
|
-
* Signs the user in with a passkey, and authorizes the app in the same call. Returns the email step
|
|
12
|
-
* for a wallet.tempo passkey whose account has no email: the app signs the user in with
|
|
13
|
-
* `Actions.email.signIn`, passing the step's `link`, which links the passkey. Throws a `RequestError` with reason
|
|
14
|
-
* `webauthn_required` when a passkey owns the Tempo Account the key acts for, since a passkey signs a
|
|
15
|
-
* key authorization only on Tempo Auth's pages. `Actions.redirect.start` authorizes it there, where
|
|
16
|
-
* the user is already signed in.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const result = await Actions.passkey.signIn(auth)
|
|
21
|
-
* if ('step' in result) showEmailForm()
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export async function signIn(auth, options = {}) {
|
|
25
|
-
const { getFn, permissions } = options;
|
|
26
|
-
const key = await AccessKey.resolve(options.accessKey);
|
|
27
|
-
const requested = await Api.json(await Api.post(auth, '/v1/auth/passkey/options', { json: {} }));
|
|
28
|
-
const deserialized = Authentication.deserializeOptions(requested.options);
|
|
29
|
-
const assertion = Authentication.serializeResponse(await Authentication.sign(
|
|
30
|
-
// ox reads `getFn` beside request options at runtime, which its types admit only beside a challenge.
|
|
31
|
-
getFn ? { ...deserialized, getFn } : deserialized));
|
|
32
|
-
const body = await Api.json(await Api.post(auth, '/v1/auth/passkey/verify', {
|
|
33
|
-
json: {
|
|
34
|
-
assertion,
|
|
35
|
-
authorize: request(auth, { accessKey: key.accessKey, permissions }),
|
|
36
|
-
},
|
|
37
|
-
}));
|
|
38
|
-
if ('step' in body)
|
|
39
|
-
return { step: body.step };
|
|
40
|
-
return Api.authorization(body.authorization, key);
|
|
41
|
-
}
|