@trezor/connect 9.1.10 → 9.1.12
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.
- package/CHANGELOG.md +32 -0
- package/README.md +1 -1
- package/lib/api/binance/api/binanceSignTransaction.js +1 -1
- package/lib/api/cardano/api/cardanoSignTransaction.js +1 -1
- package/lib/api/eos/api/eosSignTransaction.js +1 -1
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -2
- package/lib/api/firmware/uploadFirmware.d.ts +2 -2
- package/lib/api/getAddress.js +6 -0
- package/lib/api/getCoinInfo.d.ts +3 -3
- package/lib/api/nem/api/nemSignTransaction.js +5 -1
- package/lib/api/nem/nemSignTx.d.ts +1 -1
- package/lib/api/ripple/api/rippleSignTransaction.js +1 -1
- package/lib/api/solana/api/solanaSignTransaction.js +1 -1
- package/lib/api/stellar/api/stellarSignTransaction.js +1 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +1 -1
- package/lib/backend/Blockchain.d.ts +2 -2
- package/lib/core/AbstractMethod.d.ts +3 -3
- package/lib/core/AbstractMethod.js +20 -18
- package/lib/core/index.d.ts +3 -6
- package/lib/core/index.js +57 -48
- package/lib/core/method.d.ts +1 -3
- package/lib/core/method.native.d.ts +1 -3
- package/lib/data/analyticsInfo.d.ts +2 -2
- package/lib/data/coinInfo.d.ts +14 -14
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +2 -2
- package/lib/events/call.d.ts +1 -1
- package/lib/events/core.d.ts +8 -10
- package/lib/events/iframe.d.ts +1 -1
- package/lib/events/popup.d.ts +1 -1
- package/lib/events/ui-request.d.ts +1 -2
- package/lib/index.d.ts +0 -4
- package/lib/index.js +23 -40
- package/lib/types/api/ethereum/index.d.ts +4 -4
- package/lib/types/api/ethereum/index.js +1 -1
- package/lib/types/api/nem/index.d.ts +46 -46
- package/lib/types/api/nem/index.js +1 -1
- package/lib/utils/promiseUtils.d.ts +0 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# 9.1.12
|
|
2
|
+
|
|
3
|
+
- chore(connect): add new CA pubkeys and update timestamp (a4ca9b1)
|
|
4
|
+
- chore(connect): improve types, replace any with PassphrasePromptResponse (9a95962)
|
|
5
|
+
- feat: add Polygon (8c569ca)
|
|
6
|
+
- fix(connect-popup): display errors with no code (8b7cbfa)
|
|
7
|
+
- fix(connect-popup): don't show error when no device selected (f246369)
|
|
8
|
+
- fix(connect-ui): tipcontainer bottom margin (bb0379d)
|
|
9
|
+
- refactor(connect): unify message promises (b0d4b11)
|
|
10
|
+
- refactor(connect): remove initAsyncPromise (da48a71)
|
|
11
|
+
- refactor(connect): unify initCore and initTransport (00deffa, 027be4f)
|
|
12
|
+
- refactor(connect): CoreRequestMessage/CoreEventMessage separation (ea3afa2)
|
|
13
|
+
- chore(connect-ui): mirror store to local react state (b587a65)
|
|
14
|
+
- feat(connect): deal with disconnected && preferredDevice (40e9db8, 6e4ddb4)
|
|
15
|
+
- chore(connect): use preferred device from store (d1899e8)
|
|
16
|
+
- chore(connect-common): remove es5 target (fails with TypedEmitter) (0a19580)
|
|
17
|
+
- feat(connect-common): store is event emitter, saves permissions and preferred device (db0e963)
|
|
18
|
+
- feat(connect-common): message channel to allow lazy handshake (79be923)
|
|
19
|
+
- chore(connect-ui): ui changes (dcb8e02, 03c6cc6, 936f6b5, 6b7ed69, 8f9f3e2, 4cc0cd6)
|
|
20
|
+
- fix(libs): changes in libs that should allow compiling connect with typescript option skipLibCheck: false
|
|
21
|
+
- chore(connect): split dev and prod builds. (535dd48)
|
|
22
|
+
- dependencies update: @trezor/blockchain-link, @trezor/blockchain-link-types, @trezor/type-utils, @trezor/analytics, @trezor/connect-common, @trezor/env-utils, @trezor/transport, @trezor/protobuf, @trezor/utxo-lib, @trezor/utils
|
|
23
|
+
|
|
24
|
+
# 9.1.11
|
|
25
|
+
|
|
26
|
+
- fix(connect): use weak assert in altcoin signTransaction (86b3703279)
|
|
27
|
+
- fix(connect): rebootToBootloader misbehaviour (662543c429)
|
|
28
|
+
- feat(connect-explorer): add connectSrc to settings (053e9f0908)
|
|
29
|
+
- fix(connect): nem and eth signTx validation issues (a53937c2ea)
|
|
30
|
+
- fix(connect): allow empty signature in multisig in getAddress (3b356b5952)
|
|
31
|
+
- fix(connect-examples): webextensions example update usb permissions url (cfbdfc2469)
|
|
32
|
+
|
|
1
33
|
# 9.1.10
|
|
2
34
|
|
|
3
35
|
- chore(connect): bump ADA support version, min required version is now 2.4.3 (7937fea3ec)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.1.
|
|
3
|
+
API version 9.1.12
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -14,7 +14,7 @@ class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
14
14
|
this.requiredPermissions = ['read', 'write'];
|
|
15
15
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('BNB'), this.firmwareRange);
|
|
16
16
|
const { payload } = this;
|
|
17
|
-
(0, schema_utils_1.
|
|
17
|
+
(0, schema_utils_1.AssertWeak)(binance_1.BinanceSignTransaction, payload);
|
|
18
18
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
19
19
|
const transaction = helper.validate(payload.transaction);
|
|
20
20
|
this.params = {
|
|
@@ -48,7 +48,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
48
48
|
payload.auxiliaryData.cVoteRegistrationParameters =
|
|
49
49
|
payload.auxiliaryData.governanceRegistrationParameters;
|
|
50
50
|
}
|
|
51
|
-
(0, schema_utils_1.
|
|
51
|
+
(0, schema_utils_1.AssertWeak)(schema_utils_1.Type.Union([cardano_1.CardanoSignTransaction, cardano_1.CardanoSignTransactionExtended]), payload);
|
|
52
52
|
const inputsWithPath = payload.inputs.map(cardanoInputs_1.transformInput);
|
|
53
53
|
const outputsWithData = payload.outputs.map(cardanoOutputs_1.transformOutput);
|
|
54
54
|
let certificatesWithPoolOwnersAndRelays = [];
|
|
@@ -13,7 +13,7 @@ class EosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
13
13
|
this.requiredPermissions = ['read', 'write'];
|
|
14
14
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('EOS'), this.firmwareRange);
|
|
15
15
|
const { payload } = this;
|
|
16
|
-
(0, schema_utils_1.
|
|
16
|
+
(0, schema_utils_1.AssertWeak)(eos_1.EosSignTransaction, payload);
|
|
17
17
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
18
18
|
const { chain_id, header, ack } = helper.validate(payload.transaction);
|
|
19
19
|
this.params = {
|
|
@@ -32,8 +32,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
32
32
|
name: string;
|
|
33
33
|
owner: {
|
|
34
34
|
keys: {
|
|
35
|
-
type?: number | undefined;
|
|
36
35
|
address_n?: number[] | undefined;
|
|
36
|
+
type?: number | undefined;
|
|
37
37
|
weight: number;
|
|
38
38
|
key: string;
|
|
39
39
|
}[];
|
|
@@ -53,8 +53,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
53
53
|
creator: string;
|
|
54
54
|
active: {
|
|
55
55
|
keys: {
|
|
56
|
-
type?: number | undefined;
|
|
57
56
|
address_n?: number[] | undefined;
|
|
57
|
+
type?: number | undefined;
|
|
58
58
|
weight: number;
|
|
59
59
|
key: string;
|
|
60
60
|
}[];
|
|
@@ -125,8 +125,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
125
125
|
parent: string;
|
|
126
126
|
auth: {
|
|
127
127
|
keys: {
|
|
128
|
-
type?: number | undefined;
|
|
129
128
|
address_n?: number[] | undefined;
|
|
129
|
+
type?: number | undefined;
|
|
130
130
|
weight: number;
|
|
131
131
|
key: string;
|
|
132
132
|
}[];
|
|
@@ -19,7 +19,7 @@ declare const Params: import("@sinclair/typebox").TIntersect<[import("@sinclair/
|
|
|
19
19
|
domain: import("@sinclair/typebox").TObject<{
|
|
20
20
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
21
|
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
22
|
-
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt]>>;
|
|
22
|
+
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>>;
|
|
23
23
|
verifyingContract: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
24
|
salt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer, import("@sinclair/typebox").TString]>>;
|
|
25
25
|
}>;
|
|
@@ -40,7 +40,7 @@ declare const Params: import("@sinclair/typebox").TIntersect<[import("@sinclair/
|
|
|
40
40
|
domain: import("@sinclair/typebox").TObject<{
|
|
41
41
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
42
|
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
43
|
-
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt]>>;
|
|
43
|
+
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>>;
|
|
44
44
|
verifyingContract: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
45
|
salt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer, import("@sinclair/typebox").TString]>>;
|
|
46
46
|
}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreEventMessage } from '../../events';
|
|
2
2
|
import { PROTO } from '../../constants';
|
|
3
3
|
import type { Device } from '../../device/Device';
|
|
4
4
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
5
|
-
export declare const uploadFirmware: (typedCall: TypedCall, postMessage:
|
|
5
|
+
export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (message: CoreEventMessage) => void, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<{
|
|
6
6
|
message: string;
|
|
7
7
|
}>;
|
|
8
8
|
//# sourceMappingURL=uploadFirmware.d.ts.map
|
package/lib/api/getAddress.js
CHANGED
|
@@ -20,6 +20,12 @@ class GetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
20
20
|
const payload = !this.payload.bundle
|
|
21
21
|
? { ...this.payload, bundle: [this.payload] }
|
|
22
22
|
: this.payload;
|
|
23
|
+
payload === null || payload === void 0 ? void 0 : payload.bundle.forEach(bundleElement => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if (bundleElement.multisig && ((_a = bundleElement.multisig) === null || _a === void 0 ? void 0 : _a.signatures) === undefined) {
|
|
26
|
+
bundleElement.multisig.signatures = Array((_b = bundleElement.multisig) === null || _b === void 0 ? void 0 : _b.pubkeys.length).fill('');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
23
29
|
(0, schema_utils_1.Assert)((0, types_1.Bundle)(getAddress_1.GetAddress), payload);
|
|
24
30
|
this.params = payload.bundle.map(batch => {
|
|
25
31
|
const path = (0, pathUtils_1.validatePath)(batch.path, 1);
|
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
10
10
|
type: string;
|
|
11
11
|
url: string[];
|
|
12
12
|
} | undefined;
|
|
13
|
-
name: string;
|
|
14
13
|
label: string;
|
|
15
14
|
blockTime: number;
|
|
16
15
|
minFee: number;
|
|
17
16
|
maxFee: number;
|
|
17
|
+
name: string;
|
|
18
18
|
shortcut: string;
|
|
19
19
|
slip44: number;
|
|
20
20
|
support: {
|
|
@@ -65,11 +65,11 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
65
65
|
type: string;
|
|
66
66
|
url: string[];
|
|
67
67
|
} | undefined;
|
|
68
|
-
name: string;
|
|
69
68
|
label: string;
|
|
70
69
|
blockTime: number;
|
|
71
70
|
minFee: number;
|
|
72
71
|
maxFee: number;
|
|
72
|
+
name: string;
|
|
73
73
|
shortcut: string;
|
|
74
74
|
slip44: number;
|
|
75
75
|
support: {
|
|
@@ -95,11 +95,11 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
95
95
|
type: string;
|
|
96
96
|
url: string[];
|
|
97
97
|
} | undefined;
|
|
98
|
-
name: string;
|
|
99
98
|
label: string;
|
|
100
99
|
blockTime: number;
|
|
101
100
|
minFee: number;
|
|
102
101
|
maxFee: number;
|
|
102
|
+
name: string;
|
|
103
103
|
shortcut: string;
|
|
104
104
|
slip44: number;
|
|
105
105
|
support: {
|
|
@@ -10,10 +10,14 @@ const schema_utils_1 = require("@trezor/schema-utils");
|
|
|
10
10
|
const nem_1 = require("../../../types/api/nem");
|
|
11
11
|
class NEMSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
12
12
|
init() {
|
|
13
|
+
var _a;
|
|
13
14
|
this.requiredPermissions = ['read', 'write'];
|
|
14
15
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('NEM'), this.firmwareRange);
|
|
15
16
|
const { payload } = this;
|
|
16
|
-
(0
|
|
17
|
+
if ((_a = payload === null || payload === void 0 ? void 0 : payload.transaction) === null || _a === void 0 ? void 0 : _a.timestamp) {
|
|
18
|
+
payload.transaction.timeStamp = payload.transaction.timestamp;
|
|
19
|
+
}
|
|
20
|
+
(0, schema_utils_1.AssertWeak)(nem_1.NEMSignTransaction, payload);
|
|
17
21
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
18
22
|
this.params = helper.createTx(payload.transaction, path, payload.chunkify);
|
|
19
23
|
}
|
|
@@ -3,8 +3,8 @@ import * as $T from '../../types/api/nem';
|
|
|
3
3
|
export declare const createTx: (tx: $T.NEMTransaction, address_n: number[], chunkify?: boolean) => {
|
|
4
4
|
chunkify?: boolean | undefined;
|
|
5
5
|
transfer?: {
|
|
6
|
-
payload?: string | undefined;
|
|
7
6
|
public_key?: string | undefined;
|
|
7
|
+
payload?: string | undefined;
|
|
8
8
|
mosaics?: {
|
|
9
9
|
quantity: number;
|
|
10
10
|
namespace: string;
|
|
@@ -11,7 +11,7 @@ class RippleSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
11
11
|
this.requiredPermissions = ['read', 'write'];
|
|
12
12
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Ripple'), this.firmwareRange);
|
|
13
13
|
const { payload } = this;
|
|
14
|
-
(0, schema_utils_1.
|
|
14
|
+
(0, schema_utils_1.AssertWeak)(ripple_1.RippleSignTransaction, payload);
|
|
15
15
|
const path = (0, pathUtils_1.validatePath)(payload.path, 5);
|
|
16
16
|
const { transaction, chunkify } = payload;
|
|
17
17
|
this.params = {
|
|
@@ -12,7 +12,7 @@ class SolanaSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
12
12
|
this.requiredPermissions = ['read', 'write'];
|
|
13
13
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Solana'), this.firmwareRange);
|
|
14
14
|
const { payload } = this;
|
|
15
|
-
(0, schema_utils_1.
|
|
15
|
+
(0, schema_utils_1.AssertWeak)(solana_1.SolanaSignTransaction, payload);
|
|
16
16
|
const path = (0, pathUtils_1.validatePath)(payload.path, 2);
|
|
17
17
|
this.params = {
|
|
18
18
|
address_n: path,
|
|
@@ -18,7 +18,7 @@ class StellarSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
18
18
|
this.requiredPermissions = ['read', 'write'];
|
|
19
19
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Stellar'), this.firmwareRange);
|
|
20
20
|
const { payload } = this;
|
|
21
|
-
(0, schema_utils_1.
|
|
21
|
+
(0, schema_utils_1.AssertWeak)(stellar_1.StellarSignTransaction, payload);
|
|
22
22
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
23
23
|
const { transaction } = payload;
|
|
24
24
|
this.params = {
|
|
@@ -13,7 +13,7 @@ class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
13
13
|
this.requiredPermissions = ['read', 'write'];
|
|
14
14
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
|
|
15
15
|
const { payload } = this;
|
|
16
|
-
(0, schema_utils_1.
|
|
16
|
+
(0, schema_utils_1.AssertWeak)(tezos_1.TezosSignTransaction, payload);
|
|
17
17
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
18
18
|
this.params = helper.createTx(path, payload.branch, payload.operation);
|
|
19
19
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import BlockchainLink, { ServerInfo, SubscriptionAccountInfo, BlockchainLinkParams, BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
|
-
import {
|
|
2
|
+
import { CoreEventMessage } from '../events';
|
|
3
3
|
import { ERRORS } from '../constants';
|
|
4
4
|
import type { CoinInfo, Proxy } from '../types';
|
|
5
5
|
export type BlockchainOptions = {
|
|
6
6
|
coinInfo: CoinInfo;
|
|
7
|
-
postMessage:
|
|
7
|
+
postMessage: (message: CoreEventMessage) => void;
|
|
8
8
|
proxy?: Proxy;
|
|
9
9
|
debug?: boolean;
|
|
10
10
|
onConnected?: (url: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Deferred } from '@trezor/utils/lib/createDeferred';
|
|
2
2
|
import { NETWORK } from '../constants';
|
|
3
|
-
import { CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromiseCreator,
|
|
3
|
+
import { CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromiseCreator, CoreEventMessage } from '../events';
|
|
4
4
|
import type { Device } from '../device/Device';
|
|
5
5
|
import type { FirmwareRange } from '../types';
|
|
6
6
|
export type Payload<M> = Extract<CallMethodPayload, {
|
|
@@ -40,18 +40,18 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
40
40
|
confirmation?(): Promise<boolean | undefined>;
|
|
41
41
|
noBackupConfirmation?(allowSuppression?: boolean): Promise<boolean>;
|
|
42
42
|
getButtonRequestData?(code: string): UiRequestButtonData | undefined;
|
|
43
|
-
postMessage:
|
|
43
|
+
postMessage: (message: CoreEventMessage) => void;
|
|
44
44
|
getPopupPromise: () => Deferred<void>;
|
|
45
45
|
createUiPromise: UiPromiseCreator;
|
|
46
46
|
removeUiPromise: (promise: Deferred<any>) => void;
|
|
47
47
|
initAsync?(): Promise<void>;
|
|
48
|
-
initAsyncPromise?: Promise<void>;
|
|
49
48
|
constructor(message: {
|
|
50
49
|
id?: number;
|
|
51
50
|
payload: Payload<Name>;
|
|
52
51
|
});
|
|
53
52
|
setDevice(device: Device): void;
|
|
54
53
|
requestPermissions(): Promise<boolean>;
|
|
54
|
+
private getOriginPermissions;
|
|
55
55
|
checkPermissions(): void;
|
|
56
56
|
savePermissions(temporary?: boolean): void;
|
|
57
57
|
checkFirmwareRange(isUsingPopup?: boolean): Promise<"ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined>;
|
|
@@ -81,47 +81,49 @@ class AbstractMethod {
|
|
|
81
81
|
}
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
|
+
getOriginPermissions() {
|
|
85
|
+
var _a;
|
|
86
|
+
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
87
|
+
if (!origin) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
return ((_a = connect_common_1.storage.loadForOrigin(origin)) === null || _a === void 0 ? void 0 : _a.permissions) || [];
|
|
91
|
+
}
|
|
84
92
|
checkPermissions() {
|
|
85
|
-
const
|
|
93
|
+
const originPermissions = this.getOriginPermissions();
|
|
86
94
|
let notPermitted = [...this.requiredPermissions];
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return !granted;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
+
if (originPermissions.length > 0) {
|
|
96
|
+
notPermitted = notPermitted.filter(np => {
|
|
97
|
+
const granted = originPermissions.find(p => p.type === np && p.device === this.device.features.device_id);
|
|
98
|
+
return !granted;
|
|
99
|
+
});
|
|
95
100
|
}
|
|
96
101
|
this.requiredPermissions = notPermitted;
|
|
97
102
|
}
|
|
98
103
|
savePermissions(temporary = false) {
|
|
99
|
-
const
|
|
104
|
+
const originPermissions = this.getOriginPermissions();
|
|
100
105
|
let permissionsToSave = this.requiredPermissions.map(p => ({
|
|
101
|
-
origin: DataManager_1.DataManager.getSettings('origin'),
|
|
102
106
|
type: p,
|
|
103
107
|
device: this.device.features.device_id || undefined,
|
|
104
108
|
}));
|
|
105
109
|
let emitEvent = false;
|
|
106
110
|
if (this.requiredPermissions.indexOf('read') >= 0) {
|
|
107
|
-
const wasAlreadyGranted =
|
|
108
|
-
p.type === 'read' &&
|
|
109
|
-
p.device === this.device.features.device_id);
|
|
111
|
+
const wasAlreadyGranted = originPermissions.filter(p => p.type === 'read' && p.device === this.device.features.device_id);
|
|
110
112
|
if (wasAlreadyGranted.length < 1) {
|
|
111
113
|
emitEvent = true;
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
|
-
const originPermissions = savedPermissions.filter(p => p.origin === DataManager_1.DataManager.getSettings('origin'));
|
|
115
116
|
if (originPermissions.length > 0) {
|
|
116
117
|
permissionsToSave = permissionsToSave.filter(p2s => {
|
|
117
118
|
const granted = originPermissions.find(p => p.type === p2s.type && p.device === p2s.device);
|
|
118
119
|
return !granted;
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
123
|
+
connect_common_1.storage.saveForOrigin(state => ({
|
|
122
124
|
...state,
|
|
123
|
-
permissions:
|
|
124
|
-
}), temporary);
|
|
125
|
+
permissions: [...(state.permissions || []), ...permissionsToSave],
|
|
126
|
+
}), origin, temporary);
|
|
125
127
|
if (emitEvent) {
|
|
126
128
|
this.postMessage((0, events_1.createDeviceMessage)(events_1.DEVICE.CONNECT, this.device.toMessageObject()));
|
|
127
129
|
}
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
import { TransportInfo,
|
|
3
|
+
import { TransportInfo, CoreRequestMessage, CoreEventMessage } from '../events';
|
|
4
4
|
import { AbstractMethod } from './AbstractMethod';
|
|
5
5
|
import { LogWriter } from '../utils/debug';
|
|
6
6
|
import type { ConnectSettings } from '../types';
|
|
7
|
-
export declare const handleMessage: (message: CoreMessage) => void;
|
|
8
|
-
export declare const onCall: (message: CoreMessage) => Promise<void>;
|
|
9
7
|
export declare class Core extends EventEmitter {
|
|
10
|
-
handleMessage(message:
|
|
8
|
+
handleMessage(message: CoreRequestMessage): void;
|
|
11
9
|
dispose(): Promise<void>;
|
|
12
10
|
getCurrentMethod(): Promise<AbstractMethod<any, undefined>>;
|
|
13
11
|
getTransportInfo(): TransportInfo | undefined;
|
|
14
12
|
enumerate(): void;
|
|
15
13
|
}
|
|
16
|
-
export declare const initCore: (settings: ConnectSettings, logWriterFactory?: () => LogWriter | undefined) => Promise<Core>;
|
|
17
|
-
export declare const initTransport: (settings: ConnectSettings) => Promise<void>;
|
|
14
|
+
export declare const initCore: (settings: ConnectSettings, onCoreEvent: (message: CoreEventMessage) => void, logWriterFactory?: () => LogWriter | undefined) => Promise<Core>;
|
|
18
15
|
//# sourceMappingURL=index.d.ts.map
|