@tempoxyz/auth 0.0.0-pr-44.sha-c64ed55 → 0.0.0-pr-41.sha-b2e4e21
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 +0 -2
- package/dist/Actions.js +3 -3
- package/dist/Auth.d.ts +1 -1
- package/dist/actions/device.js +2 -2
- package/dist/actions/email.js +2 -2
- package/dist/actions/provider.js +2 -2
- package/dist/actions/tempoAccount.js +2 -2
- package/dist/internal/api.d.ts +0 -5
- package/dist/internal/api.js +0 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -241,8 +241,6 @@ try {
|
|
|
241
241
|
| `storage` | Where `redirect.start` keeps its state, without serializing it. Defaults to IndexedDB |
|
|
242
242
|
| `fetch` | Calls Tempo Auth. Defaults to the global `fetch` |
|
|
243
243
|
|
|
244
|
-
The actions call version 1 of Tempo Auth's JSON API, under `/api/v1`. [API versions](../../docs/versioning.md) describes the version and the deprecated unversioned paths that earlier releases call.
|
|
245
|
-
|
|
246
244
|
### `Actions`
|
|
247
245
|
|
|
248
246
|
Each sign-in flow has its own namespace. The actions every flow shares sit at the top level. Every action that creates a key also takes optional `accessKey` and `permissions`.
|
package/dist/Actions.js
CHANGED
|
@@ -19,13 +19,13 @@ export * as tempoAccount from './actions/tempoAccount.js';
|
|
|
19
19
|
*/
|
|
20
20
|
export async function authorize(auth, options = {}) {
|
|
21
21
|
// Checking the session first answers a visitor without one with no failed request.
|
|
22
|
-
const session = await Api.json(await (auth.fetch ?? fetch)(new URL(
|
|
22
|
+
const session = await Api.json(await (auth.fetch ?? fetch)(new URL('/api/auth/session', auth.url), {
|
|
23
23
|
credentials: 'include',
|
|
24
24
|
}));
|
|
25
25
|
if (!session.user)
|
|
26
26
|
return undefined;
|
|
27
27
|
const key = await AccessKey.resolve(options.accessKey);
|
|
28
|
-
const response = await Api.post(auth,
|
|
28
|
+
const response = await Api.post(auth, '/api/authorize', {
|
|
29
29
|
json: request(auth, {
|
|
30
30
|
accessKey: key.accessKey,
|
|
31
31
|
permissions: options.permissions,
|
|
@@ -61,5 +61,5 @@ export async function refresh(auth, options) {
|
|
|
61
61
|
*/
|
|
62
62
|
export async function signOut(auth) {
|
|
63
63
|
// A JSON body keeps the request out of Tempo Auth's CSRF check for cross-site form posts.
|
|
64
|
-
await Api.json(await Api.post(auth,
|
|
64
|
+
await Api.json(await Api.post(auth, '/api/auth/logout', { json: {} }));
|
|
65
65
|
}
|
package/dist/Auth.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare namespace RequestError {
|
|
|
49
49
|
uri?: string | undefined;
|
|
50
50
|
};
|
|
51
51
|
/** Each refusal's stable name. `docs/errors.md` explains each one. */
|
|
52
|
-
type Reason = 'already_decided' | 'duplicate_limit' | 'empty_limits' | 'empty_scopes' | 'expiry_exceeds_maximum' | 'expiry_passed' | 'foreign_account' | 'invalid_chain' | 'invalid_code' | 'invalid_expiry' | 'invalid_field' | 'invalid_origin' | 'invalid_public_key' | 'limit_exceeds_maximum' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | 'periodic_limit' | 'rejected' | 'scope_without_limit' | 'unknown_code' | 'unsupported_call' | 'unsupported_step' | 'unsupported_token';
|
|
52
|
+
type Reason = 'already_decided' | 'duplicate_limit' | 'empty_limits' | 'empty_scopes' | 'expiry_exceeds_maximum' | 'expiry_passed' | 'foreign_account' | 'invalid_chain' | 'invalid_code' | 'invalid_expiry' | 'invalid_field' | 'invalid_origin' | 'invalid_public_key' | 'limit_exceeds_maximum' | 'missing_code_challenge' | 'missing_key' | 'missing_recipients' | 'periodic_limit' | 'rate_limited' | 'rejected' | 'scope_without_limit' | 'unknown_code' | 'unsupported_call' | 'unsupported_step' | 'unsupported_token';
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Creates a Tempo Auth instance.
|
package/dist/actions/device.js
CHANGED
|
@@ -15,7 +15,7 @@ import { request } from '../internal/request.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export async function authorize(auth, options) {
|
|
17
17
|
const key = await AccessKey.resolve(options.accessKey);
|
|
18
|
-
const code = await Api.json(await Api.post(auth,
|
|
18
|
+
const code = await Api.json(await Api.post(auth, '/api/device/authorize', {
|
|
19
19
|
json: {
|
|
20
20
|
device: options.device,
|
|
21
21
|
keyAuthorization: request(auth, {
|
|
@@ -30,7 +30,7 @@ export async function authorize(auth, options) {
|
|
|
30
30
|
const deadline = Date.now() + code.expires_in * 1000;
|
|
31
31
|
while (Date.now() < deadline) {
|
|
32
32
|
await new Promise((resolve) => setTimeout(resolve, interval * 1000));
|
|
33
|
-
const response = await Api.post(auth,
|
|
33
|
+
const response = await Api.post(auth, '/api/device/token', {
|
|
34
34
|
json: { device_code: code.device_code },
|
|
35
35
|
});
|
|
36
36
|
const body = (await response.json());
|
package/dist/actions/email.js
CHANGED
|
@@ -10,7 +10,7 @@ import { request } from '../internal/request.js';
|
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
export async function sendCode(auth, options) {
|
|
13
|
-
await Api.json(await Api.post(auth,
|
|
13
|
+
await Api.json(await Api.post(auth, '/api/auth/code', { json: options }));
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Signs the user in with the code they were emailed, and authorizes the app in the same call.
|
|
@@ -25,7 +25,7 @@ export async function sendCode(auth, options) {
|
|
|
25
25
|
export async function signIn(auth, options) {
|
|
26
26
|
const { code, email, permissions } = options;
|
|
27
27
|
const key = await AccessKey.resolve(options.accessKey);
|
|
28
|
-
const body = await Api.json(await Api.post(auth,
|
|
28
|
+
const body = await Api.json(await Api.post(auth, '/api/auth/code/verify', {
|
|
29
29
|
json: {
|
|
30
30
|
authorize: request(auth, { accessKey: key.accessKey, permissions }),
|
|
31
31
|
code,
|
package/dist/actions/provider.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as Api from '../internal/api.js';
|
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
11
|
export async function list(auth) {
|
|
12
|
-
const { providers } = await Api.json(await (auth.fetch ?? fetch)(new URL(
|
|
12
|
+
const { providers } = await Api.json(await (auth.fetch ?? fetch)(new URL('/api/auth/providers', auth.url)));
|
|
13
13
|
return providers;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -25,7 +25,7 @@ export async function list(auth) {
|
|
|
25
25
|
export function signIn(auth, options) {
|
|
26
26
|
const url = 'url' in options
|
|
27
27
|
? new URL(options.url)
|
|
28
|
-
: new URL(
|
|
28
|
+
: new URL(`/api/auth/oauth/${options.provider}`, auth.url);
|
|
29
29
|
url.searchParams.set('return_to', options.returnTo ?? window.location.href);
|
|
30
30
|
window.location.assign(url);
|
|
31
31
|
}
|
|
@@ -12,7 +12,7 @@ import * as Api from '../internal/api.js';
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export async function create(auth) {
|
|
15
|
-
const { address } = await Api.json(await Api.post(auth,
|
|
15
|
+
const { address } = await Api.json(await Api.post(auth, '/api/account/tempo', { json: {} }));
|
|
16
16
|
return { address };
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -24,7 +24,7 @@ export async function create(auth) {
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export async function list(auth) {
|
|
27
|
-
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL(
|
|
27
|
+
const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL('/api/account', auth.url), {
|
|
28
28
|
credentials: 'include',
|
|
29
29
|
}));
|
|
30
30
|
return tempo.map(({ address }) => ({ address }));
|
package/dist/internal/api.d.ts
CHANGED
|
@@ -37,11 +37,6 @@ export declare function error(body: Partial<ErrorBody>, options: {
|
|
|
37
37
|
export declare function post(auth: Auth, path: string, options: {
|
|
38
38
|
json?: unknown;
|
|
39
39
|
}): Promise<Response>;
|
|
40
|
-
/**
|
|
41
|
-
* The path prefix of the Tempo Auth API version the package calls. Every JSON route starts with it,
|
|
42
|
-
* and the OAuth endpoints under `/oauth2` do not.
|
|
43
|
-
*/
|
|
44
|
-
export declare const prefix = "/api/v1";
|
|
45
40
|
/**
|
|
46
41
|
* Calls Tempo Auth's OAuth token endpoint, adding the client and any secret. It forwards standard
|
|
47
42
|
* OAuth form posts to WorkOS.
|
package/dist/internal/api.js
CHANGED
|
@@ -60,11 +60,6 @@ export function post(auth, path, options) {
|
|
|
60
60
|
method: 'POST',
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
* The path prefix of the Tempo Auth API version the package calls. Every JSON route starts with it,
|
|
65
|
-
* and the OAuth endpoints under `/oauth2` do not.
|
|
66
|
-
*/
|
|
67
|
-
export const prefix = '/api/v1';
|
|
68
63
|
/**
|
|
69
64
|
* Calls Tempo Auth's OAuth token endpoint, adding the client and any secret. It forwards standard
|
|
70
65
|
* OAuth form posts to WorkOS.
|
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-41.sha-b2e4e21",
|
|
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": {
|