@welshman/signer 0.12.5 → 0.13.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 (67) hide show
  1. package/dist/lib/src/TaskQueue.d.ts.map +1 -1
  2. package/dist/lib/src/TaskQueue.js +8 -2
  3. package/dist/lib/src/TaskQueue.js.map +1 -1
  4. package/dist/net/src/message.d.ts +4 -0
  5. package/dist/net/src/message.d.ts.map +1 -1
  6. package/dist/net/src/message.js +2 -0
  7. package/dist/net/src/message.js.map +1 -1
  8. package/dist/net/src/policy.d.ts.map +1 -1
  9. package/dist/net/src/policy.js +11 -3
  10. package/dist/net/src/policy.js.map +1 -1
  11. package/dist/net/src/repository.d.ts +24 -12
  12. package/dist/net/src/repository.d.ts.map +1 -1
  13. package/dist/net/src/repository.js +79 -70
  14. package/dist/net/src/repository.js.map +1 -1
  15. package/dist/net/src/util.d.ts +2 -1
  16. package/dist/net/src/util.d.ts.map +1 -1
  17. package/dist/net/src/util.js +6 -5
  18. package/dist/net/src/util.js.map +1 -1
  19. package/dist/net/src/wrapManager.d.ts +0 -2
  20. package/dist/net/src/wrapManager.d.ts.map +1 -1
  21. package/dist/net/src/wrapManager.js +8 -23
  22. package/dist/net/src/wrapManager.js.map +1 -1
  23. package/dist/signer/src/index.d.ts +1 -0
  24. package/dist/signer/src/index.d.ts.map +1 -1
  25. package/dist/signer/src/index.js +1 -0
  26. package/dist/signer/src/index.js.map +1 -1
  27. package/dist/signer/src/nip59.d.ts +13 -6
  28. package/dist/signer/src/nip59.d.ts.map +1 -1
  29. package/dist/signer/src/nip59.js +38 -19
  30. package/dist/signer/src/nip59.js.map +1 -1
  31. package/dist/signer/src/queue.d.ts +21 -0
  32. package/dist/signer/src/queue.d.ts.map +1 -0
  33. package/dist/signer/src/queue.js +40 -0
  34. package/dist/signer/src/queue.js.map +1 -0
  35. package/dist/signer/src/signers/nip01.d.ts +14 -2
  36. package/dist/signer/src/signers/nip01.d.ts.map +1 -1
  37. package/dist/signer/src/signers/nip01.js +6 -2
  38. package/dist/signer/src/signers/nip01.js.map +1 -1
  39. package/dist/signer/src/signers/nip07.d.ts +9 -9
  40. package/dist/signer/src/signers/nip07.d.ts.map +1 -1
  41. package/dist/signer/src/signers/nip07.js +15 -27
  42. package/dist/signer/src/signers/nip07.js.map +1 -1
  43. package/dist/signer/src/signers/nip46.d.ts +7 -3
  44. package/dist/signer/src/signers/nip46.d.ts.map +1 -1
  45. package/dist/signer/src/signers/nip46.js +12 -8
  46. package/dist/signer/src/signers/nip46.js.map +1 -1
  47. package/dist/signer/src/signers/nip55.d.ts +7 -7
  48. package/dist/signer/src/signers/nip55.d.ts.map +1 -1
  49. package/dist/signer/src/signers/nip55.js +33 -40
  50. package/dist/signer/src/signers/nip55.js.map +1 -1
  51. package/dist/signer/src/util.d.ts +27 -15
  52. package/dist/signer/src/util.d.ts.map +1 -1
  53. package/dist/signer/src/util.js +47 -14
  54. package/dist/signer/src/util.js.map +1 -1
  55. package/dist/tsconfig.build.tsbuildinfo +1 -1
  56. package/dist/util/src/Bolt12.d.ts.map +1 -1
  57. package/dist/util/src/Bolt12.js +11 -8
  58. package/dist/util/src/Bolt12.js.map +1 -1
  59. package/dist/util/src/Events.d.ts +1 -0
  60. package/dist/util/src/Events.d.ts.map +1 -1
  61. package/dist/util/src/Events.js +10 -1
  62. package/dist/util/src/Events.js.map +1 -1
  63. package/dist/util/src/Lightning.d.ts +1 -0
  64. package/dist/util/src/Lightning.d.ts.map +1 -1
  65. package/dist/util/src/Lightning.js +1 -0
  66. package/dist/util/src/Lightning.js.map +1 -1
  67. package/package.json +7 -7
@@ -8,7 +8,8 @@ export declare const WRAP_DRIFT: number;
8
8
  * Rewrites a filter so re-sending it picks up where the subscription left off rather than
9
9
  * repeating itself. A filter asking for gift wraps reaches further back, since a wrap
10
10
  * published after the subscription dropped carries a timestamp from before it. Neither reaches
11
- * back past the filter's own `since`.
11
+ * back past the filter's own `since`. A limit sizes the subscription's first page, and `since`
12
+ * bounds the gap, so the catch-up drops it.
12
13
  * @param filter - the filter as originally sent
13
14
  * @param since - when the socket last heard from the relay
14
15
  * @returns a filter covering the gap
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../net/src/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,UAAU,QAAU,CAAA;AAEjC;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAS7D,CAAA"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../net/src/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,UAAU,QAAU,CAAA;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAQ7D,CAAA"}
@@ -8,7 +8,8 @@ export const WRAP_DRIFT = 2 * DAY;
8
8
  * Rewrites a filter so re-sending it picks up where the subscription left off rather than
9
9
  * repeating itself. A filter asking for gift wraps reaches further back, since a wrap
10
10
  * published after the subscription dropped carries a timestamp from before it. Neither reaches
11
- * back past the filter's own `since`.
11
+ * back past the filter's own `since`. A limit sizes the subscription's first page, and `since`
12
+ * bounds the gap, so the catch-up drops it.
12
13
  * @param filter - the filter as originally sent
13
14
  * @param since - when the socket last heard from the relay
14
15
  * @returns a filter covering the gap
@@ -16,9 +17,9 @@ export const WRAP_DRIFT = 2 * DAY;
16
17
  export const catchUpFilter = (filter, since) => {
17
18
  // Only a filter that names wraps is widened: one without kinds would fetch days of everything
18
19
  const drift = filter.kinds?.includes(WRAP) ? WRAP_DRIFT : 0;
19
- if (filter.limit === 0) {
20
- filter = omit(["limit"], filter);
21
- }
22
- return { ...filter, since: Math.max(filter.since || 0, since - drift) };
20
+ return {
21
+ ...omit(["limit"], filter),
22
+ since: Math.max(filter.since || 0, since - drift),
23
+ };
23
24
  };
24
25
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../net/src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACvC,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAA;AAKnC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,CAAA;AAEjC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,KAAa,EAAU,EAAE;IACrE,8FAA8F;IAC9F,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3D,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,EAAC,GAAG,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAC,CAAA;AACvE,CAAC,CAAA"}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../net/src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACvC,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAA;AAKnC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,CAAA;AAEjC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,KAAa,EAAU,EAAE;IACrE,8FAA8F;IAC9F,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3D,OAAO;QACL,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;KAClD,CAAA;AACH,CAAC,CAAA"}
@@ -29,8 +29,6 @@ export declare class WrapManager extends Emitter {
29
29
  remove: (id: string) => void;
30
30
  removeByRumorId: (rumorId: string) => void;
31
31
  _add: (wrapItem: WrapItem) => void;
32
- _addReference: (index: Map<string, WrapReference>, key: string, wrapId: string) => void;
33
32
  _remove: (wrapItem: WrapItem) => void;
34
- _removeReference: (index: Map<string, WrapReference>, key: string, wrapId: string) => void;
35
33
  }
36
34
  //# sourceMappingURL=wrapManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrapManager.d.ts","sourceRoot":"","sources":["../../../../net/src/wrapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAe,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAE1C,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AA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AAiB,CAAA;AAE1C,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,EAAE,CAAA;AAEpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,qBAAa,WAAY,SAAQ,OAAO;IAI1B,QAAQ,CAAC,OAAO,EAAE,kBAAkB;IAHhD,UAAU,wBAA8B;IACxC,WAAW,6BAAmC;gBAEzB,OAAO,EAAE,kBAAkB;IAMhD,IAAI,mBAA6C;IAEjD,QAAQ,GAAI,SAAS,MAAM,gBACwD;IAEnF,QAAQ,GAAI,QAAQ,MAAM,uDAMzB;IAID,KAAK,aAIJ;IAED,IAAI,GAAI,WAAW,QAAQ,EAAE,UAS5B;IAED,GAAG,GAAI,4BAA0B;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAC,UAgB1F;IAID,MAAM,GAAI,IAAI,MAAM,UAanB;IAED,eAAe,GAAI,SAAS,MAAM,UAIjC;IAID,IAAI,GAAI,UAAU,QAAQ,UAGzB;IAED,OAAO,GAAI,UAAU,QAAQ,UAU5B;CACF"}
@@ -1,4 +1,4 @@
1
- import { Emitter, remove, omit } from "@welshman/lib";
1
+ import { Emitter, remove, omit, pushToMapKey } from "@welshman/lib";
2
2
  export class WrapManager extends Emitter {
3
3
  options;
4
4
  _wrapIndex = new Map();
@@ -63,31 +63,16 @@ export class WrapManager extends Emitter {
63
63
  // Utils
64
64
  _add = (wrapItem) => {
65
65
  this._wrapIndex.set(wrapItem.id, wrapItem);
66
- this._addReference(this._rumorIndex, wrapItem.rumorId, wrapItem.id);
67
- };
68
- _addReference = (index, key, wrapId) => {
69
- const reference = index.get(key);
70
- if (reference) {
71
- reference.push(wrapId);
72
- }
73
- else {
74
- index.set(key, [wrapId]);
75
- }
66
+ pushToMapKey(this._rumorIndex, wrapItem.rumorId, wrapItem.id);
76
67
  };
77
68
  _remove = (wrapItem) => {
69
+ const wrapIds = remove(wrapItem.id, this._rumorIndex.get(wrapItem.rumorId) || []);
78
70
  this._wrapIndex.delete(wrapItem.id);
79
- this._removeReference(this._rumorIndex, wrapItem.rumorId, wrapItem.id);
80
- };
81
- _removeReference = (index, key, wrapId) => {
82
- const reference = index.get(key);
83
- if (reference) {
84
- const wraps = remove(wrapId, reference);
85
- if (wraps.length > 0) {
86
- index.set(key, wraps);
87
- }
88
- else {
89
- index.delete(key);
90
- }
71
+ if (wrapIds.length > 0) {
72
+ this._rumorIndex.set(wrapItem.rumorId, wrapIds);
73
+ }
74
+ else {
75
+ this._rumorIndex.delete(wrapItem.rumorId);
91
76
  }
92
77
  };
93
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wrapManager.js","sourceRoot":"","sources":["../../../../net/src/wrapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAiBnD,MAAM,OAAO,WAAY,SAAQ,OAAO;IAIjB;IAHrB,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAA;IACxC,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAA;IAE9C,YAAqB,OAA2B;QAC9C,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAoB;IAEhD,CAAC;IAED,oBAAoB;IAEpB,IAAI,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA;IAEjD,QAAQ,GAAG,CAAC,OAAe,EAAE,EAAE,CAC7B,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC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e,EAAE,EAAE;QACpC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YACrD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAA;IAED,QAAQ;IAER,IAAI,GAAG,CAAC,QAAkB,EAAE,EAAE;QAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QAC1C,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC/D,CAAC,CAAA;IAED,OAAO,GAAG,CAAC,QAAkB,EAAE,EAAE;QAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;QAEjF,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAEnC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC,CAAA;CACF"}
@@ -1,4 +1,5 @@
1
1
  export * from "./util.js";
2
+ export * from "./queue.js";
2
3
  export * from "./nip59.js";
3
4
  export * from "./signers/nip01.js";
4
5
  export * from "./signers/nip07.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from "./util.js";
2
+ export * from "./queue.js";
2
3
  export * from "./nip59.js";
3
4
  export * from "./signers/nip01.js";
4
5
  export * from "./signers/nip07.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
@@ -1,10 +1,17 @@
1
1
  import { SignedEvent, HashedEvent, StampedEvent } from "@welshman/util";
2
- import { ISigner } from "./util.js";
2
+ import { ISigner, SignerOptions } from "./util.js";
3
3
  export declare const now: (drift?: number) => number;
4
- export declare const getSeal: (signer: ISigner, pubkey: string, rumor: HashedEvent) => Promise<SignedEvent>;
4
+ export declare const getSeal: (signer: ISigner, pubkey: string, rumor: HashedEvent, options?: SignerOptions) => Promise<SignedEvent>;
5
5
  export declare const getWrap: (wrapper: ISigner, pubkey: string, seal: SignedEvent, tags: string[][]) => Promise<SignedEvent>;
6
- export declare const wrap: (signer: ISigner, wrapper: ISigner, pubkey: string, template: StampedEvent, tags?: string[][]) => Promise<SignedEvent>;
7
- export declare const unwrap: (signer: ISigner, wrap: SignedEvent) => Promise<HashedEvent>;
6
+ export declare const wrap: (signer: ISigner, wrapper: ISigner, pubkey: string, template: StampedEvent, tags?: string[][], options?: SignerOptions) => Promise<SignedEvent>;
7
+ /**
8
+ * A decision about the wrap itself rather than a failure to reach the signer. The wrap will
9
+ * read the same way every time it is tried, so a caller is free to remember the verdict;
10
+ * anything the signer throws is about the signer and may answer next time.
11
+ */
12
+ export declare class InvalidWrapError extends Error {
13
+ }
14
+ export declare const unwrap: (signer: ISigner, wrap: SignedEvent, options?: SignerOptions) => Promise<HashedEvent>;
8
15
  export declare class Nip59 {
9
16
  private signer;
10
17
  private wrapper?;
@@ -13,7 +20,7 @@ export declare class Nip59 {
13
20
  static fromSigner: (signer: ISigner) => Nip59;
14
21
  static fromSecret: (secret: string) => Nip59;
15
22
  withWrapper: (wrapper: ISigner) => Nip59;
16
- wrap: (pubkey: string, template: StampedEvent, tags?: string[][]) => Promise<SignedEvent>;
17
- unwrap: (event: SignedEvent) => Promise<HashedEvent>;
23
+ wrap: (pubkey: string, template: StampedEvent, tags?: string[][], options?: SignerOptions) => Promise<SignedEvent>;
24
+ unwrap: (event: SignedEvent, options?: SignerOptions) => Promise<HashedEvent>;
18
25
  }
19
26
  //# sourceMappingURL=nip59.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nip59.d.ts","sourceRoot":"","sources":["../../../src/nip59.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,WAAW,EACX,YAAY,EAKb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAU,OAAO,EAAC,MAAM,WAAW,CAAA;AAG1C,eAAO,MAAM,GAA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B,QAAQ,OAAO,EACf,QAAQ,MAAM,EACd,OAAO,WAAW,EAClB,UAAU,aAAa,yBAWtB,CAAA;AAEH,eAAO,MAAM,OAAO,GAClB,SAAS,OAAO,EAChB,QAAQ,MAAM,EACd,MAAM,WAAW,EACjB,MAAM,MAAM,EAAE,EAAE,yBAUf,CAAA;AAEH,eAAO,MAAM,IAAI,GACf,QAAQ,OAAO,EACf,SAAS,OAAO,EAChB,QAAQ,MAAM,EACd,UAAU,YAAY,EACtB,OAAM,MAAM,EAAE,EAAO,EACrB,UAAU,aAAa,yBAQxB,CAAA;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAa9C,eAAO,MAAM,MAAM,GACjB,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,UAAU,aAAa,KACtB,OAAO,CAAC,WAAW,CAWrB,CAAA;AAED,qBAAa,KAAK;IAId,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO,CAAC;IAJlB,OAAO,CAAC,KAAK,CAAoD;gBAGvD,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,OAAO,YAAA;IAG3B,MAAM,CAAC,UAAU,GAAI,QAAQ,OAAO,WAAsB;IAE1D,MAAM,CAAC,UAAU,GAAI,QAAQ,MAAM,WAAuC;IAE1E,WAAW,GAAI,SAAS,OAAO,WAAoC;IAEnE,IAAI,GAAI,QAAQ,MAAM,EAAE,UAAU,YAAY,EAAE,OAAM,MAAM,EAAE,EAAO,EAAE,UAAU,aAAa,0BACD;IAE7F,MAAM,GAAU,OAAO,WAAW,EAAE,UAAU,aAAa,KAAG,OAAO,CAAC,WAAW,CAAC,CAwBjF;CACF"}
@@ -1,14 +1,15 @@
1
- import { isHashedEvent, WRAP, SEAL, prep, hash, } from "@welshman/util";
1
+ import { isHashedEvent, isSignedEvent, WRAP, SEAL, prep, hash, } from "@welshman/util";
2
+ import { isPojo, tryCatch } from "@welshman/lib";
2
3
  import { decrypt } from "./util.js";
3
4
  import { Nip01Signer } from "./signers/nip01.js";
4
5
  export const now = (drift = 0) => Math.round(Date.now() / 1000 - Math.random() * Math.pow(10, drift));
5
- export const getSeal = async (signer, pubkey, rumor) => signer.sign(hash({
6
+ export const getSeal = async (signer, pubkey, rumor, options) => signer.sign(hash({
6
7
  kind: SEAL,
7
- pubkey: await signer.getPubkey(),
8
- content: await signer.nip44.encrypt(pubkey, JSON.stringify(rumor)),
8
+ pubkey: await signer.getPubkey(options),
9
+ content: await signer.nip44.encrypt(pubkey, JSON.stringify(rumor), options),
9
10
  created_at: now(5),
10
11
  tags: [],
11
- }));
12
+ }), options);
12
13
  export const getWrap = async (wrapper, pubkey, seal, tags) => wrapper.sign(hash({
13
14
  kind: WRAP,
14
15
  pubkey: await wrapper.getPubkey(),
@@ -16,20 +17,36 @@ export const getWrap = async (wrapper, pubkey, seal, tags) => wrapper.sign(hash(
16
17
  created_at: now(5),
17
18
  tags: [...tags, ["p", pubkey]],
18
19
  }));
19
- export const wrap = async (signer, wrapper, pubkey, template, tags = []) => {
20
- const author = await signer.getPubkey();
20
+ export const wrap = async (signer, wrapper, pubkey, template, tags = [], options) => {
21
+ const author = await signer.getPubkey(options);
21
22
  const rumor = await prep(template, author);
22
- const seal = await getSeal(signer, pubkey, rumor);
23
+ const seal = await getSeal(signer, pubkey, rumor, options);
23
24
  const wrap = await getWrap(wrapper, pubkey, seal, tags);
24
25
  return wrap;
25
26
  };
26
- export const unwrap = async (signer, wrap) => {
27
- const seal = JSON.parse(await decrypt(signer, wrap.pubkey, wrap.content));
28
- const rumor = JSON.parse(await decrypt(signer, seal.pubkey, seal.content));
29
- if (seal.pubkey !== rumor.pubkey)
30
- throw new Error("Seal pubkey does not match rumor pubkey");
31
- if (!isHashedEvent(rumor))
32
- throw new Error("Unwrapped object was not a hashed event");
27
+ /**
28
+ * A decision about the wrap itself rather than a failure to reach the signer. The wrap will
29
+ * read the same way every time it is tried, so a caller is free to remember the verdict;
30
+ * anything the signer throws is about the signer and may answer next time.
31
+ */
32
+ export class InvalidWrapError extends Error {
33
+ }
34
+ // Each layer must decrypt to the event that layer carries, or the wrap is malformed
35
+ const parseLayer = (json, isLayer, layer) => {
36
+ const value = tryCatch(() => JSON.parse(json));
37
+ if (!isPojo(value) || !isLayer(value)) {
38
+ throw new InvalidWrapError(`Decrypted ${layer} was not a valid event`);
39
+ }
40
+ return value;
41
+ };
42
+ export const unwrap = async (signer, wrap, options) => {
43
+ const sealJson = await decrypt(signer, wrap.pubkey, wrap.content, options);
44
+ const seal = parseLayer(sealJson, isSignedEvent, "seal");
45
+ const rumorJson = await decrypt(signer, seal.pubkey, seal.content, options);
46
+ const rumor = parseLayer(rumorJson, isHashedEvent, "rumor");
47
+ if (seal.pubkey !== rumor.pubkey) {
48
+ throw new InvalidWrapError("Seal pubkey does not match rumor pubkey");
49
+ }
33
50
  return rumor;
34
51
  };
35
52
  export class Nip59 {
@@ -43,8 +60,8 @@ export class Nip59 {
43
60
  static fromSigner = (signer) => new Nip59(signer);
44
61
  static fromSecret = (secret) => new Nip59(new Nip01Signer(secret));
45
62
  withWrapper = (wrapper) => new Nip59(this.signer, wrapper);
46
- wrap = (pubkey, template, tags = []) => wrap(this.signer, this.wrapper || Nip01Signer.ephemeral(), pubkey, template, tags);
47
- unwrap = async (event) => {
63
+ wrap = (pubkey, template, tags = [], options) => wrap(this.signer, this.wrapper || Nip01Signer.ephemeral(), pubkey, template, tags, options);
64
+ unwrap = async (event, options) => {
48
65
  const cached = this.cache.get(event.id);
49
66
  if (cached) {
50
67
  if (cached instanceof Error) {
@@ -53,12 +70,14 @@ export class Nip59 {
53
70
  return cached;
54
71
  }
55
72
  try {
56
- const rumor = await unwrap(this.signer, event);
73
+ const rumor = await unwrap(this.signer, event, options);
57
74
  this.cache.set(event.id, rumor);
58
75
  return rumor;
59
76
  }
60
77
  catch (error) {
61
- this.cache.set(event.id, error);
78
+ if (error instanceof InvalidWrapError) {
79
+ this.cache.set(event.id, error);
80
+ }
62
81
  throw error;
63
82
  }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number;
5
+ run: () => Promise<void>;
6
+ };
7
+ /**
8
+ * The lane every request to one signer goes down. A browser extension and a native signer
9
+ * app each answer one request at a time, so a caller is already queueing; making the queue
10
+ * explicit is what lets a signature the user is waiting on overtake a backlog of
11
+ * decryptions, and what keeps one request that never answers from blocking the rest.
12
+ *
13
+ * `batchSize` is 1, since a batch is fixed once it starts and a request arriving mid-batch
14
+ * would otherwise wait out the whole of it however urgent it is. A `batchDelay` of 0 then
15
+ * costs no timer per request, since `TaskQueue` drains a zero delay in a microtask.
16
+ */
17
+ export declare class SignerQueue {
18
+ queue: TaskQueue<SignerRequest>;
19
+ push: <T>(thunk: () => Promise<T>, options?: SignerOptions) => Promise<T>;
20
+ }
21
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAc,MAAM,eAAe,CAAA;AAEpD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,WAAW,CAAA;AAE5C,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB,CAAA;AAED;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACtB,KAAK,2BAKH;IAEF,IAAI,GAAI,CAAC,EAAE,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,UAAS,aAAkB,KAAG,OAAO,CAAC,CAAC,CAAC,CAsB3E;CACF"}
@@ -0,0 +1,40 @@
1
+ import { TaskQueue, defer, noop } from "@welshman/lib";
2
+ import { signerCall } from "./util.js";
3
+ /**
4
+ * The lane every request to one signer goes down. A browser extension and a native signer
5
+ * app each answer one request at a time, so a caller is already queueing; making the queue
6
+ * explicit is what lets a signature the user is waiting on overtake a backlog of
7
+ * decryptions, and what keeps one request that never answers from blocking the rest.
8
+ *
9
+ * `batchSize` is 1, since a batch is fixed once it starts and a request arriving mid-batch
10
+ * would otherwise wait out the whole of it however urgent it is. A `batchDelay` of 0 then
11
+ * costs no timer per request, since `TaskQueue` drains a zero delay in a microtask.
12
+ */
13
+ export class SignerQueue {
14
+ queue = new TaskQueue({
15
+ batchSize: 1,
16
+ batchDelay: 0,
17
+ getPriority: (request) => request.priority,
18
+ processItem: (request) => request.run(),
19
+ });
20
+ push = (thunk, options = {}) => {
21
+ const result = defer();
22
+ const settled = result.then(noop, noop);
23
+ const abort = () => result.reject(new Error("Signer request was aborted"));
24
+ // A signal that is already aborted never fires "abort", so refuse the request here.
25
+ if (options.signal?.aborted)
26
+ abort();
27
+ options.signal?.addEventListener("abort", abort);
28
+ settled.then(() => options.signal?.removeEventListener("abort", abort));
29
+ this.queue.push({
30
+ priority: options.priority ?? 0,
31
+ run: () => {
32
+ signerCall(thunk, options).then(result.resolve, result.reject);
33
+ // The lane is given back when welshman stops waiting, not always when the signer answered
34
+ return settled;
35
+ },
36
+ });
37
+ return result;
38
+ };
39
+ }
40
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AAQpC;;;;;;;;;GASG;AACH,MAAM,OAAO,WAAW;IACtB,KAAK,GAAG,IAAI,SAAS,CAAgB;QACnC,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ;QACzD,WAAW,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;KACvD,CAAC,CAAA;IAEF,IAAI,GAAG,CAAI,KAAuB,EAAE,UAAyB,EAAE,EAAc,EAAE;QAC7E,MAAM,MAAM,GAAG,KAAK,EAAY,CAAA;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAA;QAE1E,oFAAoF;QACpF,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO;YAAE,KAAK,EAAE,CAAA;QAEpC,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;QAEvE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;YAC/B,GAAG,EAAE,GAAG,EAAE;gBACR,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;gBAE9D,0FAA0F;gBAC1F,OAAO,OAAO,CAAA;YAChB,CAAC;SACF,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;CACF"}
@@ -1,5 +1,9 @@
1
1
  import { StampedEvent } from "@welshman/util";
2
- import { ISigner, SignOptions } from "../util.js";
2
+ import { ISigner } from "../util.js";
3
+ /**
4
+ * A local key, so every request is answered synchronously. Nothing here can hang or be
5
+ * worth reordering, which is why it takes no `SignerOptions`.
6
+ */
3
7
  export declare class Nip01Signer implements ISigner {
4
8
  #private;
5
9
  private secret;
@@ -7,7 +11,15 @@ export declare class Nip01Signer implements ISigner {
7
11
  static fromSecret: (secret: string) => Nip01Signer;
8
12
  static ephemeral: () => Nip01Signer;
9
13
  getPubkey: () => Promise<string>;
10
- sign: (event: StampedEvent, options?: SignOptions) => Promise<import("@welshman/util").SignedEvent>;
14
+ sign: (event: StampedEvent) => Promise<{
15
+ sig: string;
16
+ tags: string[][];
17
+ content: string;
18
+ kind: number;
19
+ created_at: number;
20
+ pubkey: string;
21
+ id: string;
22
+ }>;
11
23
  nip04: {
12
24
  encrypt: (pubkey: string, message: string) => Promise<string>;
13
25
  decrypt: (pubkey: string, message: string) => Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"nip01.d.ts","sourceRoot":"","sources":["../../../../src/signers/nip01.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAyC,MAAM,gBAAgB,CAAA;AACnF,OAAO,EAAe,OAAO,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAA;AAE9E,qBAAa,WAAY,YAAW,OAAO;;IAG7B,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAIlC,MAAM,CAAC,UAAU,GAAI,QAAQ,MAAM,iBAA4B;IAE/D,MAAM,CAAC,SAAS,oBAAsC;IAEtD,SAAS,wBAA2B;IAEpC,IAAI,GAAI,OAAO,YAAY,EAAE,UAAS,WAAgB,mDACuB;IAE7E,KAAK;0BACqB,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAChD;IAED,KAAK;0BACqB,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAChD;CACF"}
1
+ {"version":3,"file":"nip01.d.ts","sourceRoot":"","sources":["../../../../src/signers/nip01.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAyC,MAAM,gBAAgB,CAAA;AACnF,OAAO,EAAe,OAAO,EAAC,MAAM,YAAY,CAAA;AAEhD;;;GAGG;AACH,qBAAa,WAAY,YAAW,OAAO;;IAG7B,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAIlC,MAAM,CAAC,UAAU,GAAI,QAAQ,MAAM,iBAA4B;IAE/D,MAAM,CAAC,SAAS,oBAAsC;IAEtD,SAAS,wBAA2B;IAEpC,IAAI,GAAU,OAAO,YAAY;;;;;;;;OAAsD;IAEvF,KAAK;0BACqB,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAChD;IAED,KAAK;0BACqB,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAChD;CACF"}
@@ -1,5 +1,9 @@
1
1
  import { own, hash, sign, getPubkey, makeSecret } from "@welshman/util";
2
- import { nip04, nip44, signWithOptions } from "../util.js";
2
+ import { nip04, nip44 } from "../util.js";
3
+ /**
4
+ * A local key, so every request is answered synchronously. Nothing here can hang or be
5
+ * worth reordering, which is why it takes no `SignerOptions`.
6
+ */
3
7
  export class Nip01Signer {
4
8
  secret;
5
9
  #pubkey;
@@ -10,7 +14,7 @@ export class Nip01Signer {
10
14
  static fromSecret = (secret) => new Nip01Signer(secret);
11
15
  static ephemeral = () => new Nip01Signer(makeSecret());
12
16
  getPubkey = async () => this.#pubkey;
13
- sign = (event, options = {}) => signWithOptions(sign(hash(own(event, this.#pubkey)), this.secret), options);
17
+ sign = async (event) => sign(hash(own(event, this.#pubkey)), this.secret);
14
18
  nip04 = {
15
19
  encrypt: async (pubkey, message) => nip04.encrypt(pubkey, this.secret, message),
16
20
  decrypt: async (pubkey, message) => nip04.decrypt(pubkey, this.secret, message),
@@ -1 +1 @@
1
- {"version":3,"file":"nip01.js","sourceRoot":"","sources":["../../../../src/signers/nip01.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAA;AACnF,OAAO,EAAC,KAAK,EAAE,KAAK,EAAwB,eAAe,EAAC,MAAM,YAAY,CAAA;AAE9E,MAAM,OAAO,WAAW;IAGF;IAFpB,OAAO,CAAQ;IAEf,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAChC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,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MAAc,EAAE,OAAe,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;KAChG,CAAA"}
@@ -1,7 +1,7 @@
1
- import { StampedEvent } from "@welshman/util";
2
- import { SignOptions, Sign, ISigner, EncryptionImplementation } from "../util.js";
1
+ import { SignedEvent, StampedEvent } from "@welshman/util";
2
+ import { SignerOptions, ISigner, EncryptionImplementation } from "../util.js";
3
3
  export type Nip07 = {
4
- signEvent: Sign;
4
+ signEvent: (event: StampedEvent) => Promise<SignedEvent>;
5
5
  nip04: EncryptionImplementation;
6
6
  nip44: EncryptionImplementation;
7
7
  getPublicKey: () => string | undefined;
@@ -9,15 +9,15 @@ export type Nip07 = {
9
9
  export declare const getNip07: () => Nip07 | undefined;
10
10
  export declare class Nip07Signer implements ISigner {
11
11
  #private;
12
- getPubkey: () => Promise<string>;
13
- sign: (template: StampedEvent, options?: SignOptions) => Promise<import("@welshman/util").SignedEvent>;
12
+ getPubkey: (options?: SignerOptions) => Promise<string>;
13
+ sign: (template: StampedEvent, options?: SignerOptions) => Promise<SignedEvent>;
14
14
  nip04: {
15
- encrypt: (pubkey: string, message: string) => Promise<string>;
16
- decrypt: (pubkey: string, message: string) => Promise<string>;
15
+ encrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise<string>;
16
+ decrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise<string>;
17
17
  };
18
18
  nip44: {
19
- encrypt: (pubkey: string, message: string) => Promise<string>;
20
- decrypt: (pubkey: string, message: string) => Promise<string>;
19
+ encrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise<string>;
20
+ decrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise<string>;
21
21
  };
22
22
  }
23
23
  //# sourceMappingURL=nip07.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nip07.d.ts","sourceRoot":"","sources":["../../../../src/signers/nip07.ts"],"names":[],"mappings":"AACA,OAAO,EAAC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0BACe,MAAM,WAAW,MAAM,YAAW,aAAa;0BAE/C,MAAM,WAAW,MAAM,YAAW,aAAa;MAElE;IAED,KAAK;0BACe,MAAM,WAAW,MAAM,YAAW,aAAa;0BAE/C,MAAM,WAAW,MAAM,YAAW,aAAa;MAElE;CACF"}
@@ -1,43 +1,31 @@
1
- import { noop } from "@welshman/lib";
2
- import { signWithOptions } from "../util.js";
1
+ import { SignerQueue } from "../queue.js";
3
2
  export const getNip07 = () => window.nostr;
4
- const release = (promise) => new Promise(resolve => {
5
- const timeout = setTimeout(resolve, 30_000);
6
- promise.catch(noop).then(() => {
7
- clearTimeout(timeout);
8
- resolve();
9
- });
10
- });
11
3
  export class Nip07Signer {
12
- #lock = Promise.resolve();
4
+ #queue = new SignerQueue();
13
5
  #pubkey;
14
- #then = async (f) => {
15
- const promise = this.#lock.then(() => {
16
- const ext = getNip07();
17
- if (!ext)
18
- throw new Error("Nip07 is not enabled");
19
- return f(ext);
20
- });
21
- this.#lock = release(promise);
22
- return promise;
23
- };
24
- getPubkey = () => {
6
+ #then = (f, options) => this.#queue.push(async () => {
7
+ const ext = getNip07();
8
+ if (!ext)
9
+ throw new Error("Nip07 is not enabled");
10
+ return f(ext);
11
+ }, options);
12
+ getPubkey = (options = {}) => {
25
13
  if (!this.#pubkey) {
26
- this.#pubkey = this.#then(ext => ext.getPublicKey());
14
+ this.#pubkey = this.#then(ext => ext.getPublicKey(), options);
27
15
  this.#pubkey.catch(() => {
28
16
  this.#pubkey = undefined;
29
17
  });
30
18
  }
31
19
  return this.#pubkey;
32
20
  };
33
- sign = (template, options = {}) => signWithOptions(this.#then(ext => ext.signEvent(template)), options);
21
+ sign = (template, options = {}) => this.#then(ext => ext.signEvent(template), options);
34
22
  nip04 = {
35
- encrypt: (pubkey, message) => this.#then(ext => ext.nip04.encrypt(pubkey, message)),
36
- decrypt: (pubkey, message) => this.#then(ext => ext.nip04.decrypt(pubkey, message)),
23
+ encrypt: (pubkey, message, options = {}) => this.#then(ext => ext.nip04.encrypt(pubkey, message), options),
24
+ decrypt: (pubkey, message, options = {}) => this.#then(ext => ext.nip04.decrypt(pubkey, message), options),
37
25
  };
38
26
  nip44 = {
39
- encrypt: (pubkey, message) => this.#then(ext => ext.nip44.encrypt(pubkey, message)),
40
- decrypt: (pubkey, message) => this.#then(ext => ext.nip44.decrypt(pubkey, message)),
27
+ encrypt: (pubkey, message, options = {}) => this.#then(ext => ext.nip44.encrypt(pubkey, message), options),
28
+ decrypt: (pubkey, message, options = {}) => this.#then(ext => ext.nip44.decrypt(pubkey, message), options),
41
29
  };
42
30
  }
43
31
  //# sourceMappingURL=nip07.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nip07.js","sourceRoot":"","sources":["../../../../src/signers/nip07.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAA;AAElC,OAAO,EAAC,eAAe,EAAuD,MAAM,YAAY,CAAA;AAShG,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAE,MAA0B,CAAC,KAAK,CAAA;AAE/D,MAAM,OAAO,GAAG,CAAC,OAAyB,EAAE,EAAE,CAC5C,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAE3C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAC5B,YAAY,CAAC,OAAO,CAAC,CAAA;QACrB,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ,MAAM,OAAO,WAAW;IACtB,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;IACzB,OAAO,CAAkB;IAEzB,KAAK,GAAG,KAAK,EAAK,CAAiC,EAAE,EAAE;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,GA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"}
@@ -1,7 +1,7 @@
1
1
  import { Emitter, MaybeAsync } from "@welshman/lib";
2
2
  import { HashedEvent, StampedEvent, TrustedEvent } from "@welshman/util";
3
3
  import { AdapterContext } from "@welshman/net";
4
- import { ISigner, EncryptionImplementation, SignOptions } from "../util.js";
4
+ import { ISigner, EncryptionImplementation, SignerOptions } from "../util.js";
5
5
  import { Nip01Signer } from "./nip01.js";
6
6
  export type Nip46Context = {
7
7
  debug: boolean;
@@ -116,14 +116,18 @@ export declare class Nip46Broker extends Emitter {
116
116
  nip44Decrypt: (pk: string, message: string) => Promise<string>;
117
117
  switchRelays: () => Promise<string[]>;
118
118
  }
119
+ /**
120
+ * A bunker answers over relays rather than one at a time, so requests here are not queued
121
+ * and a priority would order nothing. Each one still carries its own deadline.
122
+ */
119
123
  export declare class Nip46Signer implements ISigner {
120
124
  broker: Nip46Broker;
121
125
  pubkey?: string;
122
126
  nip04: EncryptionImplementation;
123
127
  nip44: EncryptionImplementation;
124
128
  constructor(broker: Nip46Broker);
125
- getPubkey: () => Promise<string>;
126
- sign: (template: StampedEvent, options?: SignOptions) => Promise<import("@welshman/util").SignedEvent>;
129
+ getPubkey: (options?: SignerOptions) => Promise<string>;
130
+ sign: (template: StampedEvent, options?: SignerOptions) => Promise<any>;
127
131
  cleanup: () => Promise<void>;
128
132
  }
129
133
  //# sourceMappingURL=nip46.d.ts.map