@docknetwork/wallet-sdk-core 0.4.19 → 1.4.0
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/lib/account-provider.d.ts +1 -1
- package/lib/account-provider.js +1 -1
- package/lib/biometric-provider.d.ts +1 -1
- package/lib/biometric-provider.d.ts.map +1 -1
- package/lib/biometric-provider.js +1 -0
- package/lib/biometric-provider.js.map +1 -1
- package/lib/cloud-wallet.d.ts +20 -0
- package/lib/cloud-wallet.d.ts.map +1 -0
- package/lib/cloud-wallet.js +154 -0
- package/lib/cloud-wallet.js.map +1 -0
- package/lib/credential-provider.d.ts +10 -0
- package/lib/credential-provider.d.ts.map +1 -1
- package/lib/credential-provider.js +31 -10
- package/lib/credential-provider.js.map +1 -1
- package/lib/credentials/oidvc.d.ts +14 -0
- package/lib/credentials/oidvc.d.ts.map +1 -0
- package/lib/credentials/oidvc.js +84 -0
- package/lib/credentials/oidvc.js.map +1 -0
- package/lib/did-provider.js +1 -1
- package/lib/ecosystem-tools.d.ts +8 -6
- package/lib/ecosystem-tools.d.ts.map +1 -1
- package/lib/ecosystem-tools.js +27 -13
- package/lib/ecosystem-tools.js.map +1 -1
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.d.ts.map +1 -1
- package/lib/helpers.js +9 -1
- package/lib/helpers.js.map +1 -1
- package/lib/message-provider.d.ts +2 -19
- package/lib/message-provider.d.ts.map +1 -1
- package/lib/message-provider.js +69 -13
- package/lib/message-provider.js.map +1 -1
- package/lib/messages/message-helpers.js +2 -2
- package/lib/messages/message-helpers.js.map +1 -1
- package/lib/network-resolver.d.ts +2 -1
- package/lib/network-resolver.d.ts.map +1 -1
- package/lib/network-resolver.js +37 -6
- package/lib/network-resolver.js.map +1 -1
- package/lib/types.d.ts +10 -7
- package/lib/types.d.ts.map +1 -1
- package/lib/v1-helpers.js +9 -9
- package/lib/v1-helpers.js.map +1 -1
- package/lib/verification-controller.d.ts.map +1 -1
- package/lib/verification-controller.js +12 -8
- package/lib/verification-controller.js.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +7 -0
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -1
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +11 -2
- package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -1
- package/lib/wallet-wasm.js +5 -5
- package/lib/wallet-wasm.js.map +1 -1
- package/lib/wallet.d.ts +1 -1
- package/lib/wallet.d.ts.map +1 -1
- package/lib/wallet.js +17 -53
- package/lib/wallet.js.map +1 -1
- package/package.json +6 -6
- package/src/biometric-provider.ts +1 -0
- package/src/cloud-wallet.ts +189 -0
- package/src/credential-provider.test.ts +11 -5
- package/src/credential-provider.ts +78 -25
- package/src/credentials/oidvc.test.ts +124 -0
- package/src/credentials/oidvc.ts +115 -0
- package/src/did-provider.test.ts +19 -11
- package/src/ecosystem-tools.ts +36 -11
- package/src/fixtures/biometrics-credential-bbs-revocation.json +2 -2
- package/src/fixtures/iiw-credential.json +1 -1
- package/src/fixtures/iiw-template.json +2 -2
- package/src/helpers.ts +10 -0
- package/src/message-provider.test.ts +9 -3
- package/src/message-provider.ts +97 -25
- package/src/messages/message-helpers.test.ts +15 -0
- package/src/messages/message-helpers.ts +2 -2
- package/src/network-resolver.test.ts +73 -4
- package/src/network-resolver.ts +41 -6
- package/src/types.ts +11 -5
- package/src/v1-helpers.ts +6 -6
- package/src/verification-controller.test.ts +8 -3
- package/src/verification-controller.ts +10 -6
- package/src/wallet-to-wallet-verification/walletToWalletVerificationProvider.ts +15 -0
- package/src/wallet-wasm.ts +1 -1
- package/src/wallet.test.ts +4 -1
- package/src/wallet.ts +22 -75
- package/tsconfig.build.tsbuildinfo +1 -1
- package/LICENSE +0 -39
package/src/wallet.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {createDataStore} from '@docknetwork/wallet-sdk-data-store-typeorm/src';
|
|
1
2
|
import {createDIDProvider} from './did-provider';
|
|
2
3
|
import {createWallet, ensureDocumentContext, IWallet} from './wallet';
|
|
3
4
|
|
|
@@ -6,7 +7,9 @@ describe('Wallet', () => {
|
|
|
6
7
|
|
|
7
8
|
beforeEach(async () => {
|
|
8
9
|
wallet = await createWallet({
|
|
9
|
-
|
|
10
|
+
dataStore: await createDataStore({
|
|
11
|
+
databasePath: ':memory:',
|
|
12
|
+
}),
|
|
10
13
|
});
|
|
11
14
|
});
|
|
12
15
|
|
package/src/wallet.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import {createDataStore} from '@docknetwork/wallet-sdk-data-store/src';
|
|
2
|
-
import {
|
|
3
|
-
DataStore,
|
|
4
|
-
DataStoreConfigs,
|
|
5
|
-
WalletDocument,
|
|
6
|
-
} from '@docknetwork/wallet-sdk-data-store/src/types';
|
|
7
|
-
import {
|
|
8
|
-
getDocumentsByType,
|
|
9
|
-
getDocumentById,
|
|
10
|
-
createDocument,
|
|
11
|
-
removeDocument,
|
|
12
|
-
getDocumentCorrelations,
|
|
13
|
-
getAllDocuments,
|
|
14
|
-
updateDocument,
|
|
15
|
-
removeAllDocuments,
|
|
16
|
-
getDocumentsById,
|
|
17
|
-
} from '@docknetwork/wallet-sdk-data-store/src/entities/document';
|
|
18
1
|
import {CreateWalletProps, IWallet} from './types';
|
|
19
2
|
import {toV1Wallet} from './v1-helpers';
|
|
20
3
|
import {initWalletWasm} from './wallet-wasm';
|
|
21
4
|
import {EventEmitter} from 'events';
|
|
22
5
|
import {WalletEvents} from '@docknetwork/wallet-sdk-wasm/src/modules/wallet';
|
|
23
6
|
import {walletService} from '@docknetwork/wallet-sdk-wasm/src/services/wallet';
|
|
24
|
-
import {importUniversalWalletDocuments} from '@docknetwork/wallet-sdk-data-store/src/
|
|
7
|
+
import {importUniversalWalletDocuments} from '@docknetwork/wallet-sdk-data-store/src/helpers';
|
|
25
8
|
import {ensureDID} from './did-provider';
|
|
26
9
|
export type {IWallet};
|
|
27
10
|
|
|
@@ -46,10 +29,9 @@ export function ensureDocumentContext(document) {
|
|
|
46
29
|
* @param createWalletProps
|
|
47
30
|
* @returns {Promise<IWallet>}
|
|
48
31
|
*/
|
|
49
|
-
export async function createWallet(
|
|
50
|
-
|
|
51
|
-
): Promise<IWallet> {
|
|
52
|
-
const dataStore = await createDataStore(createWalletProps);
|
|
32
|
+
export async function createWallet({
|
|
33
|
+
dataStore,
|
|
34
|
+
}: CreateWalletProps): Promise<IWallet> {
|
|
53
35
|
let status;
|
|
54
36
|
|
|
55
37
|
const eventEmitter = new EventEmitter();
|
|
@@ -68,9 +50,7 @@ export async function createWallet(
|
|
|
68
50
|
});
|
|
69
51
|
},
|
|
70
52
|
deleteWallet: async () => {
|
|
71
|
-
await removeAllDocuments(
|
|
72
|
-
dataStore,
|
|
73
|
-
});
|
|
53
|
+
await dataStore.documents.removeAllDocuments();
|
|
74
54
|
|
|
75
55
|
eventEmitter.emit(WalletEvents.walletDeleted);
|
|
76
56
|
},
|
|
@@ -84,41 +64,18 @@ export async function createWallet(
|
|
|
84
64
|
getNetworkId: () => {
|
|
85
65
|
return dataStore.networkId;
|
|
86
66
|
},
|
|
87
|
-
getDocumentById: id =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
getAllDocuments: () => {
|
|
94
|
-
return getAllDocuments({
|
|
95
|
-
dataStore,
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
getDocumentsById: idList =>
|
|
99
|
-
getDocumentsById({
|
|
100
|
-
dataStore,
|
|
101
|
-
idList,
|
|
102
|
-
}),
|
|
103
|
-
getDocumentsByType: type =>
|
|
104
|
-
getDocumentsByType({
|
|
105
|
-
dataStore,
|
|
106
|
-
type,
|
|
107
|
-
}),
|
|
67
|
+
getDocumentById: (id) => dataStore.documents.getDocumentById(id),
|
|
68
|
+
getAllDocuments: () => dataStore.documents.getAllDocuments(),
|
|
69
|
+
getDocumentsById: (idList) => dataStore.documents.getDocumentsById(idList),
|
|
70
|
+
getDocumentsByType: (type) => dataStore.documents.getDocumentsByType(type),
|
|
108
71
|
addDocument: (json: any) => {
|
|
109
|
-
return
|
|
110
|
-
dataStore,
|
|
111
|
-
json,
|
|
112
|
-
}).then(result => {
|
|
72
|
+
return dataStore.documents.addDocument(json).then(result => {
|
|
113
73
|
eventEmitter.emit(WalletEvents.documentAdded, result);
|
|
114
74
|
return result;
|
|
115
75
|
});
|
|
116
76
|
},
|
|
117
77
|
updateDocument: (document: any) => {
|
|
118
|
-
return updateDocument({
|
|
119
|
-
dataStore,
|
|
120
|
-
document,
|
|
121
|
-
}).then(result => {
|
|
78
|
+
return dataStore.documents.updateDocument(document).then(result => {
|
|
122
79
|
eventEmitter.emit(WalletEvents.documentUpdated, result);
|
|
123
80
|
return result;
|
|
124
81
|
});
|
|
@@ -126,25 +83,16 @@ export async function createWallet(
|
|
|
126
83
|
removeDocument: async (id: string) => {
|
|
127
84
|
const document = await wallet.getDocumentById(id);
|
|
128
85
|
|
|
129
|
-
return removeDocument({
|
|
130
|
-
dataStore,
|
|
131
|
-
id,
|
|
132
|
-
}).then(result => {
|
|
86
|
+
return dataStore.documents.removeDocument(id).then(result => {
|
|
133
87
|
eventEmitter.emit(WalletEvents.documentRemoved, document);
|
|
134
88
|
return result;
|
|
135
89
|
});
|
|
136
90
|
},
|
|
137
91
|
getDocumentCorrelations: (documentId: string) => {
|
|
138
|
-
return getDocumentCorrelations(
|
|
139
|
-
dataStore,
|
|
140
|
-
documentId,
|
|
141
|
-
});
|
|
92
|
+
return dataStore.documents.getDocumentCorrelations(documentId);
|
|
142
93
|
},
|
|
143
94
|
getAccountKeyPair: async (accountId: string) => {
|
|
144
|
-
const correlations = await getDocumentCorrelations(
|
|
145
|
-
dataStore,
|
|
146
|
-
documentId: accountId,
|
|
147
|
-
});
|
|
95
|
+
const correlations = await dataStore.documents.getDocumentCorrelations(accountId);
|
|
148
96
|
|
|
149
97
|
const keyPair = correlations.find(
|
|
150
98
|
correlation => correlation.type === 'KeyringPair',
|
|
@@ -179,10 +127,7 @@ export async function createWallet(
|
|
|
179
127
|
});
|
|
180
128
|
},
|
|
181
129
|
exportUniversalWalletJSON: async (password: string) => {
|
|
182
|
-
let documents = await getAllDocuments(
|
|
183
|
-
dataStore,
|
|
184
|
-
allNetworks: true,
|
|
185
|
-
});
|
|
130
|
+
let documents = await dataStore.documents.getAllDocuments(true);
|
|
186
131
|
|
|
187
132
|
const result = await wallet.exportDocuments({
|
|
188
133
|
documents,
|
|
@@ -201,11 +146,13 @@ export async function createWallet(
|
|
|
201
146
|
wallet: v1Wallet,
|
|
202
147
|
});
|
|
203
148
|
|
|
204
|
-
[WalletEvents.networkUpdated, WalletEvents.walletDeleted].forEach(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
149
|
+
[WalletEvents.networkUpdated, WalletEvents.walletDeleted].forEach(event =>
|
|
150
|
+
eventEmitter.on(event, () => {
|
|
151
|
+
ensureDID({
|
|
152
|
+
wallet: v1Wallet,
|
|
153
|
+
});
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
209
156
|
|
|
210
157
|
return v1Wallet;
|
|
211
158
|
}
|