@credebl/ssi-mobile-core 2.0.3-alpha-20260410105148 → 2.1.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/README.md +441 -122
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,194 +1,513 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @credebl/ssi-mobile-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Core package for the CREDEBL Mobile SDK. Handles wallet initialization, DID operations, credential storage, key management, and React context integration.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See the [root README](../../README.md) for prerequisites and project-level setup.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Type Safety**: Full TypeScript support with proper typing
|
|
9
|
-
- **State Management**: Built-in state management for SDK initialization
|
|
10
|
-
- **React Integration**: Follows React best practices and patterns
|
|
7
|
+
---
|
|
11
8
|
|
|
12
9
|
## Installation
|
|
13
10
|
|
|
14
11
|
```bash
|
|
15
|
-
npm install @credebl/mobile-
|
|
12
|
+
npm install @credebl/ssi-mobile-core @openwallet-foundation/askar-react-native
|
|
16
13
|
# or
|
|
17
|
-
yarn add @credebl/mobile-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
yarn add @credebl/ssi-mobile-core @openwallet-foundation/askar-react-native
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**iOS:**
|
|
18
|
+
```bash
|
|
19
|
+
cd ios && pod install
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
**Android** — ensure `minSdkVersion` >= 24 in `android/app/build.gradle`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## API Reference
|
|
27
|
+
|
|
28
|
+
### Setup
|
|
29
|
+
|
|
30
|
+
#### `MobileSDKProvider`
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
Wrap your entire app with this provider. Every hook in this package must be used inside it.
|
|
25
33
|
|
|
26
34
|
```tsx
|
|
27
|
-
import {
|
|
35
|
+
import { MobileSDKProvider } from '@credebl/ssi-mobile-core'
|
|
28
36
|
|
|
29
|
-
function App() {
|
|
37
|
+
export default function App() {
|
|
30
38
|
return (
|
|
31
|
-
<
|
|
32
|
-
{/*
|
|
33
|
-
</
|
|
34
|
-
)
|
|
39
|
+
<MobileSDKProvider>
|
|
40
|
+
{/* your app */}
|
|
41
|
+
</MobileSDKProvider>
|
|
42
|
+
)
|
|
35
43
|
}
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
#### `useMobileSDKInitializer()`
|
|
49
|
+
|
|
50
|
+
Initializes the SDK. Call this once on app startup, inside `MobileSDKProvider`.
|
|
39
51
|
|
|
40
52
|
```tsx
|
|
41
|
-
import {
|
|
53
|
+
import { useEffect } from 'react'
|
|
54
|
+
import { useMobileSDKInitializer, ConsoleLogger, LogLevel } from '@credebl/ssi-mobile-core'
|
|
42
55
|
|
|
43
56
|
function AppInitializer() {
|
|
44
|
-
const { initializeSDK, isInitialized } =
|
|
57
|
+
const { initializeSDK, isInitialized } = useMobileSDKInitializer()
|
|
45
58
|
|
|
46
59
|
useEffect(() => {
|
|
47
60
|
if (!isInitialized) {
|
|
48
|
-
initializeSDK(
|
|
61
|
+
initializeSDK({
|
|
62
|
+
agentConfig: {
|
|
63
|
+
label: 'My Wallet',
|
|
64
|
+
logger: new ConsoleLogger(LogLevel.debug),
|
|
65
|
+
},
|
|
66
|
+
askarConfig: {
|
|
67
|
+
id: 'my-wallet-id',
|
|
68
|
+
key: 'my-wallet-key',
|
|
69
|
+
},
|
|
70
|
+
modules: {},
|
|
71
|
+
})
|
|
49
72
|
}
|
|
50
|
-
}, [
|
|
73
|
+
}, [isInitialized])
|
|
51
74
|
|
|
52
|
-
return null
|
|
75
|
+
return null
|
|
53
76
|
}
|
|
54
77
|
```
|
|
55
78
|
|
|
56
|
-
|
|
79
|
+
| Return value | Type | Description |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `initializeSDK` | `(options) => Promise<MobileSDK>` | Call with your config to start the SDK |
|
|
82
|
+
| `isInitialized` | `boolean` | `true` once the SDK is ready |
|
|
83
|
+
| `sdk` | `MobileSDK \| null` | The SDK instance after initialization |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
#### `useMobileSDK()`
|
|
88
|
+
|
|
89
|
+
Access the SDK instance from any component inside `MobileSDKProvider`.
|
|
57
90
|
|
|
58
91
|
```tsx
|
|
59
|
-
import {
|
|
92
|
+
import { useMobileSDK } from '@credebl/ssi-mobile-core'
|
|
60
93
|
|
|
61
|
-
function
|
|
62
|
-
const { sdk, isInitialized } =
|
|
63
|
-
|
|
64
|
-
if (!isInitialized || !sdk)
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const handleAction = () => {
|
|
69
|
-
// Use sdk methods here
|
|
70
|
-
console.log('SDK is ready:', sdk);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return <button onClick={handleAction}>Perform Action</button>;
|
|
94
|
+
function MyComponent() {
|
|
95
|
+
const { sdk, isInitialized } = useMobileSDK()
|
|
96
|
+
|
|
97
|
+
if (!isInitialized || !sdk) return <Text>Loading...</Text>
|
|
98
|
+
|
|
99
|
+
return <Button title="Ready" onPress={() => console.log(sdk)} />
|
|
74
100
|
}
|
|
75
101
|
```
|
|
76
102
|
|
|
77
|
-
|
|
103
|
+
When using extra modules (like DIDComm), pass the module type:
|
|
78
104
|
|
|
79
|
-
|
|
105
|
+
```tsx
|
|
106
|
+
import { DidCommSDK } from '@credebl/ssi-mobile-didcomm'
|
|
107
|
+
|
|
108
|
+
type AppModules = { didcomm: DidCommSDK }
|
|
109
|
+
|
|
110
|
+
const { sdk } = useMobileSDK<AppModules>()
|
|
111
|
+
// sdk.modules.didcomm is now typed correctly
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| Return value | Type | Description |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `sdk` | `MobileSDK<T>` | The initialized SDK instance |
|
|
117
|
+
| `isInitialized` | `boolean` | `true` once the SDK is ready |
|
|
118
|
+
| `initialize` | `(sdk) => void` | Manually set the SDK (advanced use) |
|
|
119
|
+
| `shutdown` | `() => void` | Shut down the SDK |
|
|
80
120
|
|
|
81
|
-
|
|
121
|
+
---
|
|
82
122
|
|
|
83
|
-
|
|
84
|
-
- `children`: React nodes to be wrapped by the provider
|
|
123
|
+
#### `MobileSDK.AppProvider`
|
|
85
124
|
|
|
86
|
-
|
|
125
|
+
Provides the underlying `Agent` to credential and record hooks. Wrap the parts of your app that use credential hooks with this.
|
|
87
126
|
|
|
88
|
-
|
|
127
|
+
```tsx
|
|
128
|
+
import { MobileSDK } from '@credebl/ssi-mobile-core'
|
|
89
129
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
function App() {
|
|
131
|
+
return (
|
|
132
|
+
<MobileSDKProvider>
|
|
133
|
+
<MobileSDK.AppProvider>
|
|
134
|
+
{/* hooks like useW3cCredentialRecords() work here */}
|
|
135
|
+
</MobileSDK.AppProvider>
|
|
136
|
+
</MobileSDKProvider>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
```
|
|
94
140
|
|
|
95
|
-
|
|
141
|
+
---
|
|
96
142
|
|
|
97
|
-
|
|
143
|
+
### DID Operations
|
|
98
144
|
|
|
99
|
-
|
|
100
|
-
- `initializeSDK`: Function to initialize the SDK
|
|
101
|
-
- `isInitialized`: Boolean indicating if the SDK is initialized
|
|
145
|
+
All methods below are called on the `sdk` instance returned by `useMobileSDK()`.
|
|
102
146
|
|
|
103
|
-
|
|
147
|
+
#### `sdk.createDid(options)`
|
|
104
148
|
|
|
105
|
-
|
|
149
|
+
Create a new DID and store it in the wallet.
|
|
106
150
|
|
|
107
151
|
```tsx
|
|
108
|
-
|
|
109
|
-
|
|
152
|
+
// Create a did:key
|
|
153
|
+
const didRecord = await sdk.createDid({ method: 'key' })
|
|
154
|
+
|
|
155
|
+
// Create a did:jwk with a specific key type
|
|
156
|
+
const didRecord = await sdk.createDid({
|
|
157
|
+
method: 'jwk',
|
|
158
|
+
options: { keyType: 'Ed25519' },
|
|
159
|
+
})
|
|
160
|
+
```
|
|
110
161
|
|
|
111
|
-
|
|
112
|
-
function SDKInitializer() {
|
|
113
|
-
const { initializeSDK, isInitialized } = useSDKInitializer();
|
|
162
|
+
---
|
|
114
163
|
|
|
115
|
-
|
|
116
|
-
if (!isInitialized) {
|
|
117
|
-
initializeSDK();
|
|
118
|
-
}
|
|
119
|
-
}, [initializeSDK, isInitialized]);
|
|
164
|
+
#### `sdk.getDids(options?)`
|
|
120
165
|
|
|
121
|
-
|
|
122
|
-
}
|
|
166
|
+
Retrieve DIDs that were created by this wallet.
|
|
123
167
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
168
|
+
```tsx
|
|
169
|
+
// Get all DIDs
|
|
170
|
+
const dids = await sdk.getDids({})
|
|
127
171
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
172
|
+
// Filter by method
|
|
173
|
+
const keyDids = await sdk.getDids({ method: 'key' })
|
|
131
174
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
<p>SDK instance: {sdk.constructor.name}</p>
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
175
|
+
// Look up a specific DID
|
|
176
|
+
const dids = await sdk.getDids({ did: 'did:key:z6Mk...' })
|
|
177
|
+
```
|
|
139
178
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<SDKUser />
|
|
146
|
-
</SDKProvider>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
#### `sdk.resolveDid({ did })`
|
|
182
|
+
|
|
183
|
+
Resolve a DID document — works for any DID, not just ones in the wallet.
|
|
149
184
|
|
|
150
|
-
|
|
185
|
+
```tsx
|
|
186
|
+
const result = await sdk.resolveDid({ did: 'did:key:z6Mk...' })
|
|
187
|
+
console.log(result.didDocument)
|
|
151
188
|
```
|
|
152
189
|
|
|
153
|
-
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
#### `sdk.addTagToDid({ did, tag, tagValue })`
|
|
154
193
|
|
|
155
|
-
|
|
194
|
+
Attach a custom tag to a DID record so you can look it up later.
|
|
156
195
|
|
|
157
196
|
```tsx
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
197
|
+
await sdk.addTagToDid({
|
|
198
|
+
did: 'did:key:z6Mk...',
|
|
199
|
+
tag: 'purpose',
|
|
200
|
+
tagValue: 'authentication',
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
// Later, find it by tag
|
|
204
|
+
const dids = await sdk.getDids({ tag: 'purpose', tagValue: 'authentication' })
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### Credential Storage
|
|
210
|
+
|
|
211
|
+
#### `sdk.deleteCredential({ id, format })`
|
|
212
|
+
|
|
213
|
+
Delete a stored credential by ID and format.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { CredentialRecord } from '@credebl/ssi-mobile-core'
|
|
217
|
+
|
|
218
|
+
await sdk.deleteCredential({
|
|
219
|
+
id: 'credential-id',
|
|
220
|
+
format: CredentialRecord.SdJwt, // or CredentialRecord.Mdoc / CredentialRecord.W3c
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
#### `sdk.storeOpenIdCredential(credential)`
|
|
227
|
+
|
|
228
|
+
Manually store a credential record received via OpenID4VC.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
// credential is a W3cCredentialRecord, SdJwtVcRecord, or MdocRecord
|
|
232
|
+
await sdk.storeOpenIdCredential(credentialRecord)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
#### `sdk.setTagsToCredential({ credId, tags, format? })`
|
|
238
|
+
|
|
239
|
+
Attach custom tags to a credential for later filtering.
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
await sdk.setTagsToCredential({
|
|
243
|
+
credId: 'credential-id',
|
|
244
|
+
tags: { status: 'active', issuer: 'university' },
|
|
245
|
+
})
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
#### `sdk.getCredentialsByTag({ tags, format? })`
|
|
251
|
+
|
|
252
|
+
Query credentials by their custom tags.
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
const creds = await sdk.getCredentialsByTag({
|
|
256
|
+
tags: { status: 'active' },
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
// Filter by format
|
|
260
|
+
const sdJwtCreds = await sdk.getCredentialsByTag({
|
|
261
|
+
tags: { issuer: 'university' },
|
|
262
|
+
format: CredentialRecord.SdJwt,
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### Generic Records
|
|
269
|
+
|
|
270
|
+
Use generic records to store arbitrary structured data in the wallet (e.g. app settings, user preferences, custom metadata).
|
|
271
|
+
|
|
272
|
+
#### `sdk.addGenericRecord({ content, tags?, id? })`
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
const record = await sdk.addGenericRecord({
|
|
276
|
+
content: { theme: 'dark', notifications: true },
|
|
277
|
+
tags: { type: 'settings' },
|
|
278
|
+
})
|
|
279
|
+
console.log(record.id)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
#### `sdk.getGenericRecord(id)`
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
const record = await sdk.getGenericRecord(record.id)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
#### `sdk.findGenericRecordsByQuery(query)`
|
|
293
|
+
|
|
294
|
+
```tsx
|
|
295
|
+
const records = await sdk.findGenericRecordsByQuery({ type: 'settings' })
|
|
165
296
|
```
|
|
166
297
|
|
|
167
|
-
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
#### `sdk.updateGenericRecord(record)`
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
record.content.theme = 'light'
|
|
304
|
+
await sdk.updateGenericRecord(record)
|
|
305
|
+
```
|
|
168
306
|
|
|
169
|
-
|
|
170
|
-
2. **Error Boundaries**: Wrap your app with error boundaries to handle SDK initialization errors
|
|
171
|
-
3. **Loading States**: Always check `isInitialized` before using the SDK
|
|
172
|
-
4. **Type Safety**: Use TypeScript for better development experience and error catching
|
|
307
|
+
---
|
|
173
308
|
|
|
174
|
-
|
|
309
|
+
#### `sdk.deleteGenericRecord(id)`
|
|
175
310
|
|
|
176
|
-
|
|
311
|
+
```tsx
|
|
312
|
+
await sdk.deleteGenericRecord(record.id)
|
|
313
|
+
```
|
|
177
314
|
|
|
178
|
-
|
|
179
|
-
- Ensure your component is wrapped with SDKProvider
|
|
180
|
-
- Check that the provider is imported correctly
|
|
315
|
+
---
|
|
181
316
|
|
|
182
|
-
|
|
183
|
-
- Verify that `initializeSDK()` is being called
|
|
184
|
-
- Check browser console for any errors
|
|
185
|
-
- Ensure all required dependencies are installed
|
|
317
|
+
### Wallet Management
|
|
186
318
|
|
|
187
|
-
|
|
188
|
-
- Make sure you're using TypeScript
|
|
189
|
-
- Check that all imports are correct
|
|
190
|
-
- Verify that the MobileSDK class is properly exported
|
|
319
|
+
#### `sdk.exportWallet(exportToStore)`
|
|
191
320
|
|
|
192
|
-
|
|
321
|
+
Export the wallet to a different storage location (useful for backup).
|
|
193
322
|
|
|
194
|
-
|
|
323
|
+
```tsx
|
|
324
|
+
await sdk.exportWallet({
|
|
325
|
+
id: 'backup-wallet-id',
|
|
326
|
+
key: 'backup-wallet-key',
|
|
327
|
+
path: '/path/to/backup/file',
|
|
328
|
+
})
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### Key Management
|
|
334
|
+
|
|
335
|
+
#### `sdk.createKey(options)`
|
|
336
|
+
|
|
337
|
+
Create a cryptographic key pair stored in the wallet.
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
const keyPair = await sdk.createKey({ keyType: 'Ed25519' })
|
|
341
|
+
console.log(keyPair.keyId)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
#### `sdk.signData(options)`
|
|
347
|
+
|
|
348
|
+
Sign data with a key from the wallet.
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
const signature = await sdk.signData({
|
|
352
|
+
keyId: keyPair.keyId,
|
|
353
|
+
data: new Uint8Array([1, 2, 3]),
|
|
354
|
+
})
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
#### `sdk.verifyData(options)`
|
|
360
|
+
|
|
361
|
+
Verify that a signature was produced by a given key.
|
|
362
|
+
|
|
363
|
+
```tsx
|
|
364
|
+
const isValid = await sdk.verifyData({
|
|
365
|
+
keyId: keyPair.keyId,
|
|
366
|
+
data: new Uint8Array([1, 2, 3]),
|
|
367
|
+
signature,
|
|
368
|
+
})
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
#### `sdk.createJwsCompact({ header, payload, keyId })`
|
|
374
|
+
|
|
375
|
+
Create a compact JWS (JSON Web Signature) token.
|
|
376
|
+
|
|
377
|
+
```tsx
|
|
378
|
+
const jws = await sdk.createJwsCompact({
|
|
379
|
+
header: { alg: 'EdDSA' },
|
|
380
|
+
payload: { sub: 'user-123', iat: Math.floor(Date.now() / 1000) },
|
|
381
|
+
keyId: keyPair.keyId,
|
|
382
|
+
})
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
### React Hooks — Credential Records
|
|
388
|
+
|
|
389
|
+
These hooks give real-time reactive access to credentials stored in the wallet. They update automatically when credentials are added, updated, or deleted.
|
|
390
|
+
|
|
391
|
+
> Must be used inside `MobileSDK.AppProvider`.
|
|
392
|
+
|
|
393
|
+
#### `useW3cCredentialRecords()`
|
|
394
|
+
|
|
395
|
+
Subscribe to all W3C credential records.
|
|
396
|
+
|
|
397
|
+
```tsx
|
|
398
|
+
import { useW3cCredentialRecords } from '@credebl/ssi-mobile-core'
|
|
399
|
+
|
|
400
|
+
const { w3cCredentialRecords, isLoading } = useW3cCredentialRecords()
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### `useW3cCredentialRecordById(id)`
|
|
404
|
+
|
|
405
|
+
```tsx
|
|
406
|
+
const record = useW3cCredentialRecordById('record-id')
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
#### `useSdJwtVcRecords()`
|
|
412
|
+
|
|
413
|
+
Subscribe to all SD-JWT credential records.
|
|
414
|
+
|
|
415
|
+
```tsx
|
|
416
|
+
import { useSdJwtVcRecords } from '@credebl/ssi-mobile-core'
|
|
417
|
+
|
|
418
|
+
const { sdJwtVcRecords, isLoading } = useSdJwtVcRecords()
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### `useSdJwtVcRecordById(id)`
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
const record = useSdJwtVcRecordById('record-id')
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
#### `useMdocRecords()`
|
|
430
|
+
|
|
431
|
+
Subscribe to all mDoc credential records.
|
|
432
|
+
|
|
433
|
+
```tsx
|
|
434
|
+
import { useMdocRecords } from '@credebl/ssi-mobile-core'
|
|
435
|
+
|
|
436
|
+
const { mdocRecords, isLoading } = useMdocRecords()
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
#### `useMdocRecordById(id)`
|
|
440
|
+
|
|
441
|
+
```tsx
|
|
442
|
+
const record = useMdocRecordById('record-id')
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
#### `useGenericRecords(options?)`
|
|
448
|
+
|
|
449
|
+
Subscribe to generic records, with optional tag filtering.
|
|
450
|
+
|
|
451
|
+
```tsx
|
|
452
|
+
import { useGenericRecords } from '@credebl/ssi-mobile-core'
|
|
453
|
+
|
|
454
|
+
const { genericRecords, isLoading } = useGenericRecords({
|
|
455
|
+
filterByTagKey: 'type',
|
|
456
|
+
filterByTags: { type: 'settings' },
|
|
457
|
+
})
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
#### `useGenericRecordById(id)`
|
|
461
|
+
|
|
462
|
+
```tsx
|
|
463
|
+
const record = useGenericRecordById('record-id')
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
### Wallet Utilities
|
|
469
|
+
|
|
470
|
+
These are standalone functions — no hook or SDK instance needed.
|
|
471
|
+
|
|
472
|
+
#### `isWalletPinCorrect(storeConfig)`
|
|
473
|
+
|
|
474
|
+
Check if a wallet key is correct before opening. Useful for PIN verification screens.
|
|
475
|
+
|
|
476
|
+
```tsx
|
|
477
|
+
import { isWalletPinCorrect } from '@credebl/ssi-mobile-core'
|
|
478
|
+
|
|
479
|
+
const isCorrect = await isWalletPinCorrect({
|
|
480
|
+
id: 'wallet-id',
|
|
481
|
+
key: 'entered-pin',
|
|
482
|
+
})
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
#### `isWalletImportable(storeConfig, importFromStore)`
|
|
488
|
+
|
|
489
|
+
Check whether a wallet backup file can be imported before attempting the import.
|
|
490
|
+
|
|
491
|
+
```tsx
|
|
492
|
+
import { isWalletImportable } from '@credebl/ssi-mobile-core'
|
|
493
|
+
|
|
494
|
+
const canImport = await isWalletImportable(
|
|
495
|
+
{ id: 'new-wallet', key: 'new-wallet-key' },
|
|
496
|
+
{ id: 'backup-wallet', key: 'backup-key', path: '/path/to/backup' }
|
|
497
|
+
)
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
#### `importWalletToStore(storeConfig, importFromStore)`
|
|
503
|
+
|
|
504
|
+
Import a wallet from a backup file.
|
|
505
|
+
|
|
506
|
+
```tsx
|
|
507
|
+
import { importWalletToStore } from '@credebl/ssi-mobile-core'
|
|
508
|
+
|
|
509
|
+
await importWalletToStore(
|
|
510
|
+
{ id: 'new-wallet', key: 'new-wallet-key' },
|
|
511
|
+
{ id: 'backup-wallet', key: 'backup-key', path: '/path/to/backup' }
|
|
512
|
+
)
|
|
513
|
+
```
|