Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
cre8 committed Sep 26, 2024
1 parent 3d0e823 commit a4f73cb
Show file tree
Hide file tree
Showing 44 changed files with 1,071 additions and 106 deletions.
4 changes: 2 additions & 2 deletions case-studies/citizenship.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"createdAt": "2022-01-01",
"stakeholders": [
{
"name": "BC Wallet",
"name": "British Columbia",
"contact": "https://example.com"
},
{
"name": "Altme",
"name": "Altme LLT",
"contact": "https://example.com"
}
]
Expand Down
2 changes: 1 addition & 1 deletion case-studies/trees.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"createdAt": "2022-01-01",
"stakeholders": [
{
"name": "BC Wallet",
"name": "Greenpeace",
"contact": "https://example.com"
}
]
Expand Down
4 changes: 3 additions & 1 deletion dependencies/credo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"name": "Credo",
"url": "https://github.com/openwallet-foundation/credo-ts",
"description": "Typescript framework for building decentralized identity and verifiable credential solutions",
"community": "https://discord.gg/openwalletfoundation"
"community": "https://discord.gg/openwalletfoundation",
"language": "TypeScript",
"license": "Apache-2.0"
}
4 changes: 3 additions & 1 deletion dependencies/sd-jwt-js.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"name": "SD-JWT-JS",
"url": "https://github.com/openwallet-foundation-labs/sd-jwt-js",
"description": "A TypeScript implementation of the Selective Disclosure JWT (SD-JWT) spec.",
"community": "https://discord.gg/openwalletfoundation"
"community": "https://discord.gg/openwalletfoundation",
"language": "TypeScript",
"license": "Apache-2.0"
}
28 changes: 1 addition & 27 deletions viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@angular/platform-browser-dynamic": "^18.2.5",
"@angular/router": "^18.2.5",
"@ngbracket/ngx-layout": "^17.0.1",
"@sendgrid/client": "^8.1.3",
"ajv": "^8.17.1",
"rxjs": "~7.8.0",
"tslib": "^2.6.3",
Expand All @@ -36,7 +37,6 @@
"@angular-devkit/build-angular": "^18.2.5",
"@angular/cli": "^18.2.5",
"@angular/compiler-cli": "^18.2.5",
"@sendgrid/mail": "^8.1.3",
"@types/jasmine": "~5.1.0",
"ajv-formats": "^3.0.1",
"angular-eslint": "18.3.0",
Expand Down
23 changes: 21 additions & 2 deletions viewer/scripts/mail-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@
<div class="case-study">
<img src="{{this.imageUrl}}" alt="{{this.headline}}">
<h2>{{this.headline}}</h2>
<h3>provided by <a href="{{ this.companyUrl }}">{{ this.company }}</a> with <a href="{{ this.referenceUrl }}">{{ this.reference }}</a></h3>
<h3>provided by
{{#each this.wallets}}
<a href="{{ this.companyUrl }}">{{ this.company }}</a> with <a href="{{ this.urk }}">{{ this.name }}</a>{{#unless @last}},{{/unless}}
{{/each}}
</h3>
<p>{{this.summary}}</p>
<br>
<a href="{{this.url}}" target="_blank">Read More</a>
Expand All @@ -226,13 +230,28 @@
<div style="font-family: inherit; text-align: inherit">You want to add your case study in the next newsletter? Submit it via <a href="https://github.com/openwallet-foundation/digital-wallet-and-agent-overviews-sig?tab=readme-ov-file#case-studies">Github</a>.</div><div></div></div></td>
</tr>
</tbody>
</table><table class="module" role="module" data-type="divider" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;" data-muid="d51fddf6-e9d3-430e-ba2f-8362b4902bbd">
<tbody>
<tr>
<td style="padding:0px 0px 0px 0px;" role="module-content" height="100%" valign="top" bgcolor="">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" height="10px" style="line-height:10px; font-size:10px;">
<tbody>
<tr>
<td style="padding:0px 0px 10px 0px;" bgcolor="#000000"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table><table class="module" role="module" data-type="text" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;" data-muid="a31d2873-b243-4e4e-aa65-c2ebeb427bc7" data-mc-module-version="2019-10-22">
<tbody>
<tr>
<td style="padding:18px 0px 18px 0px; line-height:22px; text-align:inherit;" height="100%" valign="top" bgcolor="" role="module-content"><div><div style="font-family: inherit; text-align: inherit">This newsletter was provided by the <a href="https://github.com/openwallet-foundation/digital-wallet-and-agent-overviews-sig">Wallet and Agent Overview SIG</a> at the <a href="https://openwallet.foundation">OpenWallet Foundation</a>.</div><div></div></div></td>
</tr>
</tbody>
</table></td>
</table>
</td>
</tr>
</table>
<!--[if mso]>
Expand Down
1 change: 1 addition & 0 deletions viewer/scripts/merge-wallets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const readAndProcessFiles = (directory, processFile) => {
const files = readdirSync(directory);
return files.map(file => {
const json = JSON.parse(readFileSync(`${directory}/${file}`));
json.id = file.slice(0, -5);
return processFile(json, file);
});
};
Expand Down
66 changes: 59 additions & 7 deletions viewer/scripts/newsletter.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import {config} from 'dotenv';
import fs from 'fs';
import nodemailer from 'nodemailer';
import handlebars from 'handlebars';
import { execSync } from 'child_process';
import {Client} from '@sendgrid/client';
import {createTransport} from 'nodemailer'

config();

const service = new Client();

service.setApiKey(process.env.SENDGRID_API_KEY);


const walletFiles = fs.readdirSync('../wallets');
const walletCounter = walletFiles.length;

const wallets = walletFiles.map(walletFile => {
const content = JSON.parse(fs.readFileSync(`../wallets/${walletFile}`, 'utf8'));
content.id = walletFile.slice(0, -5);
return content;
});

Expand All @@ -34,15 +41,22 @@ const caseStudyFiles = execSync(`git log --diff-filter=A --since="${fromDate}" -

console.log(`Found ${caseStudyFiles.length} new case ${caseStudyFiles.length === 1 ? 'study' : 'studies'}: ${caseStudyFiles.join(', ')}`);

//const url = 'https://openwallet-foundation.github.io/digital-wallet-and-agent-overviews-sig/#';
const url = 'http://localhost:4200/#';

// format the case studies
const caseStudies = caseStudyFiles.map(caseStudy => {
const id = caseStudy.split('/')[1].slice(0, -5);
const content = JSON.parse(fs.readFileSync(`../${caseStudy}`, 'utf8'));
delete content['$schema'];
const wallet = wallets.find(w => w.name === content.reference);
content.company = wallet.company;
content.companyUrl = wallet.companyUrl ?? wallet.urlWeb;
content.reference = wallet.name;
content.referenceUrl = `https://openwallet-foundation.github.io/digital-wallet-and-agent-overviews-sig/#/${encodeURIComponent(wallet.name)}`;

content.wallets = wallets.filter(w =>content.references.includes(w.id)).map(wallet => ({
name: wallet.name,
company: wallet.company,
url: `${url}/wallets/${encodeURIComponent(wallet.id)}`,
companyUrl: wallet.companyUrl ?? wallet.urlWebsite,
}))
content.url = `${url}/case-studies/${encodeURIComponent(id)}`;
return content;
});

Expand All @@ -55,8 +69,9 @@ const template = handlebars.compile(templateSource);
const html = template({ caseStudies, lastMonth: currentMonthName, subject, preHeader, walletCounter });


//when using nodemail
// Create a transporter
let transporter = nodemailer.createTransport({
let transporter = createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL_ADDRESS,
Expand All @@ -79,3 +94,40 @@ transporter.sendMail(mailOptions, (error, info) => {
}
console.log('Email sent: ' + info.response);
});

/* const request = {
url: `/v3/verified_senders`,
method: 'GET',
}
service.request(request)
.then(([response, body]) => {
console.log(response.statusCode);
console.log(response.body);
})
.catch(error => {
console.error(error);
}); */

// use sendgrid
/* const listId = "d88713fd-1c3d-427a-8761-004b38e7a6c3";
const senderId = 6190879;
service.request({
url: `/v3/marketing/singlesends`,
method: 'POST',
body: {
name: "Monthly Case Study Overview", // Name for your campaign
send_to: {
list_ids: [listId], // Array of contact list IDs
all: false, // If true, it sends to all contacts
},
email_config: {
sender_id: senderId, // Sender ID, should be a verified sender in SendGrid
html_content: html,
subject,
send_at: 'now',
suppression_group_id: 180616,
},
},
}).then(res => console.log(res), (err) => console.log(err.response.body));
*/
22 changes: 8 additions & 14 deletions viewer/scripts/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import axios from 'axios';

const ajv = new Ajv({allowUnionTypes: true});
addFormats(ajv);
const dependencyNames = [];
const walletNames = [];
const dependencyIds = [];
const walletIds = [];

// validate dependencies
function validateDependencies() {
Expand All @@ -20,11 +20,8 @@ function validateDependencies() {
console.error(JSON.stringify(validate.errors, null, 2));
success = false;
}
if(dependencyNames.includes(dependency.name)) {
console.error(`Duplicate dependency name: ${dependency.name}`);
success = false;
}
dependencyNames.push(dependency.name);
const fileName = file.slice(0, -5);
dependencyIds.push(fileName);
});
if(success) {
console.info('All dependencies are valid');
Expand All @@ -47,15 +44,12 @@ async function validateWallets() {
console.error(JSON.stringify(validate.errors, null, 2));
success = false;
}
if(walletNames.includes(wallet.name)) {
console.error(`Duplicate wallet name: ${wallet.name}`);
success = false;
}
walletNames.push(wallet.name);
const fileName = file.slice(0, -5);
walletIds.push(fileName);
// validate the dependencies if the key is a valid one
if(wallet.dependencies) {
for(const dependency of wallet.dependencies) {
if(!dependencyNames.includes(dependency)) {
if(!dependencyIds.includes(dependency)) {
console.error(`dependency ${dependency} not found in dependencies`);
success = false;
}
Expand Down Expand Up @@ -84,7 +78,7 @@ function validateCaseStudies() {
}
// check if the referenced wallets exist
caseStudy.references.forEach(element => {
if(!walletNames.includes(element)) {
if(!walletIds.includes(element)) {
console.error(`Referenced wallet ${element} not found in wallets`);
success = false
}
Expand Down
Loading

0 comments on commit a4f73cb

Please sign in to comment.