forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
41 lines (34 loc) · 1009 Bytes
/
utils.js
File metadata and controls
41 lines (34 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var fs = require('fs')
var fsExtra = require('fs-extra')
var rimraf = require('rimraf')
var path = require('path')
const OIDCProvider = require('@trust/oidc-op')
exports.rm = function (file) {
return rimraf.sync(path.join(__dirname, '/resources/' + file))
}
exports.write = function (text, file) {
return fs.writeFileSync(path.join(__dirname, '/resources/' + file), text)
}
exports.cp = function (src, dest) {
return fsExtra.copySync(
path.join(__dirname, '/resources/' + src),
path.join(__dirname, '/resources/' + dest))
}
exports.read = function (file) {
return fs.readFileSync(path.join(__dirname, '/resources/' + file), {
'encoding': 'utf8'
})
}
/**
* @param configPath {string}
*
* @returns {Promise<Provider>}
*/
exports.loadProvider = function loadProvider (configPath) {
return Promise.resolve()
.then(() => {
const config = require(configPath)
const provider = new OIDCProvider(config)
return provider.initializeKeyChain(config.keys)
})
}