smsapi / smsapi-javascript-client Goto Github PK
View Code? Open in Web Editor NEWSMSAPI javascripts client that allows you to send messages and administrate your SMSAPI account.
Home Page: https://www.smsapi.com/
License: Apache License 2.0
SMSAPI javascripts client that allows you to send messages and administrate your SMSAPI account.
Home Page: https://www.smsapi.com/
License: Apache License 2.0
Please provide a typescript .d.ts typings for the library. Typescript is gaining popularity very quickly, and it is a great solution for critical apps as it prevents many mistakes at a very early stage of development. SMS sending is indeed a critical part of an app as it has both money and direct user experience involved. Thanks!
Your Axios version has vulnerability:
https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
Please prepare a solution for this issue.
Please provide a changelog so that one could determine what kind of changes are released with new versions.
Are there any breaking API changes with the 2.0 release?
(You may consider using semantic-release
to manage versioning)
=== npm audit security report ===
┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Server-Side Request Forgery │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ axios │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.21.1 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ smsapi │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ smsapi > axios │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1594 │
└───────────────┴──────────────────────────────────────────────────────────────┘
The error using this module in nodejs v12.13.0
No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future.
implementation:
import { Injectable } from '@nestjs/common';
import {configService} from "../../shared/config/config.service";const SMSAPI = require('smsapi');
@Injectable()
export class SmsService {private smsFrom: string; private smsapi: any; constructor() { this.smsFrom = configService.getValue('SMS_FROM'); this.smsapi = new SMSAPI({ oauth: { accessToken: configService.getValue('SMS_ACCESS_TOKEN') } }); } public sendMessage(to: string, body: string): Promise<any> { return this.smsapi.message .sms() .from(this.smsFrom) .to(to) .message(body) .execute(); }
}
everything works fine when commenting smsapi related logic (leaving tbh empty sendMessage and config related things)
ps. sorry for bad formatting, cant work it out to work with nestjs annotations
As I understand, ProxyAbstract
is exposed by smsapi.js
, in order to provide a method for implementing a custom class, that has a request method, which returns an instance of lib/Request
.
My issue is that lib/Request
is not exposed on lib/smsapi
, so I can't really return an instance of this private library class.
importing the library in nestjs (express, typescript) ends with error: SMSAPI is not a constructor
tried all possible versions from 1.0 to 2.0.11.
node: v.16.15.1
code:
import { Controller, Get } from '@nestjs/common';
import { SMSAPI } from 'smsapi';
@Controller('sms')
export class SmsController {
@Get()
async testSms() {
const smsapi = new SMSAPI('Bxxxxxxxxxxxxxxxxxxxxxxxxxi');
try {
const result = smsapi.sms.sendSms('+486xxxxxxxxx', 'My first message!');
console.log(result);
} catch (err) {
console.log(err);
}
}
}
error:
express-server | [Nest] 842 - 11/29/2023, 8:23:20 AM [ExceptionsHandler] smsapi_1.SMSAPI is not a constructor +52636550ms
express-server | TypeError: smsapi_1.SMSAPI is not a constructor
express-server | at SmsController.test2 (/usr/src/app/dist/src/sms/sms.controller.js:17:24)
express-server | at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:38:29
express-server | at InterceptorsConsumer.intercept (/usr/src/app/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:11:20)
express-server | at /usr/src/app/node_modules/@nestjs/core/router/router-execution-context.js:46:60
express-server | at /usr/src/app/node_modules/@nestjs/core/router/router-proxy.js:9:23
express-server | at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
express-server | at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
express-server | at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
express-server | at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
express-server | at /usr/src/app/node_modules/express/lib/router/index.js:281:22
Example:
smsapi.message.sms()
.from('Info')
.to('501501501')
.message('My message')
.normalize(false)
.execute()
Calling .normalize(false)
will actually result in setting the normalize
option to true
. I presume this is because it is probably sent to the server as normalize=false
which is not normalize=0
and therefore is interpreted as setting the option.
The use case:
var message = 'Pewna wiadomość'
return smsapi.message.sms()
.from('Info')
.to('501501501')
.message(message)
.normalize(message.length > 70)
.execute()
Temporary fix: coercing to number like this: .normalize(+(message.length > 70))
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.