Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auth0-ext-compilers

Package Overview
Dependencies
Maintainers
40
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-ext-compilers - npm Package Compare versions

Comparing version 5.5.2 to 5.5.3

37

lib/compilers/send-phone-message.js

@@ -24,6 +24,2 @@ 'use strict';

}
if (!((webtaskContext.body.context.factor_type === 'first') ||
webtaskContext.body.context.factor_type === 'second')) {
return cb(new Error('Body.context.factor_type received by extensibility point is not `first` or `second`'));
}
if (!((webtaskContext.body.context.message_type === 'sms') ||

@@ -34,4 +30,4 @@ webtaskContext.body.context.message_type === 'voice')) {

if (!((webtaskContext.body.context.action === 'enrollment') ||
webtaskContext.body.context.action ==='authentication')) {
return cb(new Error('Body.context.action received by extensibility point is not `enrollment` or `authentication`'));
webtaskContext.body.context.action ==='second-factor-authentication')) {
return cb(new Error('Body.context.action received by extensibility point is not `enrollment` or `second-factor-authentication`'));
}

@@ -50,14 +46,19 @@ if (typeof webtaskContext.body.context.language !== 'string') {

}
if (typeof webtaskContext.body.context.client !== 'object') {
return cb(new Error('Body.context.client received by extensibility point is not an object'));
// This is optional for now.
if(webtaskContext.body.context.client !== undefined) {
if (typeof webtaskContext.body.context.client !== 'object') {
return cb(new Error('Body.context.client received by extensibility point is not an object'));
}
if (typeof webtaskContext.body.context.client.client_id !== 'string') {
return cb(new Error('Body.context.client.client_id received by extensibility point is not a string'));
}
if (typeof webtaskContext.body.context.client.name !== 'string') {
return cb(new Error('Body.context.client.name received by extensibility point is not a string'));
}
if (webtaskContext.body.context.client.client_metadata !== undefined) {
if (typeof webtaskContext.body.context.client.client_metadata !== 'object') {
return cb(new Error('Body.context.client.client_metadata received by extensibility point is not an object'));
}
}
}
if (typeof webtaskContext.body.context.client.client_id !== 'string') {
return cb(new Error('Body.context.client.client_id received by extensibility point is not a string'));
}
if (typeof webtaskContext.body.context.client.name !== 'string') {
return cb(new Error('Body.context.client.name received by extensibility point is not a string'));
}
if (typeof webtaskContext.body.context.client.client_metadata !== 'object') {
return cb(new Error('Body.context.client.client_metadata received by extensibility point is not an object'));
}
if (typeof webtaskContext.body.context.user !== 'object') {

@@ -67,4 +68,6 @@ return cb(new Error('Body.context.user received by extensibility point is not an object'));

webtaskContext.body.context.webtask = webtaskContext;
return func(webtaskContext.body.recipient, webtaskContext.body.text, webtaskContext.body.context, cb);
});
}

@@ -8,3 +8,3 @@ {

},
"version": "5.5.2",
"version": "5.5.3",
"description": "Webtask compilers for Auth0 platform extensibility points",

@@ -11,0 +11,0 @@ "engines": {

@@ -89,46 +89,2 @@ /* eslint-env node, mocha */

it('rejects bad factor_type', function (done) {
compiler({
nodejsCompiler,
script: 'module.exports = function(recipient, text, context, cb) { cb(); };'
}, function (error, func) {
Assert.ifError(error);
simulate(func, {
body: {recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {factor_type: 'wrong'}},
headers: {},
method: 'POST',
}, function (error, data) {
Assert.ok(error);
Assert.equal(error.statusCode, 500);
Assert.equal(error.message, 'Body.context.factor_type received by extensibility point is not `first` or `second`');
Assert.equal(data, undefined);
done();
});
});
});
it('does not fail on `second` factor_type', function (done) {
compiler({
nodejsCompiler,
script: 'module.exports = function(recipient, text, context, cb) { cb(); };'
}, function (error, func) {
Assert.ifError(error);
simulate(func, {
body: {
recipient: '1-999-888-657-2134',
text: 'dis iz a text',
context: {factor_type: 'second'}
},
headers: {},
method: 'POST',
}, function (error, data) {
Assert.ok(error);
Assert.notEqual(error.message, 'Body.context.factor_type received by extensibility point is not `first` or `second`');
done();
});
});
});
it('rejects bad message_type', function (done) {

@@ -145,3 +101,3 @@ compiler({

text: 'dis iz a text',
context: {factor_type: 'first', message_type: 'telephone'}
context: {message_type: 'telephone'}
},

@@ -171,3 +127,3 @@ headers: {},

text: 'dis iz a text',
context: {factor_type: 'first', message_type: 'voice'}
context: {message_type: 'voice'}
},

@@ -184,3 +140,3 @@ headers: {},

it('does not fail on `authentication` action type', function (done) {
it('does not fail on `second-factor-authentication` action type', function (done) {
compiler({

@@ -195,5 +151,4 @@ nodejsCompiler,

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',
action: 'authentication'
action: 'second-factor-authentication'
}

@@ -205,3 +160,3 @@ },

Assert.ok(error);
Assert.notEqual(error.message, 'Body.context.action received by extensibility point is not `enrollment` or `authentication`');
Assert.notEqual(error.message, 'Body.context.action received by extensibility point is not `enrollment` or `second-factor-authentication`');
done();

@@ -222,3 +177,2 @@ });

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -233,3 +187,3 @@ action: 'wrong'

Assert.equal(error.statusCode, 500);
Assert.equal(error.message, 'Body.context.action received by extensibility point is not `enrollment` or `authentication`');
Assert.equal(error.message, 'Body.context.action received by extensibility point is not `enrollment` or `second-factor-authentication`');
Assert.equal(data, undefined);

@@ -251,3 +205,2 @@ done();

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -280,3 +233,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -310,3 +262,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -341,3 +292,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -375,3 +325,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -407,3 +356,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -441,3 +389,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -475,3 +422,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -512,3 +458,2 @@ action: 'enrollment',

recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
factor_type: 'first',
message_type: 'sms',

@@ -540,3 +485,99 @@ action: 'enrollment',

});
});
}); // invalid payload
describe('valid payload', function() {
it('works without client', function (done) {
compiler({
nodejsCompiler,
script: 'module.exports = function(recipient, text, context, cb) { cb(null, JSON.stringify({})); };'
}, function (error, func) {
Assert.ifError(error);
simulate(func, {
body: {
recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
message_type: 'sms',
action: 'enrollment',
language: 'korean',
code: 'SOMEOTP12345',
ip: '127.0.0.1',
user_agent: 'someAgent',
user: {}
}
},
headers: {},
method: 'POST',
}, function (error, data) {
Assert.equal(error, null);
done();
});
});
});
it('works with a client', function (done) {
compiler({
nodejsCompiler,
script: 'module.exports = function(recipient, text, context, cb) { cb(null, JSON.stringify({})); };'
}, function (error, func) {
Assert.ifError(error);
simulate(func, {
body: {
recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
message_type: 'sms',
action: 'second-factor-authentication',
language: 'korean',
code: 'SOMEOTP12345',
ip: '127.0.0.1',
user_agent: 'someAgent',
user: {},
client: {
client_id: 'someClientId',
name: 'Test Application',
client_metadata: {}
}
}
},
headers: {},
method: 'POST',
}, function (error, data) {
Assert.equal(error, null);
done();
});
});
});
it('works with a client with no client_metadata', function (done) {
compiler({
nodejsCompiler,
script: 'module.exports = function(recipient, text, context, cb) { cb(null, JSON.stringify({})); };'
}, function (error, func) {
Assert.ifError(error);
simulate(func, {
body: {
recipient: '1-999-888-657-2134', text: 'dis iz a text', context: {
message_type: 'sms',
action: 'second-factor-authentication',
language: 'korean',
code: 'SOMEOTP12345',
ip: '127.0.0.1',
user_agent: 'someAgent',
user: {},
client: {
client_id: 'someClientId',
name: 'Test Application',
client_metadata: {}
}
}
},
headers: {},
method: 'POST',
}, function (error, data) {
Assert.equal(error, null);
done();
});
});
});
}); // valid payload
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc