Merge pull request #21284 from overleaf/ls-scripts-to-esm-6

Migrate scripts/ukamf to esm

GitOrigin-RevId: e7318d9fb112304153912303649fc597ef7a19db
This commit is contained in:
Liangjun Song 2024-10-24 12:13:04 +01:00 committed by Copybot
parent 30eb5416f3
commit e3b93f0a22
6 changed files with 36 additions and 40 deletions

View file

@ -1,5 +1,3 @@
'use strict'
/** /**
* Checks that all institutional sso provider certs are still current with the * Checks that all institutional sso provider certs are still current with the
* data provided by the ukamf export file. * data provided by the ukamf export file.
@ -10,18 +8,13 @@
* http://metadata.ukfederation.org.uk/ * http://metadata.ukfederation.org.uk/
*/ */
const { Certificate } = require('@fidm/x509') import { Certificate } from '@fidm/x509'
const UKAMFDB = require('./ukamf-db') import UKAMFDB from './ukamf-db.js'
const V1Api = require('../../app/src/Features/V1/V1Api').promises import V1ApiModule from '../../app/src/Features/V1/V1Api.js'
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb') import { db, waitForDb } from '../../app/src/infrastructure/mongodb.js'
const moment = require('moment') import moment from 'moment'
waitForDb() const { promises: V1Api } = V1ApiModule
.then(main)
.catch(err => {
console.error(err.stack)
})
.then(() => process.exit())
async function main() { async function main() {
const [, , file] = process.argv const [, , file] = process.argv
@ -96,3 +89,11 @@ async function getActiveProviderIds() {
'samlIdentifiers.externalUserId': { $exists: true }, 'samlIdentifiers.externalUserId': { $exists: true },
}) })
} }
try {
await waitForDb()
await main()
} catch (error) {
console.error(error.stack)
}
process.exit()

View file

@ -4,11 +4,11 @@
Run with: node check-idp-metadata /path/idp-metadata.xml Run with: node check-idp-metadata /path/idp-metadata.xml
*/ */
const { Certificate } = require('@fidm/x509') import { Certificate } from '@fidm/x509'
const _ = require('lodash') import _ from 'lodash'
const moment = require('moment') import moment from 'moment'
const fs = require('fs-extra') import fs from 'fs-extra'
const xml2js = require('xml2js') import xml2js from 'xml2js'
function checkCertDates(signingKey) { function checkCertDates(signingKey) {
let cert = _.get(signingKey, [ let cert = _.get(signingKey, [

View file

@ -1,5 +1,3 @@
'use strict'
/** /**
* Run with: node metadata-processor /path/ukamf.xml http://idp/entity/id * Run with: node metadata-processor /path/ukamf.xml http://idp/entity/id
* *
@ -11,14 +9,9 @@
* The entity id should be provided by the university. * The entity id should be provided by the university.
*/ */
const { Certificate } = require('@fidm/x509') import { Certificate } from '@fidm/x509'
const moment = require('moment') import moment from 'moment'
import UKAMFDB from './ukamf-db.js'
const UKAMFDB = require('./ukamf-db')
main().catch(err => {
console.error(err.stack)
})
async function main() { async function main() {
const [, , file, entityId] = process.argv const [, , file, entityId] = process.argv
@ -71,3 +64,9 @@ async function main() {
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
} }
} }
try {
await main()
} catch (error) {
console.error(error)
}

View file

@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"@fidm/x509": "^1.2.1" "@fidm/x509": "^1.2.1"
} },
"type": "module"
} }

View file

@ -1,9 +1,6 @@
'use strict' import fs from 'fs-extra'
import xml2js from 'xml2js'
const fs = require('fs-extra') import UKAMFEntity from './ukamf-entity.js'
const xml2js = require('xml2js')
const UKAMFEntity = require('./ukamf-entity')
class UKAMFDB { class UKAMFDB {
constructor(file) { constructor(file) {
@ -28,4 +25,4 @@ class UKAMFDB {
} }
} }
module.exports = UKAMFDB export default UKAMFDB

View file

@ -1,6 +1,4 @@
'use strict' import _ from 'lodash'
const _ = require('lodash')
class UKAMFEntity { class UKAMFEntity {
constructor(data) { constructor(data) {
@ -68,4 +66,4 @@ class UKAMFEntity {
} }
} }
module.exports = UKAMFEntity export default UKAMFEntity