Skip to content

Commit 9b32b6c

Browse files
author
William Duncan
committed
login operation
1 parent 3a6e49a commit 9b32b6c

File tree

7 files changed

+122
-1
lines changed

7 files changed

+122
-1
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ 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)
8081
- [`cloudnode.auth.register(username, email, password)`](#cloudnodeauthregisterusername-email-password)
8182
- [`cloudnode.newsletter.get(id)`](#cloudnodenewslettergetid)
8283
- [`cloudnode.newsletter.list([limit], [page])`](#cloudnodenewsletterlistlimit-page)
@@ -164,6 +165,23 @@ Get all other pages of paginated results and return the complete data
164165
- 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
165166
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
166167

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+
167185
<a name="cloudnodeauthregisterusername-email-password"></a>
168186

169187
### `cloudnode.auth.register(username, email, password)`

browser/Cloudnode.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,23 @@ class Cloudnode {
353353
register: async (username, email, password) => {
354354
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 });
355355
},
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+
},
356373
};
357374
}
358375
(function (Cloudnode) {

browser/Cloudnode.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,41 @@
565565
"type": "Error & {code: \"IP_REJECTED\"}"
566566
}
567567
]
568+
},
569+
"login": {
570+
"type": "operation",
571+
"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.",
572+
"method": "POST",
573+
"path": "/auth/login",
574+
"parameters": {
575+
"body": {
576+
"user": {
577+
"description": "User ID (starts with `user_`), username or e-mail address.",
578+
"type": "string",
579+
"required": true
580+
},
581+
"password": {
582+
"description": "The password of the account.",
583+
"type": "string",
584+
"required": true
585+
}
586+
}
587+
},
588+
"returns": [
589+
{
590+
"status": 201,
591+
"type": "{session: string}",
592+
"description": "Session token. Also returned in `Set-Cookie` header."
593+
},
594+
{
595+
"status": 401,
596+
"type": "Error & {code: \"UNAUTHORIZED\"}"
597+
},
598+
{
599+
"status": 403,
600+
"type": "Error & {code: \"IP_REJECTED\"}"
601+
}
602+
]
568603
}
569604
}
570605
}

src/Cloudnode.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,23 @@ declare class Cloudnode {
190190
readonly register: (username: string, email: string, password: string) => Promise<Cloudnode.ApiResponse<{
191191
session: string;
192192
}>>;
193+
/**
194+
* Create a session using user ID/username/e-mail and password.
195+
196+
> **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.
197+
* @POST /auth/login
198+
* @param user User ID (starts with `user_`), username or e-mail address.
199+
* @param password The password of the account.
200+
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}
201+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
202+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
203+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
204+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
205+
* @returns Session token. Also returned in `Set-Cookie` header.
206+
*/
207+
readonly login: (user: string, password: string) => Promise<Cloudnode.ApiResponse<{
208+
session: string;
209+
}>>;
193210
};
194211
}
195212
declare namespace Cloudnode {

src/Cloudnode.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,23 @@ class Cloudnode {
353353
register: async (username, email, password) => {
354354
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 });
355355
},
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+
},
356373
};
357374
}
358375
(function (Cloudnode) {

src/Cloudnode.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,23 @@ class Cloudnode {
361361
register: async (username: string, email: string, password: string): Promise<Cloudnode.ApiResponse<{session: string}>> => {
362362
return await this.#sendRequest<{session: string}>({"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});
363363
},
364+
/**
365+
* Create a session using user ID/username/e-mail and password.
366+
367+
> **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.
368+
* @POST /auth/login
369+
* @param user User ID (starts with `user_`), username or e-mail address.
370+
* @param password The password of the account.
371+
* @throws {Cloudnode.Error & {code: "UNAUTHORIZED"}}
372+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
373+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
374+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
375+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
376+
* @returns Session token. Also returned in `Set-Cookie` header.
377+
*/
378+
login: async (user: string, password: string): Promise<Cloudnode.ApiResponse<{session: string}>> => {
379+
return await this.#sendRequest<{session: string}>({"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});
380+
},
364381
} as const;
365382

366383
}

0 commit comments

Comments
 (0)