-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into eeen17/lead-screen
* kinda messed up rebase, so merging to clean it all up, won't touch rebase after pushing to remote again lol
- Loading branch information
Showing
51 changed files
with
2,437 additions
and
2,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import jwt from 'jsonwebtoken'; | ||
import jwt from "jsonwebtoken"; | ||
import * as dotenv from "dotenv"; | ||
dotenv.config(); | ||
|
||
const username = process.env.JWTGEN_USERNAME || '[email protected]' | ||
const username = process.env.JWTGEN_USERNAME || "[email protected]" | ||
const payload = { | ||
aud: "custom_jwt", | ||
iss: "custom_jwt", | ||
iat: Math.floor(Date.now() / 1000), | ||
nbf: Math.floor(Date.now() / 1000), | ||
exp: Math.floor(Date.now() / 1000) + (3600 * 24), // Token expires after 24 hour | ||
acr: "1", | ||
aio: "AXQAi/8TAAAA", | ||
amr: ["pwd"], | ||
appid: "your-app-id", | ||
appidacr: "1", | ||
email: username, | ||
groups: ["0"], | ||
idp: "https://login.microsoftonline.com", | ||
ipaddr: "192.168.1.1", | ||
name: "Doe, John", | ||
oid: "00000000-0000-0000-0000-000000000000", | ||
rh: "rh-value", | ||
scp: "user_impersonation", | ||
sub: "subject", | ||
tid: "tenant-id", | ||
unique_name: username, | ||
uti: "uti-value", | ||
ver: "1.0" | ||
aud: "custom_jwt", | ||
iss: "custom_jwt", | ||
iat: Math.floor(Date.now() / 1000), | ||
nbf: Math.floor(Date.now() / 1000), | ||
exp: Math.floor(Date.now() / 1000) + 3600 * 24, // Token expires after 24 hour | ||
acr: "1", | ||
aio: "AXQAi/8TAAAA", | ||
amr: ["pwd"], | ||
appid: "your-app-id", | ||
appidacr: "1", | ||
email: username, | ||
groups: ["0"], | ||
idp: "https://login.microsoftonline.com", | ||
ipaddr: "192.168.1.1", | ||
name: "Doe, John", | ||
oid: "00000000-0000-0000-0000-000000000000", | ||
rh: "rh-value", | ||
scp: "user_impersonation", | ||
sub: "subject", | ||
tid: "tenant-id", | ||
unique_name: username, | ||
uti: "uti-value", | ||
ver: "1.0", | ||
}; | ||
|
||
const secretKey = process.env.JwtSigningKey; | ||
const token = jwt.sign(payload, secretKey, { algorithm: 'HS256' }); | ||
console.log(`USERNAME=${username}`) | ||
console.log('=====================') | ||
console.log(token) | ||
const token = jwt.sign(payload, secretKey, { algorithm: "HS256" }); | ||
console.log(`USERNAME=${username}`); | ||
console.log("====================="); | ||
console.log(token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Stripe from "stripe"; | ||
|
||
export type StripeLinkCreateParams = { | ||
invoiceId: string; | ||
invoiceAmountUsd: number; | ||
contactName: string; | ||
contactEmail: string; | ||
createdBy: string; | ||
stripeApiKey: string; | ||
}; | ||
|
||
/** | ||
* Create a Stripe payment link for an invoice. Note that invoiceAmountUsd MUST IN CENTS!! | ||
* @param {StripeLinkCreateParams} options | ||
* @returns {string} A stripe link that can be used to pay the invoice | ||
*/ | ||
export const createStripeLink = async ({ | ||
invoiceId, | ||
invoiceAmountUsd, | ||
contactName, | ||
contactEmail, | ||
createdBy, | ||
stripeApiKey, | ||
}: StripeLinkCreateParams): Promise<{ | ||
linkId: string; | ||
priceId: string; | ||
productId: string; | ||
url: string; | ||
}> => { | ||
const stripe = new Stripe(stripeApiKey); | ||
const description = `Created for ${contactName} (${contactEmail}) by ${createdBy}.`; | ||
const product = await stripe.products.create({ | ||
name: `Payment for Invoice: ${invoiceId}`, | ||
description, | ||
}); | ||
const price = await stripe.prices.create({ | ||
currency: "usd", | ||
unit_amount: invoiceAmountUsd, | ||
product: product.id, | ||
}); | ||
const paymentLink = await stripe.paymentLinks.create({ | ||
line_items: [ | ||
{ | ||
price: price.id, | ||
quantity: 1, | ||
}, | ||
], | ||
}); | ||
return { | ||
url: paymentLink.url, | ||
linkId: paymentLink.id, | ||
productId: product.id, | ||
priceId: price.id, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.