cortico-world-hands 0.1.4 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +8 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -673,7 +673,8 @@ var Hands = class {
673
673
  /** 留言板:写一条。 */
674
674
  async noteAdd(text, kind) {
675
675
  const cfg = this.cfg();
676
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
676
+ const credential = this.readToken();
677
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
677
678
  const k = kind ? `&kind=${encodeURIComponent(kind)}` : "";
678
679
  const path = `/hand/note?text=${encodeURIComponent(text)}${k}${token}`;
679
680
  const res = await get(this.port(cfg.handPort), path, ACTION_TIMEOUT_MS);
@@ -687,7 +688,8 @@ var Hands = class {
687
688
  /** 留言板:全部留言。 */
688
689
  async noteList() {
689
690
  const cfg = this.cfg();
690
- const token = cfg.handToken ? `?t=${encodeURIComponent(cfg.handToken)}` : "";
691
+ const credential = this.readToken();
692
+ const token = credential ? `?t=${encodeURIComponent(credential)}` : "";
691
693
  const res = await get(this.port(cfg.handPort), `/hand/notes${token}`, ACTION_TIMEOUT_MS);
692
694
  try {
693
695
  const body = JSON.parse(res.body.toString("utf8"));
@@ -699,7 +701,8 @@ var Hands = class {
699
701
  /** 留言板:划掉一条。 */
700
702
  async noteDone(id) {
701
703
  const cfg = this.cfg();
702
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
704
+ const credential = this.readToken();
705
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
703
706
  const res = await get(this.port(cfg.handPort), `/hand/note/done?id=${encodeURIComponent(id)}${token}`, ACTION_TIMEOUT_MS);
704
707
  return res.status === 200;
705
708
  }
@@ -708,7 +711,8 @@ var Hands = class {
708
711
  const cfg = this.cfg();
709
712
  const tries = Math.max(0, Math.min(12, Math.round(Number(opts.tries ?? 5))));
710
713
  const scroll = opts.scroll === false ? "0" : "1";
711
- const token = cfg.handToken ? `&t=${encodeURIComponent(cfg.handToken)}` : "";
714
+ const credential = this.readToken();
715
+ const token = credential ? `&t=${encodeURIComponent(credential)}` : "";
712
716
  const path = `/hand/find?text=${encodeURIComponent(text)}&tries=${tries}&scroll=${scroll}${token}`;
713
717
  const res = await get(this.port(cfg.handPort), path, ACTION_TIMEOUT_MS);
714
718
  let body = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
6
6
  "license": "MIT",