@tempoxyz/auth 0.0.0-pr-73.sha-163f721 → 0.0.0-pr-73.sha-5210d72
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 +6 -0
- package/dist/Actions.js +1 -0
- package/dist/Auth.d.ts +1 -1
- package/dist/Permissions.d.ts +1 -8
- package/dist/actions/device.d.ts +6 -0
- package/dist/actions/device.js +3 -0
- package/dist/actions/email.d.ts +6 -0
- package/dist/actions/email.js +6 -2
- package/dist/actions/passkey.d.ts +6 -0
- package/dist/actions/passkey.js +6 -2
- package/dist/actions/redirect.d.ts +12 -0
- package/dist/actions/redirect.js +3 -0
- package/dist/internal/request.d.ts +3 -1
- package/dist/internal/request.js +2 -2
- package/package.json +1 -1
package/dist/Actions.d.ts
CHANGED
|
@@ -35,6 +35,12 @@ export declare namespace authorize {
|
|
|
35
35
|
* defaults to the user's first. Defaults to a new key.
|
|
36
36
|
*/
|
|
37
37
|
accessKey?: Account.Account | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
40
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
41
|
+
* `tempo-auth:sign` scope may send one.
|
|
42
|
+
*/
|
|
43
|
+
challenge?: string | undefined;
|
|
38
44
|
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
|
39
45
|
permissions?: Permissions<chainId> | undefined;
|
|
40
46
|
};
|
package/dist/Actions.js
CHANGED
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' | 'periodic_limit' | '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'
|
|
89
|
+
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_public_key' | 'limit_exceeds_maximum' | 'malformed_body' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | 'periodic_limit' | '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
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/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
|
|
@@ -19,11 +17,6 @@ export type Permissions<chainId extends number = number> = {
|
|
|
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/device.d.ts
CHANGED
|
@@ -21,6 +21,12 @@ export declare namespace authorize {
|
|
|
21
21
|
* defaults to the user's first. Defaults to a new key.
|
|
22
22
|
*/
|
|
23
23
|
accessKey?: Account.Account | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
26
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
27
|
+
* `tempo-auth:sign` scope may send one.
|
|
28
|
+
*/
|
|
29
|
+
challenge?: string | undefined;
|
|
24
30
|
/**
|
|
25
31
|
* The name the approval page shows. Defaults to the machine's hostname in Node, Bun, and Deno,
|
|
26
32
|
* and to `Unknown device` elsewhere.
|
package/dist/actions/device.js
CHANGED
|
@@ -17,6 +17,9 @@ export async function authorize(auth, options = {}) {
|
|
|
17
17
|
const key = await AccessKey.resolve(options.accessKey);
|
|
18
18
|
const code = await Api.json(await Api.post(auth, '/v1/device/authorize', {
|
|
19
19
|
json: {
|
|
20
|
+
...(options.challenge === undefined
|
|
21
|
+
? {}
|
|
22
|
+
: { challenge: options.challenge }),
|
|
20
23
|
device: options.device ?? hostname(),
|
|
21
24
|
key_authorization: request(auth, {
|
|
22
25
|
accessKey: key.accessKey,
|
package/dist/actions/email.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ export declare namespace signIn {
|
|
|
40
40
|
* defaults to the user's first. Defaults to a new key.
|
|
41
41
|
*/
|
|
42
42
|
accessKey?: Account.Account | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
45
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
46
|
+
* `tempo-auth:sign` scope may send one.
|
|
47
|
+
*/
|
|
48
|
+
challenge?: string | undefined;
|
|
43
49
|
/** The 6-digit code the user was emailed. */
|
|
44
50
|
code: string;
|
|
45
51
|
/** The address the code was sent to. */
|
package/dist/actions/email.js
CHANGED
|
@@ -23,11 +23,15 @@ export async function sendCode(auth, options) {
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export async function signIn(auth, options) {
|
|
26
|
-
const { code, email, link, permissions } = options;
|
|
26
|
+
const { challenge, code, email, link, 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
|
-
authorize: request(auth, {
|
|
30
|
+
authorize: request(auth, {
|
|
31
|
+
accessKey: key.accessKey,
|
|
32
|
+
challenge,
|
|
33
|
+
permissions,
|
|
34
|
+
}),
|
|
31
35
|
code,
|
|
32
36
|
email,
|
|
33
37
|
...(link ? { link } : {}),
|
|
@@ -30,6 +30,12 @@ export declare namespace signIn {
|
|
|
30
30
|
* defaults to the user's first. Defaults to a new key.
|
|
31
31
|
*/
|
|
32
32
|
accessKey?: Account.Account | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
35
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
36
|
+
* `tempo-auth:sign` scope may send one.
|
|
37
|
+
*/
|
|
38
|
+
challenge?: string | undefined;
|
|
33
39
|
/**
|
|
34
40
|
* Runs the WebAuthn ceremony in place of `navigator.credentials.get`, such as a native passkey
|
|
35
41
|
* module. Its assertion must report a web origin on the relying party's domain that the app
|
package/dist/actions/passkey.js
CHANGED
|
@@ -22,7 +22,7 @@ import { request } from '../internal/request.js';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export async function signIn(auth, options = {}) {
|
|
25
|
-
const { getFn, permissions } = options;
|
|
25
|
+
const { challenge, getFn, permissions } = options;
|
|
26
26
|
const key = await AccessKey.resolve(options.accessKey);
|
|
27
27
|
const requested = await Api.json(await Api.post(auth, '/v1/auth/passkey/options', { json: {} }));
|
|
28
28
|
const deserialized = Authentication.deserializeOptions(requested.options);
|
|
@@ -32,7 +32,11 @@ export async function signIn(auth, options = {}) {
|
|
|
32
32
|
const body = await Api.json(await Api.post(auth, '/v1/auth/passkey/verify', {
|
|
33
33
|
json: {
|
|
34
34
|
assertion,
|
|
35
|
-
authorize: request(auth, {
|
|
35
|
+
authorize: request(auth, {
|
|
36
|
+
accessKey: key.accessKey,
|
|
37
|
+
challenge,
|
|
38
|
+
permissions,
|
|
39
|
+
}),
|
|
36
40
|
},
|
|
37
41
|
}));
|
|
38
42
|
if ('step' in body)
|
|
@@ -45,6 +45,12 @@ export declare namespace createUrl {
|
|
|
45
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
|
+
/**
|
|
49
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
50
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
51
|
+
* `tempo-auth:sign` scope may send one.
|
|
52
|
+
*/
|
|
53
|
+
challenge?: string | undefined;
|
|
48
54
|
/** What the key may do. Tempo Auth's pages show it, and the headless ceiling fills what it leaves out. */
|
|
49
55
|
permissions?: Permissions | undefined;
|
|
50
56
|
/** Where Tempo Auth redirects back to. Defaults to the instance's `redirectUri`. */
|
|
@@ -97,6 +103,12 @@ export declare namespace start {
|
|
|
97
103
|
* key, which `storage` keeps until the browser returns.
|
|
98
104
|
*/
|
|
99
105
|
accessKey?: Account.Account | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
108
|
+
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
109
|
+
* `tempo-auth:sign` scope may send one.
|
|
110
|
+
*/
|
|
111
|
+
challenge?: string | undefined;
|
|
100
112
|
/** What the key may do. Tempo Auth's pages show it, and the headless ceiling fills what it leaves out. */
|
|
101
113
|
permissions?: Permissions | undefined;
|
|
102
114
|
};
|
package/dist/actions/redirect.js
CHANGED
|
@@ -75,6 +75,9 @@ export async function createUrl(auth, options = {}) {
|
|
|
75
75
|
});
|
|
76
76
|
const url = new URL('/authorize', auth.url);
|
|
77
77
|
url.search = new URLSearchParams({
|
|
78
|
+
...(options.challenge === undefined
|
|
79
|
+
? {}
|
|
80
|
+
: { challenge: options.challenge }),
|
|
78
81
|
client_id,
|
|
79
82
|
code_challenge: Base64.fromBytes(Hash.sha256(Bytes.fromString(pending.verifier)), base64url),
|
|
80
83
|
key_authorization: Base64.fromString(JSON.stringify(key_authorization), base64url),
|
|
@@ -7,8 +7,11 @@ import type { Permissions } from '../Permissions.ts';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function request(auth: Auth, options: {
|
|
9
9
|
accessKey: Account.Account;
|
|
10
|
+
/** A message the key's witness binds. */
|
|
11
|
+
challenge?: string | undefined;
|
|
10
12
|
permissions?: Permissions | undefined;
|
|
11
13
|
}): {
|
|
14
|
+
challenge?: string;
|
|
12
15
|
client_id: string;
|
|
13
16
|
key_authorization: {
|
|
14
17
|
account?: `0x${string}`;
|
|
@@ -22,7 +25,6 @@ export declare function request(auth: Auth, options: {
|
|
|
22
25
|
token: `0x${string}`;
|
|
23
26
|
}[] | undefined;
|
|
24
27
|
scopes: readonly Account.z_KeyAuthorization.Scope<`0x${string}`>[] | undefined;
|
|
25
|
-
witness: `0x${string}` | undefined;
|
|
26
28
|
};
|
|
27
29
|
redirect_uri: string;
|
|
28
30
|
scope: string;
|
package/dist/internal/request.js
CHANGED
|
@@ -9,8 +9,9 @@ import { Hex } from 'ox';
|
|
|
9
9
|
* key account names its Tempo Account through `access`, and a plain key leaves it to Tempo Auth.
|
|
10
10
|
*/
|
|
11
11
|
export function request(auth, options) {
|
|
12
|
-
const { accessKey, permissions = {} } = options;
|
|
12
|
+
const { accessKey, challenge, permissions = {} } = options;
|
|
13
13
|
return {
|
|
14
|
+
...(challenge === undefined ? {} : { challenge }),
|
|
14
15
|
client_id: auth.clientId,
|
|
15
16
|
key_authorization: {
|
|
16
17
|
...(accessKey.accessKeyAddress ? { account: accessKey.address } : {}),
|
|
@@ -24,7 +25,6 @@ export function request(auth, options) {
|
|
|
24
25
|
token,
|
|
25
26
|
})),
|
|
26
27
|
scopes: permissions.scopes,
|
|
27
|
-
witness: permissions.witness,
|
|
28
28
|
},
|
|
29
29
|
redirect_uri: auth.redirectUri ?? `${globalThis.location?.origin ?? auth.url}/`,
|
|
30
30
|
scope: auth.scope,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempoxyz/auth",
|
|
3
|
-
"version": "0.0.0-pr-73.sha-
|
|
3
|
+
"version": "0.0.0-pr-73.sha-5210d72",
|
|
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": {
|