Skip to content

Commit 252d21c

Browse files
committed
refactor: cleaned up schemas
1 parent 4e2310d commit 252d21c

19 files changed

Lines changed: 477 additions & 974 deletions

File tree

README.md

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -162,62 +162,9 @@ Choose the matcher package that fits your needs. Registering credentials for a m
162162
```tsx
163163
import { registerCredentials } from "@animo-id/expo-digital-credentials-api-cmwallet";
164164

165+
// Build credentialBytes from the matcher schema (see example/matcherEncoding.ts for a reference encoder)
165166
await registerCredentials({
166-
credentials: [
167-
{
168-
id: "1",
169-
display: {
170-
title: "Drivers License",
171-
subtitle: "Issued by Utopia",
172-
claims: [
173-
{
174-
path: ["org.iso.18013.5.1", "family_name"],
175-
displayName: "Family Name",
176-
},
177-
],
178-
iconDataUrl:
179-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAaUlEQVR4nOzPUQkAIQDA0OMwpxksY19D+PEQ9hJsY6/5vezXAbca0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0E4AAAD//7vSAeZjAN7dAAAAAElFTkSuQmCC",
180-
},
181-
credential: {
182-
doctype: "org.iso.18013.5.1.mDL",
183-
format: "mso_mdoc",
184-
namespaces: {
185-
"org.iso.18013.5.1": {
186-
family_name: "Glastra",
187-
},
188-
},
189-
},
190-
},
191-
{
192-
id: "2",
193-
display: {
194-
title: "PID",
195-
subtitle: "Issued by Utopia",
196-
claims: [
197-
{
198-
path: ["first_name"],
199-
displayName: "First Name",
200-
},
201-
{
202-
path: ["address", "city"],
203-
displayName: "Resident City",
204-
},
205-
],
206-
iconDataUrl:
207-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAaUlEQVR4nOzPUQkAIQDA0OMwpxksY19D+PEQ9hJsY6/5vezXAbca0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0BrQGtAa0E4AAAD//7vSAeZjAN7dAAAAAElFTkSuQmCC",
208-
},
209-
credential: {
210-
vct: "eu.europa.ec.eudi.pid.1",
211-
format: "dc+sd-jwt",
212-
claims: {
213-
first_name: "Timo",
214-
address: {
215-
city: "Somewhere",
216-
},
217-
},
218-
},
219-
},
220-
],
167+
credentialBytes,
221168
});
222169
```
223170

@@ -228,13 +175,9 @@ To allow OpenID4VCI issuance, register creation options with the CMWallet issuan
228175
```tsx
229176
import { registerCreationOptions } from "@animo-id/expo-digital-credentials-api-cmwallet-issuance";
230177

178+
// Build creationOptions bytes from the matcher schema (see example/matcherEncoding.ts for a reference encoder)
231179
await registerCreationOptions({
232-
display: {
233-
title: "My Wallet",
234-
subtitle: "Save your document",
235-
iconDataUrl: "data:image/png;base64,...",
236-
},
237-
issuerAllowlist: ["https://issuer.example"],
180+
creationOptions,
238181
});
239182
```
240183

example/App.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import { isCreateCredentialActivity, isGetCredentialActivity } from '@animo-id/expo-digital-credentials-api'
2-
import {
3-
registerCredentials as registerCmWallet,
4-
type CredentialItem,
5-
type SdJwtDcClaims,
6-
} from '@animo-id/expo-digital-credentials-api-cmwallet'
1+
import { registerCredentials as registerCmWallet } from '@animo-id/expo-digital-credentials-api-cmwallet'
72
import { registerCreationOptions as registerCmWalletIssuance } from '@animo-id/expo-digital-credentials-api-cmwallet-issuance'
3+
import { registerCredentials as registerAptitude } from '@animo-id/expo-digital-credentials-api-aptitude-consortium'
4+
import { registerCredentials as registerUbique } from '@animo-id/expo-digital-credentials-api-ubique'
85
import {
96
encodeAptitudeConsortiumConfig,
10-
registerCredentials as registerAptitude,
11-
type AptitudeConsortiumConfig,
12-
} from '@animo-id/expo-digital-credentials-api-aptitude-consortium'
13-
import { registerCredentials as registerUbique } from '@animo-id/expo-digital-credentials-api-ubique'
14-
import { useMemo } from 'react'
7+
encodeIssuanceCreationOptions,
8+
encodeMatcherCredentials,
9+
type AptitudeConsortiumConfigInput,
10+
type CredentialItem,
11+
type SdJwtDcClaims,
12+
} from './matcherEncoding'
1513
import { Button, SafeAreaView, ScrollView, Text, View } from 'react-native'
1614

1715
export default function App() {
@@ -568,7 +566,7 @@ export default function App() {
568566
},
569567
]
570568

571-
const aptitudeConfig: AptitudeConsortiumConfig = {
569+
const aptitudeConfig: AptitudeConsortiumConfigInput = {
572570
default_id_prefix: 'cred-',
573571
openid4vp: {
574572
enabled: true,
@@ -659,28 +657,30 @@ export default function App() {
659657

660658
const register = (matcher: 'ubique' | 'cmwallet' | 'aptitude-consortium') => {
661659
if (matcher === 'aptitude-consortium') {
662-
const encoded = encodeAptitudeConsortiumConfig(aptitudeConfig, { debug: true })
663-
const decoded = new TextDecoder().decode(encoded)
660+
const credentialBytes = encodeAptitudeConsortiumConfig(aptitudeConfig, { debug: true })
661+
const decoded = new TextDecoder().decode(credentialBytes)
664662
console.log('Aptitude matcher payload (json)', decoded)
665-
return registerAptitude({ aptitudeConsortiumConfig: aptitudeConfig, debug: true })
663+
return registerAptitude({ credentialBytes })
666664
.then(() => console.log('success', matcher))
667665
.catch((error) => console.error('error', error))
668666
}
669667

670668
const registerFn = matcher === 'ubique' ? registerUbique : registerCmWallet
671-
return registerFn({ credentials: legacyCredentials, debug: true })
669+
const credentialBytes = encodeMatcherCredentials(legacyCredentials, { debug: true })
670+
return registerFn({ credentialBytes })
672671
.then(() => console.log('success', matcher))
673672
.catch((error) => console.error('error', error))
674673
}
675674

676675
const registerIssuance = () => {
677-
return registerCmWalletIssuance({
676+
const creationOptions = encodeIssuanceCreationOptions({
678677
display: {
679678
title: 'CMWallet',
680679
subtitle: 'Save your document to CMWallet',
681680
iconDataUrl: mdlIconDataUrl,
682681
},
683682
})
683+
return registerCmWalletIssuance({ creationOptions })
684684
.then(() => console.log('success', 'cmwallet-issuance'))
685685
.catch((error) => console.error('error', error))
686686
}

0 commit comments

Comments
 (0)