@tempoxyz/auth 0.0.0-pr-109.sha-db45aa4 → 0.0.0-pr-117.sha-cf46870
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/README.md +2 -2
- package/dist/Actions.d.ts +6 -6
- package/dist/Actions.js +7 -7
- package/dist/Auth.d.ts +12 -12
- package/dist/Auth.js +4 -4
- package/dist/Decorator.d.ts +4 -4
- package/dist/Decorator.js +2 -2
- package/dist/Key.d.ts +1 -1
- package/dist/Key.js +1 -1
- package/dist/Pending.d.ts +3 -3
- package/dist/Permissions.d.ts +1 -1
- package/dist/Provider.d.ts +1 -1
- package/dist/Storage.d.ts +1 -1
- package/dist/TempoAccount.d.ts +2 -2
- package/dist/actions/account.js +1 -1
- package/dist/actions/device.d.ts +1 -1
- package/dist/actions/device.js +1 -1
- package/dist/actions/email.d.ts +1 -1
- package/dist/actions/email.js +2 -2
- package/dist/actions/oauth.d.ts +3 -3
- package/dist/actions/oauth.js +2 -2
- package/dist/actions/passkey.d.ts +2 -2
- package/dist/actions/passkey.js +1 -1
- package/dist/actions/provider.d.ts +3 -3
- package/dist/actions/provider.js +2 -2
- package/dist/actions/redirect.d.ts +9 -9
- package/dist/actions/redirect.js +4 -4
- package/dist/internal/api.d.ts +5 -5
- package/dist/internal/api.js +4 -4
- package/dist/internal/request.d.ts +2 -2
- package/dist/internal/request.js +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tempoxyz/auth
|
|
2
2
|
|
|
3
|
-
Signs users in to Tempo through [Tempo
|
|
3
|
+
Signs users in to Tempo through [Tempo ID](../../docs/README.md), and returns their tokens for Tempo APIs and a [Viem](https://viem.sh) access key account on their Tempo Account.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -53,4 +53,4 @@ pnpm add @tempoxyz/auth viem
|
|
|
53
53
|
- [Guides](docs/guides/README.md): each sign-in flow, access keys, sessions, errors, and Viem.
|
|
54
54
|
- [Viem](docs/guides/viem.md): `tempoAuth`, which extends a Viem client with the same actions as `client.auth`.
|
|
55
55
|
- [API reference](docs/api/README.md): every action, function, and type.
|
|
56
|
-
- [Tempo
|
|
56
|
+
- [Tempo ID](../../docs/README.md): the service the package calls, over HTTP.
|
package/dist/Actions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tempo
|
|
2
|
+
* Tempo ID's actions. Each takes an instance from `Auth.create`. Each sign-in flow has its own
|
|
3
3
|
* namespace, `oauth` holds the standard OAuth endpoints for tokens an app holds, and the actions
|
|
4
4
|
* every flow shares sit at the top level.
|
|
5
5
|
* @module
|
|
@@ -19,14 +19,14 @@ export * as provider from './actions/provider.ts';
|
|
|
19
19
|
export * as realm from './actions/realm.ts';
|
|
20
20
|
export * as redirect from './actions/redirect.ts';
|
|
21
21
|
/**
|
|
22
|
-
* Authorizes the app for a user already signed in to Tempo
|
|
23
|
-
* without a session, so the app shows sign-in. The key must fit Tempo
|
|
22
|
+
* Authorizes the app for a user already signed in to Tempo ID, from any app. Returns `undefined`
|
|
23
|
+
* without a session, so the app shows sign-in. The key must fit Tempo ID's headless ceiling. An
|
|
24
24
|
* `account` that the call names becomes the app's account for its later requests, such as the
|
|
25
25
|
* account the user selected in a sign-in's account step.
|
|
26
26
|
*
|
|
27
27
|
* A passkey-owned account signs the key with a passkey prompt on the page, when the page is the
|
|
28
28
|
* app's own on Tempo's domain. Elsewhere the call throws a `RequestError` with reason
|
|
29
|
-
* `webauthn_required`, and `Actions.redirect.start` authorizes the key on Tempo
|
|
29
|
+
* `webauthn_required`, and `Actions.redirect.start` authorizes the key on Tempo ID's pages.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
32
|
* ```ts
|
|
@@ -50,7 +50,7 @@ export declare namespace authorize {
|
|
|
50
50
|
account?: `0x${string}` | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
53
|
-
* Tempo
|
|
53
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
54
54
|
* `tempo-auth:sign` scope may send one.
|
|
55
55
|
*/
|
|
56
56
|
challenge?: string | undefined;
|
|
@@ -84,7 +84,7 @@ export declare namespace refresh {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Ends the user's Tempo
|
|
87
|
+
* Ends the user's Tempo ID session, which signs them out of every app that relies on it.
|
|
88
88
|
*
|
|
89
89
|
* @example
|
|
90
90
|
* ```ts
|
package/dist/Actions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tempo
|
|
2
|
+
* Tempo ID's actions. Each takes an instance from `Auth.create`. Each sign-in flow has its own
|
|
3
3
|
* namespace, `oauth` holds the standard OAuth endpoints for tokens an app holds, and the actions
|
|
4
4
|
* every flow shares sit at the top level.
|
|
5
5
|
* @module
|
|
@@ -18,14 +18,14 @@ export * as provider from './actions/provider.js';
|
|
|
18
18
|
export * as realm from './actions/realm.js';
|
|
19
19
|
export * as redirect from './actions/redirect.js';
|
|
20
20
|
/**
|
|
21
|
-
* Authorizes the app for a user already signed in to Tempo
|
|
22
|
-
* without a session, so the app shows sign-in. The key must fit Tempo
|
|
21
|
+
* Authorizes the app for a user already signed in to Tempo ID, from any app. Returns `undefined`
|
|
22
|
+
* without a session, so the app shows sign-in. The key must fit Tempo ID's headless ceiling. An
|
|
23
23
|
* `account` that the call names becomes the app's account for its later requests, such as the
|
|
24
24
|
* account the user selected in a sign-in's account step.
|
|
25
25
|
*
|
|
26
26
|
* A passkey-owned account signs the key with a passkey prompt on the page, when the page is the
|
|
27
27
|
* app's own on Tempo's domain. Elsewhere the call throws a `RequestError` with reason
|
|
28
|
-
* `webauthn_required`, and `Actions.redirect.start` authorizes the key on Tempo
|
|
28
|
+
* `webauthn_required`, and `Actions.redirect.start` authorizes the key on Tempo ID's pages.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* ```ts
|
|
@@ -40,7 +40,7 @@ export async function authorize(auth, options = {}) {
|
|
|
40
40
|
}));
|
|
41
41
|
if (!session.user)
|
|
42
42
|
return undefined;
|
|
43
|
-
// A passkey sign-in's account step kept the key its assertion signed, which Tempo
|
|
43
|
+
// A passkey sign-in's account step kept the key its assertion signed, which Tempo ID
|
|
44
44
|
// authorizes with no second assertion when the passkey's account is chosen.
|
|
45
45
|
const kept = options.accessKey
|
|
46
46
|
? undefined
|
|
@@ -89,7 +89,7 @@ export async function refresh(auth, options) {
|
|
|
89
89
|
}));
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Ends the user's Tempo
|
|
92
|
+
* Ends the user's Tempo ID session, which signs them out of every app that relies on it.
|
|
93
93
|
*
|
|
94
94
|
* @example
|
|
95
95
|
* ```ts
|
|
@@ -97,6 +97,6 @@ export async function refresh(auth, options) {
|
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
99
|
export async function signOut(auth) {
|
|
100
|
-
// A JSON body keeps the request out of Tempo
|
|
100
|
+
// A JSON body keeps the request out of Tempo ID's CSRF check for cross-site form posts.
|
|
101
101
|
await Api.json(await Api.post(auth, '/v1/auth/logout', { json: {} }));
|
|
102
102
|
}
|
package/dist/Auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A Tempo
|
|
2
|
+
* A Tempo ID instance, which every action takes. Create one with {@link create}, then pass it
|
|
3
3
|
* to each action in `Actions`. Every sign-in returns an `Authorization`: the user's tokens and a
|
|
4
4
|
* Viem access key account.
|
|
5
5
|
*
|
|
@@ -36,7 +36,7 @@ export type Account = ViemAccount.AccessKeyAccount & {
|
|
|
36
36
|
/** What the account signs as, which only the `tempoAuth` extension reads. */
|
|
37
37
|
readonly [AccountState.key]: AccountState.State;
|
|
38
38
|
};
|
|
39
|
-
/** A Tempo
|
|
39
|
+
/** A Tempo ID instance, which every action takes. */
|
|
40
40
|
export type Auth = {
|
|
41
41
|
/** The chain the app's keys act on, unless an action's `permissions` names another. */
|
|
42
42
|
chainId: number;
|
|
@@ -44,22 +44,22 @@ export type Auth = {
|
|
|
44
44
|
clientId: string;
|
|
45
45
|
/** The app's client secret. Only a backend holds one. */
|
|
46
46
|
clientSecret?: string | undefined;
|
|
47
|
-
/** Calls Tempo
|
|
47
|
+
/** Calls Tempo ID. Defaults to the global `fetch`. */
|
|
48
48
|
fetch?: typeof globalThis.fetch | undefined;
|
|
49
|
-
/** Where Tempo
|
|
49
|
+
/** Where Tempo ID redirects back to. Defaults to the page's origin in a browser. */
|
|
50
50
|
redirectUri?: string | undefined;
|
|
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
|
|
54
|
+
* Where `Actions.redirect.start` keeps its state until Tempo ID redirects back, and
|
|
55
55
|
* `Actions.passkey.signIn` keeps a new key its email step signed. It must keep objects as they
|
|
56
56
|
* are, since a browser key is a `CryptoKey`. Defaults to IndexedDB.
|
|
57
57
|
*/
|
|
58
58
|
storage?: Storage | undefined;
|
|
59
|
-
/** Where Tempo
|
|
59
|
+
/** Where Tempo ID runs, such as `https://auth.tempo.xyz`. */
|
|
60
60
|
url: string;
|
|
61
61
|
};
|
|
62
|
-
/** A request Tempo
|
|
62
|
+
/** A request Tempo ID refused, with its status and message. */
|
|
63
63
|
export declare class RequestError extends Error {
|
|
64
64
|
readonly name = "Auth.RequestError";
|
|
65
65
|
/** The OAuth error code, such as `invalid_authorization_details`. */
|
|
@@ -70,7 +70,7 @@ export declare class RequestError extends Error {
|
|
|
70
70
|
readonly meta: Readonly<Record<string, number | string>> | undefined;
|
|
71
71
|
/** A stable name for the refusal, to branch on. */
|
|
72
72
|
readonly reason: RequestError.Reason | undefined;
|
|
73
|
-
/** The HTTP status of Tempo
|
|
73
|
+
/** The HTTP status of Tempo ID's response. */
|
|
74
74
|
readonly status: number;
|
|
75
75
|
/** The page that explains the error. */
|
|
76
76
|
readonly uri: string | undefined;
|
|
@@ -88,7 +88,7 @@ export declare namespace RequestError {
|
|
|
88
88
|
meta?: Readonly<Record<string, number | string>> | undefined;
|
|
89
89
|
/** A stable name for the refusal, to branch on. Absent from the issuer's own errors. */
|
|
90
90
|
reason?: Reason | undefined;
|
|
91
|
-
/** The HTTP status of Tempo
|
|
91
|
+
/** The HTTP status of Tempo ID's response. */
|
|
92
92
|
status: number;
|
|
93
93
|
/** The page that explains the error, from `error_uri`. */
|
|
94
94
|
uri?: string | undefined;
|
|
@@ -116,7 +116,7 @@ export declare class SignedOutError extends Error {
|
|
|
116
116
|
*/
|
|
117
117
|
export declare function account(): Account;
|
|
118
118
|
/**
|
|
119
|
-
* Creates a Tempo
|
|
119
|
+
* Creates a Tempo ID instance.
|
|
120
120
|
*
|
|
121
121
|
* @example
|
|
122
122
|
* ```ts
|
|
@@ -132,7 +132,7 @@ export declare namespace create {
|
|
|
132
132
|
*/
|
|
133
133
|
chainId?: number | undefined;
|
|
134
134
|
/**
|
|
135
|
-
* Whether to use Tempo
|
|
135
|
+
* Whether to use Tempo ID's development deployment, `https://auth.tehq.dev`, with keys on
|
|
136
136
|
* Tempo testnet unless `chainId` names another chain. Defaults to `false`.
|
|
137
137
|
*/
|
|
138
138
|
dev?: boolean | undefined;
|
|
@@ -141,7 +141,7 @@ export declare namespace create {
|
|
|
141
141
|
* Defaults to `offline_access`, for a refresh token.
|
|
142
142
|
*/
|
|
143
143
|
scope?: string | undefined;
|
|
144
|
-
/** Where Tempo
|
|
144
|
+
/** Where Tempo ID runs. Defaults to `https://auth.tempo.xyz`, or `https://auth.tehq.dev` with `dev`. */
|
|
145
145
|
url?: string | undefined;
|
|
146
146
|
};
|
|
147
147
|
}
|
package/dist/Auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tempo, tempoTestnet } from 'viem/tempo/chains';
|
|
2
2
|
import * as AccountState from './internal/account.js';
|
|
3
|
-
/** A request Tempo
|
|
3
|
+
/** A request Tempo ID refused, with its status and message. */
|
|
4
4
|
export class RequestError extends Error {
|
|
5
5
|
name = 'Auth.RequestError';
|
|
6
6
|
/** The OAuth error code, such as `invalid_authorization_details`. */
|
|
@@ -11,7 +11,7 @@ export class RequestError extends Error {
|
|
|
11
11
|
meta;
|
|
12
12
|
/** A stable name for the refusal, to branch on. */
|
|
13
13
|
reason;
|
|
14
|
-
/** The HTTP status of Tempo
|
|
14
|
+
/** The HTTP status of Tempo ID's response. */
|
|
15
15
|
status;
|
|
16
16
|
/** The page that explains the error. */
|
|
17
17
|
uri;
|
|
@@ -74,7 +74,7 @@ export function account() {
|
|
|
74
74
|
return proxy;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Creates a Tempo
|
|
77
|
+
* Creates a Tempo ID instance.
|
|
78
78
|
*
|
|
79
79
|
* @example
|
|
80
80
|
* ```ts
|
|
@@ -92,7 +92,7 @@ export function create(options) {
|
|
|
92
92
|
url: url ?? (dev ? urls.dev : urls.production),
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
/** Where Tempo
|
|
95
|
+
/** Where Tempo ID runs unless `create` receives a `url`. */
|
|
96
96
|
const urls = {
|
|
97
97
|
dev: 'https://auth.tehq.dev',
|
|
98
98
|
production: 'https://auth.tempo.xyz',
|
package/dist/Decorator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `tempoAuth`, a Viem client extension that adds Tempo
|
|
2
|
+
* `tempoAuth`, a Viem client extension that adds Tempo ID's actions as `client.auth`. It reads the
|
|
3
3
|
* chain from the client, and sets the client's {@link Auth.Account} at each sign-in, so the client
|
|
4
4
|
* sends with the signed-in user's access key.
|
|
5
5
|
*
|
|
@@ -44,7 +44,7 @@ export declare class SupersededError extends Error {
|
|
|
44
44
|
constructor();
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Returns a Viem client extension that adds Tempo
|
|
47
|
+
* Returns a Viem client extension that adds Tempo ID's actions as `client.auth`. Each member calls
|
|
48
48
|
* the action of the same name in `Actions` with one instance, whose `chainId` is the client's chain.
|
|
49
49
|
* Each sign-in sets the client's account to the authorization's, and `signOut` empties it at once.
|
|
50
50
|
* A sign-in that another sign-in or a sign-out overtook throws {@link SupersededError}. Throws
|
|
@@ -68,7 +68,7 @@ export declare namespace tempoAuth {
|
|
|
68
68
|
* defaults to `chainId`, and an override names another chain.
|
|
69
69
|
*/
|
|
70
70
|
type Decorator<chainId extends number> = {
|
|
71
|
-
/** Tempo
|
|
71
|
+
/** Tempo ID's actions, with the extension's instance. */
|
|
72
72
|
auth: {
|
|
73
73
|
/** Actions for the user's Tempo Account. */
|
|
74
74
|
account: {
|
|
@@ -126,7 +126,7 @@ export declare namespace tempoAuth {
|
|
|
126
126
|
/** `Actions.realm.list`. */
|
|
127
127
|
list: () => Promise<Actions.realm.list.ReturnType>;
|
|
128
128
|
};
|
|
129
|
-
/** Actions for sign-in through a redirect to Tempo
|
|
129
|
+
/** Actions for sign-in through a redirect to Tempo ID's pages. */
|
|
130
130
|
redirect: {
|
|
131
131
|
/** `Actions.redirect.complete`, which sets the client's account. */
|
|
132
132
|
complete: (options?: Actions.redirect.complete.Options) => Promise<Actions.redirect.complete.ReturnType>;
|
package/dist/Decorator.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as Key from './Key.js';
|
|
|
6
6
|
export class AccountRequiredError extends Error {
|
|
7
7
|
name = 'Decorator.AccountRequiredError';
|
|
8
8
|
constructor() {
|
|
9
|
-
super('The client has no Tempo
|
|
9
|
+
super('The client has no Tempo ID account. Create the client with `account: Auth.account()`.');
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
/** A client created without a chain, which the extension reads the instance's `chainId` from. */
|
|
@@ -27,7 +27,7 @@ export class SupersededError extends Error {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Returns a Viem client extension that adds Tempo
|
|
30
|
+
* Returns a Viem client extension that adds Tempo ID's actions as `client.auth`. Each member calls
|
|
31
31
|
* the action of the same name in `Actions` with one instance, whose `chainId` is the client's chain.
|
|
32
32
|
* Each sign-in sets the client's account to the authorization's, and `signOut` empties it at once.
|
|
33
33
|
* A sign-in that another sign-in or a sign-out overtook throws {@link SupersededError}. Throws
|
package/dist/Key.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An app's access key on a user's Tempo Account, as the app stores it: the account it acts for,
|
|
3
|
-
* the authorization Tempo
|
|
3
|
+
* the authorization Tempo ID signed for it, and the key material the library generated.
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { type Address, type Hex, type WebCryptoP256 } from 'ox';
|
package/dist/Key.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An app's access key on a user's Tempo Account, as the app stores it: the account it acts for,
|
|
3
|
-
* the authorization Tempo
|
|
3
|
+
* the authorization Tempo ID signed for it, and the key material the library generated.
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { PublicKey } from 'ox';
|
package/dist/Pending.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A sign-in redirect in progress, which an app keeps until Tempo
|
|
2
|
+
* A sign-in redirect in progress, which an app keeps until Tempo ID redirects back.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import type * as Key from './Key.ts';
|
|
6
6
|
/**
|
|
7
|
-
* A sign-in redirect in progress: what the app keeps until Tempo
|
|
7
|
+
* A sign-in redirect in progress: what the app keeps until Tempo ID redirects back, with the
|
|
8
8
|
* material of the new access key the callback authorizes.
|
|
9
9
|
*/
|
|
10
10
|
export type Pending = Key.Material & {
|
|
11
|
-
/** Where Tempo
|
|
11
|
+
/** Where Tempo ID redirects back to, which the code exchange repeats. */
|
|
12
12
|
redirectUri: string;
|
|
13
13
|
/** The value the callback must echo, so a forged callback is refused. */
|
|
14
14
|
state: string;
|
package/dist/Permissions.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { KeyAuthorization } from 'ox/tempo';
|
|
6
6
|
/**
|
|
7
|
-
* What an app's access key may do, as Viem's `accessKey.authorize` takes it. Tempo
|
|
7
|
+
* What an app's access key may do, as Viem's `accessKey.authorize` takes it. Tempo ID fills what
|
|
8
8
|
* it leaves out with the headless ceiling. `chainId` carries the chain's ID as a literal type, which
|
|
9
9
|
* the authorization's `key.chainId` keeps.
|
|
10
10
|
*/
|
package/dist/Provider.d.ts
CHANGED
package/dist/Storage.d.ts
CHANGED
package/dist/TempoAccount.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export type TempoAccount = {
|
|
|
7
7
|
/** The account's address, the same on every Tempo chain. */
|
|
8
8
|
address: `0x${string}`;
|
|
9
9
|
/**
|
|
10
|
-
* Who holds the account's owner key: a Privy wallet, which Tempo
|
|
11
|
-
* passkey, which signs only on a Tempo
|
|
10
|
+
* Who holds the account's owner key: a Privy wallet, which Tempo ID signs with (`privy`), or a
|
|
11
|
+
* passkey, which signs only on a Tempo ID page (`webAuthn`). Treat another value as an owner
|
|
12
12
|
* that may refuse a key authorization.
|
|
13
13
|
*/
|
|
14
14
|
owner: 'privy' | 'webAuthn' | (string & {});
|
package/dist/actions/account.js
CHANGED
|
@@ -13,6 +13,6 @@ import * as Api from '../internal/api.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export async function get(auth) {
|
|
15
15
|
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL(`/v1/account?${new URLSearchParams({ client_id: auth.clientId })}`, auth.url), { credentials: 'include' }));
|
|
16
|
-
// Tempo
|
|
16
|
+
// Tempo ID lists the account the app uses first, and always lists one.
|
|
17
17
|
return Api.tempoAccount(tempo[0]);
|
|
18
18
|
}
|
package/dist/actions/device.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare namespace authorize {
|
|
|
23
23
|
accessKey?: Account.Account | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
26
|
-
* Tempo
|
|
26
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
27
27
|
* `tempo-auth:sign` scope may send one.
|
|
28
28
|
*/
|
|
29
29
|
challenge?: string | undefined;
|
package/dist/actions/device.js
CHANGED
|
@@ -64,7 +64,7 @@ export async function authorize(auth, options = {}) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* The machine's hostname, within the 64 characters Tempo
|
|
67
|
+
* The machine's hostname, within the 64 characters Tempo ID accepts. `getBuiltinModule` loads
|
|
68
68
|
* `node:os` without an import, which browser and React Native bundlers would fail to resolve.
|
|
69
69
|
*/
|
|
70
70
|
function hostname() {
|
package/dist/actions/email.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare namespace signIn {
|
|
|
45
45
|
accessKey?: Account.Account | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
48
|
-
* Tempo
|
|
48
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
49
49
|
* `tempo-auth:sign` scope may send one.
|
|
50
50
|
*/
|
|
51
51
|
challenge?: string | undefined;
|
package/dist/actions/email.js
CHANGED
|
@@ -28,7 +28,7 @@ export async function sendCode(auth, options) {
|
|
|
28
28
|
*/
|
|
29
29
|
export async function signIn(auth, options) {
|
|
30
30
|
const { challenge, code, email, link, permissions } = options;
|
|
31
|
-
// A one-tap passkey sign-in's email step already signed the key it generated, which Tempo
|
|
31
|
+
// A one-tap passkey sign-in's email step already signed the key it generated, which Tempo ID
|
|
32
32
|
// returns once this request names it again. A key the app supplies replaces it.
|
|
33
33
|
const kept = link && !options.accessKey ? await Link.get(auth, { link }) : undefined;
|
|
34
34
|
const key = kept ?? (await AccessKey.resolve(options.accessKey));
|
|
@@ -44,7 +44,7 @@ export async function signIn(auth, options) {
|
|
|
44
44
|
...(link ? { link } : {}),
|
|
45
45
|
},
|
|
46
46
|
}));
|
|
47
|
-
// A refusal throws above, which keeps the key for a retry with a new code. Tempo
|
|
47
|
+
// A refusal throws above, which keeps the key for a retry with a new code. Tempo ID already took
|
|
48
48
|
// the parked request. A failed removal keeps the stale key, which the next email step
|
|
49
49
|
// replaces, rather than discard the authorization.
|
|
50
50
|
if (kept && link)
|
package/dist/actions/oauth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Calls Tempo
|
|
2
|
+
* Calls Tempo ID's standard OAuth endpoints for tokens an app already holds: introspection, the
|
|
3
3
|
* user's claims, and the signing keys that verify every token.
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
@@ -44,8 +44,8 @@ export declare namespace introspect {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Returns the issuer's JSON Web Key Set, whose keys verify every Tempo
|
|
48
|
-
* it, or passes Tempo
|
|
47
|
+
* Returns the issuer's JSON Web Key Set, whose keys verify every Tempo ID token. An API caches
|
|
48
|
+
* it, or passes Tempo ID's `/oauth2/jwks` URL to a JWT library that caches it, such as jose's
|
|
49
49
|
* `createRemoteJWKSet`.
|
|
50
50
|
*
|
|
51
51
|
* @example
|
package/dist/actions/oauth.js
CHANGED
|
@@ -34,8 +34,8 @@ export async function introspect(auth, options) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Returns the issuer's JSON Web Key Set, whose keys verify every Tempo
|
|
38
|
-
* it, or passes Tempo
|
|
37
|
+
* Returns the issuer's JSON Web Key Set, whose keys verify every Tempo ID token. An API caches
|
|
38
|
+
* it, or passes Tempo ID's `/oauth2/jwks` URL to a JWT library that caches it, such as jose's
|
|
39
39
|
* `createRemoteJWKSet`.
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
@@ -23,7 +23,7 @@ import type { Step } from '../Step.ts';
|
|
|
23
23
|
* instance's `storage`.
|
|
24
24
|
*
|
|
25
25
|
* Throws a `RequestError` with reason `webauthn_required` when another passkey owns the account.
|
|
26
|
-
* That passkey signs only on Tempo
|
|
26
|
+
* That passkey signs only on Tempo ID's pages, where `Actions.redirect.start` authorizes it for
|
|
27
27
|
* the signed-in user.
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
@@ -42,7 +42,7 @@ export declare namespace signIn {
|
|
|
42
42
|
accessKey?: Account.Account | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
45
|
-
* Tempo
|
|
45
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
46
46
|
* `tempo-auth:sign` scope may send one.
|
|
47
47
|
*/
|
|
48
48
|
challenge?: string | undefined;
|
package/dist/actions/passkey.js
CHANGED
|
@@ -22,7 +22,7 @@ import { request } from '../internal/request.js';
|
|
|
22
22
|
* instance's `storage`.
|
|
23
23
|
*
|
|
24
24
|
* Throws a `RequestError` with reason `webauthn_required` when another passkey owns the account.
|
|
25
|
-
* That passkey signs only on Tempo
|
|
25
|
+
* That passkey signs only on Tempo ID's pages, where `Actions.redirect.start` authorizes it for
|
|
26
26
|
* the signed-in user.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signs the user in to Tempo
|
|
2
|
+
* Signs the user in to Tempo ID through an OAuth provider or an SSO connection, from the app's
|
|
3
3
|
* own sign-in buttons.
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type { Auth } from '../Auth.ts';
|
|
7
7
|
import type { Provider } from '../Provider.ts';
|
|
8
8
|
/**
|
|
9
|
-
* Lists the OAuth providers Tempo
|
|
9
|
+
* Lists the OAuth providers Tempo ID offers, for an app that shows its own sign-in buttons.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -25,7 +25,7 @@ export declare namespace list {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Sends the browser to an OAuth provider, or to the SSO connection a `Step` names, and back to
|
|
28
|
-
* `returnTo` signed in to Tempo
|
|
28
|
+
* `returnTo` signed in to Tempo ID. Unlike `Actions.email.signIn`, it does not authorize the
|
|
29
29
|
* app: the app calls `Actions.authorize` once the browser returns.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
package/dist/actions/provider.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Api from '../internal/api.js';
|
|
2
2
|
/**
|
|
3
|
-
* Lists the OAuth providers Tempo
|
|
3
|
+
* Lists the OAuth providers Tempo ID offers, for an app that shows its own sign-in buttons.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -14,7 +14,7 @@ export async function list(auth) {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Sends the browser to an OAuth provider, or to the SSO connection a `Step` names, and back to
|
|
17
|
-
* `returnTo` signed in to Tempo
|
|
17
|
+
* `returnTo` signed in to Tempo ID. Unlike `Actions.email.signIn`, it does not authorize the
|
|
18
18
|
* app: the app calls `Actions.authorize` once the browser returns.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
@@ -4,7 +4,7 @@ import type { Authorization } from '../Authorization.ts';
|
|
|
4
4
|
import * as Pending from '../Pending.ts';
|
|
5
5
|
import type { Permissions } from '../Permissions.ts';
|
|
6
6
|
/**
|
|
7
|
-
* Finishes a {@link start} when the page loads with Tempo
|
|
7
|
+
* Finishes a {@link start} when the page loads with Tempo ID's callback, and returns `undefined`
|
|
8
8
|
* otherwise. The code is redeemed once, however often the page calls this.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
@@ -24,7 +24,7 @@ export declare namespace complete {
|
|
|
24
24
|
type ReturnType = Authorization | undefined;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Returns the URL that signs the user in on Tempo
|
|
27
|
+
* Returns the URL that signs the user in on Tempo ID's pages and redirects back with a code,
|
|
28
28
|
* and the `Pending` state to keep until then, such as in a sealed cookie.
|
|
29
29
|
* {@link handleCallback} redeems the code for the tokens and the key authorization.
|
|
30
30
|
*
|
|
@@ -47,13 +47,13 @@ export declare namespace createUrl {
|
|
|
47
47
|
accessKey?: Account.Account | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
50
|
-
* Tempo
|
|
50
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
51
51
|
* `tempo-auth:sign` scope may send one.
|
|
52
52
|
*/
|
|
53
53
|
challenge?: string | undefined;
|
|
54
|
-
/** What the key may do. Tempo
|
|
54
|
+
/** What the key may do. Tempo ID's pages show it, and the headless ceiling fills what it leaves out. */
|
|
55
55
|
permissions?: Permissions | undefined;
|
|
56
|
-
/** Where Tempo
|
|
56
|
+
/** Where Tempo ID redirects back to. Defaults to the instance's `redirectUri`. */
|
|
57
57
|
redirectUri?: string | undefined;
|
|
58
58
|
};
|
|
59
59
|
type ReturnType = {
|
|
@@ -82,12 +82,12 @@ export declare namespace handleCallback {
|
|
|
82
82
|
accessKey?: Account.Account | undefined;
|
|
83
83
|
/** What `createUrl` returned to keep. */
|
|
84
84
|
pending: Pending.Pending;
|
|
85
|
-
/** The callback URL Tempo
|
|
85
|
+
/** The callback URL Tempo ID redirected to. */
|
|
86
86
|
url: string | URL;
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* Sends the browser to Tempo
|
|
90
|
+
* Sends the browser to Tempo ID's pages to sign in, keeping the redirect's state in `storage`.
|
|
91
91
|
* {@link complete} finishes it when the browser returns.
|
|
92
92
|
*
|
|
93
93
|
* @example
|
|
@@ -105,11 +105,11 @@ export declare namespace start {
|
|
|
105
105
|
accessKey?: Account.Account | undefined;
|
|
106
106
|
/**
|
|
107
107
|
* A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
|
|
108
|
-
* Tempo
|
|
108
|
+
* Tempo ID binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
|
|
109
109
|
* `tempo-auth:sign` scope may send one.
|
|
110
110
|
*/
|
|
111
111
|
challenge?: string | undefined;
|
|
112
|
-
/** What the key may do. Tempo
|
|
112
|
+
/** What the key may do. Tempo ID's pages show it, and the headless ceiling fills what it leaves out. */
|
|
113
113
|
permissions?: Permissions | undefined;
|
|
114
114
|
};
|
|
115
115
|
}
|
package/dist/actions/redirect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Signs the user in on Tempo
|
|
2
|
+
* Signs the user in on Tempo ID's pages, which redirect back with a code. `start` and `complete`
|
|
3
3
|
* keep the redirect's state in `storage` for a browser app. `createUrl` and `handleCallback` leave
|
|
4
4
|
* it to the app to keep, for a backend or a native app.
|
|
5
5
|
* @module
|
|
@@ -12,7 +12,7 @@ import { request } from '../internal/request.js';
|
|
|
12
12
|
import * as Store from '../internal/store.js';
|
|
13
13
|
import * as Pending from '../Pending.js';
|
|
14
14
|
/**
|
|
15
|
-
* Finishes a {@link start} when the page loads with Tempo
|
|
15
|
+
* Finishes a {@link start} when the page loads with Tempo ID's callback, and returns `undefined`
|
|
16
16
|
* otherwise. The code is redeemed once, however often the page calls this.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
@@ -46,7 +46,7 @@ export function complete(auth, options = {}) {
|
|
|
46
46
|
return completed;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Returns the URL that signs the user in on Tempo
|
|
49
|
+
* Returns the URL that signs the user in on Tempo ID's pages and redirects back with a code,
|
|
50
50
|
* and the `Pending` state to keep until then, such as in a sealed cookie.
|
|
51
51
|
* {@link handleCallback} redeems the code for the tokens and the key authorization.
|
|
52
52
|
*
|
|
@@ -138,7 +138,7 @@ export async function handleCallback(auth, options) {
|
|
|
138
138
|
}, { accessKey: options.accessKey, material });
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
|
-
* Sends the browser to Tempo
|
|
141
|
+
* Sends the browser to Tempo ID's pages to sign in, keeping the redirect's state in `storage`.
|
|
142
142
|
* {@link complete} finishes it when the browser returns.
|
|
143
143
|
*
|
|
144
144
|
* @example
|
package/dist/internal/api.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Key from '../Key.ts';
|
|
|
6
6
|
import type { TempoAccount } from '../TempoAccount.ts';
|
|
7
7
|
import type { Tokens } from '../Tokens.ts';
|
|
8
8
|
/**
|
|
9
|
-
* Builds an authorization from what Tempo
|
|
9
|
+
* Builds an authorization from what Tempo ID returned and the sign-in's key: the material the
|
|
10
10
|
* library generated, or the `accessKey` the app supplied. `chainId` is the chain the request named,
|
|
11
11
|
* which the key authorization repeats.
|
|
12
12
|
*/
|
|
@@ -35,7 +35,7 @@ export type Headless = {
|
|
|
35
35
|
};
|
|
36
36
|
/** Reads a JSON response, and throws a {@link RequestError} for a refused request. */
|
|
37
37
|
export declare function json<value = unknown>(response: Response): Promise<value>;
|
|
38
|
-
/** An OAuth error response, with Tempo
|
|
38
|
+
/** An OAuth error response, with Tempo ID's extension members. */
|
|
39
39
|
export type ErrorBody = {
|
|
40
40
|
/** The OAuth error code, which `reason` determines. */
|
|
41
41
|
error: string;
|
|
@@ -54,12 +54,12 @@ export type ErrorBody = {
|
|
|
54
54
|
export declare function error(body: Partial<ErrorBody>, options: {
|
|
55
55
|
status: number;
|
|
56
56
|
}): RequestError;
|
|
57
|
-
/** Posts JSON to Tempo
|
|
57
|
+
/** Posts JSON to Tempo ID's API with the session cookie. */
|
|
58
58
|
export declare function post(auth: Auth, path: string, options: {
|
|
59
59
|
json: unknown;
|
|
60
60
|
}): Promise<Response>;
|
|
61
61
|
/**
|
|
62
|
-
* Calls Tempo
|
|
62
|
+
* Calls Tempo ID's OAuth token endpoint, adding the client and any secret. It forwards standard
|
|
63
63
|
* OAuth form posts to WorkOS.
|
|
64
64
|
*/
|
|
65
65
|
export declare function token(auth: Auth, body: Record<string, string>): Promise<TokenResponse>;
|
|
@@ -86,7 +86,7 @@ export type TempoAccountResponse = {
|
|
|
86
86
|
name: string;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
/** What Tempo
|
|
89
|
+
/** What Tempo ID's token endpoint returns. Redeeming a redirect's code adds its key authorization. */
|
|
90
90
|
export type TokenResponse = {
|
|
91
91
|
/** The access token, which authorizes the app's requests to its APIs. */
|
|
92
92
|
access_token: string;
|
package/dist/internal/api.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Calls Tempo
|
|
2
|
+
* Calls Tempo ID's API, and reads its responses into what the actions return.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import { Base64 } from 'ox';
|
|
6
6
|
import { RequestError } from '../Auth.js';
|
|
7
7
|
import * as Key from '../Key.js';
|
|
8
8
|
/**
|
|
9
|
-
* Builds an authorization from what Tempo
|
|
9
|
+
* Builds an authorization from what Tempo ID returned and the sign-in's key: the material the
|
|
10
10
|
* library generated, or the `accessKey` the app supplied. `chainId` is the chain the request named,
|
|
11
11
|
* which the key authorization repeats.
|
|
12
12
|
*/
|
|
@@ -48,7 +48,7 @@ export function error(body, options) {
|
|
|
48
48
|
uri: body.error_uri,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
/** Posts JSON to Tempo
|
|
51
|
+
/** Posts JSON to Tempo ID's API with the session cookie. */
|
|
52
52
|
export function post(auth, path, options) {
|
|
53
53
|
return (auth.fetch ?? fetch)(new URL(path, auth.url), {
|
|
54
54
|
body: JSON.stringify(options.json),
|
|
@@ -58,7 +58,7 @@ export function post(auth, path, options) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Calls Tempo
|
|
61
|
+
* Calls Tempo ID's OAuth token endpoint, adding the client and any secret. It forwards standard
|
|
62
62
|
* OAuth form posts to WorkOS.
|
|
63
63
|
*/
|
|
64
64
|
export async function token(auth, body) {
|
|
@@ -2,8 +2,8 @@ import type { Account } from 'viem/tempo';
|
|
|
2
2
|
import type { Auth } from '../Auth.ts';
|
|
3
3
|
import type { Permissions } from '../Permissions.ts';
|
|
4
4
|
/**
|
|
5
|
-
* The authorization request and key authorization request, in Tempo
|
|
6
|
-
* key account names its Tempo Account through `access`, and a plain key leaves it to Tempo
|
|
5
|
+
* The authorization request and key authorization request, in Tempo ID's wire format. An access
|
|
6
|
+
* key account names its Tempo Account through `access`, and a plain key leaves it to Tempo ID.
|
|
7
7
|
*/
|
|
8
8
|
export declare function request(auth: Auth, options: {
|
|
9
9
|
accessKey: Account.Account;
|
package/dist/internal/request.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builds the authorization and key authorization requests the actions send, in Tempo
|
|
3
|
-
* format. The root type check holds them to Tempo
|
|
2
|
+
* Builds the authorization and key authorization requests the actions send, in Tempo ID's wire
|
|
3
|
+
* format. The root type check holds them to Tempo ID's routes.
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { Hex } from 'ox';
|
|
7
7
|
/**
|
|
8
|
-
* The authorization request and key authorization request, in Tempo
|
|
9
|
-
* key account names its Tempo Account through `access`, and a plain key leaves it to Tempo
|
|
8
|
+
* The authorization request and key authorization request, in Tempo ID's wire format. An access
|
|
9
|
+
* key account names its Tempo Account through `access`, and a plain key leaves it to Tempo ID.
|
|
10
10
|
*/
|
|
11
11
|
export function request(auth, options) {
|
|
12
12
|
const { accessKey, challenge, permissions = {} } = options;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempoxyz/auth",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
4
|
-
"description": "Signs users in to Tempo through Tempo
|
|
3
|
+
"version": "0.0.0-pr-117.sha-cf46870",
|
|
4
|
+
"description": "Signs users in to Tempo through Tempo ID, and returns Viem access key accounts on their Tempo Accounts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|