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
* data provided by the ukamf export file.
@ -10,18 +8,13 @@
* http://metadata.ukfederation.org.uk/
*/
const { Certificate } = require('@fidm/x509')
const UKAMFDB = require('./ukamf-db')
const V1Api = require('../../app/src/Features/V1/V1Api').promises
const { db, waitForDb } = require('../../app/src/infrastructure/mongodb')
const moment = require('moment')
import { Certificate } from '@fidm/x509'
import UKAMFDB from './ukamf-db.js'
import V1ApiModule from '../../app/src/Features/V1/V1Api.js'
import { db, waitForDb } from '../../app/src/infrastructure/mongodb.js'
import moment from 'moment'
waitForDb()
.then(main)
.catch(err => {
console.error(err.stack)
})
.then(() => process.exit())
const { promises: V1Api } = V1ApiModule
async function main() {
const [, , file] = process.argv
@ -96,3 +89,11 @@ async function getActiveProviderIds() {
'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
*/
const { Certificate } = require('@fidm/x509')
const _ = require('lodash')
const moment = require('moment')
const fs = require('fs-extra')
const xml2js = require('xml2js')
import { Certificate } from '@fidm/x509'
import _ from 'lodash'
import moment from 'moment'
import fs from 'fs-extra'
import xml2js from 'xml2js'
function checkCertDates(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
*
@ -11,14 +9,9 @@
* The entity id should be provided by the university.
*/
const { Certificate } = require('@fidm/x509')
const moment = require('moment')
const UKAMFDB = require('./ukamf-db')
main().catch(err => {
console.error(err.stack)
})
import { Certificate } from '@fidm/x509'
import moment from 'moment'
import UKAMFDB from './ukamf-db.js'
async function main() {
const [, , file, entityId] = process.argv
@ -71,3 +64,9 @@ async function main() {
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
}
}
try {
await main()
} catch (error) {
console.error(error)
}

View file

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

View file

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

View file

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