Skip to content

Commit ccc4bfd

Browse files
author
williamd5
authored
Merge pull request #43 from cloudnode-pro/next
Set API version to 5.10.0
2 parents 871787a + 9b32b6c commit ccc4bfd

File tree

15 files changed

+315
-8
lines changed

15 files changed

+315
-8
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Cloudnode API SDK
22

33
![Client Version: 1.8.1](https://img.shields.io/badge/Client%20Version-1.8.1-%2316a34a)
4-
![API Version: 5.8.0](https://img.shields.io/badge/API%20Version-5.8.0-%232563eb)
4+
![API Version: 5.10.0](https://img.shields.io/badge/API%20Version-5.10.0-%232563eb)
55
![build: passing](https://img.shields.io/badge/build-passing-%2316a34a)
66
![npm downloads](https://img.shields.io/npm/dt/cloudnode-ts?label=downloads)
77

@@ -77,6 +77,8 @@ console.log(newsletter._response.status); // 200
7777
- [`Cloudnode.getNextPage<T>(response)`](#cloudnodegetnextpagetresponse)
7878
- [`Cloudnode.getPreviousPage<T>(response)`](#cloudnodegetpreviouspagetresponse)
7979
- [`Cloudnode.getAllPages<T>(response)`](#cloudnodegetallpagestresponse)
80+
- [`cloudnode.auth.login(user, password)`](#cloudnodeauthloginuser-password)
81+
- [`cloudnode.auth.register(username, email, password)`](#cloudnodeauthregisterusername-email-password)
8082
- [`cloudnode.newsletter.get(id)`](#cloudnodenewslettergetid)
8183
- [`cloudnode.newsletter.list([limit], [page])`](#cloudnodenewsletterlistlimit-page)
8284
- [`cloudnode.newsletter.subscribe(id, email, [data])`](#cloudnodenewslettersubscribeid-email-data)
@@ -163,6 +165,41 @@ Get all other pages of paginated results and return the complete data
163165
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> All of the data in 1 page
164166
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
165167

168+
<a name="cloudnodeauthloginuser-password"></a>
169+
170+
### `cloudnode.auth.login(user, password)`
171+
172+
Create a session using user ID/username/e-mail and password.
173+
174+
> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.
175+
176+
- `user` <code>[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)</code> User ID (starts with `user_`), username or e-mail address.
177+
- `password` <code>[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)</code> The password of the account.
178+
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;{session: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>></code> Session token. Also returned in `Set-Cookie` header.
179+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "UNAUTHORIZED"}</code>
180+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "IP_REJECTED"}</code>
181+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}</code>
182+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}</code>
183+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}</code>
184+
185+
<a name="cloudnodeauthregisterusername-email-password"></a>
186+
187+
### `cloudnode.auth.register(username, email, password)`
188+
189+
Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
190+
191+
> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.
192+
193+
- `username` <code>[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)</code> The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.
194+
- `email` <code>[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)</code> The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.
195+
- `password` <code>[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)</code> The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.
196+
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;{session: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>></code> Session token. Also returned in `Set-Cookie` header.
197+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INVALID_DATA"}</code>
198+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "IP_REJECTED"}</code>
199+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "RATE_LIMITED"}</code>
200+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "INTERNAL_SERVER_ERROR"}</code>
201+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror) & {code: "MAINTENANCE"}</code>
202+
166203
<a name="cloudnodenewslettergetid"></a>
167204

168205
### `cloudnode.newsletter.get(id)`

browser/Cloudnode.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,43 @@ class Cloudnode {
334334
return await this.#sendRequest({ "type": "operation", "description": "Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely.", "token": "token.refresh", "method": "POST", "path": "/token/refresh", "parameters": {}, "returns": [{ "status": 201, "type": "Token" }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"NO_PERMISSION\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, {});
335335
},
336336
};
337+
auth = {
338+
/**
339+
* Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
340+
341+
> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.
342+
* @POST /auth/register
343+
* @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.
344+
* @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.
345+
* @param password The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.
346+
* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
347+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
348+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
349+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
350+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
351+
* @returns Session token. Also returned in `Set-Cookie` header.
352+
*/
353+
register: async (username, email, password) => {
354+
return await this.#sendRequest({ "type": "operation", "description": "Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.\n\n> **Note**: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.", "method": "POST", "path": "/auth/register", "parameters": { "body": { "username": { "description": "The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. May contain only letters, numbers, dashes and underscores. Must be unique.", "type": "string", "required": true }, "email": { "description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.", "type": "string", "required": true }, "password": { "description": "The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 422, "type": "Error & {code: \"INVALID_DATA\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { username, email, password });
355+
},
356+
/**
357+
* Create a session using user ID/username/e-mail and password.
358+
359+
> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.
360+
* @POST /auth/login
361+
* @param user User ID (starts with `user_`), username or e-mail address.
362+
* @param password The password of the account.
363+
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}
364+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
365+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
366+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
367+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
368+
* @returns Session token. Also returned in `Set-Cookie` header.
369+
*/
370+
login: async (user, password) => {
371+
return await this.#sendRequest({ "type": "operation", "description": "Create a session using user ID/username/e-mail and password.\n\n> **Note**: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.", "method": "POST", "path": "/auth/login", "parameters": { "body": { "user": { "description": "User ID (starts with `user_`), username or e-mail address.", "type": "string", "required": true }, "password": { "description": "The password of the account.", "type": "string", "required": true } } }, "returns": [{ "status": 201, "type": "{session: string}", "description": "Session token. Also returned in `Set-Cookie` header." }, { "status": 401, "type": "Error & {code: \"UNAUTHORIZED\"}" }, { "status": 403, "type": "Error & {code: \"IP_REJECTED\"}" }, { "status": 429, "type": "Error & {code: \"RATE_LIMITED\"}" }, { "status": 500, "type": "Error & {code: \"INTERNAL_SERVER_ERROR\"}" }, { "status": 503, "type": "Error & {code: \"MAINTENANCE\"}" }] }, {}, {}, { user, password });
372+
},
373+
};
337374
}
338375
(function (Cloudnode) {
339376
class RawResponse {

0 commit comments

Comments
 (0)