@tempoxyz/auth 0.0.0-pr-87.sha-2321eb7 → 0.0.0-pr-89.sha-d96be45

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 CHANGED
@@ -32,14 +32,9 @@ export declare namespace authorize {
32
32
  type Options<chainId extends number = number> = {
33
33
  /**
34
34
  * The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
35
- * defaults to the one the user selected at sign-in, or their oldest. Defaults to a new key.
35
+ * defaults to the user's first. Defaults to a new key.
36
36
  */
37
37
  accessKey?: Account.Account | undefined;
38
- /**
39
- * The address of the user's Tempo Account the key acts for, such as the one the user chose from
40
- * a sign-in's account step. Takes the place of `accessKey`'s `access`.
41
- */
42
- account?: `0x${string}` | undefined;
43
38
  /**
44
39
  * A message the owner's signature binds, such as a sign-in challenge the app's backend issued.
45
40
  * Tempo Auth binds its EIP-191 hash as the key authorization's `witness`. Only an app with the
package/dist/Actions.js CHANGED
@@ -30,7 +30,6 @@ export async function authorize(auth, options = {}) {
30
30
  const response = await Api.post(auth, '/v1/authorize', {
31
31
  json: request(auth, {
32
32
  accessKey: key.accessKey,
33
- account: options.account,
34
33
  challenge: options.challenge,
35
34
  permissions: options.permissions,
36
35
  }),
package/dist/Step.d.ts CHANGED
@@ -2,20 +2,8 @@
2
2
  * A step a sign-in needs before it finishes, such as the SSO connection an address requires.
3
3
  * @module
4
4
  */
5
- import type { TempoAccount } from './TempoAccount.ts';
6
- /**
7
- * A step a sign-in needs before it finishes: the SSO connection an address requires, or the choice
8
- * of account for a user with more than one Tempo Account.
9
- */
5
+ /** A step a sign-in needs before it finishes, such as the SSO connection an address requires. */
10
6
  export type Step = {
11
- /** The user's Tempo Accounts: the one the browser selected before first, then oldest first. */
12
- accounts: readonly TempoAccount[];
13
- /**
14
- * The kind of step. The user is signed in, and chooses an account, whose `address`
15
- * `Actions.authorize` takes as `account`.
16
- */
17
- type: 'account';
18
- } | {
19
7
  /** The kind of step. */
20
8
  type: 'sso';
21
9
  /** Where `Actions.provider.signIn` sends the browser to take the step. */
@@ -18,7 +18,7 @@ export declare namespace authorize {
18
18
  type Options<chainId extends number = number> = {
19
19
  /**
20
20
  * The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
21
- * defaults to the one the user selected at sign-in, or their oldest. Defaults to a new key.
21
+ * defaults to the user's first. Defaults to a new key.
22
22
  */
23
23
  accessKey?: Account.Account | undefined;
24
24
  /**
@@ -24,15 +24,12 @@ export declare namespace sendCode {
24
24
  }
25
25
  /**
26
26
  * Signs the user in with the code they were emailed, and authorizes the app in the same call.
27
- * Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues,
28
- * or when the user has more than one Tempo Account, whose chosen `address` `Actions.authorize` takes
29
- * as `account`.
27
+ * Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues.
30
28
  *
31
29
  * @example
32
30
  * ```ts
33
31
  * const result = await Actions.email.signIn(auth, { code, email })
34
- * if ('step' in result && result.step.type === 'sso')
35
- * Actions.provider.signIn(auth, { url: result.step.url })
32
+ * if ('step' in result) Actions.provider.signIn(auth, { url: result.step.url })
36
33
  * ```
37
34
  */
38
35
  export declare function signIn<const chainId extends number = number>(auth: Auth, options: signIn.Options<chainId>): Promise<signIn.ReturnType<chainId>>;
@@ -40,7 +37,7 @@ export declare namespace signIn {
40
37
  type Options<chainId extends number = number> = {
41
38
  /**
42
39
  * The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
43
- * defaults to the one the user selected at sign-in, or their oldest. Defaults to a new key.
40
+ * defaults to the user's first. Defaults to a new key.
44
41
  */
45
42
  accessKey?: Account.Account | undefined;
46
43
  /**
@@ -63,7 +60,7 @@ export declare namespace signIn {
63
60
  /** What the key may do. It must fit the headless ceiling, which fills what it leaves out. */
64
61
  permissions?: Permissions<chainId> | undefined;
65
62
  };
66
- /** The authorization, or the step the address or the user's accounts require first. */
63
+ /** The authorization, or the step the address requires first. */
67
64
  type ReturnType<chainId extends number = number> = Authorization<chainId> | {
68
65
  step: Step;
69
66
  };
@@ -15,15 +15,12 @@ export async function sendCode(auth, options) {
15
15
  }
16
16
  /**
17
17
  * Signs the user in with the code they were emailed, and authorizes the app in the same call.
18
- * Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues,
19
- * or when the user has more than one Tempo Account, whose chosen `address` `Actions.authorize` takes
20
- * as `account`.
18
+ * Returns a {@link Step} when the address requires SSO, which `Actions.provider.signIn` continues.
21
19
  *
22
20
  * @example
23
21
  * ```ts
24
22
  * const result = await Actions.email.signIn(auth, { code, email })
25
- * if ('step' in result && result.step.type === 'sso')
26
- * Actions.provider.signIn(auth, { url: result.step.url })
23
+ * if ('step' in result) Actions.provider.signIn(auth, { url: result.step.url })
27
24
  * ```
28
25
  */
29
26
  export async function signIn(auth, options) {
@@ -49,17 +46,9 @@ export async function signIn(auth, options) {
49
46
  // rather than discard the authorization.
50
47
  if (kept && link)
51
48
  await Link.release(auth, { link }).catch(() => undefined);
52
- if ('step' in body) {
53
- if (body.step.type === 'account')
54
- return {
55
- step: {
56
- accounts: body.step.accounts.map(Api.tempoAccount),
57
- type: 'account',
58
- },
59
- };
49
+ if ('step' in body)
60
50
  return {
61
51
  step: { ...body.step, url: new URL(body.step.url, auth.url).href },
62
52
  };
63
- }
64
53
  return Api.authorization(body.authorization, key);
65
54
  }
@@ -9,7 +9,6 @@ import type { Account } from 'viem/tempo';
9
9
  import type { Auth } from '../Auth.ts';
10
10
  import type { Authorization } from '../Authorization.ts';
11
11
  import type { Permissions } from '../Permissions.ts';
12
- import type { Step } from '../Step.ts';
13
12
  /**
14
13
  * Signs the user in with a passkey, and authorizes the app in the same call. On a page, the
15
14
  * passkey's one assertion also signs the app's key when that passkey owns the Tempo Account, since
@@ -34,7 +33,7 @@ export declare namespace signIn {
34
33
  type Options<chainId extends number = number> = {
35
34
  /**
36
35
  * The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
37
- * defaults to the one the user selected at sign-in, or their oldest. Defaults to a new key.
36
+ * defaults to the user's first. Defaults to a new key.
38
37
  */
39
38
  accessKey?: Account.Account | undefined;
40
39
  /**
@@ -75,14 +74,8 @@ export declare namespace signIn {
75
74
  /** The kind of step. */
76
75
  type: 'email';
77
76
  };
78
- /**
79
- * The authorization, the email step, or the account step of a user with more than one Tempo
80
- * Account. A passkey that owns one of the user's accounts selects it, so only a passkey that owns
81
- * none returns the account step.
82
- */
77
+ /** The authorization, or the email step. */
83
78
  type ReturnType<chainId extends number = number> = Authorization<chainId> | {
84
- step: EmailStep | Extract<Step, {
85
- type: 'account';
86
- }>;
79
+ step: EmailStep;
87
80
  };
88
81
  }
@@ -54,13 +54,6 @@ export async function signIn(auth, options = {}) {
54
54
  json: native ? { assertion, authorize } : { assertion },
55
55
  }));
56
56
  if ('step' in body) {
57
- if (body.step.type === 'account')
58
- return {
59
- step: {
60
- accounts: body.step.accounts.map(Api.tempoAccount),
61
- type: 'account',
62
- },
63
- };
64
57
  // The emailed-code sign-in that sends the link returns this key's authorization, so a key the
65
58
  // library generated waits for it in `storage`.
66
59
  if (body.step.signed && !options.accessKey)
@@ -42,7 +42,7 @@ export declare namespace createUrl {
42
42
  type Options = {
43
43
  /**
44
44
  * The key to authorize, as a Viem account. Its `access` names the Tempo Account, which
45
- * defaults to the one the user selected at sign-in, or their oldest. Defaults to a new key, whose material `pending` keeps.
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
48
  /**
@@ -22,8 +22,7 @@ export declare namespace create {
22
22
  type ReturnType = TempoAccount;
23
23
  }
24
24
  /**
25
- * Lists the signed-in user's Tempo Accounts, their default first: the one they selected at sign-in,
26
- * or else their oldest.
25
+ * Lists the signed-in user's Tempo Accounts, their default first.
27
26
  *
28
27
  * @example
29
28
  * ```ts
@@ -12,11 +12,10 @@ import * as Api from '../internal/api.js';
12
12
  * ```
13
13
  */
14
14
  export async function create(auth) {
15
- return Api.tempoAccount(await Api.json(await Api.post(auth, '/v1/account/tempo', { json: {} })));
15
+ return toTempoAccount(await Api.json(await Api.post(auth, '/v1/account/tempo', { json: {} })));
16
16
  }
17
17
  /**
18
- * Lists the signed-in user's Tempo Accounts, their default first: the one they selected at sign-in,
19
- * or else their oldest.
18
+ * Lists the signed-in user's Tempo Accounts, their default first.
20
19
  *
21
20
  * @example
22
21
  * ```ts
@@ -27,5 +26,12 @@ export async function list(auth) {
27
26
  const { tempo } = await Api.json(await (auth.fetch ?? fetch)(new URL('/v1/account', auth.url), {
28
27
  credentials: 'include',
29
28
  }));
30
- return tempo.map(Api.tempoAccount);
29
+ return tempo.map(toTempoAccount);
30
+ }
31
+ /** Reads the account's address and the type of its owner, which the API lists first. */
32
+ function toTempoAccount(account) {
33
+ return {
34
+ address: account.address,
35
+ owner: account.config.owners[0].type,
36
+ };
31
37
  }
@@ -3,7 +3,6 @@ import type { Account } from 'viem/tempo';
3
3
  import { type Auth, RequestError } from '../Auth.ts';
4
4
  import type { Authorization } from '../Authorization.ts';
5
5
  import * as Key from '../Key.ts';
6
- import type { TempoAccount } from '../TempoAccount.ts';
7
6
  import type { Tokens } from '../Tokens.ts';
8
7
  /**
9
8
  * Builds an authorization from what Tempo Auth returned and the sign-in's key: the material the
@@ -14,14 +13,6 @@ export declare function authorization<chainId extends number = number>(body: Hea
14
13
  accessKey?: Account.Account | undefined;
15
14
  material: Key.Material;
16
15
  }): Authorization<chainId>;
17
- /**
18
- * A sign-in's account step as the API returns it: the accounts of a user with more than one, who
19
- * selects one before a key is authorized.
20
- */
21
- export type AccountStep = {
22
- accounts: readonly TempoAccountResponse[];
23
- type: 'account';
24
- };
25
16
  /** What the headless API returns for an authorization. */
26
17
  export type Headless = {
27
18
  account: Key.Key['account'];
@@ -52,19 +43,6 @@ export declare function post(auth: Auth, path: string, options: {
52
43
  * OAuth form posts to WorkOS.
53
44
  */
54
45
  export declare function token(auth: Auth, body: Record<string, string>): Promise<TokenResponse>;
55
- /** Reads the account's address and the type of its owner, which the API lists first. */
56
- export declare function tempoAccount(account: TempoAccountResponse): TempoAccount;
57
- /** A Tempo Account as the API returns it, with the fields the package reads. */
58
- export type TempoAccountResponse = {
59
- address: `0x${string}`;
60
- config: {
61
- owners: readonly [{
62
- type: string;
63
- }, ...{
64
- type: string;
65
- }[]];
66
- };
67
- };
68
46
  /** What Tempo Auth's token endpoint returns. Redeeming a redirect's code adds its key authorization. */
69
47
  export type TokenResponse = {
70
48
  access_token: string;
@@ -71,13 +71,6 @@ export async function token(auth, body) {
71
71
  method: 'POST',
72
72
  }));
73
73
  }
74
- /** Reads the account's address and the type of its owner, which the API lists first. */
75
- export function tempoAccount(account) {
76
- return {
77
- address: account.address,
78
- owner: account.config.owners[0].type,
79
- };
80
- }
81
74
  /** Reads a token response into `Tokens`. */
82
75
  export function tokens(response) {
83
76
  return {
@@ -7,8 +7,6 @@ import type { Permissions } from '../Permissions.ts';
7
7
  */
8
8
  export declare function request(auth: Auth, options: {
9
9
  accessKey: Account.Account;
10
- /** The user's Tempo Account the key acts for, in place of the one `accessKey` names. */
11
- account?: `0x${string}` | undefined;
12
10
  /** A message the key's witness binds. */
13
11
  challenge?: string | undefined;
14
12
  permissions?: Permissions | undefined;
@@ -10,13 +10,11 @@ import { Hex } from 'ox';
10
10
  */
11
11
  export function request(auth, options) {
12
12
  const { accessKey, challenge, permissions = {} } = options;
13
- const account = options.account ??
14
- (accessKey.accessKeyAddress ? accessKey.address : undefined);
15
13
  return {
16
14
  ...(challenge === undefined ? {} : { challenge }),
17
15
  client_id: auth.clientId,
18
16
  key_authorization: {
19
- ...(account ? { account } : {}),
17
+ ...(accessKey.accessKeyAddress ? { account: accessKey.address } : {}),
20
18
  address: accessKey.accessKeyAddress ?? accessKey.address,
21
19
  chainId: Hex.fromNumber(permissions.chainId ?? auth.chainId),
22
20
  expiry: permissions.expiry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempoxyz/auth",
3
- "version": "0.0.0-pr-87.sha-2321eb7",
3
+ "version": "0.0.0-pr-89.sha-d96be45",
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": {