Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package org.multipaz.documenttype.knowntypes

import org.multipaz.cbor.toDataItem
import org.multipaz.cbor.toDataItemFullDate
import org.multipaz.documenttype.DocumentAttributeType
import org.multipaz.documenttype.DocumentType
import org.multipaz.documenttype.Icon
import org.multipaz.util.fromBase64Url
import kotlinx.datetime.LocalDate

object Loyalty {
const val LOYALTY_DOCTYPE = "org.multipaz.loyalty.1"
const val LOYALTY_NAMESPACE = "org.multipaz.loyalty.1"

/**
* Build the Loyalty ID Document Type.
*/
fun getDocumentType(): DocumentType {
return DocumentType.Builder("Loyalty")
.addMdocDocumentType(LOYALTY_DOCTYPE)
// Core holder data relevant for a loyalty card
//
.addMdocAttribute(
DocumentAttributeType.String,
"family_name",
"Family Name",
"Last name, surname, or primary identifier, of the document holder",
true,
LOYALTY_NAMESPACE,
Icon.PERSON,
SampleData.FAMILY_NAME.toDataItem()
)
.addMdocAttribute(
DocumentAttributeType.String,
"given_name",
"Given Names",
"First name(s), other name(s), or secondary identifier, of the document holder",
true,
LOYALTY_NAMESPACE,
Icon.PERSON,
SampleData.GIVEN_NAME.toDataItem()
)
.addMdocAttribute(
DocumentAttributeType.Picture,
"portrait",
"Photo of Holder",
"A reproduction of the document holder’s portrait.",
true,
LOYALTY_NAMESPACE,
Icon.ACCOUNT_BOX,
SampleData.PORTRAIT_BASE64URL.fromBase64Url().toDataItem()
)
// Then the LoyaltyID specific data elements.
//
.addMdocAttribute(
DocumentAttributeType.String,
"membership_number",
"Membership ID",
"Person identifier of the Loyalty ID holder.",
false,
LOYALTY_NAMESPACE,
Icon.NUMBERS,
SampleData.PERSON_ID.toDataItem()
)
.addMdocAttribute(
DocumentAttributeType.String,
"tier",
"Tier",
"Membership tier (basic, silver, gold, platinum, elite)",
false,
LOYALTY_NAMESPACE,
Icon.STARS,
"basic".toDataItem()
)
.addMdocAttribute(
DocumentAttributeType.Date,
"issue_date",
"Date of Issue",
"Date when document was issued",
true,
LOYALTY_NAMESPACE,
Icon.CALENDAR_CLOCK,
LocalDate.parse(SampleData.ISSUE_DATE).toDataItemFullDate()
)
.addMdocAttribute(
DocumentAttributeType.Date,
"expiry_date",
"Date of Expiry",
"Date when document expires",
true,
LOYALTY_NAMESPACE,
Icon.CALENDAR_CLOCK,
LocalDate.parse(SampleData.EXPIRY_DATE).toDataItemFullDate()
)
// Finally for the sample requests.
//
.addSampleRequest(
id = "mandatory",
displayName = "Mandatory Data Elements",
mdocDataElements = mapOf(
LOYALTY_NAMESPACE to mapOf(
"family_name" to false,
"given_name" to false,
"portrait" to false,
"membership_number" to false,
"tier" to false,
"issue_date" to false,
"expiry_date" to false,
)
)
)
.addSampleRequest(
id = "full",
displayName ="All Data Elements",
mdocDataElements = mapOf(
LOYALTY_NAMESPACE to mapOf()
)
)
.build()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.multipaz.cbor.DataItem
import org.multipaz.crypto.X509CertChain
import org.multipaz.documenttype.knowntypes.AgeVerification
import org.multipaz.documenttype.knowntypes.EUPersonalID
import org.multipaz.documenttype.knowntypes.LoyaltyID
import org.multipaz.documenttype.knowntypes.Loyalty
import org.multipaz.openid4vci.request.wellKnownOpenidCredentialIssuer

/**
Expand Down Expand Up @@ -62,7 +62,7 @@ internal interface CredentialFactory {
CredentialFactoryUtopiaNaturatization(),
CredentialFactoryUtopiaMovieTicket(),
CredentialFactoryAgeVerification(),
CredentialFactoryUtopiaLoyaltyID(),
CredentialFactoryUtopiaLoyalty(),
)
factories.forEach { it.initialize() }
registeredFactories = RegisteredFactories(
Expand Down Expand Up @@ -99,7 +99,7 @@ internal data class Openid4VciFormatMdoc(val docType: String) : Openid4VciFormat
internal val openId4VciFormatMdl = Openid4VciFormatMdoc(DrivingLicense.MDL_DOCTYPE)
internal val openId4VciFormatPid = Openid4VciFormatMdoc(EUPersonalID.EUPID_DOCTYPE)
internal val openId4VciFormatAv = Openid4VciFormatMdoc(AgeVerification.AV_DOCTYPE)
internal val openId4VciFormatLoyaltyId = Openid4VciFormatMdoc(LoyaltyID.LOYALTY_ID_DOCTYPE)
internal val openId4VciFormatLoyalty = Openid4VciFormatMdoc(Loyalty.LOYALTY_DOCTYPE)

internal data class Openid4VciFormatSdJwt(val vct: String) : Openid4VciFormat() {
override val id: String get() = "dc+sd-jwt"
Expand Down
Loading