@shadow-corp/nearconnect 1.0.0 → 1.0.4
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/build/NearConnector.d.ts +29 -0
- package/build/NearConnector.js +96 -0
- package/build/NearConnector.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +7 -2
- package/build/index.js.map +1 -1
- package/build/types.d.ts +5 -0
- package/build/wallets/external/manager.js +24 -14
- package/build/wallets/external/manager.js.map +1 -1
- package/build/wallets/injected/adapter.d.ts +47 -0
- package/build/wallets/injected/adapter.js +233 -0
- package/build/wallets/injected/adapter.js.map +1 -0
- package/build/wallets/injected/detector.d.ts +82 -0
- package/build/wallets/injected/detector.js +237 -0
- package/build/wallets/injected/detector.js.map +1 -0
- package/build/wallets/injected/index.d.ts +10 -0
- package/build/wallets/injected/index.js +15 -0
- package/build/wallets/injected/index.js.map +1 -0
- package/build/wallets/injected/manager.d.ts +51 -0
- package/build/wallets/injected/manager.js +94 -0
- package/build/wallets/injected/manager.js.map +1 -0
- package/package.json +12 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Injected Wallet Manager
|
|
4
|
+
*
|
|
5
|
+
* Manages detection and interaction with browser extension wallets.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.InjectedWalletManager = void 0;
|
|
9
|
+
const detector_1 = require("./detector");
|
|
10
|
+
const adapter_1 = require("./adapter");
|
|
11
|
+
class InjectedWalletManager {
|
|
12
|
+
detector;
|
|
13
|
+
adapters = new Map();
|
|
14
|
+
config;
|
|
15
|
+
initialized = false;
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
this.detector = new detector_1.InjectedWalletDetector();
|
|
18
|
+
this.config = config;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initialize detection
|
|
22
|
+
*/
|
|
23
|
+
async init() {
|
|
24
|
+
if (this.initialized) {
|
|
25
|
+
return this.getWallets();
|
|
26
|
+
}
|
|
27
|
+
const timeout = this.config.detectionTimeout ?? 2000;
|
|
28
|
+
const detected = await this.detector.detect(timeout);
|
|
29
|
+
for (const wallet of detected) {
|
|
30
|
+
this.addAdapter(wallet);
|
|
31
|
+
}
|
|
32
|
+
// Subscribe to future detections
|
|
33
|
+
this.detector.onDetected((wallets) => {
|
|
34
|
+
for (const wallet of wallets) {
|
|
35
|
+
if (!this.adapters.has(wallet.info.id)) {
|
|
36
|
+
this.addAdapter(wallet);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (this.config.onDetected) {
|
|
40
|
+
this.config.onDetected(this.getWallets());
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.initialized = true;
|
|
44
|
+
console.log(`[NearConnect] Found ${detected.length} injected wallet(s)`);
|
|
45
|
+
return this.getWallets();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add an adapter for a detected wallet
|
|
49
|
+
*/
|
|
50
|
+
addAdapter(wallet) {
|
|
51
|
+
const adapter = new adapter_1.InjectedWalletAdapter(wallet);
|
|
52
|
+
this.adapters.set(wallet.info.id, adapter);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get all detected wallets as NearWalletBase
|
|
56
|
+
*/
|
|
57
|
+
getWallets() {
|
|
58
|
+
return Array.from(this.adapters.values());
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get a specific wallet by ID
|
|
62
|
+
*/
|
|
63
|
+
getWallet(walletId) {
|
|
64
|
+
return this.adapters.get(walletId);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if wallet ID is an injected wallet
|
|
68
|
+
*/
|
|
69
|
+
isInjectedWallet(walletId) {
|
|
70
|
+
return this.adapters.has(walletId);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if any injected wallets were detected
|
|
74
|
+
*/
|
|
75
|
+
hasWallets() {
|
|
76
|
+
return this.adapters.size > 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get count of detected wallets
|
|
80
|
+
*/
|
|
81
|
+
get count() {
|
|
82
|
+
return this.adapters.size;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Cleanup
|
|
86
|
+
*/
|
|
87
|
+
destroy() {
|
|
88
|
+
this.detector.destroy();
|
|
89
|
+
this.adapters.clear();
|
|
90
|
+
this.initialized = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.InjectedWalletManager = InjectedWalletManager;
|
|
94
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/wallets/injected/manager.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,yCAAyE;AACzE,uCAAkD;AASlD,MAAa,qBAAqB;IACxB,QAAQ,CAAyB;IACjC,QAAQ,GAAuC,IAAI,GAAG,EAAE,CAAC;IACzD,MAAM,CAA8B;IACpC,WAAW,GAAG,KAAK,CAAC;IAE5B,YAAY,SAAsC,EAAE;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAsB,EAAE,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC;QACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAErD,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAA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CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF;AAhGD,sDAgGC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadow-corp/nearconnect",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "Shadow Corp",
|
|
9
|
-
"description": "
|
|
9
|
+
"description": "NEAR Protocol wallet connector with four-tier architecture and security layers",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/ShadowCorp-Dev/NearConnect"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/
|
|
14
|
+
"homepage": "https://github.com/ShadowCorp-Dev/NearConnect",
|
|
15
15
|
"directories": {
|
|
16
16
|
"build": "build"
|
|
17
17
|
},
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
"build": "rm -rf build && npx tsc",
|
|
24
24
|
"cdn": "vite build"
|
|
25
25
|
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@walletconnect/sign-client": "^2.0.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@walletconnect/sign-client": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
26
34
|
"devDependencies": {
|
|
27
35
|
"@near-js/transactions": "^2.5.1",
|
|
28
36
|
"@near-js/types": "^2.5.1",
|