@tempoxyz/auth 0.0.0-pr-43.sha-8021459 → 0.0.0-pr-48.sha-9d0ea2b

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/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' | 'body_too_large' | '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';
52
+ type Reason = 'already_decided' | 'body_too_large' | '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';
53
53
  }
54
54
  /**
55
55
  * Creates a Tempo Auth instance.
@@ -99,6 +99,14 @@ export async function createUrl(auth, options = {}) {
99
99
  export async function handleCallback(auth, options) {
100
100
  const { redirectUri, state, verifier, ...material } = options.pending;
101
101
  const params = new URL(options.url).searchParams;
102
+ // State comes first, so a forged link cannot supply the error an app shows.
103
+ if (params.get('state') !== state)
104
+ throw new RequestError({
105
+ code: 'invalid_request',
106
+ field: 'state',
107
+ message: 'Invalid `state` in the callback URL. Start sign-in again from this app.',
108
+ status: 400,
109
+ });
102
110
  const code = params.get('code');
103
111
  if (!code)
104
112
  throw new RequestError({
@@ -108,13 +116,6 @@ export async function handleCallback(auth, options) {
108
116
  'Missing `code` in the callback URL. Start sign-in again.',
109
117
  status: 400,
110
118
  });
111
- if (params.get('state') !== state)
112
- throw new RequestError({
113
- code: 'invalid_request',
114
- field: 'state',
115
- message: 'Invalid `state` in the callback URL. Start sign-in again from this app.',
116
- status: 400,
117
- });
118
119
  const body = await Api.token(auth, {
119
120
  code,
120
121
  code_verifier: verifier,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempoxyz/auth",
3
- "version": "0.0.0-pr-43.sha-8021459",
3
+ "version": "0.0.0-pr-48.sha-9d0ea2b",
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": {