@tempoxyz/auth 0.0.0-pr-74.sha-816e2d5 → 0.0.0-pr-71.sha-fb86173
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 -6
- package/dist/Actions.js +0 -1
- package/dist/Auth.d.ts +3 -4
- package/dist/actions/device.d.ts +0 -6
- package/dist/actions/device.js +0 -3
- package/dist/actions/email.d.ts +1 -8
- package/dist/actions/email.js +3 -14
- package/dist/actions/passkey.d.ts +8 -25
- package/dist/actions/passkey.js +15 -34
- package/dist/actions/redirect.d.ts +0 -12
- package/dist/actions/redirect.js +10 -7
- package/dist/internal/accessKey.d.ts +0 -5
- package/dist/internal/accessKey.js +0 -11
- package/dist/internal/request.d.ts +0 -3
- package/dist/internal/request.js +1 -2
- package/package.json +1 -1
- package/dist/internal/link.d.ts +0 -31
- package/dist/internal/link.js +0 -22
- package/dist/internal/store.d.ts +0 -11
- package/dist/internal/store.js +0 -14
package/dist/Actions.d.ts
CHANGED
|
@@ -35,12 +35,6 @@ 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;
|
|
44
38
|
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
|
45
39
|
permissions?: Permissions<chainId> | undefined;
|
|
46
40
|
};
|
package/dist/Actions.js
CHANGED
package/dist/Auth.d.ts
CHANGED
|
@@ -51,9 +51,8 @@ export type Auth = {
|
|
|
51
51
|
/** The scopes the app's tokens carry. */
|
|
52
52
|
scope: string;
|
|
53
53
|
/**
|
|
54
|
-
* Where `Actions.redirect.start` keeps its state until Tempo Auth redirects back
|
|
55
|
-
*
|
|
56
|
-
* are, since a browser key is a `CryptoKey`. Defaults to IndexedDB.
|
|
54
|
+
* Where `Actions.redirect.start` keeps its state until Tempo Auth redirects back. It must keep
|
|
55
|
+
* objects as they are, since a browser key is a `CryptoKey`. Defaults to IndexedDB.
|
|
57
56
|
*/
|
|
58
57
|
storage?: Storage | undefined;
|
|
59
58
|
/** Where Tempo Auth runs, such as `https://auth.tempo.xyz`. */
|
|
@@ -87,7 +86,7 @@ export declare namespace RequestError {
|
|
|
87
86
|
uri?: string | undefined;
|
|
88
87
|
};
|
|
89
88
|
/** Each refusal's stable name. `docs/errors.md` explains each one. */
|
|
90
|
-
type Reason = 'already_decided' | 'approval_pending' | 'body_too_large' | '
|
|
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' | 'webauthn_rejected' | 'webauthn_required';
|
|
91
90
|
}
|
|
92
91
|
/** A client's {@link Account} read before a sign-in set it, or after sign-out emptied it. */
|
|
93
92
|
export declare class SignedOutError extends Error {
|
package/dist/actions/device.d.ts
CHANGED
|
@@ -21,12 +21,6 @@ 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;
|
|
30
24
|
/**
|
|
31
25
|
* The name the approval page shows. Defaults to the machine's hostname in Node, Bun, and Deno,
|
|
32
26
|
* and to `Unknown device` elsewhere.
|
package/dist/actions/device.js
CHANGED
|
@@ -17,9 +17,6 @@ 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 }),
|
|
23
20
|
device: options.device ?? hostname(),
|
|
24
21
|
key_authorization: request(auth, {
|
|
25
22
|
accessKey: key.accessKey,
|
package/dist/actions/email.d.ts
CHANGED
|
@@ -40,20 +40,13 @@ 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;
|
|
49
43
|
/** The 6-digit code the user was emailed. */
|
|
50
44
|
code: string;
|
|
51
45
|
/** The address the code was sent to. */
|
|
52
46
|
email: string;
|
|
53
47
|
/**
|
|
54
48
|
* The `link` from `Actions.passkey.signIn`'s email step, which links that wallet.tempo passkey
|
|
55
|
-
* to the user.
|
|
56
|
-
* authorized with its assertion, given the same `accessKey` if the app supplied one.
|
|
49
|
+
* to the user.
|
|
57
50
|
*/
|
|
58
51
|
link?: string | undefined;
|
|
59
52
|
/** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
|
package/dist/actions/email.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as AccessKey from '../internal/accessKey.js';
|
|
2
2
|
import * as Api from '../internal/api.js';
|
|
3
|
-
import * as Link from '../internal/link.js';
|
|
4
3
|
import { request } from '../internal/request.js';
|
|
5
4
|
/**
|
|
6
5
|
* Emails the user a sign-in code. The response is the same for every address.
|
|
@@ -24,26 +23,16 @@ export async function sendCode(auth, options) {
|
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
25
|
export async function signIn(auth, options) {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
// returns once this request names it again.
|
|
30
|
-
const kept = link ? await Link.get(auth, { link }) : undefined;
|
|
31
|
-
const key = kept ?? (await AccessKey.resolve(options.accessKey));
|
|
26
|
+
const { code, email, link, permissions } = options;
|
|
27
|
+
const key = await AccessKey.resolve(options.accessKey);
|
|
32
28
|
const body = await Api.json(await Api.post(auth, '/v1/auth/code/verify', {
|
|
33
29
|
json: {
|
|
34
|
-
authorize: request(auth, {
|
|
35
|
-
accessKey: key.accessKey,
|
|
36
|
-
challenge,
|
|
37
|
-
permissions,
|
|
38
|
-
}),
|
|
30
|
+
authorize: request(auth, { accessKey: key.accessKey, permissions }),
|
|
39
31
|
code,
|
|
40
32
|
email,
|
|
41
33
|
...(link ? { link } : {}),
|
|
42
34
|
},
|
|
43
35
|
}));
|
|
44
|
-
// A refusal throws above, which keeps the key for a retry with a new code.
|
|
45
|
-
if (kept)
|
|
46
|
-
await Link.release(auth);
|
|
47
36
|
if ('step' in body)
|
|
48
37
|
return {
|
|
49
38
|
step: { ...body.step, url: new URL(body.step.url, auth.url).href },
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signs the user in with a passkey from the app's own sign-in form
|
|
3
|
-
*
|
|
4
|
-
* email first.
|
|
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.
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
6
|
import { Authentication } from 'ox/webauthn';
|
|
@@ -10,17 +9,12 @@ import type { Auth } from '../Auth.ts';
|
|
|
10
9
|
import type { Authorization } from '../Authorization.ts';
|
|
11
10
|
import type { Permissions } from '../Permissions.ts';
|
|
12
11
|
/**
|
|
13
|
-
* Signs the user in with a passkey, and authorizes the app in the same call.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `accessKey`, `challenge`, and `permissions`. A `signed` step's assertion already signed the key,
|
|
20
|
-
* which that call returns without another tap, so a new key waits in the instance's `storage`.
|
|
21
|
-
* Throws a `RequestError` with reason `webauthn_required` when another passkey owns
|
|
22
|
-
* the account, which signs only on Tempo Auth's pages, where `Actions.redirect.start` authorizes it
|
|
23
|
-
* for the signed-in user.
|
|
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.
|
|
24
18
|
*
|
|
25
19
|
* @example
|
|
26
20
|
* ```ts
|
|
@@ -36,12 +30,6 @@ export declare namespace signIn {
|
|
|
36
30
|
* defaults to the user's first. Defaults to a new key.
|
|
37
31
|
*/
|
|
38
32
|
accessKey?: Account.Account | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
41
|
-
* Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
42
|
-
* `tempo-auth:sign` scope may send one.
|
|
43
|
-
*/
|
|
44
|
-
challenge?: string | undefined;
|
|
45
33
|
/**
|
|
46
34
|
* Runs the WebAuthn ceremony in place of `navigator.credentials.get`, such as a native passkey
|
|
47
35
|
* module. Its assertion must report a web origin on the relying party's domain that the app
|
|
@@ -55,11 +43,6 @@ export declare namespace signIn {
|
|
|
55
43
|
type EmailStep = {
|
|
56
44
|
/** Passed as `link` to `Actions.email.signIn`, which links the passkey to that user. */
|
|
57
45
|
link: string;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the assertion already signed the key, which `Actions.email.signIn` returns with
|
|
60
|
-
* `link`. Otherwise that call authorizes the key itself.
|
|
61
|
-
*/
|
|
62
|
-
signed: boolean;
|
|
63
46
|
/** The kind of step. */
|
|
64
47
|
type: 'email';
|
|
65
48
|
};
|
package/dist/actions/passkey.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signs the user in with a passkey from the app's own sign-in form
|
|
3
|
-
*
|
|
4
|
-
* email first.
|
|
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.
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
6
|
import { Authentication } from 'ox/webauthn';
|
|
8
7
|
import * as AccessKey from '../internal/accessKey.js';
|
|
9
8
|
import * as Api from '../internal/api.js';
|
|
10
|
-
import * as Link from '../internal/link.js';
|
|
11
9
|
import { request } from '../internal/request.js';
|
|
12
10
|
/**
|
|
13
|
-
* Signs the user in with a passkey, and authorizes the app in the same call.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `accessKey`, `challenge`, and `permissions`. A `signed` step's assertion already signed the key,
|
|
20
|
-
* which that call returns without another tap, so a new key waits in the instance's `storage`.
|
|
21
|
-
* Throws a `RequestError` with reason `webauthn_required` when another passkey owns
|
|
22
|
-
* the account, which signs only on Tempo Auth's pages, where `Actions.redirect.start` authorizes it
|
|
23
|
-
* for the signed-in user.
|
|
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.
|
|
24
17
|
*
|
|
25
18
|
* @example
|
|
26
19
|
* ```ts
|
|
@@ -29,32 +22,20 @@ import { request } from '../internal/request.js';
|
|
|
29
22
|
* ```
|
|
30
23
|
*/
|
|
31
24
|
export async function signIn(auth, options = {}) {
|
|
32
|
-
const {
|
|
25
|
+
const { getFn, permissions } = options;
|
|
33
26
|
const key = await AccessKey.resolve(options.accessKey);
|
|
34
|
-
const
|
|
35
|
-
accessKey: key.accessKey,
|
|
36
|
-
challenge,
|
|
37
|
-
permissions,
|
|
38
|
-
});
|
|
39
|
-
// A page sends the request with the options, so the challenge is its key's digest. A native app
|
|
40
|
-
// sends no `Origin` to bind one-tap to, so it sends the request with the assertion instead.
|
|
41
|
-
const native = !/^https?:/i.test(authorize.redirect_uri);
|
|
42
|
-
const requested = await Api.json(await Api.post(auth, '/v1/auth/passkey/options', {
|
|
43
|
-
json: native ? {} : { authorize },
|
|
44
|
-
}));
|
|
27
|
+
const requested = await Api.json(await Api.post(auth, '/v1/auth/passkey/options', { json: {} }));
|
|
45
28
|
const deserialized = Authentication.deserializeOptions(requested.options);
|
|
46
29
|
const assertion = Authentication.serializeResponse(await Authentication.sign(
|
|
47
30
|
// ox reads `getFn` beside request options at runtime, which its types admit only beside a challenge.
|
|
48
31
|
getFn ? { ...deserialized, getFn } : deserialized));
|
|
49
32
|
const body = await Api.json(await Api.post(auth, '/v1/auth/passkey/verify', {
|
|
50
|
-
json:
|
|
33
|
+
json: {
|
|
34
|
+
assertion,
|
|
35
|
+
authorize: request(auth, { accessKey: key.accessKey, permissions }),
|
|
36
|
+
},
|
|
51
37
|
}));
|
|
52
|
-
if ('step' in body)
|
|
53
|
-
// The emailed-code sign-in that sends the link returns this key's authorization, so a key the
|
|
54
|
-
// library generated waits for it in `storage`.
|
|
55
|
-
if (body.step.signed && !options.accessKey)
|
|
56
|
-
await Link.keep(auth, { link: body.step.link, material: key.material });
|
|
38
|
+
if ('step' in body)
|
|
57
39
|
return { step: body.step };
|
|
58
|
-
}
|
|
59
40
|
return Api.authorization(body.authorization, key);
|
|
60
41
|
}
|
|
@@ -45,12 +45,6 @@ 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;
|
|
54
48
|
/** What the key may do. Tempo Auth's pages show it, and the headless ceiling fills what it leaves out. */
|
|
55
49
|
permissions?: Permissions | undefined;
|
|
56
50
|
/** Where Tempo Auth redirects back to. Defaults to the instance's `redirectUri`. */
|
|
@@ -103,12 +97,6 @@ export declare namespace start {
|
|
|
103
97
|
* key, which `storage` keeps until the browser returns.
|
|
104
98
|
*/
|
|
105
99
|
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;
|
|
112
100
|
/** What the key may do. Tempo Auth's pages show it, and the headless ceiling fills what it leaves out. */
|
|
113
101
|
permissions?: Permissions | undefined;
|
|
114
102
|
};
|
package/dist/actions/redirect.js
CHANGED
|
@@ -8,8 +8,8 @@ import { Base64, Bytes, Hash } from 'ox';
|
|
|
8
8
|
import { RequestError } from '../Auth.js';
|
|
9
9
|
import * as AccessKey from '../internal/accessKey.js';
|
|
10
10
|
import * as Api from '../internal/api.js';
|
|
11
|
+
import * as IndexedDb from '../internal/indexedDb.js';
|
|
11
12
|
import { request } from '../internal/request.js';
|
|
12
|
-
import * as Store from '../internal/store.js';
|
|
13
13
|
import * as Pending from '../Pending.js';
|
|
14
14
|
/**
|
|
15
15
|
* Finishes a {@link start} when the page loads with Tempo Auth's callback, and returns `undefined`
|
|
@@ -24,8 +24,8 @@ import * as Pending from '../Pending.js';
|
|
|
24
24
|
*/
|
|
25
25
|
export function complete(auth, options = {}) {
|
|
26
26
|
completed ??= (async () => {
|
|
27
|
-
const stored = (await
|
|
28
|
-
await
|
|
27
|
+
const stored = (await storage(auth).getItem(storageKey));
|
|
28
|
+
await storage(auth).removeItem(storageKey);
|
|
29
29
|
const url = new URL(window.location.href);
|
|
30
30
|
if (!url.searchParams.has('code'))
|
|
31
31
|
return undefined;
|
|
@@ -75,9 +75,6 @@ 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 }),
|
|
81
78
|
client_id,
|
|
82
79
|
code_challenge: Base64.fromBytes(Hash.sha256(Bytes.fromString(pending.verifier)), base64url),
|
|
83
80
|
key_authorization: Base64.fromString(JSON.stringify(key_authorization), base64url),
|
|
@@ -148,12 +145,18 @@ export async function handleCallback(auth, options) {
|
|
|
148
145
|
*/
|
|
149
146
|
export async function start(auth, options = {}) {
|
|
150
147
|
const { pending, url } = await createUrl(auth, options);
|
|
151
|
-
await
|
|
148
|
+
await storage(auth).setItem(storageKey, pending);
|
|
152
149
|
window.location.assign(url);
|
|
153
150
|
}
|
|
154
151
|
/** Unpadded URL-safe Base64, as PKCE and `key_authorization` use. */
|
|
155
152
|
const base64url = { pad: false, url: true };
|
|
156
153
|
/** The redirect this page load returns from, so its code is redeemed once. */
|
|
157
154
|
let completed;
|
|
155
|
+
/** The default `storage`, opened on first use. */
|
|
156
|
+
let indexedDb;
|
|
158
157
|
/** Where a redirect keeps its state in `storage`. */
|
|
159
158
|
const storageKey = 'tempo-auth:redirect';
|
|
159
|
+
/** Where a redirect keeps its state: the instance's `storage`, or IndexedDB. */
|
|
160
|
+
function storage(auth) {
|
|
161
|
+
return auth.storage ?? (indexedDb ??= IndexedDb.create());
|
|
162
|
+
}
|
|
@@ -5,11 +5,6 @@ import type * as Key from '../Key.ts';
|
|
|
5
5
|
* a `CryptoKey` across page loads. Elsewhere a CLI or native app must store the key as a string.
|
|
6
6
|
*/
|
|
7
7
|
export declare function resolve(accessKey: Account.Account | undefined): Promise<resolve.ReturnType>;
|
|
8
|
-
/**
|
|
9
|
-
* Rebuilds a key that {@link resolve} generated from its material. Returns `undefined` for the
|
|
10
|
-
* empty material of a key the app supplied.
|
|
11
|
-
*/
|
|
12
|
-
export declare function restore(material: Key.Material): resolve.ReturnType | undefined;
|
|
13
8
|
export declare namespace resolve {
|
|
14
9
|
type ReturnType = {
|
|
15
10
|
/** The key, as a Viem account that signs with it. */
|
|
@@ -24,14 +24,3 @@ export async function resolve(accessKey) {
|
|
|
24
24
|
material: { privateKey },
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Rebuilds a key that {@link resolve} generated from its material. Returns `undefined` for the
|
|
29
|
-
* empty material of a key the app supplied.
|
|
30
|
-
*/
|
|
31
|
-
export function restore(material) {
|
|
32
|
-
if (material.keyPair)
|
|
33
|
-
return { accessKey: Account.fromWebCryptoP256(material.keyPair), material };
|
|
34
|
-
if (material.privateKey)
|
|
35
|
-
return { accessKey: Account.fromSecp256k1(material.privateKey), material };
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
@@ -7,11 +7,8 @@ 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;
|
|
12
10
|
permissions?: Permissions | undefined;
|
|
13
11
|
}): {
|
|
14
|
-
challenge?: string;
|
|
15
12
|
client_id: string;
|
|
16
13
|
key_authorization: {
|
|
17
14
|
account?: `0x${string}`;
|
package/dist/internal/request.js
CHANGED
|
@@ -9,9 +9,8 @@ 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,
|
|
12
|
+
const { accessKey, permissions = {} } = options;
|
|
13
13
|
return {
|
|
14
|
-
...(challenge === undefined ? {} : { challenge }),
|
|
15
14
|
client_id: auth.clientId,
|
|
16
15
|
key_authorization: {
|
|
17
16
|
...(accessKey.accessKeyAddress ? { account: accessKey.address } : {}),
|
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-71.sha-fb86173",
|
|
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/internal/link.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keeps a new key that a one-tap passkey sign-in signed, until the emailed-code sign-in that sends
|
|
3
|
-
* its email step's `link` returns the key's authorization.
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type { Auth } from '../Auth.ts';
|
|
7
|
-
import type * as Key from '../Key.ts';
|
|
8
|
-
import * as AccessKey from './accessKey.ts';
|
|
9
|
-
/** Keeps the key's material for `link`. Keeps nothing outside a browser without `storage`. */
|
|
10
|
-
export declare function keep(auth: Auth, options: keep.Options): Promise<void>;
|
|
11
|
-
export declare namespace keep {
|
|
12
|
-
type Options = {
|
|
13
|
-
/** The email step's `link`. */
|
|
14
|
-
link: string;
|
|
15
|
-
/** The key `AccessKey.resolve` generated. */
|
|
16
|
-
material: Key.Material;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns the key kept for `link`, or `undefined` when none is. Leaves it in place, so a refused
|
|
21
|
-
* code retries with the same key, until {@link release} removes it.
|
|
22
|
-
*/
|
|
23
|
-
export declare function get(auth: Auth, options: get.Options): Promise<AccessKey.resolve.ReturnType | undefined>;
|
|
24
|
-
export declare namespace get {
|
|
25
|
-
type Options = {
|
|
26
|
-
/** The `link` the emailed-code sign-in sends. */
|
|
27
|
-
link: string;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/** Removes the kept key, once the emailed-code sign-in that used it finished. */
|
|
31
|
-
export declare function release(auth: Auth): Promise<void>;
|
package/dist/internal/link.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as AccessKey from './accessKey.js';
|
|
2
|
-
import * as Store from './store.js';
|
|
3
|
-
/** Where the key waits in `storage`. A later email step replaces it. */
|
|
4
|
-
const storageKey = 'tempo-auth:passkey-link';
|
|
5
|
-
/** Keeps the key's material for `link`. Keeps nothing outside a browser without `storage`. */
|
|
6
|
-
export async function keep(auth, options) {
|
|
7
|
-
await Store.get(auth)?.setItem(storageKey, options);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Returns the key kept for `link`, or `undefined` when none is. Leaves it in place, so a refused
|
|
11
|
-
* code retries with the same key, until {@link release} removes it.
|
|
12
|
-
*/
|
|
13
|
-
export async function get(auth, options) {
|
|
14
|
-
const kept = (await Store.get(auth)?.getItem(storageKey));
|
|
15
|
-
if (kept?.link !== options.link)
|
|
16
|
-
return undefined;
|
|
17
|
-
return AccessKey.restore(kept.material);
|
|
18
|
-
}
|
|
19
|
-
/** Removes the kept key, once the emailed-code sign-in that used it finished. */
|
|
20
|
-
export async function release(auth) {
|
|
21
|
-
await Store.get(auth)?.removeItem(storageKey);
|
|
22
|
-
}
|
package/dist/internal/store.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves where actions keep state across page loads: the instance's `storage`, or IndexedDB.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type { Auth } from '../Auth.ts';
|
|
6
|
-
import type { Storage } from '../Storage.ts';
|
|
7
|
-
/**
|
|
8
|
-
* Returns the instance's `storage`, or the page's IndexedDB. Returns `undefined` outside a browser
|
|
9
|
-
* when the instance names no `storage`.
|
|
10
|
-
*/
|
|
11
|
-
export declare function get(auth: Auth): Storage | undefined;
|
package/dist/internal/store.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as IndexedDb from './indexedDb.js';
|
|
2
|
-
/** The default `storage`, opened on first use. */
|
|
3
|
-
let indexedDb;
|
|
4
|
-
/**
|
|
5
|
-
* Returns the instance's `storage`, or the page's IndexedDB. Returns `undefined` outside a browser
|
|
6
|
-
* when the instance names no `storage`.
|
|
7
|
-
*/
|
|
8
|
-
export function get(auth) {
|
|
9
|
-
if (auth.storage)
|
|
10
|
-
return auth.storage;
|
|
11
|
-
if (typeof indexedDB === 'undefined')
|
|
12
|
-
return undefined;
|
|
13
|
-
return (indexedDb ??= IndexedDb.create());
|
|
14
|
-
}
|