@wagmi/core 3.3.1 → 3.3.3
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/dist/esm/actions/connect.js.map +1 -1
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/tempo/Connectors.js +44 -18
- package/dist/esm/tempo/Connectors.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/tempo/Connectors.d.ts +13 -3
- package/dist/types/tempo/Connectors.d.ts.map +1 -1
- package/dist/types/types/properties.d.ts +6 -0
- package/dist/types/types/properties.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/actions/connect.ts +1 -1
- package/src/exports/internal.ts +2 -0
- package/src/tempo/Connectors.ts +70 -21
- package/src/types/properties.ts +8 -0
- package/src/version.ts +1 -1
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '3.3.
|
|
1
|
+
export const version = '3.3.3';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type WatchChainsParameters, type WatchChainsReturnType, watchChains, } from '../actions/watchChains.js';
|
|
2
2
|
export { createEmitter, Emitter, type EventData, } from '../createEmitter.js';
|
|
3
3
|
export type { SelectChains } from '../types/chain.js';
|
|
4
|
-
export type { ChainIdParameter, ConnectorParameter, ScopeKeyParameter, } from '../types/properties.js';
|
|
4
|
+
export type { ChainIdParameter, ConfigParameter, ConnectorParameter, EnabledParameter, ScopeKeyParameter, } from '../types/properties.js';
|
|
5
5
|
export type { QueryParameter } from '../types/query.js';
|
|
6
6
|
export type { Compute, ExactPartial, FixedArray, Mutable, OneOf, PartialBy, RemoveUndefined, RequiredBy, StrictOmit as Omit, UnionCompute, UnionExactPartial, UnionLooseOmit, UnionStrictOmit, } from '../types/utils.js';
|
|
7
7
|
export { deepEqual } from '../utils/deepEqual.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,WAAW,GACZ,MAAM,2BAA2B,CAAA;AAMlC,OAAO,EACL,aAAa,EACb,OAAO,EACP,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAA;AAM5B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAE/B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,YAAY,EACV,OAAO,EACP,YAAY,EACZ,UAAU,EACV,OAAO,EACP,KAAK,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,UAAU,IAAI,IAAI,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,WAAW,GACZ,MAAM,2BAA2B,CAAA;AAMlC,OAAO,EACL,aAAa,EACb,OAAO,EACP,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAA;AAM5B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAE/B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,YAAY,EACV,OAAO,EACP,YAAY,EACZ,UAAU,EACV,OAAO,EACP,KAAK,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,UAAU,IAAI,IAAI,EAClB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Address from 'ox/Address';
|
|
2
|
+
import type * as Hex from 'ox/Hex';
|
|
2
3
|
import { KeyAuthorization } from 'ox/tempo';
|
|
3
4
|
import { type LocalAccount } from 'viem/accounts';
|
|
4
5
|
import { WebAuthnP256 } from 'viem/tempo';
|
|
@@ -16,7 +17,7 @@ export declare function webAuthn(options: webAuthn.Parameters): import("../conne
|
|
|
16
17
|
}, "request">, {
|
|
17
18
|
connect<withCapabilities extends boolean = false>(parameters: {
|
|
18
19
|
chainId?: number | undefined;
|
|
19
|
-
capabilities?: OneOf<{
|
|
20
|
+
capabilities?: (OneOf<{
|
|
20
21
|
label?: string | undefined;
|
|
21
22
|
type: "sign-up";
|
|
22
23
|
} | {
|
|
@@ -24,11 +25,20 @@ export declare function webAuthn(options: webAuthn.Parameters): import("../conne
|
|
|
24
25
|
type: "sign-in";
|
|
25
26
|
} | {
|
|
26
27
|
type?: undefined;
|
|
27
|
-
}>
|
|
28
|
+
}> & {
|
|
29
|
+
sign?: {
|
|
30
|
+
hash: Hex.Hex;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}) | undefined;
|
|
28
33
|
isReconnecting?: boolean | undefined;
|
|
29
34
|
withCapabilities?: withCapabilities | boolean | undefined;
|
|
30
35
|
}): Promise<{
|
|
31
|
-
accounts: readonly
|
|
36
|
+
accounts: withCapabilities extends true ? readonly {
|
|
37
|
+
address: Address.Address;
|
|
38
|
+
capabilities: {
|
|
39
|
+
signature?: Hex.Hex | undefined;
|
|
40
|
+
};
|
|
41
|
+
}[] : readonly Address.Address[];
|
|
32
42
|
chainId: number;
|
|
33
43
|
}>;
|
|
34
44
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connectors.d.ts","sourceRoot":"","sources":["../../../src/tempo/Connectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"Connectors.d.ts","sourceRoot":"","sources":["../../../src/tempo/Connectors.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,9 +2,15 @@ import type { Config, Connector } from '../createConfig.js';
|
|
|
2
2
|
export type ChainIdParameter<config extends Config, chainId extends config['chains'][number]['id'] | undefined = config['chains'][number]['id']> = {
|
|
3
3
|
chainId?: (chainId extends config['chains'][number]['id'] ? chainId : undefined) | config['chains'][number]['id'] | undefined;
|
|
4
4
|
};
|
|
5
|
+
export type ConfigParameter<config extends Config = Config> = {
|
|
6
|
+
config?: Config | config | undefined;
|
|
7
|
+
};
|
|
5
8
|
export type ConnectorParameter = {
|
|
6
9
|
connector?: Connector | undefined;
|
|
7
10
|
};
|
|
11
|
+
export type EnabledParameter = {
|
|
12
|
+
enabled?: boolean | undefined;
|
|
13
|
+
};
|
|
8
14
|
export type ScopeKeyParameter = {
|
|
9
15
|
scopeKey?: string | undefined;
|
|
10
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../../src/types/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,MAAM,gBAAgB,CAC1B,MAAM,SAAS,MAAM,EACrB,OAAO,SACH,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAC9B,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAC5C;IACF,OAAO,CAAC,EACJ,CAAC,OAAO,SAAS,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,GACtE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAC9B,SAAS,CAAA;CACd,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAEjE,MAAM,MAAM,2BAA2B,GAAG;IACxC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACzC,CAAA"}
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../../src/types/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,MAAM,gBAAgB,CAC1B,MAAM,SAAS,MAAM,EACrB,OAAO,SACH,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAC9B,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAC5C;IACF,OAAO,CAAC,EACJ,CAAC,OAAO,SAAS,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,GACtE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAC9B,SAAS,CAAA;CACd,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAEjE,MAAM,MAAM,2BAA2B,GAAG;IACxC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACzC,CAAA"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "3.3.
|
|
1
|
+
export declare const version = "3.3.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
package/src/actions/connect.ts
CHANGED
package/src/exports/internal.ts
CHANGED
package/src/tempo/Connectors.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
55
55
|
connect<withCapabilities extends boolean = false>(parameters: {
|
|
56
56
|
chainId?: number | undefined
|
|
57
57
|
capabilities?:
|
|
58
|
-
| OneOf<
|
|
58
|
+
| (OneOf<
|
|
59
59
|
| {
|
|
60
60
|
label?: string | undefined
|
|
61
61
|
type: 'sign-up'
|
|
@@ -67,11 +67,25 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
67
67
|
| {
|
|
68
68
|
type?: undefined
|
|
69
69
|
}
|
|
70
|
-
>
|
|
70
|
+
> & {
|
|
71
|
+
sign?:
|
|
72
|
+
| {
|
|
73
|
+
hash: Hex.Hex
|
|
74
|
+
}
|
|
75
|
+
| undefined
|
|
76
|
+
})
|
|
71
77
|
| undefined
|
|
72
78
|
isReconnecting?: boolean | undefined
|
|
73
79
|
withCapabilities?: withCapabilities | boolean | undefined
|
|
74
|
-
}): Promise<{
|
|
80
|
+
}): Promise<{
|
|
81
|
+
accounts: withCapabilities extends true
|
|
82
|
+
? readonly {
|
|
83
|
+
address: Address.Address
|
|
84
|
+
capabilities: { signature?: Hex.Hex | undefined }
|
|
85
|
+
}[]
|
|
86
|
+
: readonly Address.Address[]
|
|
87
|
+
chainId: number
|
|
88
|
+
}>
|
|
75
89
|
}
|
|
76
90
|
type Provider = Pick<EIP1193Provider, 'request'>
|
|
77
91
|
type StorageItem = {
|
|
@@ -98,6 +112,8 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
98
112
|
async connect(parameters = {}) {
|
|
99
113
|
const capabilities =
|
|
100
114
|
'capabilities' in parameters ? (parameters.capabilities ?? {}) : {}
|
|
115
|
+
const signHash =
|
|
116
|
+
'sign' in capabilities ? capabilities.sign?.hash : undefined
|
|
101
117
|
|
|
102
118
|
if (
|
|
103
119
|
accessKeyOptions?.strict &&
|
|
@@ -112,7 +128,12 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
112
128
|
// - a WebAuthn `credential` to instantiate an account
|
|
113
129
|
// - optionally, a `keyPair` to use as the access key for the account
|
|
114
130
|
// - optionally, a signed `keyAuthorization` to provision the access key
|
|
115
|
-
const {
|
|
131
|
+
const {
|
|
132
|
+
credential,
|
|
133
|
+
keyAuthorization,
|
|
134
|
+
keyPair,
|
|
135
|
+
signature: signedHash,
|
|
136
|
+
} = await (async () => {
|
|
116
137
|
// If the connection type is of "sign-up", we are going to create a new credential
|
|
117
138
|
// and provision an access key (if needed).
|
|
118
139
|
if (capabilities.type === 'sign-up') {
|
|
@@ -138,12 +159,14 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
138
159
|
})
|
|
139
160
|
|
|
140
161
|
// Get key pair (access key) to use for the account.
|
|
162
|
+
// Skip if signing a hash — access key provisioning is deferred.
|
|
141
163
|
const keyPair = await (async () => {
|
|
164
|
+
if (signHash) return undefined
|
|
142
165
|
if (!accessKeyOptions) return undefined
|
|
143
166
|
return await WebCryptoP256.createKeyPair()
|
|
144
167
|
})()
|
|
145
168
|
|
|
146
|
-
return { credential, keyPair }
|
|
169
|
+
return { credential, keyPair, signature: undefined }
|
|
147
170
|
}
|
|
148
171
|
|
|
149
172
|
// If we are not selecting an account, we will check if an active credential is present in
|
|
@@ -154,6 +177,12 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
154
177
|
)) as WebAuthnP256.getCredential.ReturnValue | undefined
|
|
155
178
|
|
|
156
179
|
if (credential) {
|
|
180
|
+
// If signing a hash, skip local keypair checks and return
|
|
181
|
+
// the stored credential — the hash will be signed via
|
|
182
|
+
// `account.sign` since `createCredential` cannot sign.
|
|
183
|
+
if (signHash)
|
|
184
|
+
return { credential, keyPair: undefined, signature: undefined }
|
|
185
|
+
|
|
157
186
|
// Get key pair (access key) to use for the account.
|
|
158
187
|
const keyPair = await (async () => {
|
|
159
188
|
if (!accessKeyOptions) return undefined
|
|
@@ -164,10 +193,11 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
164
193
|
})()
|
|
165
194
|
|
|
166
195
|
// If the access key provisioning is not in strict mode, return the credential and key pair (if exists).
|
|
167
|
-
if (!accessKeyOptions?.strict)
|
|
196
|
+
if (!accessKeyOptions?.strict)
|
|
197
|
+
return { credential, keyPair, signature: undefined }
|
|
168
198
|
|
|
169
199
|
// If a key pair is found, return the credential and key pair.
|
|
170
|
-
if (keyPair) return { credential, keyPair }
|
|
200
|
+
if (keyPair) return { credential, keyPair, signature: undefined }
|
|
171
201
|
|
|
172
202
|
// If we are reconnecting, throw an error if not found.
|
|
173
203
|
if (parameters.isReconnecting)
|
|
@@ -180,7 +210,9 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
180
210
|
// Discover credential
|
|
181
211
|
{
|
|
182
212
|
// Get key pair (access key) to use for the account.
|
|
213
|
+
// Skip if signing a hash — access key provisioning is deferred.
|
|
183
214
|
const keyPair = await (async () => {
|
|
215
|
+
if (signHash) return undefined
|
|
184
216
|
if (!accessKeyOptions) return undefined
|
|
185
217
|
return await WebCryptoP256.createKeyPair()
|
|
186
218
|
})()
|
|
@@ -188,12 +220,17 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
188
220
|
// If we are provisioning an access key, we will need to sign a key authorization.
|
|
189
221
|
// We will need the hash (digest) to sign, and the address of the access key to construct the key authorization.
|
|
190
222
|
const { hash, keyAuthorization_unsigned } = await (async () => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
const accessKeyAddress = keyPair
|
|
224
|
+
? Address.fromPublicKey(keyPair.publicKey)
|
|
225
|
+
: undefined
|
|
226
|
+
|
|
227
|
+
if (!accessKeyAddress)
|
|
228
|
+
return { keyAuthorization_unsigned: undefined, hash: undefined }
|
|
229
|
+
|
|
194
230
|
const keyAuthorization_unsigned = KeyAuthorization.from({
|
|
195
|
-
...accessKeyOptions,
|
|
196
231
|
address: accessKeyAddress,
|
|
232
|
+
expiry: accessKeyOptions?.expiry,
|
|
233
|
+
strict: accessKeyOptions?.strict ?? false,
|
|
197
234
|
type: 'p256',
|
|
198
235
|
})
|
|
199
236
|
const hash = KeyAuthorization.getSignPayload(
|
|
@@ -216,23 +253,30 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
216
253
|
if (!publicKey) throw new Error('publicKey not found.')
|
|
217
254
|
return publicKey
|
|
218
255
|
},
|
|
219
|
-
hash,
|
|
256
|
+
hash: signHash ?? hash,
|
|
220
257
|
rpId: options.getOptions?.rpId ?? options.rpId,
|
|
221
258
|
})
|
|
222
259
|
|
|
260
|
+
const envelope = SignatureEnvelope.from({
|
|
261
|
+
metadata: credential.metadata,
|
|
262
|
+
signature: credential.signature,
|
|
263
|
+
publicKey: PublicKey.fromHex(credential.publicKey),
|
|
264
|
+
type: 'webAuthn',
|
|
265
|
+
})
|
|
266
|
+
|
|
223
267
|
const keyAuthorization = keyAuthorization_unsigned
|
|
224
268
|
? KeyAuthorization.from({
|
|
225
269
|
...keyAuthorization_unsigned,
|
|
226
|
-
signature:
|
|
227
|
-
metadata: credential.metadata,
|
|
228
|
-
signature: credential.signature,
|
|
229
|
-
publicKey: PublicKey.fromHex(credential.publicKey),
|
|
230
|
-
type: 'webAuthn',
|
|
231
|
-
}),
|
|
270
|
+
signature: envelope,
|
|
232
271
|
})
|
|
233
272
|
: undefined
|
|
234
273
|
|
|
235
|
-
|
|
274
|
+
const signature =
|
|
275
|
+
signHash && !keyAuthorization_unsigned
|
|
276
|
+
? SignatureEnvelope.serialize(envelope)
|
|
277
|
+
: undefined
|
|
278
|
+
|
|
279
|
+
return { credential, keyAuthorization, keyPair, signature }
|
|
236
280
|
}
|
|
237
281
|
})()
|
|
238
282
|
|
|
@@ -249,7 +293,12 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
249
293
|
rpId: options.getOptions?.rpId ?? options.rpId,
|
|
250
294
|
})
|
|
251
295
|
|
|
252
|
-
|
|
296
|
+
let signature: Hex.Hex | undefined
|
|
297
|
+
if (signHash && !signedHash) {
|
|
298
|
+
signature = await account.sign({ hash: signHash })
|
|
299
|
+
} else if (signedHash) {
|
|
300
|
+
signature = signedHash
|
|
301
|
+
} else if (keyPair) {
|
|
253
302
|
accessKey = Account.fromWebCryptoP256(keyPair, {
|
|
254
303
|
access: account,
|
|
255
304
|
})
|
|
@@ -307,7 +356,7 @@ export function webAuthn(options: webAuthn.Parameters) {
|
|
|
307
356
|
|
|
308
357
|
return {
|
|
309
358
|
accounts: (parameters.withCapabilities
|
|
310
|
-
? [{ address }]
|
|
359
|
+
? [{ address, capabilities: { signature } }]
|
|
311
360
|
: [address]) as never,
|
|
312
361
|
chainId,
|
|
313
362
|
}
|
package/src/types/properties.ts
CHANGED
|
@@ -12,10 +12,18 @@ export type ChainIdParameter<
|
|
|
12
12
|
| undefined
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export type ConfigParameter<config extends Config = Config> = {
|
|
16
|
+
config?: Config | config | undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
export type ConnectorParameter = {
|
|
16
20
|
connector?: Connector | undefined
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
export type EnabledParameter = {
|
|
24
|
+
enabled?: boolean | undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
export type ScopeKeyParameter = { scopeKey?: string | undefined }
|
|
20
28
|
|
|
21
29
|
export type SyncConnectedChainParameter = {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.3.
|
|
1
|
+
export const version = '3.3.3'
|