@polkadot-apps/signer 0.1.1

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 (45) hide show
  1. package/dist/container.d.ts +11 -0
  2. package/dist/container.d.ts.map +1 -0
  3. package/dist/container.js +98 -0
  4. package/dist/container.js.map +1 -0
  5. package/dist/errors.d.ts +56 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +226 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +15 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +14 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/providers/dev.d.ts +39 -0
  14. package/dist/providers/dev.d.ts.map +1 -0
  15. package/dist/providers/dev.js +232 -0
  16. package/dist/providers/dev.js.map +1 -0
  17. package/dist/providers/extension.d.ts +46 -0
  18. package/dist/providers/extension.d.ts.map +1 -0
  19. package/dist/providers/extension.js +363 -0
  20. package/dist/providers/extension.js.map +1 -0
  21. package/dist/providers/host.d.ts +160 -0
  22. package/dist/providers/host.d.ts.map +1 -0
  23. package/dist/providers/host.js +724 -0
  24. package/dist/providers/host.js.map +1 -0
  25. package/dist/providers/types.d.ts +45 -0
  26. package/dist/providers/types.d.ts.map +1 -0
  27. package/dist/providers/types.js +2 -0
  28. package/dist/providers/types.js.map +1 -0
  29. package/dist/retry.d.ts +23 -0
  30. package/dist/retry.d.ts.map +1 -0
  31. package/dist/retry.js +197 -0
  32. package/dist/retry.js.map +1 -0
  33. package/dist/signer-manager.d.ts +168 -0
  34. package/dist/signer-manager.d.ts.map +1 -0
  35. package/dist/signer-manager.js +1447 -0
  36. package/dist/signer-manager.js.map +1 -0
  37. package/dist/sleep.d.ts +9 -0
  38. package/dist/sleep.d.ts.map +1 -0
  39. package/dist/sleep.js +85 -0
  40. package/dist/sleep.js.map +1 -0
  41. package/dist/types.d.ts +96 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +71 -0
  44. package/dist/types.js.map +1 -0
  45. package/package.json +41 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Detect if running inside a Host container (Polkadot Desktop / Android).
3
+ *
4
+ * Checks for well-known signals that the host environment injects before
5
+ * the app loads. This is a fast synchronous check — use it as a pre-filter
6
+ * to skip the host provider timeout when clearly outside a container.
7
+ *
8
+ * Does NOT import product-sdk (that would defeat the "fast" purpose).
9
+ */
10
+ export declare function isInsideContainer(): boolean;
11
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CA8B3C"}
@@ -0,0 +1,98 @@
1
+ import { createLogger } from "@polkadot-apps/logger";
2
+ const log = createLogger("signer:container");
3
+ /**
4
+ * Detect if running inside a Host container (Polkadot Desktop / Android).
5
+ *
6
+ * Checks for well-known signals that the host environment injects before
7
+ * the app loads. This is a fast synchronous check — use it as a pre-filter
8
+ * to skip the host provider timeout when clearly outside a container.
9
+ *
10
+ * Does NOT import product-sdk (that would defeat the "fast" purpose).
11
+ */
12
+ export function isInsideContainer() {
13
+ if (typeof globalThis.window === "undefined")
14
+ return false;
15
+ const win = globalThis.window;
16
+ // Webview marker injected by Polkadot Desktop / Android
17
+ if (win.__HOST_WEBVIEW_MARK__ === true) {
18
+ log.debug("container detected via __HOST_WEBVIEW_MARK__");
19
+ return true;
20
+ }
21
+ // MessagePort injected by Polkadot Desktop for host-api transport
22
+ if (win.__HOST_API_PORT__ != null) {
23
+ log.debug("container detected via __HOST_API_PORT__");
24
+ return true;
25
+ }
26
+ // Iframe detection (polkadot.com browser embeds apps in iframes)
27
+ try {
28
+ if (globalThis.window !== globalThis.window.top) {
29
+ log.debug("container detected via iframe");
30
+ return true;
31
+ }
32
+ }
33
+ catch {
34
+ // Cross-origin iframe — likely inside a container
35
+ log.debug("container detected via cross-origin iframe");
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ if (import.meta.vitest) {
41
+ const { test, expect, describe, beforeEach, afterEach } = import.meta.vitest;
42
+ describe("isInsideContainer", () => {
43
+ let savedWindow;
44
+ beforeEach(() => {
45
+ savedWindow = globalThis.window;
46
+ });
47
+ afterEach(() => {
48
+ if (savedWindow === undefined) {
49
+ // biome-ignore lint/performance/noDelete: need to fully remove window to restore Node env
50
+ delete globalThis.window;
51
+ }
52
+ else {
53
+ globalThis.window = savedWindow;
54
+ }
55
+ });
56
+ test("returns false in Node environment (no window)", () => {
57
+ // biome-ignore lint/performance/noDelete: need to fully remove window to restore Node env
58
+ delete globalThis.window;
59
+ expect(isInsideContainer()).toBe(false);
60
+ });
61
+ test("returns true when __HOST_WEBVIEW_MARK__ is set", () => {
62
+ const fakeWindow = { __HOST_WEBVIEW_MARK__: true };
63
+ fakeWindow.top = fakeWindow;
64
+ globalThis.window = fakeWindow;
65
+ expect(isInsideContainer()).toBe(true);
66
+ });
67
+ test("returns true when __HOST_API_PORT__ is set", () => {
68
+ const fakeWindow = { __HOST_API_PORT__: 12345 };
69
+ fakeWindow.top = fakeWindow;
70
+ globalThis.window = fakeWindow;
71
+ expect(isInsideContainer()).toBe(true);
72
+ });
73
+ test("returns true when inside an iframe (window !== window.top)", () => {
74
+ const fakeTop = {};
75
+ const fakeWindow = { top: fakeTop };
76
+ globalThis.window = fakeWindow;
77
+ expect(isInsideContainer()).toBe(true);
78
+ });
79
+ test("returns true when cross-origin iframe (accessing top throws)", () => {
80
+ const fakeWindow = {};
81
+ Object.defineProperty(fakeWindow, "top", {
82
+ get() {
83
+ throw new DOMException("Blocked a frame with origin");
84
+ },
85
+ configurable: true,
86
+ });
87
+ globalThis.window = fakeWindow;
88
+ expect(isInsideContainer()).toBe(true);
89
+ });
90
+ test("returns false in standard browser window (no markers, same top)", () => {
91
+ const fakeWindow = {};
92
+ fakeWindow.top = fakeWindow;
93
+ globalThis.window = fakeWindow;
94
+ expect(isInsideContainer()).toBe(false);
95
+ });
96
+ });
97
+ }
98
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,GAAG,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB;IAC7B,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAE3D,MAAM,GAAG,GAAG,UAAU,CAAC,MAA4C,CAAC;IAEpE,wDAAwD;IACxD,IAAI,GAAG,CAAC,qBAAqB,KAAK,IAAI,EAAE,CAAC;QACrC,GAAG,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kEAAkE;IAClE,IAAI,GAAG,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,iEAAiE;IACjE,IAAI,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YAC9C,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAC3C,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,kDAAkD;QAClD,GAAG,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAA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EH,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;YACpE,MAAM,OAAO,GAAG,EAAY,CAAC;YAC7B,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,OAAO,EAA2C,CAAC;YAC7E,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC;YAC/B,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,UAAU,GAAG,EAA2C,CAAC;YAC/D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE;gBACrC,GAAG;oBACC,MAAM,IAAI,YAAY,CAAC,6BAA6B,CAAC,CAAC;gBAC1D,CAAC;gBACD,YAAY,EAAE,IAAI;aACrB,CAAC,CAAC;YACH,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC;YAC/B,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iEAAiE,EAAE,GAAG,EAAE;YACzE,MAAM,UAAU,GAAG,EAA2C,CAAC;YAC/D,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC;YAC5B,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC;YAC/B,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ProviderType } from "./types.js";
2
+ /** Base class for all signer errors. Use `instanceof SignerError` to catch any signer-related error. */
3
+ export declare class SignerError extends Error {
4
+ constructor(message: string, options?: ErrorOptions);
5
+ }
6
+ /** The Host API is not available (product-sdk not installed or not inside a container). */
7
+ export declare class HostUnavailableError extends SignerError {
8
+ constructor(message?: string);
9
+ }
10
+ /** The host rejected the account or signing request. */
11
+ export declare class HostRejectedError extends SignerError {
12
+ constructor(message?: string);
13
+ }
14
+ /** The host connection was lost. */
15
+ export declare class HostDisconnectedError extends SignerError {
16
+ constructor(message?: string);
17
+ }
18
+ /** A browser extension was not found. */
19
+ export declare class ExtensionNotFoundError extends SignerError {
20
+ readonly extensionName: string;
21
+ constructor(extensionName: string, message?: string);
22
+ }
23
+ /** A browser extension rejected the connection request. */
24
+ export declare class ExtensionRejectedError extends SignerError {
25
+ readonly extensionName: string;
26
+ constructor(extensionName: string, message?: string);
27
+ }
28
+ /** A signing operation failed. */
29
+ export declare class SigningFailedError extends SignerError {
30
+ constructor(cause: unknown, message?: string);
31
+ }
32
+ /** No accounts available from the provider. */
33
+ export declare class NoAccountsError extends SignerError {
34
+ readonly provider: ProviderType;
35
+ constructor(provider: ProviderType, message?: string);
36
+ }
37
+ /** An operation timed out. */
38
+ export declare class TimeoutError extends SignerError {
39
+ readonly operation: string;
40
+ readonly ms: number;
41
+ constructor(operation: string, ms: number);
42
+ }
43
+ /** An account was not found by address. */
44
+ export declare class AccountNotFoundError extends SignerError {
45
+ readonly address: string;
46
+ constructor(address: string);
47
+ }
48
+ /** The SignerManager has been destroyed and is no longer usable. */
49
+ export declare class DestroyedError extends SignerError {
50
+ constructor();
51
+ }
52
+ /** Check if a SignerError is a host-related error. */
53
+ export declare function isHostError(e: SignerError): e is HostUnavailableError | HostRejectedError | HostDisconnectedError;
54
+ /** Check if a SignerError is an extension-related error. */
55
+ export declare function isExtensionError(e: SignerError): e is ExtensionNotFoundError | ExtensionRejectedError;
56
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wGAAwG;AACxG,qBAAa,WAAY,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM,EA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wBAAgB,WAAW,CACvB,CAAC,EAAE,WAAW,GACf,CAAC,IAAI,oBAAoB,GAAG,iBAAiB,GAAG,qBAAqB,CAMvE;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAC5B,CAAC,EAAE,WAAW,GACf,CAAC,IAAI,sBAAsB,GAAG,sBAAsB,CAEtD"}
package/dist/errors.js ADDED
@@ -0,0 +1,226 @@
1
+ /** Base class for all signer errors. Use `instanceof SignerError` to catch any signer-related error. */
2
+ export class SignerError extends Error {
3
+ constructor(message, options) {
4
+ super(message, options);
5
+ this.name = "SignerError";
6
+ }
7
+ }
8
+ /** The Host API is not available (product-sdk not installed or not inside a container). */
9
+ export class HostUnavailableError extends SignerError {
10
+ constructor(message = "Host API is not available") {
11
+ super(message);
12
+ this.name = "HostUnavailableError";
13
+ }
14
+ }
15
+ /** The host rejected the account or signing request. */
16
+ export class HostRejectedError extends SignerError {
17
+ constructor(message = "Host rejected the request") {
18
+ super(message);
19
+ this.name = "HostRejectedError";
20
+ }
21
+ }
22
+ /** The host connection was lost. */
23
+ export class HostDisconnectedError extends SignerError {
24
+ constructor(message = "Host connection lost") {
25
+ super(message);
26
+ this.name = "HostDisconnectedError";
27
+ }
28
+ }
29
+ /** A browser extension was not found. */
30
+ export class ExtensionNotFoundError extends SignerError {
31
+ extensionName;
32
+ constructor(extensionName, message) {
33
+ super(message ?? `Browser extension "${extensionName}" not found`);
34
+ this.name = "ExtensionNotFoundError";
35
+ this.extensionName = extensionName;
36
+ }
37
+ }
38
+ /** A browser extension rejected the connection request. */
39
+ export class ExtensionRejectedError extends SignerError {
40
+ extensionName;
41
+ constructor(extensionName, message) {
42
+ super(message ?? `Browser extension "${extensionName}" rejected the request`);
43
+ this.name = "ExtensionRejectedError";
44
+ this.extensionName = extensionName;
45
+ }
46
+ }
47
+ /** A signing operation failed. */
48
+ export class SigningFailedError extends SignerError {
49
+ constructor(cause, message) {
50
+ super(message ?? `Signing failed: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
51
+ this.name = "SigningFailedError";
52
+ }
53
+ }
54
+ /** No accounts available from the provider. */
55
+ export class NoAccountsError extends SignerError {
56
+ provider;
57
+ constructor(provider, message) {
58
+ super(message ?? `No accounts available from ${provider} provider`);
59
+ this.name = "NoAccountsError";
60
+ this.provider = provider;
61
+ }
62
+ }
63
+ /** An operation timed out. */
64
+ export class TimeoutError extends SignerError {
65
+ operation;
66
+ ms;
67
+ constructor(operation, ms) {
68
+ super(`Operation "${operation}" timed out after ${ms}ms`);
69
+ this.name = "TimeoutError";
70
+ this.operation = operation;
71
+ this.ms = ms;
72
+ }
73
+ }
74
+ /** An account was not found by address. */
75
+ export class AccountNotFoundError extends SignerError {
76
+ address;
77
+ constructor(address) {
78
+ super(`Account not found: ${address}`);
79
+ this.name = "AccountNotFoundError";
80
+ this.address = address;
81
+ }
82
+ }
83
+ /** The SignerManager has been destroyed and is no longer usable. */
84
+ export class DestroyedError extends SignerError {
85
+ constructor() {
86
+ super("SignerManager has been destroyed");
87
+ this.name = "DestroyedError";
88
+ }
89
+ }
90
+ // ── Type guards ──────────────────────────────────────────────────────
91
+ /** Check if a SignerError is a host-related error. */
92
+ export function isHostError(e) {
93
+ return (e instanceof HostUnavailableError ||
94
+ e instanceof HostRejectedError ||
95
+ e instanceof HostDisconnectedError);
96
+ }
97
+ /** Check if a SignerError is an extension-related error. */
98
+ export function isExtensionError(e) {
99
+ return e instanceof ExtensionNotFoundError || e instanceof ExtensionRejectedError;
100
+ }
101
+ if (import.meta.vitest) {
102
+ const { test, expect, describe } = import.meta.vitest;
103
+ describe("error classes", () => {
104
+ test("SignerError is the base class", () => {
105
+ const e = new HostUnavailableError();
106
+ expect(e).toBeInstanceOf(SignerError);
107
+ expect(e).toBeInstanceOf(Error);
108
+ });
109
+ test("HostUnavailableError with default message", () => {
110
+ const e = new HostUnavailableError();
111
+ expect(e.name).toBe("HostUnavailableError");
112
+ expect(e.message).toBe("Host API is not available");
113
+ });
114
+ test("HostUnavailableError with custom message", () => {
115
+ const e = new HostUnavailableError("custom");
116
+ expect(e.message).toBe("custom");
117
+ });
118
+ test("HostRejectedError", () => {
119
+ const e = new HostRejectedError();
120
+ expect(e).toBeInstanceOf(SignerError);
121
+ expect(e.message).toContain("rejected");
122
+ });
123
+ test("HostDisconnectedError", () => {
124
+ const e = new HostDisconnectedError();
125
+ expect(e).toBeInstanceOf(SignerError);
126
+ expect(e.message).toContain("lost");
127
+ });
128
+ test("ExtensionNotFoundError with default message", () => {
129
+ const e = new ExtensionNotFoundError("talisman");
130
+ expect(e).toBeInstanceOf(SignerError);
131
+ expect(e.extensionName).toBe("talisman");
132
+ expect(e.message).toContain("talisman");
133
+ });
134
+ test("ExtensionNotFoundError with custom message", () => {
135
+ const e = new ExtensionNotFoundError("talisman", "custom");
136
+ expect(e.message).toBe("custom");
137
+ });
138
+ test("ExtensionRejectedError with default message", () => {
139
+ const e = new ExtensionRejectedError("polkadot-js");
140
+ expect(e).toBeInstanceOf(SignerError);
141
+ expect(e.extensionName).toBe("polkadot-js");
142
+ expect(e.message).toContain("polkadot-js");
143
+ });
144
+ test("ExtensionRejectedError with custom message", () => {
145
+ const e = new ExtensionRejectedError("polkadot-js", "denied");
146
+ expect(e.message).toBe("denied");
147
+ });
148
+ test("SigningFailedError with Error cause", () => {
149
+ const cause = new Error("bad signature");
150
+ const e = new SigningFailedError(cause);
151
+ expect(e).toBeInstanceOf(SignerError);
152
+ expect(e.cause).toBe(cause);
153
+ expect(e.message).toContain("bad signature");
154
+ });
155
+ test("SigningFailedError with string cause", () => {
156
+ const e = new SigningFailedError("oops");
157
+ expect(e.message).toContain("oops");
158
+ });
159
+ test("SigningFailedError with custom message", () => {
160
+ const e = new SigningFailedError("oops", "custom msg");
161
+ expect(e.message).toBe("custom msg");
162
+ });
163
+ test("NoAccountsError", () => {
164
+ const e = new NoAccountsError("host");
165
+ expect(e).toBeInstanceOf(SignerError);
166
+ expect(e.provider).toBe("host");
167
+ expect(e.message).toContain("host");
168
+ });
169
+ test("NoAccountsError with custom message", () => {
170
+ const e = new NoAccountsError("extension", "none found");
171
+ expect(e.message).toBe("none found");
172
+ });
173
+ test("TimeoutError", () => {
174
+ const e = new TimeoutError("connect", 5000);
175
+ expect(e).toBeInstanceOf(SignerError);
176
+ expect(e.operation).toBe("connect");
177
+ expect(e.ms).toBe(5000);
178
+ expect(e.message).toContain("5000");
179
+ });
180
+ test("AccountNotFoundError", () => {
181
+ const e = new AccountNotFoundError("5GrwvaEF...");
182
+ expect(e).toBeInstanceOf(SignerError);
183
+ expect(e.address).toBe("5GrwvaEF...");
184
+ });
185
+ test("DestroyedError", () => {
186
+ const e = new DestroyedError();
187
+ expect(e).toBeInstanceOf(SignerError);
188
+ expect(e.message).toContain("destroyed");
189
+ });
190
+ test("all errors have stack traces", () => {
191
+ const e = new HostUnavailableError();
192
+ expect(e.stack).toBeDefined();
193
+ expect(e.stack).toContain("HostUnavailableError");
194
+ });
195
+ });
196
+ describe("type guards", () => {
197
+ test("isHostError returns true for host errors", () => {
198
+ expect(isHostError(new HostUnavailableError())).toBe(true);
199
+ expect(isHostError(new HostRejectedError())).toBe(true);
200
+ expect(isHostError(new HostDisconnectedError())).toBe(true);
201
+ });
202
+ test("isHostError returns false for non-host errors", () => {
203
+ expect(isHostError(new ExtensionNotFoundError("x"))).toBe(false);
204
+ expect(isHostError(new ExtensionRejectedError("x"))).toBe(false);
205
+ expect(isHostError(new SigningFailedError("x"))).toBe(false);
206
+ expect(isHostError(new NoAccountsError("dev"))).toBe(false);
207
+ expect(isHostError(new TimeoutError("op", 100))).toBe(false);
208
+ expect(isHostError(new AccountNotFoundError("x"))).toBe(false);
209
+ expect(isHostError(new DestroyedError())).toBe(false);
210
+ });
211
+ test("isExtensionError returns true for extension errors", () => {
212
+ expect(isExtensionError(new ExtensionNotFoundError("x"))).toBe(true);
213
+ expect(isExtensionError(new ExtensionRejectedError("x"))).toBe(true);
214
+ });
215
+ test("isExtensionError returns false for non-extension errors", () => {
216
+ expect(isExtensionError(new HostUnavailableError())).toBe(false);
217
+ expect(isExtensionError(new HostRejectedError())).toBe(false);
218
+ expect(isExtensionError(new SigningFailedError("x"))).toBe(false);
219
+ expect(isExtensionError(new NoAccountsError("dev"))).toBe(false);
220
+ expect(isExtensionError(new TimeoutError("op", 100))).toBe(false);
221
+ expect(isExtensionError(new AccountNotFoundError("x"))).toBe(false);
222
+ expect(isExtensionError(new DestroyedError())).toBe(false);
223
+ });
224
+ });
225
+ }
226
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,wGAAwG;AACxG,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClC,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC9B,CAAC;CACJ;AAED,2FAA2F;AAC3F,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACjD,YAAY,OAAO,GAAG,2BAA2B;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACvC,CAAC;CACJ;AAED,wDAAwD;AACxD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAC9C,YAAY,OAAO,GAAG,2BAA2B;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACpC,CAAC;CACJ;AAED,oCAAoC;AACpC,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAClD,YAAY,OAAO,GAAG,sBAAsB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACxC,CAAC;CACJ;AAED,yCAAyC;AACzC,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IAC1C,aAAa,CAAS;IAE/B,YAAY,aAAq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-0,0 +1,15 @@
1
+ export { SignerManager } from "./signer-manager.js";
2
+ export type { AccountPersistence, ConnectionStatus, ProviderFactory, ProviderType, Result, SignerAccount, SignerManagerOptions, SignerState, } from "./types.js";
3
+ export { err, ok } from "./types.js";
4
+ export { SignerError, HostUnavailableError, HostRejectedError, HostDisconnectedError, ExtensionNotFoundError, ExtensionRejectedError, SigningFailedError, NoAccountsError, TimeoutError, AccountNotFoundError, DestroyedError, isHostError, isExtensionError, } from "./errors.js";
5
+ export type { SignerProvider, Unsubscribe } from "./providers/types.js";
6
+ export { DevProvider } from "./providers/dev.js";
7
+ export type { DevKeyType, DevProviderOptions } from "./providers/dev.js";
8
+ export { ExtensionProvider } from "./providers/extension.js";
9
+ export type { ExtensionProviderOptions } from "./providers/extension.js";
10
+ export { HostProvider } from "./providers/host.js";
11
+ export type { ContextualAlias, HostProviderOptions, ProductAccount, RingLocation, } from "./providers/host.js";
12
+ export { isInsideContainer } from "./container.js";
13
+ export { withRetry } from "./retry.js";
14
+ export type { RetryOptions } from "./retry.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,YAAY,EACR,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,MAAM,EACN,aAAa,EACb,oBAAoB,EACpB,WAAW,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,EACH,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,gBAAgB,GACnB,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACR,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,YAAY,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // Core manager
2
+ export { SignerManager } from "./signer-manager.js";
3
+ export { err, ok } from "./types.js";
4
+ // Errors
5
+ export { SignerError, HostUnavailableError, HostRejectedError, HostDisconnectedError, ExtensionNotFoundError, ExtensionRejectedError, SigningFailedError, NoAccountsError, TimeoutError, AccountNotFoundError, DestroyedError, isHostError, isExtensionError, } from "./errors.js";
6
+ // Concrete providers (for advanced / direct usage)
7
+ export { DevProvider } from "./providers/dev.js";
8
+ export { ExtensionProvider } from "./providers/extension.js";
9
+ export { HostProvider } from "./providers/host.js";
10
+ // Container detection
11
+ export { isInsideContainer } from "./container.js";
12
+ // Retry utility
13
+ export { withRetry } from "./retry.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAapD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,SAAS;AACT,OAAO,EACH,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,gBAAgB,GACnB,MAAM,aAAa,CAAC;AAKrB,mDAAmD;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQnD,sBAAsB;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { SignerError } from "../errors.js";
2
+ import type { Result, SignerAccount } from "../types.js";
3
+ import type { SignerProvider, Unsubscribe } from "./types.js";
4
+ /** Standard Substrate dev account names. */
5
+ declare const DEFAULT_DEV_NAMES: readonly ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"];
6
+ export type DevAccountName = (typeof DEFAULT_DEV_NAMES)[number];
7
+ /** Supported key types for dev account derivation. */
8
+ export type DevKeyType = "sr25519" | "ed25519";
9
+ /** Options for the dev account provider. */
10
+ export interface DevProviderOptions {
11
+ /** Which dev accounts to create. Default: all 6 standard accounts. */
12
+ names?: readonly string[];
13
+ /** Custom mnemonic phrase instead of DEV_PHRASE. */
14
+ mnemonic?: string;
15
+ /** SS58 prefix for address encoding. Default: 42 */
16
+ ss58Prefix?: number;
17
+ /** Key type for account derivation. Default: "sr25519" */
18
+ keyType?: DevKeyType;
19
+ }
20
+ /**
21
+ * Provider for Substrate development accounts.
22
+ *
23
+ * Uses the well-known DEV_PHRASE with hard derivation paths (`//Alice`, `//Bob`, etc.)
24
+ * to create deterministic accounts for local development and testing.
25
+ */
26
+ export declare class DevProvider implements SignerProvider {
27
+ readonly type: "dev";
28
+ private readonly names;
29
+ private readonly mnemonic;
30
+ private readonly ss58Prefix;
31
+ private readonly keyType;
32
+ constructor(options?: DevProviderOptions);
33
+ connect(): Promise<Result<SignerAccount[], SignerError>>;
34
+ disconnect(): void;
35
+ onStatusChange(_callback: (status: "disconnected" | "connecting" | "connected") => void): Unsubscribe;
36
+ onAccountsChange(_callback: (accounts: SignerAccount[]) => void): Unsubscribe;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/providers/dev.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9D,4CAA4C;AAC5C,QAAA,MAAM,iBAAiB,+DAAgE,CAAC;AAExF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,sDAAsD;AACtD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,WAAW,kBAAkB;IAC/B,sEAAsE;IACtE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,cAAc;IAC9C,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C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