@subwallet/extension-base 0.3.6-2 → 0.4.2-2

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 (82) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +10 -10
  3. package/background/KoniTypes.d.ts +595 -462
  4. package/background/KoniTypes.js +2 -1
  5. package/background/RequestBytesSign.d.ts +12 -12
  6. package/background/RequestBytesSign.js +1 -1
  7. package/background/RequestExtrinsicSign.d.ts +12 -12
  8. package/background/RequestExtrinsicSign.js +1 -1
  9. package/background/handlers/Extension.d.ts +49 -49
  10. package/background/handlers/Extension.js +1 -1
  11. package/background/handlers/State.d.ts +87 -87
  12. package/background/handlers/State.js +1 -1
  13. package/background/handlers/Tabs.d.ts +24 -24
  14. package/background/handlers/Tabs.js +1 -1
  15. package/background/handlers/helpers.d.ts +1 -1
  16. package/background/handlers/helpers.js +1 -1
  17. package/background/handlers/index.d.ts +3 -3
  18. package/background/handlers/index.js +1 -1
  19. package/background/handlers/subscriptions.d.ts +5 -4
  20. package/background/handlers/subscriptions.js +4 -1
  21. package/background/types.d.ts +345 -345
  22. package/bundle.d.ts +1 -1
  23. package/bundle.js +1 -1
  24. package/cjs/background/KoniTypes.js +2 -1
  25. package/cjs/background/RequestBytesSign.js +1 -1
  26. package/cjs/background/RequestExtrinsicSign.js +1 -1
  27. package/cjs/background/handlers/Extension.js +1 -1
  28. package/cjs/background/handlers/State.js +1 -1
  29. package/cjs/background/handlers/Tabs.js +1 -1
  30. package/cjs/background/handlers/helpers.js +1 -1
  31. package/cjs/background/handlers/index.js +1 -1
  32. package/cjs/background/handlers/subscriptions.js +6 -1
  33. package/cjs/defaults.js +1 -1
  34. package/cjs/packageInfo.js +1 -1
  35. package/cjs/page/Accounts.js +1 -1
  36. package/cjs/page/Injected.js +1 -1
  37. package/cjs/page/Metadata.js +1 -1
  38. package/cjs/page/PostMessageProvider.js +28 -28
  39. package/cjs/page/Signer.js +1 -1
  40. package/cjs/page/index.js +1 -1
  41. package/cjs/stores/Accounts.js +1 -1
  42. package/cjs/stores/Base.js +1 -1
  43. package/cjs/stores/Metadata.js +1 -1
  44. package/cjs/utils/canDerive.js +1 -1
  45. package/cjs/utils/getId.js +1 -1
  46. package/defaults.d.ts +10 -10
  47. package/defaults.js +1 -1
  48. package/detectOther.d.ts +7 -7
  49. package/detectPackage.d.ts +1 -1
  50. package/index.d.ts +1 -1
  51. package/index.js +1 -1
  52. package/package.json +4 -4
  53. package/packageInfo.d.ts +6 -6
  54. package/packageInfo.js +1 -1
  55. package/page/Accounts.d.ts +7 -7
  56. package/page/Accounts.js +1 -1
  57. package/page/Injected.d.ts +13 -13
  58. package/page/Injected.js +1 -1
  59. package/page/Metadata.d.ts +7 -7
  60. package/page/Metadata.js +1 -1
  61. package/page/PostMessageProvider.d.ts +62 -62
  62. package/page/PostMessageProvider.js +28 -28
  63. package/page/Signer.d.ts +8 -8
  64. package/page/Signer.js +1 -1
  65. package/page/index.d.ts +16 -16
  66. package/page/index.js +1 -1
  67. package/page/types.d.ts +6 -6
  68. package/stores/Accounts.d.ts +6 -6
  69. package/stores/Accounts.js +1 -1
  70. package/stores/Base.d.ts +10 -10
  71. package/stores/Base.js +1 -1
  72. package/stores/Metadata.d.ts +5 -5
  73. package/stores/Metadata.js +1 -1
  74. package/stores/index.d.ts +2 -2
  75. package/stores/index.js +1 -1
  76. package/types.d.ts +9 -9
  77. package/utils/canDerive.d.ts +2 -2
  78. package/utils/canDerive.js +1 -1
  79. package/utils/getId.d.ts +1 -1
  80. package/utils/getId.js +1 -1
  81. package/utils/index.d.ts +1 -1
  82. package/utils/index.js +1 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export let ApiInitStatus;
4
4
 
@@ -44,6 +44,7 @@ export let TransferErrorCode;
44
44
  TransferErrorCode["KEYRING_ERROR"] = "keyringError";
45
45
  TransferErrorCode["TRANSFER_ERROR"] = "transferError";
46
46
  TransferErrorCode["TIMEOUT"] = "timeout";
47
+ TransferErrorCode["UNSUPPORTED"] = "unsupported";
47
48
  })(TransferErrorCode || (TransferErrorCode = {}));
48
49
 
49
50
  export let TransferStep;
@@ -1,12 +1,12 @@
1
- import type { KeyringPair } from '@polkadot/keyring/types';
2
- import type { SignerPayloadRaw } from '@polkadot/types/types';
3
- import type { HexString } from '@polkadot/util/types';
4
- import type { RequestSign } from './types';
5
- import { TypeRegistry } from '@polkadot/types';
6
- export default class RequestBytesSign implements RequestSign {
7
- readonly payload: SignerPayloadRaw;
8
- constructor(payload: SignerPayloadRaw);
9
- sign(_registry: TypeRegistry, pair: KeyringPair): {
10
- signature: HexString;
11
- };
12
- }
1
+ import type { KeyringPair } from '@polkadot/keyring/types';
2
+ import type { SignerPayloadRaw } from '@polkadot/types/types';
3
+ import type { HexString } from '@polkadot/util/types';
4
+ import type { RequestSign } from './types';
5
+ import { TypeRegistry } from '@polkadot/types';
6
+ export default class RequestBytesSign implements RequestSign {
7
+ readonly payload: SignerPayloadRaw;
8
+ constructor(payload: SignerPayloadRaw);
9
+ sign(_registry: TypeRegistry, pair: KeyringPair): {
10
+ signature: HexString;
11
+ };
12
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { wrapBytes } from '@subwallet/extension-dapp/wrapBytes';
4
4
  import { u8aToHex } from '@polkadot/util';
@@ -1,12 +1,12 @@
1
- import type { KeyringPair } from '@polkadot/keyring/types';
2
- import type { SignerPayloadJSON } from '@polkadot/types/types';
3
- import type { HexString } from '@polkadot/util/types';
4
- import type { RequestSign } from './types';
5
- import { TypeRegistry } from '@polkadot/types';
6
- export default class RequestExtrinsicSign implements RequestSign {
7
- readonly payload: SignerPayloadJSON;
8
- constructor(payload: SignerPayloadJSON);
9
- sign(registry: TypeRegistry, pair: KeyringPair): {
10
- signature: HexString;
11
- };
12
- }
1
+ import type { KeyringPair } from '@polkadot/keyring/types';
2
+ import type { SignerPayloadJSON } from '@polkadot/types/types';
3
+ import type { HexString } from '@polkadot/util/types';
4
+ import type { RequestSign } from './types';
5
+ import { TypeRegistry } from '@polkadot/types';
6
+ export default class RequestExtrinsicSign implements RequestSign {
7
+ readonly payload: SignerPayloadJSON;
8
+ constructor(payload: SignerPayloadJSON);
9
+ sign(registry: TypeRegistry, pair: KeyringPair): {
10
+ signature: HexString;
11
+ };
12
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export default class RequestExtrinsicSign {
4
4
  constructor(payload) {
@@ -1,49 +1,49 @@
1
- /// <reference types="chrome" />
2
- import type { KeypairType } from '@polkadot/util-crypto/types';
3
- import type { MessageTypes, RequestTypes, ResponseType } from '../types';
4
- import State from './State';
5
- export declare const SEED_DEFAULT_LENGTH = 12;
6
- export declare const SEED_LENGTHS: number[];
7
- export declare const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0";
8
- export declare function getSuri(seed: string, type?: KeypairType): string;
9
- export default class Extension {
10
- #private;
11
- constructor(state: State);
12
- private accountsCreateExternal;
13
- private accountsCreateHardware;
14
- private accountsCreateSuri;
15
- private accountsChangePassword;
16
- private accountsEdit;
17
- private accountsExport;
18
- private accountsForget;
19
- private refreshAccountPasswordCache;
20
- private accountsShow;
21
- private accountsTie;
22
- private accountsValidate;
23
- private accountsSubscribe;
24
- private authorizeApprove;
25
- private getAuthList;
26
- private authorizeReject;
27
- private authorizeSubscribe;
28
- private metadataApprove;
29
- private metadataGet;
30
- private metadataList;
31
- private metadataReject;
32
- private metadataSubscribe;
33
- private jsonRestore;
34
- private batchRestore;
35
- private jsonGetAccountInfo;
36
- private seedCreate;
37
- private seedValidate;
38
- private signingApprovePassword;
39
- private signingApproveSignature;
40
- private signingCancel;
41
- private signingIsLocked;
42
- private signingSubscribe;
43
- private windowOpen;
44
- private derive;
45
- private derivationValidate;
46
- private derivationCreate;
47
- private toggleAuthorization;
48
- handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
49
- }
1
+ /// <reference types="chrome" />
2
+ import type { KeypairType } from '@polkadot/util-crypto/types';
3
+ import type { MessageTypes, RequestTypes, ResponseType } from '../types';
4
+ import State from './State';
5
+ export declare const SEED_DEFAULT_LENGTH = 12;
6
+ export declare const SEED_LENGTHS: number[];
7
+ export declare const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0";
8
+ export declare function getSuri(seed: string, type?: KeypairType): string;
9
+ export default class Extension {
10
+ #private;
11
+ constructor(state: State);
12
+ private accountsCreateExternal;
13
+ private accountsCreateHardware;
14
+ private accountsCreateSuri;
15
+ private accountsChangePassword;
16
+ private accountsEdit;
17
+ private accountsExport;
18
+ private accountsForget;
19
+ private refreshAccountPasswordCache;
20
+ private accountsShow;
21
+ private accountsTie;
22
+ private accountsValidate;
23
+ private accountsSubscribe;
24
+ private authorizeApprove;
25
+ private getAuthList;
26
+ private authorizeReject;
27
+ private authorizeSubscribe;
28
+ private metadataApprove;
29
+ private metadataGet;
30
+ private metadataList;
31
+ private metadataReject;
32
+ private metadataSubscribe;
33
+ private jsonRestore;
34
+ private batchRestore;
35
+ private jsonGetAccountInfo;
36
+ private seedCreate;
37
+ private seedValidate;
38
+ private signingApprovePassword;
39
+ private signingApproveSignature;
40
+ private signingCancel;
41
+ private signingIsLocked;
42
+ private signingSubscribe;
43
+ private windowOpen;
44
+ private derive;
45
+ private derivationValidate;
46
+ private derivationCreate;
47
+ private toggleAuthorization;
48
+ handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
49
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@subwallet/extension-base/defaults';
4
4
  import { TypeRegistry } from '@polkadot/types';
@@ -1,87 +1,87 @@
1
- /// <reference types="chrome" />
2
- import type { MetadataDef, ProviderMeta } from '@subwallet/extension-inject/types';
3
- import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
4
- import type { AccountJson, AuthorizeRequest, MetadataRequest, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning, SigningRequest } from '../types';
5
- import { BehaviorSubject } from 'rxjs';
6
- export interface Resolver<T> {
7
- reject: (error: Error) => void;
8
- resolve: (result: T) => void;
9
- }
10
- export interface AuthRequest extends Resolver<boolean> {
11
- id: string;
12
- idStr: string;
13
- request: RequestAuthorizeTab;
14
- url: string;
15
- }
16
- export declare type AuthUrls = Record<string, AuthUrlInfo>;
17
- export interface AuthUrlInfo {
18
- count: number;
19
- id: string;
20
- isAllowed: boolean;
21
- origin: string;
22
- url: string;
23
- isAllowedMap: Record<string, boolean>;
24
- }
25
- interface MetaRequest extends Resolver<boolean> {
26
- id: string;
27
- request: MetadataDef;
28
- url: string;
29
- }
30
- declare type Providers = Record<string, {
31
- meta: ProviderMeta;
32
- start: () => ProviderInterface;
33
- }>;
34
- interface SignRequest extends Resolver<ResponseSigning> {
35
- account: AccountJson;
36
- id: string;
37
- request: RequestSign;
38
- url: string;
39
- }
40
- export declare enum NotificationOptions {
41
- None = 0,
42
- Normal = 1,
43
- PopUp = 2
44
- }
45
- export default class State {
46
- #private;
47
- readonly authSubject: BehaviorSubject<AuthorizeRequest[]>;
48
- readonly metaSubject: BehaviorSubject<MetadataRequest[]>;
49
- readonly signSubject: BehaviorSubject<SigningRequest[]>;
50
- constructor(providers?: Providers);
51
- get knownMetadata(): MetadataDef[];
52
- get numAuthRequests(): number;
53
- get numMetaRequests(): number;
54
- get numSignRequests(): number;
55
- get allAuthRequests(): AuthorizeRequest[];
56
- get allMetaRequests(): MetadataRequest[];
57
- get allSignRequests(): SigningRequest[];
58
- get authUrls(): AuthUrls;
59
- protected popupClose(): void;
60
- protected popupOpen(): void;
61
- private authComplete;
62
- private saveCurrentAuthList;
63
- private metaComplete;
64
- private signComplete;
65
- stripUrl(url: string): string;
66
- private updateIcon;
67
- toggleAuthorization(url: string): AuthUrls;
68
- private updateIconAuth;
69
- private updateIconMeta;
70
- private updateIconSign;
71
- authorizeUrl(url: string, request: RequestAuthorizeTab): Promise<boolean>;
72
- ensureUrlAuthorized(url: string): boolean;
73
- injectMetadata(url: string, request: MetadataDef): Promise<boolean>;
74
- getAuthRequest(id: string): AuthRequest;
75
- getMetaRequest(id: string): MetaRequest;
76
- getSignRequest(id: string): SignRequest;
77
- rpcListProviders(): Promise<ResponseRpcListProviders>;
78
- rpcSend(request: RequestRpcSend, port: chrome.runtime.Port): Promise<JsonRpcResponse>;
79
- rpcStartProvider(key: string, port: chrome.runtime.Port): Promise<ProviderMeta>;
80
- rpcSubscribe({ method, params, type }: RequestRpcSubscribe, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): Promise<number | string>;
81
- rpcSubscribeConnected(_request: null, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): void;
82
- rpcUnsubscribe(request: RequestRpcUnsubscribe, port: chrome.runtime.Port): Promise<boolean>;
83
- saveMetadata(meta: MetadataDef): void;
84
- setNotification(notification: string): boolean;
85
- sign(url: string, request: RequestSign, account: AccountJson): Promise<ResponseSigning>;
86
- }
87
- export {};
1
+ /// <reference types="chrome" />
2
+ import type { MetadataDef, ProviderMeta } from '@subwallet/extension-inject/types';
3
+ import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
4
+ import type { AccountJson, AuthorizeRequest, MetadataRequest, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning, SigningRequest } from '../types';
5
+ import { BehaviorSubject } from 'rxjs';
6
+ export interface Resolver<T> {
7
+ reject: (error: Error) => void;
8
+ resolve: (result: T) => void;
9
+ }
10
+ export interface AuthRequest extends Resolver<boolean> {
11
+ id: string;
12
+ idStr: string;
13
+ request: RequestAuthorizeTab;
14
+ url: string;
15
+ }
16
+ export declare type AuthUrls = Record<string, AuthUrlInfo>;
17
+ export interface AuthUrlInfo {
18
+ count: number;
19
+ id: string;
20
+ isAllowed: boolean;
21
+ origin: string;
22
+ url: string;
23
+ isAllowedMap: Record<string, boolean>;
24
+ }
25
+ interface MetaRequest extends Resolver<boolean> {
26
+ id: string;
27
+ request: MetadataDef;
28
+ url: string;
29
+ }
30
+ declare type Providers = Record<string, {
31
+ meta: ProviderMeta;
32
+ start: () => ProviderInterface;
33
+ }>;
34
+ interface SignRequest extends Resolver<ResponseSigning> {
35
+ account: AccountJson;
36
+ id: string;
37
+ request: RequestSign;
38
+ url: string;
39
+ }
40
+ export declare enum NotificationOptions {
41
+ None = 0,
42
+ Normal = 1,
43
+ PopUp = 2
44
+ }
45
+ export default class State {
46
+ #private;
47
+ readonly authSubject: BehaviorSubject<AuthorizeRequest[]>;
48
+ readonly metaSubject: BehaviorSubject<MetadataRequest[]>;
49
+ readonly signSubject: BehaviorSubject<SigningRequest[]>;
50
+ constructor(providers?: Providers);
51
+ get knownMetadata(): MetadataDef[];
52
+ get numAuthRequests(): number;
53
+ get numMetaRequests(): number;
54
+ get numSignRequests(): number;
55
+ get allAuthRequests(): AuthorizeRequest[];
56
+ get allMetaRequests(): MetadataRequest[];
57
+ get allSignRequests(): SigningRequest[];
58
+ get authUrls(): AuthUrls;
59
+ protected popupClose(): void;
60
+ protected popupOpen(): void;
61
+ private authComplete;
62
+ private saveCurrentAuthList;
63
+ private metaComplete;
64
+ private signComplete;
65
+ stripUrl(url: string): string;
66
+ private updateIcon;
67
+ toggleAuthorization(url: string): AuthUrls;
68
+ private updateIconAuth;
69
+ private updateIconMeta;
70
+ private updateIconSign;
71
+ authorizeUrl(url: string, request: RequestAuthorizeTab): Promise<boolean>;
72
+ ensureUrlAuthorized(url: string): boolean;
73
+ injectMetadata(url: string, request: MetadataDef): Promise<boolean>;
74
+ getAuthRequest(id: string): AuthRequest;
75
+ getMetaRequest(id: string): MetaRequest;
76
+ getSignRequest(id: string): SignRequest;
77
+ rpcListProviders(): Promise<ResponseRpcListProviders>;
78
+ rpcSend(request: RequestRpcSend, port: chrome.runtime.Port): Promise<JsonRpcResponse>;
79
+ rpcStartProvider(key: string, port: chrome.runtime.Port): Promise<ProviderMeta>;
80
+ rpcSubscribe({ method, params, type }: RequestRpcSubscribe, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): Promise<number | string>;
81
+ rpcSubscribeConnected(_request: null, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): void;
82
+ rpcUnsubscribe(request: RequestRpcUnsubscribe, port: chrome.runtime.Port): Promise<boolean>;
83
+ saveMetadata(meta: MetadataDef): void;
84
+ setNotification(notification: string): boolean;
85
+ sign(url: string, request: RequestSign, account: AccountJson): Promise<ResponseSigning>;
86
+ }
87
+ export {};
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension-bg authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension-bg authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { getId } from '@subwallet/extension-base/utils/getId';
4
4
  import { addMetadata, knownMetadata } from '@subwallet/extension-chains';
@@ -1,24 +1,24 @@
1
- /// <reference types="chrome" />
2
- import type { MessageTypes, RequestTypes, ResponseTypes } from '../types';
3
- import State from './State';
4
- export default class Tabs {
5
- #private;
6
- constructor(state: State);
7
- private authorize;
8
- private accountsList;
9
- private accountsSubscribe;
10
- private getSigningPair;
11
- private bytesSign;
12
- private extrinsicSign;
13
- private metadataProvide;
14
- private metadataList;
15
- private rpcListProviders;
16
- private rpcSend;
17
- private rpcStartProvider;
18
- private rpcSubscribe;
19
- private rpcSubscribeConnected;
20
- private rpcUnsubscribe;
21
- private redirectPhishingLanding;
22
- protected redirectIfPhishing(url: string): Promise<boolean>;
23
- handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], url: string, port: chrome.runtime.Port): Promise<ResponseTypes[keyof ResponseTypes]>;
24
- }
1
+ /// <reference types="chrome" />
2
+ import type { MessageTypes, RequestTypes, ResponseTypes } from '../types';
3
+ import State from './State';
4
+ export default class Tabs {
5
+ #private;
6
+ constructor(state: State);
7
+ private authorize;
8
+ private accountsList;
9
+ private accountsSubscribe;
10
+ private getSigningPair;
11
+ private bytesSign;
12
+ private extrinsicSign;
13
+ private metadataProvide;
14
+ private metadataList;
15
+ private rpcListProviders;
16
+ private rpcSend;
17
+ private rpcStartProvider;
18
+ private rpcSubscribe;
19
+ private rpcSubscribeConnected;
20
+ private rpcUnsubscribe;
21
+ private redirectPhishingLanding;
22
+ protected redirectIfPhishing(url: string): Promise<boolean>;
23
+ handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], url: string, port: chrome.runtime.Port): Promise<ResponseTypes[keyof ResponseTypes]>;
24
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { PHISHING_PAGE_REDIRECT } from '@subwallet/extension-base/defaults';
4
4
  import { canDerive } from '@subwallet/extension-base/utils';
@@ -1 +1 @@
1
- export declare function withErrorLog(fn: () => unknown): void;
1
+ export declare function withErrorLog(fn: () => unknown): void;
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export function withErrorLog(fn) {
4
4
  try {
@@ -1,3 +1,3 @@
1
- /// <reference types="chrome" />
2
- import type { MessageTypes, TransportRequestMessage } from '../types';
3
- export default function handler<TMessageType extends MessageTypes>({ id, message, request }: TransportRequestMessage<TMessageType>, port: chrome.runtime.Port, extensionPortName?: string): void;
1
+ /// <reference types="chrome" />
2
+ import type { MessageTypes, TransportRequestMessage } from '../types';
3
+ export default function handler<TMessageType extends MessageTypes>({ id, message, request }: TransportRequestMessage<TMessageType>, port: chrome.runtime.Port, extensionPortName?: string): void;
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { assert } from '@polkadot/util';
4
4
  import { PORT_EXTENSION } from "../../defaults.js";
@@ -1,4 +1,5 @@
1
- /// <reference types="chrome" />
2
- import type { MessageTypesWithSubscriptions, SubscriptionMessageTypes } from '../types';
3
- export declare function createSubscription<TMessageType extends MessageTypesWithSubscriptions>(id: string, port: chrome.runtime.Port): (data: SubscriptionMessageTypes[TMessageType]) => void;
4
- export declare function unsubscribe(id: string): void;
1
+ /// <reference types="chrome" />
2
+ import type { MessageTypesWithSubscriptions, SubscriptionMessageTypes } from '../types';
3
+ export declare function createSubscription<TMessageType extends MessageTypesWithSubscriptions>(id: string, port: chrome.runtime.Port): (data: SubscriptionMessageTypes[TMessageType]) => void;
4
+ export declare function isSubscriptionRunning(id: string): boolean;
5
+ export declare function unsubscribe(id: string): void;
@@ -1,4 +1,4 @@
1
- // Copyright 2019-2022 @subwallet/extension authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  const subscriptions = {}; // return a subscription callback, that will send the data to the caller via the port
4
4
 
@@ -12,6 +12,9 @@ export function createSubscription(id, port) {
12
12
  });
13
13
  }
14
14
  };
15
+ }
16
+ export function isSubscriptionRunning(id) {
17
+ return !!subscriptions[id];
15
18
  } // clear a previous subscriber
16
19
 
17
20
  export function unsubscribe(id) {