Ind.ie is now Small Technology Foundation.
Commit a9852fe9 authored by Frauke's avatar Frauke

Added generation of nonce

parent 2a3ef5e8
const errors = require('@feathersjs/errors')
const sodium = require('libsodium-wrappers')
class Service {
constructor (options) {
this.options = options || {};
}
async find (params) {
return [];
}
async get (id, params) {
if(id === 'nonce') {
const nonce = sodium.randombytes_buf(sodium.crypto_pwhash_SALTBYTES)
return sodium.to_hex(nonce)
}
}
async create (data, params) {
if (Array.isArray(data)) {
return await Promise.all(data.map(current => this.create(current)));
}
return data;
}
async update (id, data, params) {
return data;
}
async patch (id, data, params) {
return data;
}
async remove (id, params) {
return { id };
}
}
module.exports = function (options) {
return new Service(options);
};
module.exports.Service = Service;
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
after: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
};
// Initializes the `authorize` service on path `/authorize`
const createService = require('./authorize.class.js');
const hooks = require('./authorize.hooks');
module.exports = function (app) {
const paginate = app.get('paginate');
const options = {
name: 'authorize',
paginate
};
// Initialize our service with any options it requires
app.use('/authorize', createService(options));
// Get our initialized service so that we can register hooks and filters
const service = app.service('authorize');
service.hooks(hooks);
};
const keys = require('./keys/keys.service.js');
const authorize = require('./authorize/authorize.service.js');
module.exports = function (app) {
app.configure(keys);
app.configure(authorize);
};
const assert = require('assert');
const app = require('../../server/app');
describe('\'authorize\' service', () => {
it('registered the service', () => {
const service = app.service('authorize');
assert.ok(service, 'Registered the service');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment