Many Changes

This commit is contained in:
2024-02-19 07:46:28 +01:00
parent fa0eb73363
commit 630798c89f
12 changed files with 2380 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
import axios from "axios"
import {createClient} from "@supabase/supabase-js";
let key = process.env.SUPABASE_KEY
let key = process.env.SUPABASE_SERVICE_ROLE_KEY
let url = process.env.SUPABASE_URL
let interval = process.env.INTERVAL
let goCardLessBaseUrl = process.env.GOCARDLESS_URL

60
test/imapflow/index.js Normal file
View File

@@ -0,0 +1,60 @@
const { ImapFlow } = require('imapflow');
const client = new ImapFlow({
host: 'imap.strato.de',
port: 993,
secure: true,
auth: {
user: 'info@federspiel.tech',
pass: 'fpGUpbQG34'
},
logger: {}
});
const main = async () => {
// Wait until client connects and authorizes
await client.connect();
// Select and lock a mailbox. Throws if mailbox does not exist
let lock = await client.getMailboxLock('INBOX');
try {
// fetch latest message source
// client.mailbox includes information about currently selected mailbox
// "exists" value is also the largest sequence number available in the mailbox
let message = await client.fetchOne(client.mailbox.exists, { source: true });
//console.log(message.source.toString());
// list subjects for all messages
// uid value is always included in FETCH response, envelope strings are in unicode.
for await (let message of client.fetch('1', { source:true , envelope: true, flags:true, bodyStructure: true, labels:true, bodyParts: true })) {
console.log(`${message.uid}: ${message.envelope.subject}`);
//console.log(`${message.envelope}`);
console.log(message)
console.log(message.bodyStructure.childNodes)
message.bodyStructure.childNodes.forEach(i => console.log(i))
}
let data = await client.download('1','1.1');
console.log(data)
data.content.pipe(process.stdout)
/*let tree = await client.listTree();
console.log(tree)
tree.folders.forEach(mailbox => console.log(mailbox.path))*/
} finally {
// Make sure lock is released, otherwise next `getMailboxLock()` never returns
lock.release();
}
/*let mailbox = await client.mailboxOpen('INBOX');
// fetch UID for the last email in the selected mailbox
let lastMsg = await client.fetchOne('*', {uid: true})
console.log(lastMsg.uid);*/
// log out and close connection
await client.logout();
};
main().catch(err => {}/*console.error(err)*/);

54
test/oauthserver/index.js Normal file
View File

@@ -0,0 +1,54 @@
const express = require('express')
const axios = require('axios')
const cors = require('cors')
const querystring = require("querystring");
const CLIENT_ID = "3658523-0-bf5dc4c1-cce3-11ee-8a09-a1149eb4f0fe:third-party";
const CLIENT_SECRET = "Xve6SePADrn4vgI8GwVJVnUelWTesSYR";
const GITHUB_URL = "https://github.com/login/oauth/access_token";
const app = express();
app.use(cors({ credentials: true, origin: true }));
app.get("/oauth/redirect", async (req, res) => {
console.log(req.query.code)
const {data,error } = await axios({
method: "POST",
url: `https://login.sipgate.com/auth/realms/third-party/protocol/openid-connect/token`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: querystring.stringify({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
code: req.query.code,
redirect_uri: "http://localhost:8888/oauth",
grant_type: "authorization_code"
})
})
console.log(error)
console.log(data)
});
app.get("/oauth", (req,res) => {
res.send("Done")
})
app.get("/",(req,res) => {
let url = `https://login.sipgate.com/auth/realms/third-party/protocol/openid-connect/auth?` +querystring.stringify({
client_id: CLIENT_ID,
redirect_uri: "http://localhost:8888/oauth/redirect",
scope: "account:read",
response_type: "code"
})
console.log(url)
res.redirect(url)
})
const PORT = 8888;
app.listen(PORT, () => {
console.log(`Listening at port ${PORT}`);
});

30
test/vcardjs/index.js Normal file
View File

@@ -0,0 +1,30 @@
var vCardsJS = require('vcards-js');
let contacts = [{},{}]
let cardsString = ""
contacts.forEach(contact => {
//create a new vCard
var vCard = vCardsJS();
//set properties
vCard.firstName = 'Eric';
vCard.middleName = 'J';
vCard.lastName = 'Nesser';
vCard.organization = 'ACME Corporation';
vCard.photo.attachFromUrl('https://avatars2.githubusercontent.com/u/5659221?v=3&s=460', 'JPEG');
vCard.workPhone = '312-555-1212';
vCard.birthday = new Date(1985, 0, 1);
vCard.title = 'Software Developer';
vCard.url = 'https://github.com/enesser';
vCard.note = 'Notes on Eric';
//save to file
//vCard.saveToFile('./eric-nesser.vcf');
//get as formatted string
console.log(vCard.getFormattedString());
cardsString += vCard.getFormattedString();
})
console.log(cardsString)