@wirecat/amo-cli 0.2.0 → 0.4.0

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.
Files changed (183) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +19 -14
  3. package/contracts/wirecat.json +58 -19
  4. package/dist/amo/button.d.ts +53 -0
  5. package/dist/amo/button.d.ts.map +1 -0
  6. package/dist/amo/button.js +234 -0
  7. package/dist/amo/button.js.map +1 -0
  8. package/dist/amo/oauth.d.ts +12 -3
  9. package/dist/amo/oauth.d.ts.map +1 -1
  10. package/dist/amo/oauth.js +19 -6
  11. package/dist/amo/oauth.js.map +1 -1
  12. package/dist/bin/amo.js +2 -2
  13. package/dist/bundle/agent-43BMVBX2.js +40 -0
  14. package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PRNXEZRH.js} +63 -21
  15. package/dist/bundle/amo.js +28 -26
  16. package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-FDI24DU2.js} +5 -5
  17. package/dist/bundle/{app-server-2MST5EZ5.js → app-server-WAKJVDLN.js} +79 -68
  18. package/dist/bundle/{bun-4NHWOFX2.js → bun-YPXUXMBI.js} +2 -2
  19. package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-UBQ5M47X.js} +6 -6
  20. package/dist/bundle/chunk-23AQD7JU.js +559 -0
  21. package/dist/bundle/{chunk-2I5UVMLW.js → chunk-2AIG2SSJ.js} +1733 -1160
  22. package/dist/bundle/{chunk-DQV2IKCF.js → chunk-2UJ7ZZZC.js} +10 -3
  23. package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3K6T2G52.js} +43 -64
  24. package/dist/bundle/chunk-3PCVQCCV.js +108 -0
  25. package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-3WG4MTQI.js} +1 -1
  26. package/dist/bundle/chunk-4PQECIU2.js +30 -0
  27. package/dist/bundle/{chunk-T2UDLX76.js → chunk-5HZMXHRH.js} +6 -6
  28. package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-5II6TAJE.js} +1 -1
  29. package/dist/bundle/{chunk-RPWAJYI6.js → chunk-5SJEJYQZ.js} +3 -3
  30. package/dist/bundle/{chunk-5QFHNBGB.js → chunk-6PILR4AX.js} +2 -2
  31. package/dist/bundle/{chunk-TNUFLULO.js → chunk-6QMSKJB4.js} +8 -8
  32. package/dist/bundle/{chunk-5RLUHTK6.js → chunk-745FMNI5.js} +1 -1
  33. package/dist/bundle/{chunk-AUBB72VF.js → chunk-7OVTUADG.js} +41 -10
  34. package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-A4W7J6VN.js} +34 -22
  35. package/dist/bundle/chunk-ABMPZL2P.js +734 -0
  36. package/dist/bundle/{chunk-EROSAUNP.js → chunk-AN6IJYH3.js} +5 -5
  37. package/dist/bundle/{chunk-SZ2V62HB.js → chunk-AP3CWDRK.js} +2 -2
  38. package/dist/bundle/{chunk-ESZSMZKT.js → chunk-ASU63X5C.js} +2 -2
  39. package/dist/bundle/{chunk-EPOV5UIO.js → chunk-BCIZAUDV.js} +11 -11
  40. package/dist/bundle/{chunk-7PKFYX7V.js → chunk-CEBX63XY.js} +8 -8
  41. package/dist/bundle/{chunk-7GTUZY7M.js → chunk-CYHIM5SL.js} +3 -3
  42. package/dist/bundle/chunk-DWA5TZMP.js +209 -0
  43. package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-DWD3KDJA.js} +1 -1
  44. package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-E3EWS6DF.js} +23 -7
  45. package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EAX5RO7S.js} +1 -1
  46. package/dist/bundle/{chunk-LJQUYECN.js → chunk-EBNCUQLV.js} +1 -1
  47. package/dist/bundle/{chunk-UBRREVLJ.js → chunk-ELAKOEIO.js} +2 -2
  48. package/dist/bundle/{chunk-DAY6TSPF.js → chunk-FEUNZG7U.js} +62 -50
  49. package/dist/bundle/{chunk-63F65DHU.js → chunk-FQRP6JWX.js} +2 -2
  50. package/dist/bundle/{chunk-SMSTGO2G.js → chunk-G3LAYJJJ.js} +4 -4
  51. package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-GBQ76X6T.js} +2 -2
  52. package/dist/bundle/{chunk-CHUKWON6.js → chunk-GJBOZAUD.js} +3 -3
  53. package/dist/bundle/{chunk-A33TIM5D.js → chunk-GMHRPX5M.js} +225 -225
  54. package/dist/bundle/{chunk-O2UCU52O.js → chunk-GQKEMBM6.js} +171 -569
  55. package/dist/bundle/{chunk-EQUKVVHX.js → chunk-HDZNSOV5.js} +7 -7
  56. package/dist/bundle/{chunk-ZM7I52EP.js → chunk-HZZ56JO7.js} +3 -4
  57. package/dist/bundle/{chunk-XQL7FEF4.js → chunk-IBEHYGG6.js} +9 -9
  58. package/dist/bundle/{chunk-U7RLVJ34.js → chunk-IPNIF5JE.js} +4 -4
  59. package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KBAOJISR.js} +18 -8
  60. package/dist/bundle/{chunk-ADEWU4P4.js → chunk-KORZEYZN.js} +1 -1
  61. package/dist/bundle/{chunk-JMDLPBXK.js → chunk-KQZTX4LM.js} +17 -17
  62. package/dist/bundle/{chunk-NHXJYS4R.js → chunk-KRD375P7.js} +32 -28
  63. package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-LAR2DLTI.js} +4 -4
  64. package/dist/bundle/{chunk-NC76INB2.js → chunk-LZ4IWN43.js} +3088 -2266
  65. package/dist/bundle/{chunk-BVMNXI53.js → chunk-M33XHJTM.js} +25 -25
  66. package/dist/bundle/{chunk-WCYCUTSK.js → chunk-M54YKD3I.js} +7 -7
  67. package/dist/bundle/{chunk-LSND5QYI.js → chunk-MW7HUD6R.js} +9 -9
  68. package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-NFWD4QX3.js} +2 -2
  69. package/dist/bundle/{chunk-PM77PRB6.js → chunk-NKYWQTS2.js} +189 -163
  70. package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-NXNUCGGO.js} +6 -6
  71. package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-O3WE5IGP.js} +9 -9
  72. package/dist/bundle/chunk-OYMHPQF7.js +52 -0
  73. package/dist/bundle/{chunk-VVHRQ46X.js → chunk-PIOR6PIO.js} +2 -2
  74. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  75. package/dist/bundle/{chunk-XEFAMLSD.js → chunk-PL7TNKAY.js} +3 -3
  76. package/dist/bundle/chunk-PLU2IQXC.js +80 -0
  77. package/dist/bundle/{chunk-73CXFE36.js → chunk-QGFURWEP.js} +29 -1
  78. package/dist/bundle/{chunk-CDY2NJFE.js → chunk-RQPB2BSH.js} +2 -2
  79. package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-S6DTLAOB.js} +12 -12
  80. package/dist/bundle/{chunk-DJD7TBYG.js → chunk-SCMB4LI6.js} +76 -74
  81. package/dist/bundle/{chunk-TGEQNS6G.js → chunk-SFZVMKB6.js} +1 -1
  82. package/dist/bundle/{chunk-PFO76YFP.js → chunk-SHOSFYI7.js} +18 -18
  83. package/dist/bundle/{chunk-5SBLU7D7.js → chunk-SMM7GS4Q.js} +1 -1
  84. package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-SNBYFQHT.js} +1 -1
  85. package/dist/bundle/{chunk-GNTJMB6X.js → chunk-SZX7EPPY.js} +4 -4
  86. package/dist/bundle/{chunk-VX37MPTJ.js → chunk-TCSVW7BA.js} +1 -1
  87. package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TEGQVVCZ.js} +1992 -885
  88. package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-TIR3AB35.js} +758 -1205
  89. package/dist/bundle/{chunk-5HGGG3QO.js → chunk-U46RNOEQ.js} +16 -3
  90. package/dist/bundle/{chunk-Y37A3232.js → chunk-UCM7C773.js} +130 -8
  91. package/dist/bundle/{chunk-L6AFE73L.js → chunk-UEN5NWNW.js} +1 -1
  92. package/dist/bundle/{chunk-6RS7OYTD.js → chunk-V2QWX6B3.js} +3 -3
  93. package/dist/bundle/{chunk-3IRJDH2U.js → chunk-V5SETIQK.js} +2 -100
  94. package/dist/bundle/{chunk-JR6TSMFX.js → chunk-VEFAYLKX.js} +103 -70
  95. package/dist/bundle/{chunk-CUZRHF34.js → chunk-VG26HDKH.js} +4 -4
  96. package/dist/bundle/{chunk-4ZAK773N.js → chunk-VG2ERHFJ.js} +3 -3
  97. package/dist/bundle/{chunk-CHH42KI4.js → chunk-WAFB3IWJ.js} +8 -8
  98. package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-WASBOYI2.js} +4 -4
  99. package/dist/bundle/{chunk-DXGGCGRP.js → chunk-WEWJA42Q.js} +14 -14
  100. package/dist/bundle/chunk-WR2FPZTE.js +353 -0
  101. package/dist/bundle/chunk-XEYT2EQT.js +338 -0
  102. package/dist/bundle/{chunk-DOSJONCX.js → chunk-YFRTEJ6V.js} +7 -7
  103. package/dist/bundle/{chunk-XRTD2GCU.js → chunk-YHVHDRED.js} +19 -258
  104. package/dist/bundle/{chunk-JH3UOHRE.js → chunk-YREKMP24.js} +4 -4
  105. package/dist/bundle/{chunk-V77XNPXG.js → chunk-Z2B3VNRI.js} +11 -11
  106. package/dist/bundle/{chunk-FKR3M62D.js → chunk-ZJC2XJQC.js} +13 -13
  107. package/dist/bundle/{chunk-5E5R65CA.js → chunk-ZKRWNL4T.js} +2 -2
  108. package/dist/bundle/{cli-QVWTXADI.js → cli-QDPKC2HJ.js} +150 -103
  109. package/dist/bundle/command-contract-KWNCP3MQ.js +39 -0
  110. package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-TX7WNN7G.js} +28 -28
  111. package/dist/bundle/{decode-SQ5WGNDX.js → decode-BLPC7OYE.js} +5 -5
  112. package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-5JUT55CS.js} +8 -8
  113. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  114. package/dist/bundle/{echarts-25Z3RINX.js → echarts-54D3FOCL.js} +2 -2
  115. package/dist/bundle/{embed-BNOTNXMA.js → embed-O7KMDYM7.js} +6 -6
  116. package/dist/bundle/{embedder-BCUT7KKV.js → embedder-4PE67CLX.js} +9 -9
  117. package/dist/bundle/{failure-PKAC6XCT.js → failure-NNQYTB3Z.js} +2 -2
  118. package/dist/bundle/{first-run-EO5K5GME.js → first-run-EAU5SHBI.js} +12 -12
  119. package/dist/bundle/first-screen-APSNGZYZ.js +39 -0
  120. package/dist/bundle/{instructions-VLM3QAYB.js → instructions-ONXP5DZQ.js} +1 -1
  121. package/dist/bundle/{mcp-7ILNMJH5.js → mcp-ZNULRPZ4.js} +2 -2
  122. package/dist/bundle/meeting-combined-W2XIYXFU.js +24 -0
  123. package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-FWIZRKVN.js} +11 -11
  124. package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-M4YVJ57W.js} +6 -6
  125. package/dist/bundle/{node-CT3N3TNL.js → node-UTQCYQF5.js} +2 -2
  126. package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-APJG6MGL.js} +7 -7
  127. package/dist/bundle/{oauth-YBH5OKC2.js → oauth-TY7RMIBL.js} +8 -8
  128. package/dist/bundle/{open-WNSBWTAG.js → open-WDVEQL75.js} +5 -5
  129. package/dist/bundle/{openai-XSNMNLW6.js → openai-H5UJHSEZ.js} +15 -15
  130. package/dist/bundle/{process-I2QKOMM7.js → process-MGMXXPMY.js} +1 -1
  131. package/dist/bundle/{program-G6O3IJR2.js → program-IF36C6VR.js} +969 -1127
  132. package/dist/bundle/{prompt-SOG4AKPM.js → prompt-4RLIWLMF.js} +5 -5
  133. package/dist/bundle/{recognize-WMQLWMXH.js → recognize-UIRTMWM4.js} +4 -4
  134. package/dist/bundle/{remote-4BTFOLFY.js → remote-L3MNWZQK.js} +9 -9
  135. package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-F4KZQTY6.js} +7 -7
  136. package/dist/bundle/{serve-B6UANKXN.js → serve-37AUYTWS.js} +10 -10
  137. package/dist/bundle/server-CRF4QSZR.js +86 -0
  138. package/dist/bundle/{server-YRH6GJ5Z.js → server-UBG676ZJ.js} +73 -61
  139. package/dist/bundle/source-Z7GH7T4B.js +44 -0
  140. package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-CI3RW7VA.js} +6 -6
  141. package/dist/bundle/{state-DIJ5YUOE.js → state-JOHLSLUO.js} +6 -6
  142. package/dist/bundle/{store-MYTYDV6A.js → store-2MBG4IUS.js} +28 -21
  143. package/dist/bundle/{store-6WFWW7EC.js → store-OSOUXBYL.js} +28 -23
  144. package/dist/bundle/store-SNW6U32Y.js +34 -0
  145. package/dist/bundle/store-maintenance-command-W7V54SLT.js +73 -0
  146. package/dist/bundle/surface-ESJS2FUI.js +72 -0
  147. package/dist/bundle/writer-BJDQMKUV.js +46 -0
  148. package/dist/commands/account.d.ts +3 -2
  149. package/dist/commands/account.d.ts.map +1 -1
  150. package/dist/commands/account.js +38 -77
  151. package/dist/commands/account.js.map +1 -1
  152. package/dist/commands/crm-shared.d.ts.map +1 -1
  153. package/dist/commands/crm-shared.js +2 -0
  154. package/dist/commands/crm-shared.js.map +1 -1
  155. package/dist/commands/session.d.ts +23 -6
  156. package/dist/commands/session.d.ts.map +1 -1
  157. package/dist/commands/session.js +122 -77
  158. package/dist/commands/session.js.map +1 -1
  159. package/dist/identity.js +1 -1
  160. package/dist/identity.js.map +1 -1
  161. package/dist/program.d.ts.map +1 -1
  162. package/dist/program.js +0 -2
  163. package/dist/program.js.map +1 -1
  164. package/dist/reasons.js +2 -2
  165. package/dist/reasons.js.map +1 -1
  166. package/dist/setup/flow.d.ts.map +1 -1
  167. package/dist/setup/flow.js +74 -4
  168. package/dist/setup/flow.js.map +1 -1
  169. package/dist/setup/texts.en.json +22 -1
  170. package/dist/setup/texts.es.json +22 -1
  171. package/dist/setup/texts.ru.json +22 -1
  172. package/dist/version.d.ts +1 -1
  173. package/dist/version.js +1 -1
  174. package/package.json +3 -3
  175. package/skills/amo-cli/references/setup.md +8 -2
  176. package/dist/bundle/command-contract-QBUQBXH7.js +0 -39
  177. package/dist/bundle/first-screen-GMN3T6RW.js +0 -39
  178. package/dist/bundle/meeting-combined-LAMF7S2B.js +0 -24
  179. package/dist/bundle/server-S6XD6V6E.js +0 -77
  180. package/dist/bundle/source-DGFTA2TN.js +0 -42
  181. package/dist/bundle/store-CHWY2USQ.js +0 -32
  182. package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
  183. package/dist/bundle/writer-GP7VIMAU.js +0 -44
package/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  Notable changes to `@wirecat/amo-cli`. One section per version, newest first.
4
4
 
5
+ ## 0.4.0 — 24.11.2026
6
+
7
+ ### Changed — may break callers
8
+
9
+ - **`account remove` and the check against a second sign-in are cli-core's shared CRM ones** (`@wirecat/cli-core`
10
+ 0.722.0). The reasons stay `account-remove.account-shared` and `session.duplicate`, with the same details, and a
11
+ dry run still warns. The refusal now says `amoCRM account <host>`.
12
+ - **`account remove --delete-data` refuses when amo cannot tell which account another profile holds**
13
+ (`account-remove.account-unknown`, detail `profile`): a profile whose saved sign-in is unreadable and that
14
+ `session start` never remembered. `--keep-data` still removes.
15
+ - **`session start` refuses a profile named `files` or `foreign-contacts`** (`profile.reserved`): every account
16
+ shares those folders in the state folder.
17
+
18
+ ### Fixed
19
+
20
+ - **The install guide quotes amoCRM's refusal for a user who is not an administrator.** The one-click sign-in shows
21
+ that user's account too, and amoCRM refuses under «Разрешить»: «Первичная установка интеграции доступна только
22
+ администраторам аккаунта». The guide said the sign-in listed only the accounts where one is an administrator.
23
+
24
+ ## 0.3.0 — 23.11.2026
25
+
26
+ ### Added
27
+
28
+ - **Sign in with one click: `amo <profile> session start --host https://<subdomain>.amocrm.ru --one-click`.** The
29
+ browser opens a page on connect.wirecat.dev, a WireCat server in Russia that amoCRM can reach. The person
30
+ chooses the account and clicks «Разрешить», and amoCRM creates a WireCat integration in it. Nobody copies an
31
+ integration ID, a secret key or a token. amoCRM sends the integration's secret key to connect.wirecat.dev, and `amo`
32
+ collects it once. `amo` exchanges the code only with the account `--host` names, and refuses one allowed in another
33
+ account. It keeps and renews the sign-in like `--client-id`. amoCRM lets only an account administrator allow it
34
+ ([amoCRM: the button](https://www.amocrm.ru/developers/content/oauth/button)). amoCRM accounts only for now; Kommo
35
+ signs in with a token.
36
+ - **`amo setup` offers «Войти через amoCRM» first to an administrator,** with the token second. WireCat Desktop shows
37
+ the link to open, and waits until access is allowed.
38
+ - **`amo setup` asks whether you are an account administrator.** An administrator creates the integration as before.
39
+ A user who is not one gets the request to send an administrator for a long-lived token, a warning that the token
40
+ carries the administrator's rights, and, once connected, how to sync their own deals rather than the administrator's.
41
+ WireCat Desktop shows the same steps. The installation page has the same path under "If you are not an
42
+ administrator".
43
+
44
+ ### Fixed
45
+
46
+ - **The shared CRM help no longer mentions leads or Bitrix24's fields.** amoCRM has no separate leads: `changes list`,
47
+ `search all` and the other shared commands now describe deals only.
48
+ - The setup and the installation page no longer say that anyone can sign in through the integration in the browser:
49
+ amoCRM's guide says it offers that sign-in only on accounts where the person is an administrator
50
+ ([amoCRM: step by step](https://www.amocrm.ru/developers/content/oauth/step-by-step)).
51
+
5
52
  ## 0.2.0 — 19.11.2026
6
53
 
7
54
  ### Added
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- <a href="https://github.com/WireCatLabs/amo-cli/blob/main/docs/index.md">Docs</a> ·
14
- <a href="https://github.com/WireCatLabs/amo-cli/blob/main/docs/installation.md">Install</a> ·
13
+ <a href="https://wirecat.dev/en/docs/amo">Docs</a> ·
14
+ <a href="https://wirecat.dev/en/docs/amo/installation">Install</a> ·
15
15
  <a href="https://github.com/WireCatLabs/amo-cli/blob/main/docs/usage.md">Usage</a> ·
16
16
  <a href="https://t.me/wirecatdev">Telegram</a>
17
17
  </p>
@@ -74,26 +74,29 @@ and write notes by itself. In `amo` that takes `api call`, which you run yoursel
74
74
 
75
75
  ## Quick start
76
76
 
77
+ In [WireCat Desktop](https://wirecat.dev/en/download), add amoCRM from the tool list and give it the account's address
78
+ and a long-lived token when it asks. Or in a terminal:
79
+
77
80
  ```sh
78
81
  npm install -g @wirecat/amo-cli
79
82
  amo skill install # the agent skill, for Claude Code, Codex, Gemini CLI and OpenClaw
80
- amo work setup # make a private integration in amoCRM or Kommo, paste its token
83
+ amo work setup # sign in with amoCRM in the browser, or paste a token
81
84
  amo work sync # copy your deals and their clients
82
85
  amo work deals list status:open
83
86
  ```
84
87
 
85
88
  `work` is a profile, a name you choose for one account. It is the first word of every command that uses the account,
86
- and none is ever assumed. `amo work setup` shows each click in amoCRM or Kommo, asks for the account's address and the
87
- integration's long-lived token, checks them against the account and keeps the token in the system keyring. An account
88
- administrator makes the integration once. A sync copies the deals assigned to the user the token belongs to. To copy
89
- a colleague's too, see
89
+ and none is ever assumed. `amo work setup` asks for the account's address. An administrator of an amoCRM account then
90
+ clicks **Sign in with amoCRM** and allows access in the browser. Otherwise it shows each click to make a private
91
+ integration and its long-lived token, checks them against the account and keeps the token in the system keyring. A
92
+ sync copies the deals assigned to the user the token belongs to. To copy a colleague's too, see
90
93
  [which deals sync copies](https://github.com/WireCatLabs/amo-cli/blob/main/docs/configuration.md#which-deals-sync-copies).
91
94
 
92
95
  You need Node.js 22.16 or a later 22.x, or Node.js 24 or later. `amo doctor` needs no network and shows what is set
93
96
  up.
94
97
 
95
- More: [install and connect](https://github.com/WireCatLabs/amo-cli/blob/main/docs/installation.md), with the browser
96
- sign-in through the integration.
98
+ More: [install and connect](https://github.com/WireCatLabs/amo-cli/blob/main/docs/installation.md), with every way
99
+ to sign in.
97
100
 
98
101
  ## Use it with your agent
99
102
 
@@ -179,9 +182,10 @@ More: [WireCat](https://wirecat.dev)
179
182
 
180
183
  ## How it works
181
184
 
182
- - **Two ways to sign in.** A long-lived token acts with the rights of the administrator who made it. A sign-in through
183
- the integration in the browser acts with the rights of the person who signs in, and `amo` renews it itself. Either is
184
- kept in your system keyring.
185
+ - **Sign in with one click, or with a token.** An amoCRM administrator clicks amoCRM's button in the browser and
186
+ copies nothing: amoCRM creates WireCat's integration, `amo` acts with that person's rights and renews the sign-in
187
+ itself. A long-lived token works for Kommo and for users, with the rights of the administrator who made it. Either
188
+ is kept in your system keyring.
185
189
  - **A copy of your share of the CRM.** `sync` copies the pipelines, the deals assigned to you and only the contacts and
186
190
  companies on them. An administrator can choose colleagues too. No sync copies the whole CRM.
187
191
  - **Staying current.** `amo work schedule command crm --every 1h -- sync` keeps the copy fresh with a timer.
@@ -196,8 +200,9 @@ More: [command reference](https://github.com/WireCatLabs/amo-cli/blob/main/docs/
196
200
  ## Settings and permissions
197
201
 
198
202
  Each profile has a permission level for every command and every API operation: `allow`, `ask`, `readonly` or `deny`.
199
- Creating and changing deals, contacts and companies is allowed. Deletes and most other writes ask first. Messages to
200
- clients, Salesbots, webhooks, writing tasks and giving a record to another user are denied until you allow them.
203
+ Creating and changing deals, contacts and companies is allowed. Deletes and most other writes ask first in a
204
+ terminal, and run without asking over MCP. Messages to clients, Salesbots, webhooks, writing tasks and giving a
205
+ record to another user are denied until you allow them.
201
206
 
202
207
  ```sh
203
208
  amo work config set permissions.deals.close deny # this profile closes no deal
@@ -32,7 +32,7 @@
32
32
  "session",
33
33
  "start"
34
34
  ],
35
- "summary": "sign in to amoCRM or Kommo with a long-lived token or your own integration",
35
+ "summary": "sign in with one click, a long-lived token or your own integration",
36
36
  "effects": {
37
37
  "remote": "read",
38
38
  "local": "write"
@@ -71,19 +71,6 @@
71
71
  "local": "read"
72
72
  }
73
73
  },
74
- {
75
- "path": [
76
- "account",
77
- "remove"
78
- ],
79
- "summary": "sign this profile out and forget it, keeping or deleting its data",
80
- "effects": {
81
- "remote": "none",
82
- "local": "write"
83
- },
84
- "permission": "account.remove",
85
- "entity": "account_removal"
86
- },
87
74
  {
88
75
  "path": [
89
76
  "sync"
@@ -114,7 +101,7 @@
114
101
  "store",
115
102
  "apply"
116
103
  ],
117
- "summary": "apply scope mine to the contacts already stored: remove those no deal or…",
104
+ "summary": "apply scope mine to the contacts already stored: remove those no deal of the…",
118
105
  "effects": {
119
106
  "remote": "none",
120
107
  "local": "write"
@@ -557,7 +544,7 @@
557
544
  "changes",
558
545
  "list"
559
546
  ],
560
- "summary": "deals and leads made, moved, won, lost and given another owner, activities…",
547
+ "summary": "deals made, moved, won, lost and given another owner, activities added and…",
561
548
  "effects": {
562
549
  "remote": "none",
563
550
  "local": "read"
@@ -583,7 +570,7 @@
583
570
  "search",
584
571
  "all"
585
572
  ],
586
- "summary": "search stored deals and leads, messages, notes, calendar events and meetings",
573
+ "summary": "search stored deals, messages, notes, calendar events and meetings",
587
574
  "effects": {
588
575
  "remote": "none",
589
576
  "local": "read"
@@ -591,6 +578,19 @@
591
578
  "permission": "search.all",
592
579
  "entity": "hit"
593
580
  },
581
+ {
582
+ "path": [
583
+ "account",
584
+ "remove"
585
+ ],
586
+ "summary": "sign this profile out and forget it, keeping or deleting its data",
587
+ "effects": {
588
+ "remote": "none",
589
+ "local": "write"
590
+ },
591
+ "permission": "account.remove",
592
+ "entity": "account_removal"
593
+ },
594
594
  {
595
595
  "path": [
596
596
  "api",
@@ -630,7 +630,7 @@
630
630
  "schedule",
631
631
  "command"
632
632
  ],
633
- "summary": "run amo <args…> on a timer — reads save what they read, so this is how a…",
633
+ "summary": "run amo <args…> on a timer — reads save what they read, so this is how the…",
634
634
  "effects": {
635
635
  "remote": "none",
636
636
  "local": "write"
@@ -1205,6 +1205,7 @@
1205
1205
  "*.amocrm.com",
1206
1206
  "*.kommo.com",
1207
1207
  "wirecat.dev",
1208
+ "connect.wirecat.dev",
1208
1209
  "registry.npmjs.org",
1209
1210
  "huggingface.co",
1210
1211
  "*.huggingface.co",
@@ -1361,6 +1362,44 @@
1361
1362
  "app": "amo-cli",
1362
1363
  "env": "AMO"
1363
1364
  },
1364
- "settings": null
1365
+ "settings": null,
1366
+ "accountRemove": {
1367
+ "signOut": [
1368
+ "{profile}",
1369
+ "session",
1370
+ "end",
1371
+ "--record",
1372
+ "--json"
1373
+ ],
1374
+ "remove": {
1375
+ "minVersion": "0.0.0",
1376
+ "keepData": [
1377
+ "{profile}",
1378
+ "account",
1379
+ "remove",
1380
+ "--keep-data",
1381
+ "--record",
1382
+ "--json"
1383
+ ],
1384
+ "deleteData": [
1385
+ "{profile}",
1386
+ "account",
1387
+ "remove",
1388
+ "--delete-data",
1389
+ "--record",
1390
+ "--json"
1391
+ ],
1392
+ "dryRun": "--dry-run",
1393
+ "confirm": "--yes"
1394
+ },
1395
+ "removes": [
1396
+ "signIn"
1397
+ ],
1398
+ "keeps": [
1399
+ "settings",
1400
+ "data",
1401
+ "listed"
1402
+ ]
1403
+ }
1365
1404
  }
1366
1405
  }
@@ -0,0 +1,53 @@
1
+ import { type KeyringStore, type SleepLike } from "@wirecat/cli-base";
2
+ import { type OAuthClient } from "@wirecat/cli-core/oauth";
3
+ import { type AppAuth } from "./oauth.js";
4
+ export declare const CONNECT_VARIABLE: string;
5
+ /** The button page and the claim endpoint; a test moves both to one fake origin, keeping their paths. */
6
+ export declare const connectUrls: (env: NodeJS.ProcessEnv) => {
7
+ page: string;
8
+ claim: string;
9
+ };
10
+ /** Kommo's button is not checked yet, so a guess could create an integration amo then cannot finish. */
11
+ export declare const refuseKommo: (origin: string) => void;
12
+ export interface BrowserSteps {
13
+ openBrowser: (url: string) => Promise<void>;
14
+ showUrl: (url: string) => void;
15
+ readPaste?: (signal: AbortSignal) => Promise<string>;
16
+ }
17
+ interface ClaimOptions {
18
+ claim: string;
19
+ state: string;
20
+ fetch?: typeof fetch | undefined;
21
+ sleep: SleepLike;
22
+ now: () => number;
23
+ signal?: AbortSignal | undefined;
24
+ }
25
+ /**
26
+ * The keys amoCRM posted to the claim server for this `state`, read once. A 404 `not_ready` means the webhook has not come
27
+ * yet. No failure quotes the answer: a body may hold the secret.
28
+ */
29
+ export declare const claimKeys: (options: ClaimOptions) => Promise<OAuthClient>;
30
+ export interface BrowserSignInOptions<T> {
31
+ env: NodeJS.ProcessEnv;
32
+ profile: string;
33
+ origin: string;
34
+ storage: "keyring" | "file";
35
+ keyring?: KeyringStore | undefined;
36
+ fetch?: typeof fetch | undefined;
37
+ sleep: SleepLike;
38
+ now: () => number;
39
+ signal?: AbortSignal | undefined;
40
+ steps: BrowserSteps;
41
+ /** Whose rights the new tokens carry, asked of the account before anything is kept. */
42
+ check: (auth: AppAuth) => Promise<T>;
43
+ }
44
+ /**
45
+ * amoCRM's button on the connect page creates an integration in the account the person picks and posts its keys to
46
+ * the claim server; amo claims them once, exchanges the code on the account `--host` names and keeps it all as a
47
+ * `--client-id` sign-in, marked so a failed renewal names this command.
48
+ */
49
+ export declare const browserSignIn: <T extends {
50
+ id: string;
51
+ }>(options: BrowserSignInOptions<T>) => Promise<T>;
52
+ export {};
53
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/amo/button.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3F,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,yBAAyB,CAAA;AAGvE,OAAO,EACL,KAAK,OAAO,EAQb,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,gBAAgB,QAAsC,CAAA;AASnE,yGAAyG;AACzG,eAAO,MAAM,WAAW,QAAS,MAAM,CAAC,UAAU,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAoBjF,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,WAAW,WAAY,MAAM,SAQzC,CAAA;AAQD,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,OAAO,EAAE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+ import { CliError, isCliError } from "@wirecat/cli-base";
4
+ import { hostFetch } from "@wirecat/cli-base/http";
5
+ import { tokenKeeper } from "@wirecat/cli-core/oauth";
6
+ import { IDENTITY } from "../identity.js";
7
+ import { isRecord } from "./json.js";
8
+ import { appProvider, appStorage, BUTTON_RELAY_URL, CLAIM_URL, CONNECT_PAGE_URL, fetchFor, lockDirOf, } from "./oauth.js";
9
+ export const CONNECT_VARIABLE = `${IDENTITY.envPrefix}_CONNECT_URL`;
10
+ /** The claim server keeps the integration's keys 10 minutes; a wait longer than that could never be claimed. */
11
+ const CALLBACK_MS = 600_000;
12
+ /** amoCRM posts the keys before it redirects (oauth/button), so a minute covers a slow webhook. */
13
+ const CLAIM_MS = 60_000;
14
+ const CLAIM_PAUSES_MS = [500, 1000, 2000, 4000];
15
+ const REQUEST_MS = 30_000;
16
+ const AMOCRM_HOST = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.amocrm\.ru$/;
17
+ /** The button page and the claim endpoint; a test moves both to one fake origin, keeping their paths. */
18
+ export const connectUrls = (env) => {
19
+ const given = env[CONNECT_VARIABLE]?.trim();
20
+ if (!given)
21
+ return { page: CONNECT_PAGE_URL, claim: CLAIM_URL };
22
+ let url;
23
+ try {
24
+ url = new URL(given);
25
+ }
26
+ catch {
27
+ url = undefined;
28
+ }
29
+ if (url?.protocol !== "https:" || url.username || url.password)
30
+ throw new CliError("configuration_error", `${CONNECT_VARIABLE} must be an https address, such as https://connect.wirecat.dev`, {
31
+ reason: "connect.url-invalid",
32
+ });
33
+ const { origin } = url;
34
+ const moved = (address) => `${origin}${new URL(address).pathname}`;
35
+ return { page: moved(CONNECT_PAGE_URL), claim: moved(CLAIM_URL) };
36
+ };
37
+ /** Kommo's button is not checked yet, so a guess could create an integration amo then cannot finish. */
38
+ export const refuseKommo = (origin) => {
39
+ if (AMOCRM_HOST.test(new URL(origin).hostname))
40
+ return;
41
+ throw new CliError("validation_error", "the browser sign-in works only for amoCRM accounts at amocrm.ru for now; sign in to Kommo with a long-lived " +
42
+ "token or --client-id", { reason: "oauth.browser-amocrm-only", param: "--host" });
43
+ };
44
+ const queryOf = (text) => {
45
+ const trimmed = text.trim();
46
+ const start = trimmed.indexOf("?");
47
+ return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
48
+ };
49
+ /**
50
+ * The local port the relay page sends amoCRM's redirect to. cli-core's `authorize` cannot serve here: it needs the
51
+ * integration before the browser opens, puts `state` in the query and answers only the code, not amoCRM's `referer`.
52
+ */
53
+ const awaitRedirect = async (open, steps, signal) => {
54
+ if (signal?.aborted)
55
+ throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
56
+ const paste = new AbortController();
57
+ let state = "";
58
+ let settled = false;
59
+ let accept = () => { };
60
+ let fail = () => { };
61
+ const redirect = new Promise((resolve, reject) => {
62
+ accept = (query) => {
63
+ settled = true;
64
+ resolve(query);
65
+ };
66
+ fail = (error) => {
67
+ settled = true;
68
+ reject(error);
69
+ };
70
+ });
71
+ void redirect.catch(() => { });
72
+ const handler = (request, response) => {
73
+ const url = new URL(request.url ?? "/", "http://localhost");
74
+ if (request.method !== "GET" || url.pathname !== "/callback")
75
+ return void response.writeHead(404).end();
76
+ if (settled || !state || url.searchParams.get("state") !== state)
77
+ return void response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
78
+ response.end("Sign-in received; you can close this tab");
79
+ accept(url.searchParams);
80
+ };
81
+ const server = createServer(handler);
82
+ const onAbort = () => fail(new CliError("cancelled", "the amoCRM sign-in was cancelled"));
83
+ signal?.addEventListener("abort", onAbort, { once: true });
84
+ const timer = setTimeout(() => fail(new CliError("timeout", "the amoCRM sign-in timed out", { reason: "oauth.timeout" })), CALLBACK_MS);
85
+ timer.unref();
86
+ try {
87
+ await new Promise((resolve, reject) => {
88
+ server.once("error", reject);
89
+ server.listen(0, "127.0.0.1", resolve);
90
+ });
91
+ const address = server.address();
92
+ if (!address || typeof address === "string")
93
+ throw new CliError("configuration_error", "could not start the local sign-in listener");
94
+ // The relay page reads the port from the front of `state` (cli-docs amo-callback.html).
95
+ state = `${address.port}.${randomBytes(32).toString("base64url")}`;
96
+ const url = open(state);
97
+ steps.showUrl(url);
98
+ steps
99
+ .readPaste?.(paste.signal)
100
+ .then((text) => {
101
+ if (settled)
102
+ return;
103
+ const query = queryOf(text);
104
+ if (query.get("state") !== state)
105
+ fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
106
+ reason: "oauth.mismatch",
107
+ }));
108
+ else
109
+ accept(query);
110
+ })
111
+ .catch(() => { });
112
+ void Promise.resolve()
113
+ .then(() => steps.openBrowser(url))
114
+ .catch(() => { });
115
+ return { state, query: await redirect };
116
+ }
117
+ finally {
118
+ clearTimeout(timer);
119
+ signal?.removeEventListener("abort", onAbort);
120
+ paste.abort();
121
+ server.closeAllConnections();
122
+ if (server.listening)
123
+ await new Promise((resolve) => server.close(() => resolve()));
124
+ }
125
+ };
126
+ /** amoCRM names the account the person allowed access in; the code and the keys belong to that one. */
127
+ const refuseOtherAccount = (origin, query) => {
128
+ const given = (query.get("referer") ?? "").trim().toLowerCase();
129
+ const host = given.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
130
+ const expected = new URL(origin).hostname;
131
+ if (host === expected)
132
+ return;
133
+ const named = AMOCRM_HOST.test(host) ? host : undefined;
134
+ throw new CliError("authentication_error", named
135
+ ? `access was allowed in ${named}, not in ${expected}; run this again with --host https://${named}, or choose ` +
136
+ `${expected} in amoCRM's window`
137
+ : `amoCRM did not say which account access was allowed in, so nothing was sent to ${expected}; run this again`, { reason: "oauth.mismatch", ...(named ? { account: named } : {}) });
138
+ };
139
+ /**
140
+ * The keys amoCRM posted to the claim server for this `state`, read once. A 404 `not_ready` means the webhook has not come
141
+ * yet. No failure quotes the answer: a body may hold the secret.
142
+ */
143
+ export const claimKeys = async (options) => {
144
+ const host = new URL(options.claim).hostname;
145
+ const request = hostFetch({
146
+ hosts: [host],
147
+ timeoutMs: REQUEST_MS,
148
+ ...(options.fetch ? { fetch: options.fetch } : {}),
149
+ });
150
+ const again = "start the browser sign-in again";
151
+ const deadline = options.now() + CLAIM_MS;
152
+ for (let attempt = 0;; attempt += 1) {
153
+ let response;
154
+ try {
155
+ response = await request(options.claim, {
156
+ method: "POST",
157
+ headers: { accept: "application/json", "content-type": "application/json" },
158
+ body: JSON.stringify({ state: options.state }),
159
+ redirect: "error",
160
+ ...(options.signal ? { signal: options.signal } : {}),
161
+ });
162
+ }
163
+ catch (error) {
164
+ if (options.signal?.aborted)
165
+ throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
166
+ if (isCliError(error))
167
+ throw error;
168
+ throw new CliError("provider_unavailable", `could not reach ${host} for the integration's keys; ${again}`, {
169
+ retryable: true,
170
+ reason: "oauth.unavailable",
171
+ });
172
+ }
173
+ const answer = await response.json().catch(() => undefined);
174
+ if (response.ok) {
175
+ const id = isRecord(answer) ? answer.client_id : undefined;
176
+ const secret = isRecord(answer) ? answer.client_secret : undefined;
177
+ if (typeof id !== "string" || !id || typeof secret !== "string" || !secret)
178
+ throw new CliError("invalid_response", `${host} returned keys amo cannot use; ${again}`, {
179
+ reason: "oauth.invalid-response",
180
+ });
181
+ return { clientId: id, clientSecret: secret };
182
+ }
183
+ const notReady = response.status === 404 && isRecord(answer) && answer.error === "not_ready";
184
+ if (!notReady)
185
+ throw new CliError("provider_unavailable", `${host} did not hand over the integration's keys (HTTP ${response.status}); ${again}`, { status: response.status, reason: "oauth.unavailable" });
186
+ if (options.now() >= deadline)
187
+ throw new CliError("timeout", `amoCRM did not send the integration's keys to ${host} within a minute; ${again}`, {
188
+ reason: "oauth.timeout",
189
+ });
190
+ await options.sleep(CLAIM_PAUSES_MS[Math.min(attempt, CLAIM_PAUSES_MS.length - 1)] ?? 4000, options.signal, "retry");
191
+ }
192
+ };
193
+ /**
194
+ * amoCRM's button on the connect page creates an integration in the account the person picks and posts its keys to
195
+ * the claim server; amo claims them once, exchanges the code on the account `--host` names and keeps it all as a
196
+ * `--client-id` sign-in, marked so a failed renewal names this command.
197
+ */
198
+ export const browserSignIn = async (options) => {
199
+ const { origin } = options;
200
+ refuseKommo(origin);
201
+ const connect = connectUrls(options.env);
202
+ const storage = appStorage(options.env, options.profile, options.keyring, options.storage === "file" ? "file" : "auto");
203
+ storage.probe();
204
+ const { state, query } = await awaitRedirect((made) => `${connect.page}#state=${made}`, options.steps, options.signal);
205
+ if (!query.get("code"))
206
+ throw new CliError("authentication_error", "amoCRM sign-in was declined", { reason: "oauth.declined" });
207
+ refuseOtherAccount(origin, query);
208
+ const client = await claimKeys({
209
+ claim: connect.claim,
210
+ state,
211
+ fetch: options.fetch,
212
+ sleep: options.sleep,
213
+ now: options.now,
214
+ signal: options.signal,
215
+ });
216
+ const signInCommand = `${IDENTITY.command} ${options.profile} session start --host ${origin} --one-click`;
217
+ const provider = appProvider(origin, client, BUTTON_RELAY_URL);
218
+ const fetch = fetchFor(origin, options.fetch);
219
+ const tokens = await provider.exchange?.({ grant_type: "authorization_code", code: query.get("code") ?? "" }, { fetch, client, now: Date.now, signInCommand, ...(options.signal ? { signal: options.signal } : {}) });
220
+ if (!tokens)
221
+ throw new CliError("authentication_error", "amoCRM did not answer the sign-in");
222
+ const access = tokens.accessToken ?? "";
223
+ const user = await options.check({ origin, userId: "", accessToken: async () => access });
224
+ // The keeper keeps a saved entry's own client over a new one, and this sign-in brings a new integration.
225
+ storage.remove();
226
+ await tokenKeeper({ provider, storage, lockDir: lockDirOf(options.env), fetch, signInCommand }).save(tokens, {
227
+ host: origin,
228
+ userId: user.id,
229
+ redirectUri: BUTTON_RELAY_URL,
230
+ browser: true,
231
+ });
232
+ return user;
233
+ };
234
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/amo/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,YAAY,EAAwB,MAAM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AAI;KACd,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -2,11 +2,17 @@ import { type CredentialStorage, type KeyringStore } from "@wirecat/cli-base";
2
2
  import { type OAuthClient, type OAuthProvider, type SignInOptions as SignInSteps, type TokenCodec, type TokenStorage } from "@wirecat/cli-core/oauth";
3
3
  export declare const PROVIDER = "amocrm";
4
4
  /**
5
- * The integration's Redirect URI, which amoCRM sends the browser to with `code` and `state` (amocrm.ru developers
6
- * oauth/step-by-step). The static page forwards any `code` and `state` to the waiting local port (cli-docs
7
- * public/webhooks/apps/amo-callback.html).
5
+ * The Redirect URI of an integration the owner creates for `--client-id`, which amoCRM sends the browser to with
6
+ * `code` and `state` (amocrm.ru developers oauth/step-by-step). The static page forwards any `code` and `state` to the
7
+ * waiting local port (cli-docs public/webhooks/apps/amo-callback.html).
8
8
  */
9
9
  export declare const RELAY_URL = "https://wirecat.dev/webhooks/apps/amo-callback";
10
+ /** The Redirect URI amoCRM's button gives the integration it creates; the same page as RELAY_URL, on that server. */
11
+ export declare const BUTTON_RELAY_URL = "https://connect.wirecat.dev/webhooks/apps/amo-callback";
12
+ /** The page with amoCRM's button, which reads `state` from the fragment (cli-docs services/amo-connect). */
13
+ export declare const CONNECT_PAGE_URL = "https://connect.wirecat.dev/connect/amo.html";
14
+ /** Hands over once the keys amoCRM posted for a `state`. */
15
+ export declare const CLAIM_URL = "https://connect.wirecat.dev/api/amo/claim";
10
16
  /** A sign-in through the owner's own integration: the account, the user whose rights it carries, and the token. */
11
17
  export interface AppAuth {
12
18
  origin: string;
@@ -18,11 +24,14 @@ export interface AppAuth {
18
24
  * amoCRM refuses one that differs from the integration's setting (oauth/step-by-step).
19
25
  */
20
26
  export declare const appCodec: TokenCodec;
27
+ /** The folder cli-core's sign-in lock lives in, beside the config. */
28
+ export declare const lockDirOf: (env: NodeJS.ProcessEnv) => string;
21
29
  /** The same service, folder and moved-run rule as the long-lived token's `ProfileTokenStore`, under `oauth:amocrm:<profile>`. */
22
30
  export declare const appStorage: (env: NodeJS.ProcessEnv, profile: string, keyring?: KeyringStore, storage?: CredentialStorage) => TokenStorage;
23
31
  /** Where the integration's sign-in is kept, `keyring` or `file`, and never what. */
24
32
  export declare const appSourceOf: (env: NodeJS.ProcessEnv, profile: string, keyring?: KeyringStore) => import("@wirecat/cli-base").CredentialSource | undefined;
25
33
  export declare const appProvider: (origin: string, client: OAuthClient, redirectUri?: string) => OAuthProvider;
34
+ export declare const fetchFor: (origin: string, given?: typeof fetch) => import("@wirecat/cli-base/http").FetchLike;
26
35
  export interface AppSignInOptions<T> {
27
36
  env: NodeJS.ProcessEnv;
28
37
  profile: string;
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/amo/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAGtB,KAAK,YAAY,EAGlB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,aAAa,EAElB,KAAK,aAAa,IAAI,WAAW,EACjC,KAAK,UAAU,EAEf,KAAK,YAAY,EAElB,MAAM,yBAAyB,CAAA;AAKhC,eAAO,MAAM,QAAQ,WAAW,CAAA;AAChC;;;;GAIG;AACH,eAAO,MAAM,SAAS,mDAAmD,CAAA;AAIzE,mHAAmH;AACnH,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACnD;AAID;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UAStB,CAAA;AAcD,iIAAiI;AACjI,eAAO,MAAM,UAAU,QAChB,MAAM,CAAC,UAAU,WACb,MAAM,YACL,YAAY,YACb,iBAAiB,KACzB,YAKC,CAAA;AAEJ,oFAAoF;AACpF,eAAO,MAAM,WAAW,QAAS,MAAM,CAAC,UAA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