Files
the_order/services/identity/src/credential-notifications.ts
T
defiQUG 92cc41d26d Add Legal Office seal and complete Azure CDN deployment
- Add Legal Office of the Master seal (SVG design with Maltese Cross, scales of justice, legal scroll)
- Create legal-office-manifest-template.json for Legal Office credentials
- Update SEAL_MAPPING.md and DESIGN_GUIDE.md with Legal Office seal documentation
- Complete Azure CDN infrastructure deployment:
  - Resource group, storage account, and container created
  - 17 PNG seal files uploaded to Azure Blob Storage
  - All manifest templates updated with Azure URLs
  - Configuration files generated (azure-cdn-config.env)
- Add comprehensive Azure CDN setup scripts and documentation
- Fix manifest URL generation to prevent double slashes
- Verify all seals accessible via HTTPS
2025-11-12 22:03:42 -08:00

173 lines
5.9 KiB
TypeScript

/**
* Automated credential issuance notifications
*/
import { getNotificationService, CredentialNotificationTemplates } from '@the-order/notifications';
import { getEventBus, CredentialEvents } from '@the-order/events';
/**
* Initialize credential issuance notifications
*/
export async function initializeCredentialNotifications(): Promise<void> {
const eventBus = getEventBus();
const notificationService = getNotificationService();
// Subscribe to credential issued events
await eventBus.subscribe(CredentialEvents.ISSUED, async (data) => {
const eventData = data as {
subjectDid: string;
credentialType: string | string[];
credentialId?: string;
issuedAt: string;
recipientEmail?: string;
recipientPhone?: string;
recipientName?: string;
};
const credentialType = Array.isArray(eventData.credentialType)
? eventData.credentialType.join(', ')
: eventData.credentialType;
// Send email notification
if (eventData.recipientEmail) {
await notificationService.send({
to: eventData.recipientEmail,
type: 'email',
subject: CredentialNotificationTemplates.ISSUED.email.subject,
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.ISSUED.email.template,
templateData: {
recipientName: eventData.recipientName || 'User',
credentialType,
issuerName: 'The Order',
issuedAt: eventData.issuedAt,
credentialId: eventData.credentialId || 'N/A',
credentialsUrl: process.env.CREDENTIALS_URL || 'https://theorder.org/credentials',
},
});
}
// Send SMS notification
if (eventData.recipientPhone) {
await notificationService.send({
to: eventData.recipientPhone,
type: 'sms',
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.ISSUED.sms.template,
templateData: {
credentialType,
credentialId: eventData.credentialId || 'N/A',
credentialsUrl: process.env.CREDENTIALS_URL || 'https://theorder.org/credentials',
},
});
}
});
// Subscribe to credential renewed events
await eventBus.subscribe(CredentialEvents.RENEWED, async (data) => {
const eventData = data as {
subjectDid: string;
oldCredentialId: string;
newCredentialId: string;
renewedAt: string;
recipientEmail?: string;
recipientPhone?: string;
recipientName?: string;
};
if (eventData.recipientEmail) {
await notificationService.send({
to: eventData.recipientEmail,
type: 'email',
subject: CredentialNotificationTemplates.RENEWED.email.subject,
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.RENEWED.email.template,
templateData: {
recipientName: eventData.recipientName || 'User',
credentialType: 'Verifiable Credential',
newCredentialId: eventData.newCredentialId,
oldCredentialId: eventData.oldCredentialId,
renewedAt: eventData.renewedAt,
credentialsUrl: process.env.CREDENTIALS_URL || 'https://theorder.org/credentials',
},
});
}
});
// Subscribe to credential expiring events
await eventBus.subscribe(CredentialEvents.EXPIRING, async (data) => {
const eventData = data as {
credentialId: string;
subjectDid: string;
expirationDate: string;
daysUntilExpiration: number;
recipientEmail?: string;
recipientPhone?: string;
recipientName?: string;
};
if (eventData.recipientEmail) {
await notificationService.send({
to: eventData.recipientEmail,
type: 'email',
subject: CredentialNotificationTemplates.EXPIRING.email.subject,
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.EXPIRING.email.template,
templateData: {
recipientName: eventData.recipientName || 'User',
credentialType: 'Verifiable Credential',
credentialId: eventData.credentialId,
expirationDate: eventData.expirationDate,
daysUntilExpiration: eventData.daysUntilExpiration,
renewalUrl: process.env.RENEWAL_URL || 'https://theorder.org/credentials/renew',
},
});
}
if (eventData.recipientPhone) {
await notificationService.send({
to: eventData.recipientPhone,
type: 'sms',
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.EXPIRING.sms.template,
templateData: {
credentialType: 'Verifiable Credential',
daysUntilExpiration: eventData.daysUntilExpiration,
renewalUrl: process.env.RENEWAL_URL || 'https://theorder.org/credentials/renew',
},
});
}
});
// Subscribe to credential revoked events
await eventBus.subscribe(CredentialEvents.REVOKED, async (data) => {
const eventData = data as {
credentialId: string;
subjectDid: string;
reason: string;
revokedAt: string;
recipientEmail?: string;
recipientPhone?: string;
recipientName?: string;
};
if (eventData.recipientEmail) {
await notificationService.send({
to: eventData.recipientEmail,
type: 'email',
subject: CredentialNotificationTemplates.REVOKED.email.subject,
message: '', // Message will be generated from template
template: CredentialNotificationTemplates.REVOKED.email.template,
templateData: {
recipientName: eventData.recipientName || 'User',
credentialType: 'Verifiable Credential',
credentialId: eventData.credentialId,
revokedAt: eventData.revokedAt,
revocationReason: eventData.reason,
},
});
}
});
}