@docknetwork/wallet-sdk-core 0.4.19

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 (97) hide show
  1. package/LICENSE +39 -0
  2. package/babel.config.js +16 -0
  3. package/jest.config.ts +39 -0
  4. package/lib/account-provider.d.ts +8 -0
  5. package/lib/account-provider.d.ts.map +1 -0
  6. package/lib/account-provider.js +15 -0
  7. package/lib/account-provider.js.map +1 -0
  8. package/lib/biometric-provider.d.ts +29 -0
  9. package/lib/biometric-provider.d.ts.map +1 -0
  10. package/lib/biometric-provider.js +54 -0
  11. package/lib/biometric-provider.js.map +1 -0
  12. package/lib/credential-provider.d.ts +58 -0
  13. package/lib/credential-provider.d.ts.map +1 -0
  14. package/lib/credential-provider.js +198 -0
  15. package/lib/credential-provider.js.map +1 -0
  16. package/lib/did-provider.d.ts +79 -0
  17. package/lib/did-provider.d.ts.map +1 -0
  18. package/lib/did-provider.js +215 -0
  19. package/lib/did-provider.js.map +1 -0
  20. package/lib/ecosystem-tools.d.ts +11 -0
  21. package/lib/ecosystem-tools.d.ts.map +1 -0
  22. package/lib/ecosystem-tools.js +33 -0
  23. package/lib/ecosystem-tools.js.map +1 -0
  24. package/lib/helpers.d.ts +8 -0
  25. package/lib/helpers.d.ts.map +1 -0
  26. package/lib/helpers.js +63 -0
  27. package/lib/helpers.js.map +1 -0
  28. package/lib/message-provider.d.ts +36 -0
  29. package/lib/message-provider.d.ts.map +1 -0
  30. package/lib/message-provider.js +172 -0
  31. package/lib/message-provider.js.map +1 -0
  32. package/lib/messages/message-helpers.d.ts +110 -0
  33. package/lib/messages/message-helpers.d.ts.map +1 -0
  34. package/lib/messages/message-helpers.js +106 -0
  35. package/lib/messages/message-helpers.js.map +1 -0
  36. package/lib/network-resolver.d.ts +19 -0
  37. package/lib/network-resolver.d.ts.map +1 -0
  38. package/lib/network-resolver.js +80 -0
  39. package/lib/network-resolver.js.map +1 -0
  40. package/lib/types.d.ts +63 -0
  41. package/lib/types.d.ts.map +1 -0
  42. package/lib/types.js +3 -0
  43. package/lib/types.js.map +1 -0
  44. package/lib/v1-helpers.d.ts +20 -0
  45. package/lib/v1-helpers.d.ts.map +1 -0
  46. package/lib/v1-helpers.js +147 -0
  47. package/lib/v1-helpers.js.map +1 -0
  48. package/lib/verification-controller.d.ts +48 -0
  49. package/lib/verification-controller.d.ts.map +1 -0
  50. package/lib/verification-controller.js +219 -0
  51. package/lib/verification-controller.js.map +1 -0
  52. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts +20 -0
  53. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.d.ts.map +1 -0
  54. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js +140 -0
  55. package/lib/wallet-to-wallet-verification/walletToWalletVerificationProvider.js.map +1 -0
  56. package/lib/wallet-wasm.d.ts +10 -0
  57. package/lib/wallet-wasm.d.ts.map +1 -0
  58. package/lib/wallet-wasm.js +62 -0
  59. package/lib/wallet-wasm.js.map +1 -0
  60. package/lib/wallet.d.ts +11 -0
  61. package/lib/wallet.d.ts.map +1 -0
  62. package/lib/wallet.js +173 -0
  63. package/lib/wallet.js.map +1 -0
  64. package/package.json +34 -0
  65. package/setup-tests.ts +1 -0
  66. package/src/account-provider.ts +18 -0
  67. package/src/biometric-provider.ts +82 -0
  68. package/src/credential-provider.test.ts +164 -0
  69. package/src/credential-provider.ts +272 -0
  70. package/src/did-provider.test.ts +203 -0
  71. package/src/did-provider.ts +263 -0
  72. package/src/ecosystem-tools.ts +37 -0
  73. package/src/fixtures/any-credential-proof-request.json +30 -0
  74. package/src/fixtures/biometrics-credential-bbs-revocation.json +62 -0
  75. package/src/fixtures/customer-credential.json +39 -0
  76. package/src/fixtures/iiw-credential.json +59 -0
  77. package/src/fixtures/iiw-template.json +33 -0
  78. package/src/fixtures/university-degree-bbs.json +57 -0
  79. package/src/fixtures/university-degree-proof-request.json +32 -0
  80. package/src/helpers.ts +61 -0
  81. package/src/message-provider.test.ts +115 -0
  82. package/src/message-provider.ts +221 -0
  83. package/src/messages/message-helpers.ts +125 -0
  84. package/src/messages/relay-service-mocks/demo-app-messages.json +450 -0
  85. package/src/network-resolver.test.ts +142 -0
  86. package/src/network-resolver.ts +122 -0
  87. package/src/types.ts +75 -0
  88. package/src/v1-helpers.ts +160 -0
  89. package/src/verification-controller.test.ts +149 -0
  90. package/src/verification-controller.ts +276 -0
  91. package/src/wallet-to-wallet-verification/walletToWalletVerificationProvider.ts +216 -0
  92. package/src/wallet-wasm.ts +74 -0
  93. package/src/wallet.test.ts +72 -0
  94. package/src/wallet.ts +211 -0
  95. package/tsconfig.build.json +26 -0
  96. package/tsconfig.build.tsbuildinfo +1 -0
  97. package/tsconfig.json +30 -0
@@ -0,0 +1,450 @@
1
+ [
2
+ {
3
+ "_id": "64bfbb4ba1cc2185f375ac5e",
4
+ "to": ["did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso"],
5
+ "from": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB",
6
+ "msg": {
7
+ "domain": "api.dock.io",
8
+ "credentials": [
9
+ {
10
+ "@context": [
11
+ "https://www.w3.org/2018/credentials/v1",
12
+ {
13
+ "dk": "https://ld.dock.io/credentials#",
14
+ "ProofOfAddress": "dk:ProofOfAddress",
15
+ "address": "dk:address",
16
+ "name": "dk:name",
17
+ "description": "dk:description",
18
+ "logo": "dk:logo"
19
+ }
20
+ ],
21
+ "id": "https://creds-testnet.dock.io/88aa22a8fbbff4c1197804180e4798397962c61a7cb352bbcad6a0c3de4d57e6",
22
+ "type": ["VerifiableCredential", "ProofOfAddress"],
23
+ "credentialSubject": {
24
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
25
+ "address": "123 Main St"
26
+ },
27
+ "issuanceDate": "2021-01-01T14:15:22Z",
28
+ "issuer": {
29
+ "name": "Test123",
30
+ "description": "",
31
+ "logo": "",
32
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
33
+ },
34
+ "name": "Proof of Address",
35
+ "proof": {
36
+ "type": "Ed25519Signature2018",
37
+ "created": "2023-07-25T12:08:42Z",
38
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
39
+ "proofPurpose": "assertionMethod",
40
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..tx5EhtRNwo-JdZTRZKfwCs1Q0C2X_nzVOStaGEJkJL7TJN5FFwe3kOEi89fi93HJY8G2I3NWnRjBIkvsYWOwDg"
41
+ }
42
+ }
43
+ ]
44
+ },
45
+ "id": "ff8f2ca0-2ae3-11ee-aaa6-99ebf3bb7975",
46
+ "type": "https://didcomm.org/issue-credential/2.0/issue-credential",
47
+ "created_time": 1690286922,
48
+ "body": {
49
+ "domain": "api.dock.io",
50
+ "credentials": [
51
+ {
52
+ "@context": [
53
+ "https://www.w3.org/2018/credentials/v1",
54
+ {
55
+ "dk": "https://ld.dock.io/credentials#",
56
+ "ProofOfAddress": "dk:ProofOfAddress",
57
+ "address": "dk:address",
58
+ "name": "dk:name",
59
+ "description": "dk:description",
60
+ "logo": "dk:logo"
61
+ }
62
+ ],
63
+ "id": "https://creds-testnet.dock.io/88aa22a8fbbff4c1197804180e4798397962c61a7cb352bbcad6a0c3de4d57e6",
64
+ "type": ["VerifiableCredential", "ProofOfAddress"],
65
+ "credentialSubject": {
66
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
67
+ "address": "123 Main St"
68
+ },
69
+ "issuanceDate": "2021-01-01T14:15:22Z",
70
+ "issuer": {
71
+ "name": "Test123",
72
+ "description": "",
73
+ "logo": "",
74
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
75
+ },
76
+ "name": "Proof of Address",
77
+ "proof": {
78
+ "type": "Ed25519Signature2018",
79
+ "created": "2023-07-25T12:08:42Z",
80
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
81
+ "proofPurpose": "assertionMethod",
82
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..tx5EhtRNwo-JdZTRZKfwCs1Q0C2X_nzVOStaGEJkJL7TJN5FFwe3kOEi89fi93HJY8G2I3NWnRjBIkvsYWOwDg"
83
+ }
84
+ }
85
+ ]
86
+ }
87
+ },
88
+ {
89
+ "_id": "64bfbb4b04f520307c03afba",
90
+ "to": ["did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso"],
91
+ "from": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB",
92
+ "msg": {
93
+ "domain": "api.dock.io",
94
+ "credentials": [
95
+ {
96
+ "@context": [
97
+ "https://www.w3.org/2018/credentials/v1",
98
+ {
99
+ "dk": "https://ld.dock.io/credentials#",
100
+ "BankAccountDetails": "dk:BankAccountDetails",
101
+ "checkingAccount": "dk:checkingAccount",
102
+ "routingNumber": "dk:routingNumber",
103
+ "name": "dk:name",
104
+ "description": "dk:description",
105
+ "logo": "dk:logo"
106
+ }
107
+ ],
108
+ "id": "https://creds-testnet.dock.io/025c84d76f8400572530a008e3ee401cfb820246bc1f87dc11639a879fcd125b",
109
+ "type": ["VerifiableCredential", "BankAccountDetails"],
110
+ "credentialSubject": {
111
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
112
+ "checkingAccount": "**1234",
113
+ "routingNumber": "123456789"
114
+ },
115
+ "issuanceDate": "2023-07-25T12:08:42.833Z",
116
+ "issuer": {
117
+ "name": "Test123",
118
+ "description": "",
119
+ "logo": "",
120
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
121
+ },
122
+ "name": "Bank Account Details",
123
+ "proof": {
124
+ "type": "Ed25519Signature2018",
125
+ "created": "2023-07-25T12:08:42Z",
126
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
127
+ "proofPurpose": "assertionMethod",
128
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..Ytv-4agLoWHdzLPZaPwrAyb5_TrSKt8RDt10vbbRGtX88p4Eosjs3Uvh9RtPUQPZv5pT25YIMimETAoDBMQhCw"
129
+ }
130
+ }
131
+ ]
132
+ },
133
+ "id": "ff901700-2ae3-11ee-aaa6-99ebf3bb7975",
134
+ "type": "https://didcomm.org/issue-credential/2.0/issue-credential",
135
+ "created_time": 1690286922,
136
+ "body": {
137
+ "domain": "api.dock.io",
138
+ "credentials": [
139
+ {
140
+ "@context": [
141
+ "https://www.w3.org/2018/credentials/v1",
142
+ {
143
+ "dk": "https://ld.dock.io/credentials#",
144
+ "BankAccountDetails": "dk:BankAccountDetails",
145
+ "checkingAccount": "dk:checkingAccount",
146
+ "routingNumber": "dk:routingNumber",
147
+ "name": "dk:name",
148
+ "description": "dk:description",
149
+ "logo": "dk:logo"
150
+ }
151
+ ],
152
+ "id": "https://creds-testnet.dock.io/025c84d76f8400572530a008e3ee401cfb820246bc1f87dc11639a879fcd125b",
153
+ "type": ["VerifiableCredential", "BankAccountDetails"],
154
+ "credentialSubject": {
155
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
156
+ "checkingAccount": "**1234",
157
+ "routingNumber": "123456789"
158
+ },
159
+ "issuanceDate": "2023-07-25T12:08:42.833Z",
160
+ "issuer": {
161
+ "name": "Test123",
162
+ "description": "",
163
+ "logo": "",
164
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
165
+ },
166
+ "name": "Bank Account Details",
167
+ "proof": {
168
+ "type": "Ed25519Signature2018",
169
+ "created": "2023-07-25T12:08:42Z",
170
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
171
+ "proofPurpose": "assertionMethod",
172
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..Ytv-4agLoWHdzLPZaPwrAyb5_TrSKt8RDt10vbbRGtX88p4Eosjs3Uvh9RtPUQPZv5pT25YIMimETAoDBMQhCw"
173
+ }
174
+ }
175
+ ]
176
+ }
177
+ },
178
+ {
179
+ "_id": "64bfbb4bce66d2aeed5795bf",
180
+ "to": ["did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso"],
181
+ "from": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB",
182
+ "msg": {
183
+ "domain": "api.dock.io",
184
+ "credentials": [
185
+ {
186
+ "@context": [
187
+ "https://www.w3.org/2018/credentials/v1",
188
+ {
189
+ "dk": "https://ld.dock.io/credentials#",
190
+ "CustomerCredential": "dk:CustomerCredential",
191
+ "name": "dk:name",
192
+ "email": "dk:email",
193
+ "dateOfBirth": "dk:dateOfBirth",
194
+ "phone": "dk:phone",
195
+ "description": "dk:description",
196
+ "logo": "dk:logo"
197
+ }
198
+ ],
199
+ "id": "https://creds-testnet.dock.io/bb4f0b52167cb33ae1c418b4961c0db830e99f0d38add5ac8f2a8570cb15a667",
200
+ "type": ["VerifiableCredential", "CustomerCredential"],
201
+ "credentialSubject": {
202
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
203
+ "name": "Alice Doe",
204
+ "email": "alice@dock.io",
205
+ "dateOfBirth": "1990-01-01",
206
+ "phone": "555-555-5555"
207
+ },
208
+ "issuanceDate": "2023-07-25T12:08:42.836Z",
209
+ "issuer": {
210
+ "name": "Test123",
211
+ "description": "",
212
+ "logo": "",
213
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
214
+ },
215
+ "name": "Customer Credential",
216
+ "proof": {
217
+ "type": "Ed25519Signature2018",
218
+ "created": "2023-07-25T12:08:42Z",
219
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
220
+ "proofPurpose": "assertionMethod",
221
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..NJZg4TpLM75op2aA__jwLivKF1y377hybbAh9p10Ubxrz5jr-oD6IUrkd1rO4guk_Vi4RKk4umNTwPzAJ1OkAA"
222
+ }
223
+ }
224
+ ]
225
+ },
226
+ "id": "ff9212d0-2ae3-11ee-864e-fb65d9c37c90",
227
+ "type": "https://didcomm.org/issue-credential/2.0/issue-credential",
228
+ "created_time": 1690286922,
229
+ "body": {
230
+ "domain": "api.dock.io",
231
+ "credentials": [
232
+ {
233
+ "@context": [
234
+ "https://www.w3.org/2018/credentials/v1",
235
+ {
236
+ "dk": "https://ld.dock.io/credentials#",
237
+ "CustomerCredential": "dk:CustomerCredential",
238
+ "name": "dk:name",
239
+ "email": "dk:email",
240
+ "dateOfBirth": "dk:dateOfBirth",
241
+ "phone": "dk:phone",
242
+ "description": "dk:description",
243
+ "logo": "dk:logo"
244
+ }
245
+ ],
246
+ "id": "https://creds-testnet.dock.io/bb4f0b52167cb33ae1c418b4961c0db830e99f0d38add5ac8f2a8570cb15a667",
247
+ "type": ["VerifiableCredential", "CustomerCredential"],
248
+ "credentialSubject": {
249
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
250
+ "name": "Alice Doe",
251
+ "email": "alice@dock.io",
252
+ "dateOfBirth": "1990-01-01",
253
+ "phone": "555-555-5555"
254
+ },
255
+ "issuanceDate": "2023-07-25T12:08:42.836Z",
256
+ "issuer": {
257
+ "name": "Test123",
258
+ "description": "",
259
+ "logo": "",
260
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
261
+ },
262
+ "name": "Customer Credential",
263
+ "proof": {
264
+ "type": "Ed25519Signature2018",
265
+ "created": "2023-07-25T12:08:42Z",
266
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
267
+ "proofPurpose": "assertionMethod",
268
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..NJZg4TpLM75op2aA__jwLivKF1y377hybbAh9p10Ubxrz5jr-oD6IUrkd1rO4guk_Vi4RKk4umNTwPzAJ1OkAA"
269
+ }
270
+ }
271
+ ]
272
+ }
273
+ },
274
+ {
275
+ "_id": "64bfbb4bf6879647579d2b11",
276
+ "to": ["did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso"],
277
+ "from": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB",
278
+ "msg": {
279
+ "domain": "api.dock.io",
280
+ "credentials": [
281
+ {
282
+ "@context": [
283
+ "https://www.w3.org/2018/credentials/v1",
284
+ {
285
+ "dk": "https://ld.dock.io/credentials#",
286
+ "KYCCredential": "dk:KYCCredential",
287
+ "verifiedBy": "dk:verifiedBy",
288
+ "name": "dk:name",
289
+ "description": "dk:description",
290
+ "logo": "dk:logo"
291
+ }
292
+ ],
293
+ "id": "https://creds-testnet.dock.io/dea6ad7ab60c42d821a9b0ba5e8168df385e133cf23dfec29fc69de3df50baf8",
294
+ "type": ["VerifiableCredential", "KYCCredential"],
295
+ "credentialSubject": {
296
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
297
+ "verifiedBy": "IDV Provider"
298
+ },
299
+ "issuanceDate": "2023-01-01T14:15:22Z",
300
+ "issuer": {
301
+ "name": "Test123",
302
+ "description": "",
303
+ "logo": "",
304
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
305
+ },
306
+ "name": "KYC Credentials",
307
+ "proof": {
308
+ "type": "Ed25519Signature2018",
309
+ "created": "2023-07-25T12:08:42Z",
310
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
311
+ "proofPurpose": "assertionMethod",
312
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..IdV0-aqRJfBZEinFcapoTax6ULI54r1roBgBDB1Y_RAwPKrUuBRlGQCEQJ6JaScmHo6zVOlD7q4rEC3nMy0_Cg"
313
+ }
314
+ }
315
+ ]
316
+ },
317
+ "id": "ff910160-2ae3-11ee-864e-fb65d9c37c90",
318
+ "type": "https://didcomm.org/issue-credential/2.0/issue-credential",
319
+ "created_time": 1690286922,
320
+ "body": {
321
+ "domain": "api.dock.io",
322
+ "credentials": [
323
+ {
324
+ "@context": [
325
+ "https://www.w3.org/2018/credentials/v1",
326
+ {
327
+ "dk": "https://ld.dock.io/credentials#",
328
+ "KYCCredential": "dk:KYCCredential",
329
+ "verifiedBy": "dk:verifiedBy",
330
+ "name": "dk:name",
331
+ "description": "dk:description",
332
+ "logo": "dk:logo"
333
+ }
334
+ ],
335
+ "id": "https://creds-testnet.dock.io/dea6ad7ab60c42d821a9b0ba5e8168df385e133cf23dfec29fc69de3df50baf8",
336
+ "type": ["VerifiableCredential", "KYCCredential"],
337
+ "credentialSubject": {
338
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
339
+ "verifiedBy": "IDV Provider"
340
+ },
341
+ "issuanceDate": "2023-01-01T14:15:22Z",
342
+ "issuer": {
343
+ "name": "Test123",
344
+ "description": "",
345
+ "logo": "",
346
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
347
+ },
348
+ "name": "KYC Credentials",
349
+ "proof": {
350
+ "type": "Ed25519Signature2018",
351
+ "created": "2023-07-25T12:08:42Z",
352
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
353
+ "proofPurpose": "assertionMethod",
354
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..IdV0-aqRJfBZEinFcapoTax6ULI54r1roBgBDB1Y_RAwPKrUuBRlGQCEQJ6JaScmHo6zVOlD7q4rEC3nMy0_Cg"
355
+ }
356
+ }
357
+ ]
358
+ }
359
+ },
360
+ {
361
+ "_id": "64bfbb4b61fe4c5a231e39a8",
362
+ "to": ["did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso"],
363
+ "from": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB",
364
+ "msg": {
365
+ "domain": "api.dock.io",
366
+ "credentials": [
367
+ {
368
+ "@context": [
369
+ "https://www.w3.org/2018/credentials/v1",
370
+ {
371
+ "dk": "https://ld.dock.io/credentials#",
372
+ "RewardsProgram": "dk:RewardsProgram",
373
+ "eligibility": "dk:eligibility",
374
+ "rewardId": "dk:rewardId",
375
+ "name": "dk:name",
376
+ "description": "dk:description",
377
+ "logo": "dk:logo"
378
+ }
379
+ ],
380
+ "id": "https://creds-testnet.dock.io/442e270b052f5c4d8e7db4d116193e4e2cd367c94445abe9497b6a33cd8b7742",
381
+ "type": ["VerifiableCredential", "RewardsProgram"],
382
+ "credentialSubject": {
383
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
384
+ "eligibility": true,
385
+ "rewardId": "123123123"
386
+ },
387
+ "issuanceDate": "2023-07-25T12:08:42.895Z",
388
+ "issuer": {
389
+ "name": "Test123",
390
+ "description": "",
391
+ "logo": "",
392
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
393
+ },
394
+ "name": "Rewards Program",
395
+ "proof": {
396
+ "type": "Ed25519Signature2018",
397
+ "created": "2023-07-25T12:08:42Z",
398
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
399
+ "proofPurpose": "assertionMethod",
400
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..y9JNA1nx7lPcdEPessW2MIuLKMmsqGGYvRs5tINIinun6fFaz5UgrmvKi56SLRDQrNNna2uthMtXOi-FPW3YCw"
401
+ }
402
+ }
403
+ ]
404
+ },
405
+ "id": "ff9917b0-2ae3-11ee-864e-fb65d9c37c90",
406
+ "type": "https://didcomm.org/issue-credential/2.0/issue-credential",
407
+ "created_time": 1690286922,
408
+ "body": {
409
+ "domain": "api.dock.io",
410
+ "credentials": [
411
+ {
412
+ "@context": [
413
+ "https://www.w3.org/2018/credentials/v1",
414
+ {
415
+ "dk": "https://ld.dock.io/credentials#",
416
+ "RewardsProgram": "dk:RewardsProgram",
417
+ "eligibility": "dk:eligibility",
418
+ "rewardId": "dk:rewardId",
419
+ "name": "dk:name",
420
+ "description": "dk:description",
421
+ "logo": "dk:logo"
422
+ }
423
+ ],
424
+ "id": "https://creds-testnet.dock.io/442e270b052f5c4d8e7db4d116193e4e2cd367c94445abe9497b6a33cd8b7742",
425
+ "type": ["VerifiableCredential", "RewardsProgram"],
426
+ "credentialSubject": {
427
+ "id": "did:key:z6MkrPYjMKYwULkGYMJvarQGdFKM3gsLKWjX6uw47i8R3Yso",
428
+ "eligibility": true,
429
+ "rewardId": "123123123"
430
+ },
431
+ "issuanceDate": "2023-07-25T12:08:42.895Z",
432
+ "issuer": {
433
+ "name": "Test123",
434
+ "description": "",
435
+ "logo": "",
436
+ "id": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB"
437
+ },
438
+ "name": "Rewards Program",
439
+ "proof": {
440
+ "type": "Ed25519Signature2018",
441
+ "created": "2023-07-25T12:08:42Z",
442
+ "verificationMethod": "did:dock:5CgR1iELH33Qm8CN7LLXiEdTnrPTFKHgdxZgTuDwxgiyokjB#keys-1",
443
+ "proofPurpose": "assertionMethod",
444
+ "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..y9JNA1nx7lPcdEPessW2MIuLKMmsqGGYvRs5tINIinun6fFaz5UgrmvKi56SLRDQrNNna2uthMtXOi-FPW3YCw"
445
+ }
446
+ }
447
+ ]
448
+ }
449
+ }
450
+ ]
@@ -0,0 +1,142 @@
1
+ import {createWallet, IWallet} from './wallet';
2
+ import {
3
+ accountResolver,
4
+ credentialResolver,
5
+ dockDocumentNetworkResolver,
6
+ resolveApiNetwork,
7
+ } from './network-resolver';
8
+
9
+ describe('Wallet', () => {
10
+ let wallet: IWallet;
11
+
12
+ beforeEach(async () => {
13
+ wallet = await createWallet({
14
+ databasePath: ':memory:',
15
+ documentNetworkResolver: dockDocumentNetworkResolver,
16
+ });
17
+ });
18
+
19
+ it('resolveApiNetwork', () => {
20
+ expect(
21
+ resolveApiNetwork({
22
+ url: 'https://creds-staging.dock.io/proof/0bb39274-4ef1-4e7f-ab8d-d91d8926d9af',
23
+ dataStore: wallet.dataStore,
24
+ }),
25
+ ).toBe('testnet');
26
+
27
+ expect(
28
+ resolveApiNetwork({
29
+ url: 'https://creds.dock.io/proof/0bb39274-4ef1-4e7f-ab8d-d91d8926d9af',
30
+ dataStore: wallet.dataStore,
31
+ }),
32
+ ).toBe('mainnet');
33
+ });
34
+
35
+ it('expect to add document to mainnet', async () => {
36
+ const mockDocument = {
37
+ id: 'test',
38
+ type: 'VerifiableCredential',
39
+ };
40
+
41
+ await wallet.addDocument(mockDocument);
42
+
43
+ const [result] = await wallet.getDocumentsByType(mockDocument.type);
44
+ expect(result.id).toEqual(mockDocument.id);
45
+ });
46
+
47
+ it('expect to add document to testnet', async () => {
48
+ const mockDocument = {
49
+ id: 'test',
50
+ type: 'VerifiableCredential',
51
+ };
52
+
53
+ wallet.setNetwork('testnet');
54
+
55
+ await wallet.addDocument(mockDocument);
56
+
57
+ const [result] = await wallet.getDocumentsByType(mockDocument.type);
58
+ expect(result.id).toEqual(mockDocument.id);
59
+
60
+ wallet.setNetwork('mainnet');
61
+
62
+ const [result2] = await wallet.getDocumentsByType(mockDocument.type);
63
+ expect(result2).toBeUndefined();
64
+ });
65
+
66
+ it('expect to allow adding using the same document id in different networks', async () => {
67
+ const mockDocument = {
68
+ id: 'test',
69
+ type: 'VerifiableCredential',
70
+ };
71
+
72
+ wallet.setNetwork('mainnet');
73
+
74
+ await wallet.addDocument(mockDocument);
75
+
76
+ let [result] = await wallet.getDocumentsByType(mockDocument.type);
77
+ expect(result.id).toEqual(mockDocument.id);
78
+
79
+ wallet.setNetwork('testnet');
80
+
81
+ await wallet.addDocument(mockDocument);
82
+ });
83
+
84
+ it('expect to filter documents by network', async () => {
85
+ const mockDocument = {
86
+ id: 'test',
87
+ type: 'VerifiableCredential',
88
+ };
89
+
90
+ wallet.setNetwork('mainnet');
91
+
92
+ await wallet.addDocument(mockDocument);
93
+
94
+ let [result] = await wallet.getDocumentsByType(mockDocument.type);
95
+ expect(result.id).toEqual(mockDocument.id);
96
+
97
+ wallet.setNetwork('testnet');
98
+
99
+ [result] = await wallet.getDocumentsByType(mockDocument.type);
100
+ expect(result).toBeUndefined();
101
+ });
102
+
103
+ describe('credentialResolver', () => {
104
+ it('expect to resolve credential to testnet', async () => {
105
+ const result = await credentialResolver({
106
+ document: {
107
+ id: 'https://creds-staging.dock.io/d39b15fe997004db702c9faaf98f9fd619cdf40088549648fb288ea679b53e23?_ga=2.46968743.1402343540.1684360698-1482908456.1677577177',
108
+ type: ['VerifiableCredential'],
109
+ },
110
+ dataStore: wallet.dataStore,
111
+ });
112
+
113
+ expect(result).toBe('testnet');
114
+ });
115
+ });
116
+
117
+ describe('accountResolver', () => {
118
+ it('expect to resolve account to testnet', async () => {
119
+ const result = await accountResolver({
120
+ document: {
121
+ id: '37PsGbLmrTfV6VVknkrh6LKACXuC9LuSCwuxhk6ajGDjNCwc',
122
+ type: 'Address',
123
+ },
124
+ dataStore: wallet.dataStore,
125
+ });
126
+
127
+ expect(result).toBe('testnet');
128
+ });
129
+
130
+ it('expect to resolve account to mainnet', async () => {
131
+ const result = await accountResolver({
132
+ document: {
133
+ id: '3EGurYbWGtyVfouDTZjxz1t2jiV3voU9N6sSDAvhHyxaqf8L',
134
+ type: 'Address',
135
+ },
136
+ dataStore: wallet.dataStore,
137
+ });
138
+
139
+ expect(result).toBe('mainnet');
140
+ });
141
+ });
142
+ });