@tempoxyz/id 0.0.0-pr-704.sha-6a3fa61 → 0.0.0-pr-705.sha-e7637a1

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.
@@ -4,8 +4,8 @@ import {
4
4
  name,
5
5
  parseName,
6
6
  pending
7
- } from "./chunk-U2KJB64X.js";
8
- import "./chunk-IBZUNV2Y.js";
7
+ } from "./chunk-JJT3ITRO.js";
8
+ import "./chunk-YDYAVOWG.js";
9
9
  import "./chunk-YW5DUQT3.js";
10
10
  import "./chunk-MLKGABMK.js";
11
11
  export {
@@ -4,7 +4,7 @@ import {
4
4
  machines,
5
5
  prompt,
6
6
  waiting
7
- } from "./chunk-IBZUNV2Y.js";
7
+ } from "./chunk-YDYAVOWG.js";
8
8
  import "./chunk-MLKGABMK.js";
9
9
  export {
10
10
  create,
@@ -2,7 +2,7 @@ import {
2
2
  AccessKey_exports,
3
3
  Accounts_exports,
4
4
  Actions_exports
5
- } from "./chunk-IBZUNV2Y.js";
5
+ } from "./chunk-YDYAVOWG.js";
6
6
 
7
7
  // src/Session.ts
8
8
  import * as Fs from "node:fs/promises";
@@ -5,7 +5,7 @@ import {
5
5
  expired,
6
6
  from,
7
7
  revokeAccessKey
8
- } from "./chunk-IBZUNV2Y.js";
8
+ } from "./chunk-YDYAVOWG.js";
9
9
  import {
10
10
  from as from2
11
11
  } from "./chunk-YW5DUQT3.js";
@@ -19,6 +19,7 @@ import {
19
19
  var Accounts_exports = {};
20
20
  __export(Accounts_exports, {
21
21
  ChainUnavailableError: () => ChainUnavailableError,
22
+ ChallengeWithoutKeyError: () => ChallengeWithoutKeyError,
22
23
  ClientIdRequiredError: () => ClientIdRequiredError,
23
24
  ConnectionsRequiredError: () => ConnectionsRequiredError,
24
25
  EverywhereNotAllowedError: () => EverywhereNotAllowedError,
@@ -232,15 +233,10 @@ function authorization(body, options) {
232
233
  return {
233
234
  ...tokens_,
234
235
  accessKey: toAccount(key, { accessKey: accessKey2 }),
235
- ...challengeSignature(body),
236
236
  key,
237
237
  user: user(tokens_)
238
238
  };
239
239
  }
240
- function challengeSignature(body) {
241
- if (!body.account || !body.challenge_signature) return {};
242
- return { address: body.account, challengeSignature: body.challenge_signature };
243
- }
244
240
  async function json(response) {
245
241
  const body = await response.json().catch(() => ({}));
246
242
  if (!response.ok) throw error(body, { status: response.status });
@@ -479,7 +475,7 @@ function signedIn(error3, options = {}) {
479
475
  }
480
476
  function withoutKey(body) {
481
477
  const tokens_ = "accessToken" in body.tokens ? body.tokens : tokens(body.tokens);
482
- return { ...tokens_, ...challengeSignature(body), user: user(tokens_) };
478
+ return { ...tokens_, user: user(tokens_) };
483
479
  }
484
480
 
485
481
  // ../../accounts/src/actions/account.ts
@@ -945,6 +941,8 @@ function seconds(options) {
945
941
  var base64url = { pad: false, url: true };
946
942
  async function authorizeUrl(auth, options) {
947
943
  const { accessKey: accessKey2 } = options;
944
+ if (!accessKey2 && options.challenge !== void 0)
945
+ throw new ChallengeWithoutKeyError();
948
946
  const redirectUri = options.redirectUri ?? auth.redirectUri ?? `${window.location.origin}/`;
949
947
  const key = accessKey2 ? await resolve(accessKey2) : void 0;
950
948
  const pending = from2({
@@ -961,7 +959,6 @@ async function authorizeUrl(auth, options) {
961
959
  }) : void 0;
962
960
  const url = new URL("/oauth2/authorize", auth.url);
963
961
  const parameters = new URLSearchParams({
964
- ...options.challenge !== void 0 && !accessKey2 ? { chain_id: String(auth.chainId) } : {},
965
962
  ...options.challenge === void 0 ? {} : { challenge: options.challenge },
966
963
  client_id: auth.clientId,
967
964
  // In the web message mode, Tempo ID sets the challenge and redeems the code itself.
@@ -999,8 +996,6 @@ async function authorizeUrl(auth, options) {
999
996
  function request(auth, options) {
1000
997
  const { accessKey: accessKey2, challenge } = options;
1001
998
  return {
1002
- // A challenge without an access key names the instance's chain, whose view of the account signs it.
1003
- ...challenge !== void 0 && !accessKey2 ? { chain_id: auth.chainId } : {},
1004
999
  ...challenge === void 0 ? {} : { challenge },
1005
1000
  client_id: auth.clientId,
1006
1001
  ...accessKey2 ? {
@@ -1175,7 +1170,7 @@ async function sign(auth, options) {
1175
1170
  });
1176
1171
  }
1177
1172
  function steps(json2, options) {
1178
- if (!json2.key_authorization && json2.challenge === void 0) return false;
1173
+ if (!json2.key_authorization) return false;
1179
1174
  return options.getFn !== void 0 || globalThis.navigator?.credentials !== void 0;
1180
1175
  }
1181
1176
  function redemption(auth) {
@@ -1221,12 +1216,12 @@ async function sendCode(auth, options) {
1221
1216
  }
1222
1217
  async function signIn(auth, options) {
1223
1218
  const { challenge, code, email, userIp } = options;
1219
+ if (!options.accessKey && challenge !== void 0)
1220
+ throw new ChallengeWithoutKeyError();
1224
1221
  authenticated(auth);
1225
1222
  const { accessKey: accessKey2 } = options;
1226
1223
  const key = accessKey2 ? await resolve(accessKey2) : void 0;
1227
1224
  const body = await token(auth, {
1228
- // A challenge without an access key names the instance's chain, whose view of the account signs it.
1229
- ...challenge !== void 0 && !key ? { chain_id: String(auth.chainId) } : {},
1230
1225
  ...challenge === void 0 ? {} : { challenge },
1231
1226
  code,
1232
1227
  email,
@@ -1246,15 +1241,10 @@ async function signIn(auth, options) {
1246
1241
  });
1247
1242
  const tokens3 = tokens(body);
1248
1243
  if (!key)
1249
- return {
1250
- ...tokens3,
1251
- ...challengeSignature(body),
1252
- user: user(tokens3)
1253
- };
1244
+ return { ...tokens3, user: user(tokens3) };
1254
1245
  return authorization(
1255
1246
  {
1256
1247
  account: body.account,
1257
- ...body.challenge_signature ? { challenge_signature: body.challenge_signature } : {},
1258
1248
  key_authorization: body.key_authorization,
1259
1249
  tokens: tokens3
1260
1250
  },
@@ -1338,11 +1328,8 @@ __export(device_exports, {
1338
1328
  });
1339
1329
  import { Base64 as Base646 } from "ox";
1340
1330
  async function authorize2(auth, options) {
1341
- const { accessKey: accessKey2 } = options;
1342
- const key = accessKey2 ? await resolve(accessKey2) : void 0;
1331
+ const key = await resolve(options.accessKey);
1343
1332
  const body = new URLSearchParams({
1344
- // A challenge without an access key names the instance's chain, whose view of the account signs it.
1345
- ...options.challenge !== void 0 && !key ? { chain_id: String(auth.chainId) } : {},
1346
1333
  ...options.challenge === void 0 ? {} : { challenge: options.challenge },
1347
1334
  // The instance's app is the device app that the CLI signs in to, such as `tempo-cli`.
1348
1335
  client_id: auth.clientId,
@@ -1350,16 +1337,14 @@ async function authorize2(auth, options) {
1350
1337
  ...options.funding?.currency === void 0 ? {} : { funding_currency: options.funding.currency },
1351
1338
  ...options.funding ? { funding_hint: options.funding.amount } : {},
1352
1339
  ...options.funding?.token === void 0 ? {} : { funding_token: options.funding.token },
1353
- ...key && accessKey2 ? {
1354
- key_authorization: Base646.fromString(
1355
- JSON.stringify(
1356
- keyAuthorization(auth, {
1357
- accessKey: { ...accessKey2, account: key.accessKey }
1358
- })
1359
- ),
1360
- { pad: false, url: true }
1361
- )
1362
- } : {}
1340
+ key_authorization: Base646.fromString(
1341
+ JSON.stringify(
1342
+ keyAuthorization(auth, {
1343
+ accessKey: { ...options.accessKey, account: key.accessKey }
1344
+ })
1345
+ ),
1346
+ { pad: false, url: true }
1347
+ )
1363
1348
  });
1364
1349
  for (const resource of resources(auth, options))
1365
1350
  body.append("resource", resource);
@@ -1426,11 +1411,6 @@ async function authorize2(auth, options) {
1426
1411
  }
1427
1412
  async function poll(auth, options) {
1428
1413
  const { deviceCode } = options;
1429
- if (options.accessKey === false)
1430
- return request2(auth, {
1431
- deviceCode,
1432
- key: void 0
1433
- });
1434
1414
  const accessKey2 = own(options.accessKey);
1435
1415
  if (!accessKey2) throw new AccessKeyRequiredError();
1436
1416
  return request2(auth, {
@@ -1457,17 +1437,15 @@ async function request2(auth, options) {
1457
1437
  });
1458
1438
  if (typeof body === "string")
1459
1439
  return { slowDown: body === "slow_down", status: "pending" };
1460
- const authorization2 = key ? authorization(
1461
- {
1462
- account: body.account,
1463
- ...body.challenge_signature ? { challenge_signature: body.challenge_signature } : {},
1464
- key_authorization: body.key_authorization,
1465
- tokens: tokens(body)
1466
- },
1467
- key
1468
- ) : withoutKey({ ...body, tokens: tokens(body) });
1469
1440
  return {
1470
- authorization: authorization2,
1441
+ authorization: authorization(
1442
+ {
1443
+ account: body.account,
1444
+ key_authorization: body.key_authorization,
1445
+ tokens: tokens(body)
1446
+ },
1447
+ key
1448
+ ),
1471
1449
  status: "approved"
1472
1450
  };
1473
1451
  }
@@ -1734,7 +1712,7 @@ async function open(auth, options) {
1734
1712
  throw new OriginError({ origin: window.location.origin, redirectUri });
1735
1713
  if (mode === "popup" && options.mode !== "popup" && !activated()) {
1736
1714
  const address2 = await abortable(read2(), { signal });
1737
- const Sheet = await import("./Sheet-2L465IRV.js");
1715
+ const Sheet = await import("./Sheet-PTAFRAX2.js");
1738
1716
  return await new Promise((resolve3, reject) => {
1739
1717
  const abort = () => {
1740
1718
  close();
@@ -1785,7 +1763,7 @@ async function watch(auth, options) {
1785
1763
  try {
1786
1764
  return await new Promise(
1787
1765
  (resolve3, reject) => {
1788
- void import("./Sheet-2L465IRV.js").then(
1766
+ void import("./Sheet-PTAFRAX2.js").then(
1789
1767
  (Sheet) => {
1790
1768
  if (settled) return;
1791
1769
  unblock = Sheet.waiting({
@@ -1850,7 +1828,7 @@ function parse(url, options) {
1850
1828
  async function frame(auth, options) {
1851
1829
  const { redirectUri, signal, toUrl } = options;
1852
1830
  const address2 = await abortable(options.address, { signal });
1853
- const Sheet = await import("./Sheet-2L465IRV.js");
1831
+ const Sheet = await import("./Sheet-PTAFRAX2.js");
1854
1832
  signal?.throwIfAborted();
1855
1833
  let close;
1856
1834
  let abort;
@@ -2116,11 +2094,7 @@ function finish(options) {
2116
2094
  } = options.pending;
2117
2095
  if (key === false) {
2118
2096
  const tokens3 = tokens(body);
2119
- return {
2120
- ...tokens3,
2121
- ...challengeSignature(body),
2122
- user: user(tokens3)
2123
- };
2097
+ return { ...tokens3, user: user(tokens3) };
2124
2098
  }
2125
2099
  if (!body.account || !body.key_authorization)
2126
2100
  throw new RequestError({
@@ -2132,7 +2106,6 @@ function finish(options) {
2132
2106
  return authorization(
2133
2107
  {
2134
2108
  account: body.account,
2135
- ...body.challenge_signature ? { challenge_signature: body.challenge_signature } : {},
2136
2109
  key_authorization: body.key_authorization,
2137
2110
  tokens: body
2138
2111
  },
@@ -2673,10 +2646,6 @@ function toSession(result) {
2673
2646
  return from4({
2674
2647
  accessToken: result.accessToken,
2675
2648
  ...result.account ? { account: result.account } : {},
2676
- ...result.address && result.challengeSignature ? {
2677
- address: result.address,
2678
- challengeSignature: result.challengeSignature
2679
- } : {},
2680
2649
  expiresAt: result.expiresAt,
2681
2650
  ...result.idToken !== void 0 ? { idToken: result.idToken } : {},
2682
2651
  ...result.key ? { key: withLifetime(result.key) } : {},
@@ -2722,6 +2691,8 @@ async function sendCode2(auth, options) {
2722
2691
  }
2723
2692
  async function signIn3(auth, options) {
2724
2693
  const { code, email, getFn, link } = options;
2694
+ if (!options.accessKey && options.challenge !== void 0)
2695
+ throw new ChallengeWithoutKeyError();
2725
2696
  const prepared = await prepare(auth, options);
2726
2697
  const assertion = await (async () => {
2727
2698
  if (!link) return void 0;
@@ -3014,27 +2985,10 @@ async function register(auth, options = {}) {
3014
2985
  signed,
3015
2986
  headless.key
3016
2987
  );
3017
- const challenged = options.challenge === void 0 ? {} : await (async () => {
3018
- try {
3019
- return challengeSignature(
3020
- await json(
3021
- await post2(auth, {
3022
- getFn,
3023
- json: request(auth, { challenge: options.challenge })
3024
- })
3025
- )
3026
- );
3027
- } catch (error3) {
3028
- return signedIn(error3, {
3029
- message: "Challenge signature failed after the registration, with no response from Tempo ID. The passkey is registered, so sign in with it and the challenge."
3030
- });
3031
- }
3032
- })();
3033
2988
  return {
3034
2989
  ...result,
3035
2990
  authorization: {
3036
2991
  ...authorization2,
3037
- ...challenged,
3038
2992
  upgradeAvailable: signed.upgrade_available === true
3039
2993
  }
3040
2994
  };
@@ -3063,6 +3017,8 @@ function refused(error3) {
3063
3017
  }
3064
3018
  async function requestOptions(auth, options) {
3065
3019
  const { credentialId, mediation, select } = options;
3020
+ if (!options.accessKey && options.challenge !== void 0)
3021
+ throw new ChallengeWithoutKeyError();
3066
3022
  const { authorize: authorize6, key } = await prepare(auth, options);
3067
3023
  const requestedAt = Date.now();
3068
3024
  const requested = await json(
@@ -3147,6 +3103,8 @@ async function list(auth) {
3147
3103
  // ../../accounts/src/internal/Actions.ts
3148
3104
  async function authorize4(auth, options = {}) {
3149
3105
  const { accessKey: accessKey2 } = options;
3106
+ if (!accessKey2 && options.challenge !== void 0)
3107
+ throw new ChallengeWithoutKeyError();
3150
3108
  const [session2, generated] = await Promise.all([
3151
3109
  (async () => json(
3152
3110
  await (auth.fetch ?? globalThis.fetch)(
@@ -3453,7 +3411,7 @@ var signInIds = /* @__PURE__ */ new Set([
3453
3411
  function plugin() {
3454
3412
  let loading;
3455
3413
  function load() {
3456
- loading ??= import("./dialog-4KIVDDJQ.js").then((module) => module.dialog()).catch((error3) => {
3414
+ loading ??= import("./dialog-7DSDKEHU.js").then((module) => module.dialog()).catch((error3) => {
3457
3415
  loading = void 0;
3458
3416
  throw error3;
3459
3417
  });
@@ -4408,6 +4366,14 @@ var ChainUnavailableError = class extends Error {
4408
4366
  );
4409
4367
  }
4410
4368
  };
4369
+ var ChallengeWithoutKeyError = class extends Error {
4370
+ name = "Accounts.ChallengeWithoutKeyError";
4371
+ constructor() {
4372
+ super(
4373
+ "A challenge rides in the key authorization, so a sign-in without `accessKey` takes none. Remove `challenge`, or pass `accessKey` to request an access key."
4374
+ );
4375
+ }
4376
+ };
4411
4377
  var ClientIdRequiredError = class extends Error {
4412
4378
  name = "Accounts.ClientIdRequiredError";
4413
4379
  constructor() {
@@ -4665,7 +4631,7 @@ function create4(options = {}) {
4665
4631
  function connections2() {
4666
4632
  if (!connectionsOptions)
4667
4633
  return Promise.reject(new ConnectionsRequiredError());
4668
- attached ??= import("./Connections-ONCDPK23.js").then(
4634
+ attached ??= import("./Connections-7J5I4L3Q.js").then(
4669
4635
  (module) => module.attach(config, connectionsOptions)
4670
4636
  );
4671
4637
  return attached;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  env,
3
3
  login
4
- } from "../chunk-FU2TDVJS.js";
5
- import "../chunk-U2KJB64X.js";
6
- import "../chunk-IBZUNV2Y.js";
4
+ } from "../chunk-FDHRRJQI.js";
5
+ import "../chunk-JJT3ITRO.js";
6
+ import "../chunk-YDYAVOWG.js";
7
7
  import "../chunk-YW5DUQT3.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  env,
3
3
  remove
4
- } from "../chunk-FU2TDVJS.js";
5
- import "../chunk-U2KJB64X.js";
6
- import "../chunk-IBZUNV2Y.js";
4
+ } from "../chunk-FDHRRJQI.js";
5
+ import "../chunk-JJT3ITRO.js";
6
+ import "../chunk-YDYAVOWG.js";
7
7
  import "../chunk-YW5DUQT3.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
 
@@ -2,9 +2,9 @@ import {
2
2
  env,
3
3
  signedOut,
4
4
  whoami
5
- } from "../chunk-FU2TDVJS.js";
6
- import "../chunk-U2KJB64X.js";
7
- import "../chunk-IBZUNV2Y.js";
5
+ } from "../chunk-FDHRRJQI.js";
6
+ import "../chunk-JJT3ITRO.js";
7
+ import "../chunk-YDYAVOWG.js";
8
8
  import "../chunk-YW5DUQT3.js";
9
9
  import "../chunk-MLKGABMK.js";
10
10
 
@@ -4,7 +4,7 @@ import {
4
4
  expired2 as expired,
5
5
  from2 as from,
6
6
  toSession
7
- } from "./chunk-IBZUNV2Y.js";
7
+ } from "./chunk-YDYAVOWG.js";
8
8
  import "./chunk-MLKGABMK.js";
9
9
 
10
10
  // ../../accounts/src/plugins/dialog.ts
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node": ">=24.21"
10
10
  },
11
11
  "name": "@tempoxyz/id",
12
- "version": "0.0.0-pr-704.sha-6a3fa61",
12
+ "version": "0.0.0-pr-705.sha-e7637a1",
13
13
  "description": "The tempo-id CLI: sign in to Tempo ID, and call its API and the Admin API.",
14
14
  "type": "module",
15
15
  "bin": {