@stamhoofd/models 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/assets/Metropolis-Black.woff2 +0 -0
- package/dist/src/assets/Metropolis-BlackItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Bold.woff2 +0 -0
- package/dist/src/assets/Metropolis-BoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraBold.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraLight.woff2 +0 -0
- package/dist/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Light.woff2 +0 -0
- package/dist/src/assets/Metropolis-LightItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Medium.woff2 +0 -0
- package/dist/src/assets/Metropolis-MediumItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Regular.woff2 +0 -0
- package/dist/src/assets/Metropolis-RegularItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-SemiBold.woff2 +0 -0
- package/dist/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
- package/dist/src/assets/Metropolis-Thin.woff2 +0 -0
- package/dist/src/assets/Metropolis-ThinItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Black.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-BlackItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Bold.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-BoldItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-ExtraBold.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-ExtraLight.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Light.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-LightItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Medium.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-MediumItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Regular.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-RegularItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-SemiBold.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-Thin.woff2 +0 -0
- package/dist/src/assets/assets/Metropolis-ThinItalic.woff2 +0 -0
- package/dist/src/assets/assets/logo.png +0 -0
- package/dist/src/assets/logo.png +0 -0
- package/dist/src/factories/AddressFactory.d.ts +10 -0
- package/dist/src/factories/AddressFactory.d.ts.map +1 -0
- package/dist/src/factories/AddressFactory.js +42 -0
- package/dist/src/factories/AddressFactory.js.map +1 -0
- package/dist/src/factories/EmergencyContactFactory.d.ts +9 -0
- package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -0
- package/dist/src/factories/EmergencyContactFactory.js +42 -0
- package/dist/src/factories/EmergencyContactFactory.js.map +1 -0
- package/dist/src/factories/GroupFactory.d.ts +19 -0
- package/dist/src/factories/GroupFactory.d.ts.map +1 -0
- package/dist/src/factories/GroupFactory.js +52 -0
- package/dist/src/factories/GroupFactory.js.map +1 -0
- package/dist/src/factories/MemberFactory.d.ts +16 -0
- package/dist/src/factories/MemberFactory.d.ts.map +1 -0
- package/dist/src/factories/MemberFactory.js +98 -0
- package/dist/src/factories/MemberFactory.js.map +1 -0
- package/dist/src/factories/OrganizationFactory.d.ts +16 -0
- package/dist/src/factories/OrganizationFactory.d.ts.map +1 -0
- package/dist/src/factories/OrganizationFactory.js +40 -0
- package/dist/src/factories/OrganizationFactory.js.map +1 -0
- package/dist/src/factories/ParentFactory.d.ts +10 -0
- package/dist/src/factories/ParentFactory.d.ts.map +1 -0
- package/dist/src/factories/ParentFactory.js +44 -0
- package/dist/src/factories/ParentFactory.js.map +1 -0
- package/dist/src/factories/RecordFactory.d.ts +10 -0
- package/dist/src/factories/RecordFactory.d.ts.map +1 -0
- package/dist/src/factories/RecordFactory.js +14 -0
- package/dist/src/factories/RecordFactory.js.map +1 -0
- package/dist/src/factories/RegisterCodeFactory.d.ts +18 -0
- package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -0
- package/dist/src/factories/RegisterCodeFactory.js +19 -0
- package/dist/src/factories/RegisterCodeFactory.js.map +1 -0
- package/dist/src/factories/RegistrationFactory.d.ts +14 -0
- package/dist/src/factories/RegistrationFactory.d.ts.map +1 -0
- package/dist/src/factories/RegistrationFactory.js +26 -0
- package/dist/src/factories/RegistrationFactory.js.map +1 -0
- package/dist/src/factories/UserFactory.d.ts +21 -0
- package/dist/src/factories/UserFactory.d.ts.map +1 -0
- package/dist/src/factories/UserFactory.js +41 -0
- package/dist/src/factories/UserFactory.js.map +1 -0
- package/dist/src/factories/WebshopFactory.d.ts +16 -0
- package/dist/src/factories/WebshopFactory.d.ts.map +1 -0
- package/dist/src/factories/WebshopFactory.js +35 -0
- package/dist/src/factories/WebshopFactory.js.map +1 -0
- package/dist/src/helpers/DNSValidator.d.ts +6 -0
- package/dist/src/helpers/DNSValidator.d.ts.map +1 -0
- package/dist/src/helpers/DNSValidator.js +144 -0
- package/dist/src/helpers/DNSValidator.js.map +1 -0
- package/dist/src/helpers/EmailBuilder.d.ts +22 -0
- package/dist/src/helpers/EmailBuilder.d.ts.map +1 -0
- package/dist/src/helpers/EmailBuilder.js +100 -0
- package/dist/src/helpers/EmailBuilder.js.map +1 -0
- package/dist/src/helpers/GroupBuilder.d.ts +9 -0
- package/dist/src/helpers/GroupBuilder.d.ts.map +1 -0
- package/dist/src/helpers/GroupBuilder.js +382 -0
- package/dist/src/helpers/GroupBuilder.js.map +1 -0
- package/dist/src/helpers/Handlebars.d.ts +2 -0
- package/dist/src/helpers/Handlebars.d.ts.map +1 -0
- package/dist/src/helpers/Handlebars.js +192 -0
- package/dist/src/helpers/Handlebars.js.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.d.ts +29 -0
- package/dist/src/helpers/InvoiceBuilder.d.ts.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.js +406 -0
- package/dist/src/helpers/InvoiceBuilder.js.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.test.d.ts +2 -0
- package/dist/src/helpers/InvoiceBuilder.test.d.ts.map +1 -0
- package/dist/src/helpers/InvoiceBuilder.test.js +52 -0
- package/dist/src/helpers/InvoiceBuilder.test.js.map +1 -0
- package/dist/src/helpers/RateLimiter.d.ts +27 -0
- package/dist/src/helpers/RateLimiter.d.ts.map +1 -0
- package/dist/src/helpers/RateLimiter.js +57 -0
- package/dist/src/helpers/RateLimiter.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.d.ts +6 -0
- package/dist/src/helpers/WebshopCounter.d.ts.map +1 -0
- package/dist/src/helpers/WebshopCounter.js +36 -0
- package/dist/src/helpers/WebshopCounter.js.map +1 -0
- package/dist/src/helpers/WebshopCounter.test.d.ts +2 -0
- package/dist/src/helpers/WebshopCounter.test.d.ts.map +1 -0
- package/dist/src/helpers/WebshopCounter.test.js +17 -0
- package/dist/src/helpers/WebshopCounter.test.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +23 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/migrations/1593773929-create-initial-tables.sql +634 -0
- package/dist/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
- package/dist/src/migrations/1605262045-import-postcodes.d.ts +16 -0
- package/dist/src/migrations/1605262045-import-postcodes.d.ts.map +1 -0
- package/dist/src/migrations/1605262045-import-postcodes.js +116 -0
- package/dist/src/migrations/1605262045-import-postcodes.js.map +1 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts +4 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.d.ts.map +1 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.js +83 -0
- package/dist/src/migrations/1605262046-import-postcodes-nl.js.map +1 -0
- package/dist/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
- package/dist/src/migrations/1648392491-default-templates.sql +9 -0
- package/dist/src/migrations/1651245707-default-templates-reminders.sql +6 -0
- package/dist/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
- package/dist/src/migrations/1710459176-register-code-invoices.sql +3 -0
- package/dist/src/migrations/1712158247-discount-codes.sql +17 -0
- package/dist/src/migrations/1713178665-drop-invites.sql +1 -0
- package/dist/src/migrations/1713178666-drop-keychain.sql +1 -0
- package/dist/src/migrations/1713178667-drop-challenges.sql +1 -0
- package/dist/src/migrations/1713178668-drop-user-keys.sql +7 -0
- package/dist/src/migrations/1713178669-drop-organization-key.sql +2 -0
- package/dist/src/migrations/data/postcodes/nl/Drenthe +291 -0
- package/dist/src/migrations/data/postcodes/nl/Flevoland +107 -0
- package/dist/src/migrations/data/postcodes/nl/Friesland +518 -0
- package/dist/src/migrations/data/postcodes/nl/Gelderland +601 -0
- package/dist/src/migrations/data/postcodes/nl/Groningen +279 -0
- package/dist/src/migrations/data/postcodes/nl/Limburg +324 -0
- package/dist/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
- package/dist/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
- package/dist/src/migrations/data/postcodes/nl/Overrijsel +344 -0
- package/dist/src/migrations/data/postcodes/nl/Utrecht +278 -0
- package/dist/src/migrations/data/postcodes/nl/Zeeland +179 -0
- package/dist/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
- package/dist/src/models/BalanceItem.d.ts +57 -0
- package/dist/src/models/BalanceItem.d.ts.map +1 -0
- package/dist/src/models/BalanceItem.js +346 -0
- package/dist/src/models/BalanceItem.js.map +1 -0
- package/dist/src/models/BalanceItemPayment.d.ts +31 -0
- package/dist/src/models/BalanceItemPayment.d.ts.map +1 -0
- package/dist/src/models/BalanceItemPayment.js +101 -0
- package/dist/src/models/BalanceItemPayment.js.map +1 -0
- package/dist/src/models/BuckarooPayment.d.ts +8 -0
- package/dist/src/models/BuckarooPayment.d.ts.map +1 -0
- package/dist/src/models/BuckarooPayment.js +24 -0
- package/dist/src/models/BuckarooPayment.js.map +1 -0
- package/dist/src/models/Document.d.ts +44 -0
- package/dist/src/models/Document.d.ts.map +1 -0
- package/dist/src/models/Document.js +194 -0
- package/dist/src/models/Document.js.map +1 -0
- package/dist/src/models/DocumentTemplate.d.ts +45 -0
- package/dist/src/models/DocumentTemplate.d.ts.map +1 -0
- package/dist/src/models/DocumentTemplate.js +533 -0
- package/dist/src/models/DocumentTemplate.js.map +1 -0
- package/dist/src/models/EmailTemplate.d.ts +22 -0
- package/dist/src/models/EmailTemplate.d.ts.map +1 -0
- package/dist/src/models/EmailTemplate.js +70 -0
- package/dist/src/models/EmailTemplate.js.map +1 -0
- package/dist/src/models/EmailVerificationCode.d.ts +60 -0
- package/dist/src/models/EmailVerificationCode.d.ts.map +1 -0
- package/dist/src/models/EmailVerificationCode.js +307 -0
- package/dist/src/models/EmailVerificationCode.js.map +1 -0
- package/dist/src/models/Group.d.ts +36 -0
- package/dist/src/models/Group.d.ts.map +1 -0
- package/dist/src/models/Group.js +231 -0
- package/dist/src/models/Group.js.map +1 -0
- package/dist/src/models/Image.d.ts +12 -0
- package/dist/src/models/Image.d.ts.map +1 -0
- package/dist/src/models/Image.js +137 -0
- package/dist/src/models/Image.js.map +1 -0
- package/dist/src/models/Member.d.ts +66 -0
- package/dist/src/models/Member.d.ts.map +1 -0
- package/dist/src/models/Member.js +309 -0
- package/dist/src/models/Member.js.map +1 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts +11 -0
- package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -0
- package/dist/src/models/MemberResponsibilityRecord.js +47 -0
- package/dist/src/models/MemberResponsibilityRecord.js.map +1 -0
- package/dist/src/models/MolliePayment.d.ts +8 -0
- package/dist/src/models/MolliePayment.d.ts.map +1 -0
- package/dist/src/models/MolliePayment.js +24 -0
- package/dist/src/models/MolliePayment.js.map +1 -0
- package/dist/src/models/MollieToken.d.ts +45 -0
- package/dist/src/models/MollieToken.d.ts.map +1 -0
- package/dist/src/models/MollieToken.js +333 -0
- package/dist/src/models/MollieToken.js.map +1 -0
- package/dist/src/models/OneTimeToken.d.ts +38 -0
- package/dist/src/models/OneTimeToken.d.ts.map +1 -0
- package/dist/src/models/OneTimeToken.js +126 -0
- package/dist/src/models/OneTimeToken.js.map +1 -0
- package/dist/src/models/Order.d.ts +99 -0
- package/dist/src/models/Order.d.ts.map +1 -0
- package/dist/src/models/Order.js +912 -0
- package/dist/src/models/Order.js.map +1 -0
- package/dist/src/models/Organization.d.ts +119 -0
- package/dist/src/models/Organization.d.ts.map +1 -0
- package/dist/src/models/Organization.js +900 -0
- package/dist/src/models/Organization.js.map +1 -0
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts +14 -0
- package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -0
- package/dist/src/models/OrganizationRegistrationPeriod.js +62 -0
- package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -0
- package/dist/src/models/PasswordToken.d.ts +29 -0
- package/dist/src/models/PasswordToken.d.ts.map +1 -0
- package/dist/src/models/PasswordToken.js +118 -0
- package/dist/src/models/PasswordToken.js.map +1 -0
- package/dist/src/models/PayconiqPayment.d.ts +18 -0
- package/dist/src/models/PayconiqPayment.d.ts.map +1 -0
- package/dist/src/models/PayconiqPayment.js +216 -0
- package/dist/src/models/PayconiqPayment.js.map +1 -0
- package/dist/src/models/Payment.d.ts +62 -0
- package/dist/src/models/Payment.d.ts.map +1 -0
- package/dist/src/models/Payment.js +199 -0
- package/dist/src/models/Payment.js.map +1 -0
- package/dist/src/models/Platform.d.ts +15 -0
- package/dist/src/models/Platform.d.ts.map +1 -0
- package/dist/src/models/Platform.js +77 -0
- package/dist/src/models/Platform.js.map +1 -0
- package/dist/src/models/RegisterCode.d.ts +27 -0
- package/dist/src/models/RegisterCode.d.ts.map +1 -0
- package/dist/src/models/RegisterCode.js +162 -0
- package/dist/src/models/RegisterCode.js.map +1 -0
- package/dist/src/models/Registration.d.ts +47 -0
- package/dist/src/models/Registration.d.ts.map +1 -0
- package/dist/src/models/Registration.js +369 -0
- package/dist/src/models/Registration.js.map +1 -0
- package/dist/src/models/RegistrationPeriod.d.ts +15 -0
- package/dist/src/models/RegistrationPeriod.d.ts.map +1 -0
- package/dist/src/models/RegistrationPeriod.js +64 -0
- package/dist/src/models/RegistrationPeriod.js.map +1 -0
- package/dist/src/models/STCredit.d.ts +20 -0
- package/dist/src/models/STCredit.d.ts.map +1 -0
- package/dist/src/models/STCredit.js +129 -0
- package/dist/src/models/STCredit.js.map +1 -0
- package/dist/src/models/STInvoice.d.ts +51 -0
- package/dist/src/models/STInvoice.d.ts.map +1 -0
- package/dist/src/models/STInvoice.js +453 -0
- package/dist/src/models/STInvoice.js.map +1 -0
- package/dist/src/models/STPackage.d.ts +36 -0
- package/dist/src/models/STPackage.d.ts.map +1 -0
- package/dist/src/models/STPackage.js +300 -0
- package/dist/src/models/STPackage.js.map +1 -0
- package/dist/src/models/STPendingInvoice.d.ts +45 -0
- package/dist/src/models/STPendingInvoice.d.ts.map +1 -0
- package/dist/src/models/STPendingInvoice.js +284 -0
- package/dist/src/models/STPendingInvoice.js.map +1 -0
- package/dist/src/models/StripeAccount.d.ts +17 -0
- package/dist/src/models/StripeAccount.d.ts.map +1 -0
- package/dist/src/models/StripeAccount.js +81 -0
- package/dist/src/models/StripeAccount.js.map +1 -0
- package/dist/src/models/StripeCheckoutSession.d.ts +9 -0
- package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -0
- package/dist/src/models/StripeCheckoutSession.js +31 -0
- package/dist/src/models/StripeCheckoutSession.js.map +1 -0
- package/dist/src/models/StripePaymentIntent.d.ts +9 -0
- package/dist/src/models/StripePaymentIntent.d.ts.map +1 -0
- package/dist/src/models/StripePaymentIntent.js +31 -0
- package/dist/src/models/StripePaymentIntent.js.map +1 -0
- package/dist/src/models/Ticket.d.ts +61 -0
- package/dist/src/models/Ticket.d.ts.map +1 -0
- package/dist/src/models/Ticket.js +143 -0
- package/dist/src/models/Ticket.js.map +1 -0
- package/dist/src/models/Token.d.ts +49 -0
- package/dist/src/models/Token.d.ts.map +1 -0
- package/dist/src/models/Token.js +218 -0
- package/dist/src/models/Token.js.map +1 -0
- package/dist/src/models/Token.test.d.ts +2 -0
- package/dist/src/models/Token.test.d.ts.map +1 -0
- package/dist/src/models/Token.test.js +60 -0
- package/dist/src/models/Token.test.js.map +1 -0
- package/dist/src/models/UsedRegisterCode.d.ts +22 -0
- package/dist/src/models/UsedRegisterCode.d.ts.map +1 -0
- package/dist/src/models/UsedRegisterCode.js +158 -0
- package/dist/src/models/UsedRegisterCode.js.map +1 -0
- package/dist/src/models/User.d.ts +55 -0
- package/dist/src/models/User.d.ts.map +1 -0
- package/dist/src/models/User.js +314 -0
- package/dist/src/models/User.js.map +1 -0
- package/dist/src/models/UserPermissions.d.ts +15 -0
- package/dist/src/models/UserPermissions.d.ts.map +1 -0
- package/dist/src/models/UserPermissions.js +57 -0
- package/dist/src/models/UserPermissions.js.map +1 -0
- package/dist/src/models/Webshop.d.ts +44 -0
- package/dist/src/models/Webshop.d.ts.map +1 -0
- package/dist/src/models/Webshop.js +184 -0
- package/dist/src/models/Webshop.js.map +1 -0
- package/dist/src/models/WebshopDiscountCode.d.ts +18 -0
- package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -0
- package/dist/src/models/WebshopDiscountCode.js +88 -0
- package/dist/src/models/WebshopDiscountCode.js.map +1 -0
- package/dist/src/models/addresses/City.d.ts +14 -0
- package/dist/src/models/addresses/City.d.ts.map +1 -0
- package/dist/src/models/addresses/City.js +37 -0
- package/dist/src/models/addresses/City.js.map +1 -0
- package/dist/src/models/addresses/PostalCode.d.ts +20 -0
- package/dist/src/models/addresses/PostalCode.d.ts.map +1 -0
- package/dist/src/models/addresses/PostalCode.js +138 -0
- package/dist/src/models/addresses/PostalCode.js.map +1 -0
- package/dist/src/models/addresses/PostalCode.test.d.ts +2 -0
- package/dist/src/models/addresses/PostalCode.test.d.ts.map +1 -0
- package/dist/src/models/addresses/PostalCode.test.js +98 -0
- package/dist/src/models/addresses/PostalCode.test.js.map +1 -0
- package/dist/src/models/addresses/Province.d.ts +9 -0
- package/dist/src/models/addresses/Province.d.ts.map +1 -0
- package/dist/src/models/addresses/Province.js +24 -0
- package/dist/src/models/addresses/Province.js.map +1 -0
- package/dist/src/models/addresses/Street.d.ts +10 -0
- package/dist/src/models/addresses/Street.d.ts.map +1 -0
- package/dist/src/models/addresses/Street.js +26 -0
- package/dist/src/models/addresses/Street.js.map +1 -0
- package/dist/src/models/index.d.ts +37 -0
- package/dist/src/models/index.d.ts.map +1 -0
- package/dist/src/models/index.js +53 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/structures/OrganizationServerMetaData.d.ts +43 -0
- package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -0
- package/dist/src/structures/OrganizationServerMetaData.js +128 -0
- package/dist/src/structures/OrganizationServerMetaData.js.map +1 -0
- package/dist/tests/jest.global.setup.d.ts +3 -0
- package/dist/tests/jest.global.setup.d.ts.map +1 -0
- package/dist/tests/jest.global.setup.js +20 -0
- package/dist/tests/jest.global.setup.js.map +1 -0
- package/dist/tests/jest.setup.d.ts +2 -0
- package/dist/tests/jest.setup.d.ts.map +1 -0
- package/dist/tests/jest.setup.js +15 -0
- package/dist/tests/jest.setup.js.map +1 -0
- package/package.json +30 -0
- package/src/assets/Metropolis-Black.woff2 +0 -0
- package/src/assets/Metropolis-BlackItalic.woff2 +0 -0
- package/src/assets/Metropolis-Bold.woff2 +0 -0
- package/src/assets/Metropolis-BoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-ExtraBold.woff2 +0 -0
- package/src/assets/Metropolis-ExtraBoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-ExtraLight.woff2 +0 -0
- package/src/assets/Metropolis-ExtraLightItalic.woff2 +0 -0
- package/src/assets/Metropolis-Light.woff2 +0 -0
- package/src/assets/Metropolis-LightItalic.woff2 +0 -0
- package/src/assets/Metropolis-Medium.woff2 +0 -0
- package/src/assets/Metropolis-MediumItalic.woff2 +0 -0
- package/src/assets/Metropolis-Regular.woff2 +0 -0
- package/src/assets/Metropolis-RegularItalic.woff2 +0 -0
- package/src/assets/Metropolis-SemiBold.woff2 +0 -0
- package/src/assets/Metropolis-SemiBoldItalic.woff2 +0 -0
- package/src/assets/Metropolis-Thin.woff2 +0 -0
- package/src/assets/Metropolis-ThinItalic.woff2 +0 -0
- package/src/assets/logo.png +0 -0
- package/src/factories/AddressFactory.ts +42 -0
- package/src/factories/EmergencyContactFactory.ts +43 -0
- package/src/factories/GroupFactory.ts +66 -0
- package/src/factories/MemberFactory.ts +122 -0
- package/src/factories/OrganizationFactory.ts +45 -0
- package/src/factories/ParentFactory.ts +49 -0
- package/src/factories/RecordFactory.ts +12 -0
- package/src/factories/RegisterCodeFactory.ts +25 -0
- package/src/factories/RegistrationFactory.ts +32 -0
- package/src/factories/UserFactory.ts +66 -0
- package/src/factories/WebshopFactory.ts +43 -0
- package/src/helpers/DNSValidator.ts +153 -0
- package/src/helpers/EmailBuilder.ts +127 -0
- package/src/helpers/GroupBuilder.ts +438 -0
- package/src/helpers/Handlebars.ts +203 -0
- package/src/helpers/InvoiceBuilder.test.ts +57 -0
- package/src/helpers/InvoiceBuilder.ts +501 -0
- package/src/helpers/RateLimiter.ts +75 -0
- package/src/helpers/WebshopCounter.test.ts +16 -0
- package/src/helpers/WebshopCounter.ts +36 -0
- package/src/index.ts +21 -0
- package/src/migrations/1593773929-create-initial-tables.sql +634 -0
- package/src/migrations/1605261999-gemeenten-tmp.sql +2820 -0
- package/src/migrations/1605262045-import-postcodes.ts +132 -0
- package/src/migrations/1605262046-import-postcodes-nl.ts +97 -0
- package/src/migrations/1605279038-drop-gemeenten-tmp.sql +1 -0
- package/src/migrations/1648392491-default-templates.sql +9 -0
- package/src/migrations/1651245707-default-templates-reminders.sql +6 -0
- package/src/migrations/1708607340-tickets-deleted-at.sql +1 -0
- package/src/migrations/1710459176-register-code-invoices.sql +3 -0
- package/src/migrations/1712158247-discount-codes.sql +17 -0
- package/src/migrations/1713178665-drop-invites.sql +1 -0
- package/src/migrations/1713178666-drop-keychain.sql +1 -0
- package/src/migrations/1713178667-drop-challenges.sql +1 -0
- package/src/migrations/1713178668-drop-user-keys.sql +7 -0
- package/src/migrations/1713178669-drop-organization-key.sql +2 -0
- package/src/migrations/1714985451-user-nullable-organization-id.sql +2 -0
- package/src/migrations/1714985452-email-verification-code-nullable-organization-id.sql +2 -0
- package/src/migrations/1714985453-user-organization-permissions.sql +2 -0
- package/src/migrations/1714985454-user-organization-permissions.sql +2 -0
- package/src/migrations/1715079362-platform.sql +6 -0
- package/src/migrations/1715181649-registrations-organization-id.sql +2 -0
- package/src/migrations/1715181650-registrations-organization-id-fill.sql +1 -0
- package/src/migrations/1715181651-registrations-organization-id-drop-null.sql +2 -0
- package/src/migrations/1716117067-members-nullable-organization-id.sql +2 -0
- package/src/migrations/1719567581-registration-periods.sql +13 -0
- package/src/migrations/1719567582-organization-registration-periods.sql +13 -0
- package/src/migrations/1719567881-organization-periodId.sql +2 -0
- package/src/migrations/1719567882-groups-periodId.sql +2 -0
- package/src/migrations/1719567883-platform-periodId.sql +2 -0
- package/src/migrations/1719568079-default-period.sql +2 -0
- package/src/migrations/1719568080-set-default-period-platform.sql +1 -0
- package/src/migrations/1719568081-set-default-period-organizations.sql +1 -0
- package/src/migrations/1719568082-set-default-period-groups.sql +1 -0
- package/src/migrations/1719580828-registrations-periodId.sql +2 -0
- package/src/migrations/1719580829-set-default-period-registrations.sql +1 -0
- package/src/migrations/data/postcodes/nl/Drenthe +291 -0
- package/src/migrations/data/postcodes/nl/Flevoland +107 -0
- package/src/migrations/data/postcodes/nl/Friesland +518 -0
- package/src/migrations/data/postcodes/nl/Gelderland +601 -0
- package/src/migrations/data/postcodes/nl/Groningen +279 -0
- package/src/migrations/data/postcodes/nl/Limburg +324 -0
- package/src/migrations/data/postcodes/nl/Noord-Brabant +620 -0
- package/src/migrations/data/postcodes/nl/Noord-Holland +566 -0
- package/src/migrations/data/postcodes/nl/Overrijsel +344 -0
- package/src/migrations/data/postcodes/nl/Utrecht +278 -0
- package/src/migrations/data/postcodes/nl/Zeeland +179 -0
- package/src/migrations/data/postcodes/nl/Zuid-Holland +662 -0
- package/src/models/BalanceItem.ts +392 -0
- package/src/models/BalanceItemPayment.ts +106 -0
- package/src/models/BuckarooPayment.ts +19 -0
- package/src/models/Document.ts +203 -0
- package/src/models/DocumentTemplate.ts +583 -0
- package/src/models/EmailTemplate.ts +64 -0
- package/src/models/EmailVerificationCode.ts +352 -0
- package/src/models/Group.ts +293 -0
- package/src/models/Image.ts +147 -0
- package/src/models/Member.ts +386 -0
- package/src/models/MemberResponsibilityRecord.ts +39 -0
- package/src/models/MolliePayment.ts +19 -0
- package/src/models/MollieToken.ts +369 -0
- package/src/models/OneTimeToken.ts +131 -0
- package/src/models/Order.ts +1030 -0
- package/src/models/Organization.ts +1085 -0
- package/src/models/OrganizationRegistrationPeriod.ts +54 -0
- package/src/models/PasswordToken.ts +139 -0
- package/src/models/PayconiqPayment.ts +241 -0
- package/src/models/Payment.ts +216 -0
- package/src/models/Platform.ts +76 -0
- package/src/models/RegisterCode.ts +164 -0
- package/src/models/Registration.ts +405 -0
- package/src/models/RegistrationPeriod.ts +55 -0
- package/src/models/STCredit.ts +134 -0
- package/src/models/STInvoice.ts +507 -0
- package/src/models/STPackage.ts +324 -0
- package/src/models/STPendingInvoice.ts +308 -0
- package/src/models/StripeAccount.ts +71 -0
- package/src/models/StripeCheckoutSession.ts +22 -0
- package/src/models/StripePaymentIntent.ts +22 -0
- package/src/models/Ticket.ts +145 -0
- package/src/models/Token.test.ts +69 -0
- package/src/models/Token.ts +269 -0
- package/src/models/UsedRegisterCode.ts +166 -0
- package/src/models/User.ts +445 -0
- package/src/models/UserPermissions.ts +54 -0
- package/src/models/Webshop.ts +206 -0
- package/src/models/WebshopDiscountCode.ts +81 -0
- package/src/models/addresses/City.ts +31 -0
- package/src/models/addresses/PostalCode.test.ts +117 -0
- package/src/models/addresses/PostalCode.ts +164 -0
- package/src/models/addresses/Province.ts +20 -0
- package/src/models/addresses/Street.ts +25 -0
- package/src/models/index.ts +49 -0
- package/src/structures/OrganizationServerMetaData.ts +117 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { column,Model } from '@simonbackx/simple-database';
|
|
2
|
+
import { PartialWithoutMethods, PlainObject } from '@simonbackx/simple-encoding';
|
|
3
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
4
|
+
import { MollieOnboarding,MollieProfile, MollieStatus } from '@stamhoofd/structures';
|
|
5
|
+
import { IncomingMessage } from "http";
|
|
6
|
+
import https from "https";
|
|
7
|
+
|
|
8
|
+
import { Organization } from './Organization';
|
|
9
|
+
|
|
10
|
+
function sleep(ms: number) {
|
|
11
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class MollieToken extends Model {
|
|
15
|
+
static table = "mollie_tokens"
|
|
16
|
+
|
|
17
|
+
@column({ primary: true, type: "string" })
|
|
18
|
+
organizationId!: string;
|
|
19
|
+
|
|
20
|
+
@column({ type: "string" })
|
|
21
|
+
accessToken: string;
|
|
22
|
+
|
|
23
|
+
@column({ type: "string" })
|
|
24
|
+
refreshToken: string;
|
|
25
|
+
|
|
26
|
+
@column({ type: "datetime" })
|
|
27
|
+
expiresOn: Date;
|
|
28
|
+
|
|
29
|
+
@column({
|
|
30
|
+
type: "datetime", beforeSave(old?: any) {
|
|
31
|
+
if (old !== undefined) {
|
|
32
|
+
return old;
|
|
33
|
+
}
|
|
34
|
+
const date = new Date()
|
|
35
|
+
date.setMilliseconds(0)
|
|
36
|
+
return date
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
createdAt: Date
|
|
40
|
+
|
|
41
|
+
static verbose = true
|
|
42
|
+
|
|
43
|
+
static knownTokens: Map<string, MollieToken> = new Map()
|
|
44
|
+
|
|
45
|
+
static async getTokenFor(organizationId: string) {
|
|
46
|
+
const existing = this.knownTokens.get(organizationId)
|
|
47
|
+
if (existing) {
|
|
48
|
+
return existing
|
|
49
|
+
}
|
|
50
|
+
const tokens = await MollieToken.where({ organizationId })
|
|
51
|
+
if (tokens.length == 0) {
|
|
52
|
+
return undefined
|
|
53
|
+
}
|
|
54
|
+
this.knownTokens.set(organizationId, tokens[0])
|
|
55
|
+
return tokens[0]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async delete() {
|
|
59
|
+
await super.delete()
|
|
60
|
+
MollieToken.knownTokens.delete(this.organizationId)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private static objectToQueryString(obj: Record<string, string>) {
|
|
64
|
+
const str: string[] = [];
|
|
65
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
66
|
+
for (const p in obj)
|
|
67
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
68
|
+
if (obj.hasOwnProperty(p)) {
|
|
69
|
+
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
|
70
|
+
}
|
|
71
|
+
return str.join("&");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getAccessToken() {
|
|
75
|
+
if (this.expiresOn < new Date()) {
|
|
76
|
+
await this.refresh()
|
|
77
|
+
await sleep(200)
|
|
78
|
+
}
|
|
79
|
+
return this.accessToken
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async refreshIfNeeded() {
|
|
83
|
+
if (this.expiresOn < new Date()) {
|
|
84
|
+
await this.refresh()
|
|
85
|
+
await sleep(200)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async authRequest(method: string, path: string, data: PlainObject = {}) {
|
|
90
|
+
if (this.expiresOn < new Date()) {
|
|
91
|
+
await this.refresh()
|
|
92
|
+
await sleep(200)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return await MollieToken.request(method, path, data, "json", this.accessToken);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Do a post request on the API.
|
|
100
|
+
*/
|
|
101
|
+
private static request(method: string, path: string, data: PlainObject = {}, type = "json", auth: string | null = null): Promise<any> {
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
let jsonData: string;
|
|
104
|
+
if (type == "json") {
|
|
105
|
+
jsonData = JSON.stringify(data);
|
|
106
|
+
} else {
|
|
107
|
+
jsonData = this.objectToQueryString(data as Record<string, string>);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.verbose) {
|
|
111
|
+
console.log(method+" https://api.mollie.com"+path+"\n"+jsonData);
|
|
112
|
+
}
|
|
113
|
+
const req = https.request(
|
|
114
|
+
{
|
|
115
|
+
hostname: "api.mollie.com",
|
|
116
|
+
path: path,
|
|
117
|
+
method: method,
|
|
118
|
+
headers: method === 'GET' ?
|
|
119
|
+
{
|
|
120
|
+
"Authorization": auth ? "Bearer "+auth : "Basic "+Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? "")+":"+(STAMHOOFD.MOLLIE_SECRET ?? ""), "ascii").toString("base64")
|
|
121
|
+
} : {
|
|
122
|
+
"Content-Type": type == "json" ? "application/json" : "application/x-www-form-urlencoded",
|
|
123
|
+
"Content-Length": Buffer.byteLength(jsonData),
|
|
124
|
+
"Authorization": auth ? "Bearer "+auth : "Basic "+Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? "")+":"+(STAMHOOFD.MOLLIE_SECRET ?? ""), "ascii").toString("base64")
|
|
125
|
+
},
|
|
126
|
+
timeout: 10000,
|
|
127
|
+
},
|
|
128
|
+
(response: IncomingMessage) => {
|
|
129
|
+
if (this.verbose) {
|
|
130
|
+
console.log(`statusCode: ${response.statusCode ?? '/'}`);
|
|
131
|
+
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const chunks: any[] = [];
|
|
135
|
+
|
|
136
|
+
response.on("data", (chunk) => {
|
|
137
|
+
chunks.push(chunk);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
response.on("end", () => {
|
|
141
|
+
try {
|
|
142
|
+
if (!response.statusCode) {
|
|
143
|
+
reject(new Error("Unexpected order of events"));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const body = Buffer.concat(chunks).toString();
|
|
147
|
+
|
|
148
|
+
if (this.verbose) {
|
|
149
|
+
console.log(body);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (response.statusCode == 204) {
|
|
153
|
+
resolve(undefined);
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
let json: any;
|
|
158
|
+
try {
|
|
159
|
+
json = JSON.parse(body);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error(error);
|
|
162
|
+
|
|
163
|
+
// invalid json
|
|
164
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
165
|
+
if (body.length == 0) {
|
|
166
|
+
console.error(response.statusCode);
|
|
167
|
+
reject(new Error("Status " + response.statusCode));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.error(response.statusCode + " " + body);
|
|
171
|
+
reject(new Error(body));
|
|
172
|
+
return;
|
|
173
|
+
} else {
|
|
174
|
+
// something wrong: throw parse error
|
|
175
|
+
reject(error);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
181
|
+
console.error(body);
|
|
182
|
+
reject(new Error(response.statusCode + " " + response.statusMessage));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
resolve(json);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (this.verbose) {
|
|
189
|
+
console.error(error);
|
|
190
|
+
}
|
|
191
|
+
reject(error);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
// use its "timeout" event to abort the request
|
|
198
|
+
req.on("timeout", () => {
|
|
199
|
+
req.abort();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
req.on("error", (error) => {
|
|
203
|
+
if (this.verbose) {
|
|
204
|
+
console.error(error);
|
|
205
|
+
}
|
|
206
|
+
reject(error);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
if (method !== 'GET') {
|
|
210
|
+
req.write(jsonData);
|
|
211
|
+
}
|
|
212
|
+
req.end();
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Refresh the token itself, without generating a new token. Everyone who had the token has a new token now
|
|
218
|
+
*/
|
|
219
|
+
async refresh(): Promise<void> {
|
|
220
|
+
const data = await MollieToken.request("POST", "/oauth2/tokens", {
|
|
221
|
+
grant_type: "refresh_token",
|
|
222
|
+
refresh_token: this.refreshToken,
|
|
223
|
+
}, "urlencoded")
|
|
224
|
+
|
|
225
|
+
if (data && data.access_token && data.refresh_token) {
|
|
226
|
+
// Delete token if exisitng
|
|
227
|
+
this.refreshToken = data.refresh_token
|
|
228
|
+
this.accessToken = data.access_token
|
|
229
|
+
this.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60*1000)
|
|
230
|
+
await this.save()
|
|
231
|
+
|
|
232
|
+
// Update shared tokens if this object was fetched directly
|
|
233
|
+
MollieToken.knownTokens.set(this.organizationId, this)
|
|
234
|
+
return
|
|
235
|
+
}
|
|
236
|
+
throw new SimpleError({ code: "", message: "Something went wrong in the response"})
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Refresh the token itself, without generating a new token. Everyone who had the token has a new token now
|
|
242
|
+
*/
|
|
243
|
+
async revoke(): Promise<void> {
|
|
244
|
+
try {
|
|
245
|
+
await MollieToken.request("DELETE", "/oauth2/tokens", {
|
|
246
|
+
token_type_hint: "refresh_token",
|
|
247
|
+
token: this.refreshToken,
|
|
248
|
+
}, "urlencoded")
|
|
249
|
+
} catch (e) {
|
|
250
|
+
console.error("Failed to revoke token", this.organizationId, e)
|
|
251
|
+
}
|
|
252
|
+
await this.delete()
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Refresh the token itself, without generating a new token. Everyone who had the token has a new token now
|
|
257
|
+
*/
|
|
258
|
+
static async create(organization: Organization, code: string): Promise<MollieToken> {
|
|
259
|
+
const data = await MollieToken.request("POST", "/oauth2/tokens", {
|
|
260
|
+
grant_type: "authorization_code",
|
|
261
|
+
code: code
|
|
262
|
+
}, "urlencoded")
|
|
263
|
+
|
|
264
|
+
if (data && data.access_token && data.refresh_token) {
|
|
265
|
+
// Delete token if exisitng
|
|
266
|
+
const existing = await MollieToken.where({ organizationId: organization.id })
|
|
267
|
+
const token = existing[0] ?? new MollieToken()
|
|
268
|
+
token.organizationId = organization.id
|
|
269
|
+
token.refreshToken = data.refresh_token
|
|
270
|
+
token.accessToken = data.access_token
|
|
271
|
+
token.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60*1000)
|
|
272
|
+
await token.save()
|
|
273
|
+
|
|
274
|
+
this.knownTokens.set(organization.id, token)
|
|
275
|
+
|
|
276
|
+
organization.privateMeta.mollieOnboarding = await token.getOnboardingStatus()
|
|
277
|
+
await token.setup(organization)
|
|
278
|
+
|
|
279
|
+
await organization.save()
|
|
280
|
+
return token
|
|
281
|
+
}
|
|
282
|
+
throw new SimpleError({ code: "", message: "Something went wrong in the response"})
|
|
283
|
+
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async getOnboardingStatus() {
|
|
287
|
+
try {
|
|
288
|
+
const response = await this.authRequest("GET", "/v2/onboarding/me")
|
|
289
|
+
return MollieOnboarding.create({
|
|
290
|
+
canReceivePayments: !!response.canReceivePayments,
|
|
291
|
+
canReceiveSettlements: !!response.canReceiveSettlements,
|
|
292
|
+
status: response.status === "needs-data" ? MollieStatus.NeedsData : (response.status === "in-review" ? MollieStatus.InReview : (MollieStatus.Completed))
|
|
293
|
+
});
|
|
294
|
+
} catch (e) {
|
|
295
|
+
console.error("Error when requesting Mollie onboarding status:")
|
|
296
|
+
console.error(e)
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async getProfiles(): Promise<MollieProfile[]> {
|
|
302
|
+
try {
|
|
303
|
+
const response = await this.authRequest("GET", "/v2/profiles?limit=250")
|
|
304
|
+
const profiles = response._embedded.profiles as PartialWithoutMethods<MollieProfile>[];
|
|
305
|
+
return profiles.map(p => MollieProfile.create(p))
|
|
306
|
+
} catch(e) {
|
|
307
|
+
console.error('Failed to parse mollie profiles', e)
|
|
308
|
+
return [];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async getProfileId(website?: string): Promise<string | null> {
|
|
313
|
+
const response = await this.authRequest("GET", "/v2/profiles?limit=250")
|
|
314
|
+
const profiles = response._embedded.profiles;
|
|
315
|
+
|
|
316
|
+
// Search profile with Stamhoofd as name
|
|
317
|
+
if (website) {
|
|
318
|
+
for (const profile of profiles) {
|
|
319
|
+
if (profile.website.toLowerCase().includes(website)) {
|
|
320
|
+
return profile.id
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Search profile with Stamhoofd as name
|
|
326
|
+
for (const profile of profiles) {
|
|
327
|
+
if (profile.name.toLowerCase().includes("stamhoofd")) {
|
|
328
|
+
return profile.id
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return response._embedded.profiles[0]?.id ?? null
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
async getOnboardingLink() {
|
|
337
|
+
const response = await this.authRequest("GET", "/v2/onboarding/me")
|
|
338
|
+
return response._links.dashboard.href ?? ""
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Set initial onboarding values + enable bancontact
|
|
343
|
+
*/
|
|
344
|
+
async setup(organization: Organization) {
|
|
345
|
+
// Submit onboarding data
|
|
346
|
+
|
|
347
|
+
if (organization.privateMeta.mollieOnboarding && organization.privateMeta.mollieOnboarding.status == MollieStatus.NeedsData) {
|
|
348
|
+
await this.authRequest("POST", "/v2/onboarding/me", {
|
|
349
|
+
organization: {
|
|
350
|
+
name: organization.name,
|
|
351
|
+
address: {
|
|
352
|
+
streetAndNumber: organization.address.street + " "+organization.address.number,
|
|
353
|
+
postalCode: organization.address.postalCode,
|
|
354
|
+
city: organization.address.city,
|
|
355
|
+
country: organization.address.country,
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
vatRegulation: "shifted"
|
|
359
|
+
},
|
|
360
|
+
profile: {
|
|
361
|
+
name: organization.name+" - Stamhoofd",
|
|
362
|
+
//url: "https://"+organization.getHost(),
|
|
363
|
+
description: "Betalen van inschrijvingsgelden of webshops voor een vereniging via Stamhoofd (partner).",
|
|
364
|
+
categoryCode: 8398
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
|
|
2
|
+
import { column, Model } from "@simonbackx/simple-database";
|
|
3
|
+
import { AnyDecoder } from "@simonbackx/simple-encoding";
|
|
4
|
+
import basex from "base-x";
|
|
5
|
+
import crypto from "crypto";
|
|
6
|
+
|
|
7
|
+
import { Organization } from "./Organization";
|
|
8
|
+
|
|
9
|
+
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
|
10
|
+
const bs58 = basex(ALPHABET)
|
|
11
|
+
|
|
12
|
+
async function randomBytes(size: number): Promise<Buffer> {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
crypto.randomBytes(size, (err: Error | null, buf: Buffer) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
reject(err);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
resolve(buf);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enum OneTimeTokenType {
|
|
25
|
+
WebshopNotificationEmailVerification = "WebshopNotificationEmailVerification",
|
|
26
|
+
WebshopNotificationEmailUnsubscribe = "WebshopNotificationEmailUnsubscribe"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Token that saves some information and can execute an action if you have access to the token (e.g. in an email)
|
|
31
|
+
*/
|
|
32
|
+
export class OneTimeToken extends Model {
|
|
33
|
+
static table = "one_time_tokens";
|
|
34
|
+
|
|
35
|
+
// Columns
|
|
36
|
+
@column({ primary: true, type: "string" })
|
|
37
|
+
token: string;
|
|
38
|
+
|
|
39
|
+
@column({ type: "string" })
|
|
40
|
+
organizationId: string;
|
|
41
|
+
|
|
42
|
+
@column({ type: "datetime", nullable: true })
|
|
43
|
+
validUntil: Date | null = null;
|
|
44
|
+
|
|
45
|
+
@column({
|
|
46
|
+
type: "datetime", beforeSave(old?: any) {
|
|
47
|
+
if (old !== undefined) {
|
|
48
|
+
return old;
|
|
49
|
+
}
|
|
50
|
+
const date = new Date()
|
|
51
|
+
date.setMilliseconds(0)
|
|
52
|
+
return date
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
createdAt: Date
|
|
56
|
+
|
|
57
|
+
// Columns
|
|
58
|
+
@column({ type: "string" })
|
|
59
|
+
type: OneTimeTokenType
|
|
60
|
+
|
|
61
|
+
// Columns
|
|
62
|
+
@column({ type: "json", decoder: AnyDecoder })
|
|
63
|
+
data: any = {};
|
|
64
|
+
|
|
65
|
+
isExpired(): boolean {
|
|
66
|
+
return !!this.validUntil && this.validUntil < new Date()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get a token
|
|
71
|
+
* @param token
|
|
72
|
+
* @param ignoreExpireDate: do not return if it is expired
|
|
73
|
+
*/
|
|
74
|
+
static async getToken(token: string, organizationId: string, ignoreExpireDate = false): Promise<OneTimeToken | undefined> {
|
|
75
|
+
const [oneTimeToken] = await this.where({token, organizationId}, {limit: 1})
|
|
76
|
+
|
|
77
|
+
if (!oneTimeToken) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!ignoreExpireDate && oneTimeToken.isExpired()) {
|
|
82
|
+
// If the refresh token is invalid, do not return it
|
|
83
|
+
return undefined
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return oneTimeToken;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/***
|
|
90
|
+
* Create a token without saving it
|
|
91
|
+
*/
|
|
92
|
+
static async createToken(organizationId: string, type: OneTimeTokenType, data: any, options?: {validUntil?: Date, expireIn?: number}): Promise<OneTimeToken> {
|
|
93
|
+
const token = new OneTimeToken();
|
|
94
|
+
token.type = type;
|
|
95
|
+
token.data = data;
|
|
96
|
+
token.organizationId = organizationId
|
|
97
|
+
|
|
98
|
+
if (options?.validUntil) {
|
|
99
|
+
token.validUntil = new Date(options?.validUntil)
|
|
100
|
+
token.validUntil.setMilliseconds(0);
|
|
101
|
+
} else if (options?.expireIn) {
|
|
102
|
+
token.validUntil = new Date();
|
|
103
|
+
token.validUntil.setTime(token.validUntil.getTime() + options?.expireIn);
|
|
104
|
+
token.validUntil.setMilliseconds(0);
|
|
105
|
+
}
|
|
106
|
+
token.token = bs58.encode(await randomBytes(100)).toLowerCase();
|
|
107
|
+
await token.save();
|
|
108
|
+
return token;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Pass in an organization if you want to use the registration page instead of the dashboard
|
|
113
|
+
*/
|
|
114
|
+
getUrl(organization: Organization, dashboard = false) {
|
|
115
|
+
// Send an e-mail to say you already have an account + follow password forgot flow
|
|
116
|
+
const i18n = organization.i18n;
|
|
117
|
+
|
|
118
|
+
let host: string;
|
|
119
|
+
if (dashboard) {
|
|
120
|
+
host = "https://"+(STAMHOOFD.domains.dashboard ?? "stamhoofd.app")+"/"+i18n.locale
|
|
121
|
+
} else {
|
|
122
|
+
host = "https://"+organization.getHost()
|
|
123
|
+
|
|
124
|
+
if (i18n.language != organization.i18n.language) {
|
|
125
|
+
host += "/"+i18n.language
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return host+"/ott"+(dashboard ? "/"+encodeURIComponent(organization.id) : "")+"?token="+encodeURIComponent(this.token);
|
|
130
|
+
}
|
|
131
|
+
}
|