@cedx/free-mobile
Advanced tools
Comparing version 15.2.0 to 16.0.0
@@ -1,31 +0,1 @@ | ||
/** | ||
* Sends messages by SMS to a [FreeMobile](https://mobile.free.fr) account. | ||
*/ | ||
export declare class Client { | ||
/** | ||
* The Free Mobile account. | ||
*/ | ||
readonly account: string; | ||
/** | ||
* The Free Mobile API key. | ||
*/ | ||
readonly apiKey: string; | ||
/** | ||
* The base URL of the remote API endpoint. | ||
*/ | ||
readonly baseUrl: URL; | ||
/** | ||
* Creates a new client. | ||
* @param account The Free Mobile account. | ||
* @param apiKey The Free Mobile API key. | ||
* @param baseUrl The base URL of the remote API endpoint. | ||
*/ | ||
constructor(account: string, apiKey: string, baseUrl?: string | URL); | ||
/** | ||
* Sends an SMS message to the underlying account. | ||
* @param message The message text. | ||
* @returns Resolves when the message has been sent. | ||
*/ | ||
sendMessage(message: string): Promise<void>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map | ||
export * from "./client.js"; |
@@ -1,40 +0,1 @@ | ||
/** | ||
* Sends messages by SMS to a [FreeMobile](https://mobile.free.fr) account. | ||
*/ | ||
export class Client { | ||
/** | ||
* The Free Mobile account. | ||
*/ | ||
account; | ||
/** | ||
* The Free Mobile API key. | ||
*/ | ||
apiKey; | ||
/** | ||
* The base URL of the remote API endpoint. | ||
*/ | ||
baseUrl; | ||
/** | ||
* Creates a new client. | ||
* @param account The Free Mobile account. | ||
* @param apiKey The Free Mobile API key. | ||
* @param baseUrl The base URL of the remote API endpoint. | ||
*/ | ||
constructor(account, apiKey, baseUrl = "https://smsapi.free-mobile.fr") { | ||
const url = baseUrl instanceof URL ? baseUrl.href : baseUrl; | ||
this.account = account; | ||
this.apiKey = apiKey; | ||
this.baseUrl = new URL(url.endsWith("/") ? url : `${url}/`); | ||
} | ||
/** | ||
* Sends an SMS message to the underlying account. | ||
* @param message The message text. | ||
* @returns Resolves when the message has been sent. | ||
*/ | ||
async sendMessage(message) { | ||
const query = new URLSearchParams({ msg: message.trim().slice(0, 160), pass: this.apiKey, user: this.account }); | ||
const response = await fetch(new URL(`sendmsg?${query}`, this.baseUrl), { headers: { "user-agent": navigator.userAgent } }); | ||
if (!response.ok) | ||
throw Error(`${response.status} ${response.statusText}`); | ||
} | ||
} | ||
export * from "./client.js"; |
@@ -9,3 +9,3 @@ { | ||
"type": "module", | ||
"version": "15.2.0", | ||
"version": "16.0.0", | ||
"author": { | ||
@@ -17,10 +17,5 @@ "email": "cedric@belin.io", | ||
"devDependencies": { | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/gulp": "^4.0.17", | ||
"@types/node": "^20.14.12", | ||
"del": "^7.1.0", | ||
"execa": "^9.3.0", | ||
"gulp": "^5.0.0", | ||
"typescript": "^5.5.4", | ||
"typescript-eslint": "^8.0.0-alpha.54" | ||
"@coffeelint/cli": "^5.2.11", | ||
"@types/node": "^22.9.0", | ||
"coffeescript": "^2.7.0" | ||
}, | ||
@@ -46,5 +41,4 @@ "engines": { | ||
"scripts": { | ||
"prepack": "gulp", | ||
"test": "gulp build && node --test --test-reporter=spec" | ||
"test": "cake test" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7274
3
10
1
60