Skip to content

Commit 94c1c6b

Browse files
author
William Duncan
committed
add register operation
1 parent bc6da34 commit 94c1c6b

File tree

7 files changed

+146
-2
lines changed

7 files changed

+146
-2
lines changed

README.md

Lines changed: 20 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,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.register(username, email, password)`](#cloudnodeauthregisterusername-email-password)
8081
- [`cloudnode.newsletter.get(id)`](#cloudnodenewslettergetid)
8182
- [`cloudnode.newsletter.list([limit], [page])`](#cloudnodenewsletterlistlimit-page)
8283
- [`cloudnode.newsletter.subscribe(id, email, [data])`](#cloudnodenewslettersubscribeid-email-data)
@@ -163,6 +164,24 @@ Get all other pages of paginated results and return the complete data
163164
- 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
164165
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
165166

167+
<a name="cloudnodeauthregisterusername-email-password"></a>
168+
169+
### `cloudnode.auth.register(username, email, password)`
170+
171+
Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
172+
173+
> **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.
174+
175+
- `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_`. Must be unique.
176+
- `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.
177+
- `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.
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: "INVALID_DATA"}</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+
166185
<a name="cloudnodenewslettergetid"></a>
167186

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

browser/Cloudnode.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,26 @@ 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_`. 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_`. 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+
};
337357
}
338358
(function (Cloudnode) {
339359
class RawResponse {

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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,51 @@
522522
]
523523
}
524524
}
525+
},
526+
"auth": {
527+
"type": "namespace",
528+
"operations": {
529+
"register": {
530+
"type": "operation",
531+
"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.",
532+
"method": "POST",
533+
"path": "/auth/register",
534+
"parameters": {
535+
"body": {
536+
"username": {
537+
"description": "The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. Must be unique.",
538+
"type": "string",
539+
"required": true
540+
},
541+
"email": {
542+
"description": "The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.",
543+
"type": "string",
544+
"required": true
545+
},
546+
"password": {
547+
"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.",
548+
"type": "string",
549+
"required": true
550+
}
551+
}
552+
},
553+
"returns": [
554+
{
555+
"status": 201,
556+
"type": "{session: string}",
557+
"description": "Session token. Also returned in `Set-Cookie` header."
558+
},
559+
{
560+
"status": 422,
561+
"type": "Error & {code: \"INVALID_DATA\"}"
562+
},
563+
{
564+
"status": 403,
565+
"type": "Error & {code: \"IP_REJECTED\"}"
566+
}
567+
]
568+
}
569+
}
525570
}
526571
}
527572
}

src/Cloudnode.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,26 @@ declare class Cloudnode {
171171
*/
172172
readonly refresh: () => Promise<Cloudnode.ApiResponse<Cloudnode.Token>>;
173173
};
174+
auth: {
175+
/**
176+
* Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
177+
178+
> **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.
179+
* @POST /auth/register
180+
* @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. Must be unique.
181+
* @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.
182+
* @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.
183+
* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
184+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
185+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
186+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
187+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
188+
* @returns Session token. Also returned in `Set-Cookie` header.
189+
*/
190+
readonly register: (username: string, email: string, password: string) => Promise<Cloudnode.ApiResponse<{
191+
session: string;
192+
}>>;
193+
};
174194
}
175195
declare namespace Cloudnode {
176196
/**

src/Cloudnode.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,26 @@ 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_`. 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_`. 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+
};
337357
}
338358
(function (Cloudnode) {
339359
class RawResponse {

src/Cloudnode.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ class Cloudnode {
342342
return await this.#sendRequest<Cloudnode.Token>({"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\"}"}]}, {}, {}, {});
343343
},
344344
} as const;
345+
public auth = {
346+
/**
347+
* Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
348+
349+
> **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.
350+
* @POST /auth/register
351+
* @param username The username to use for the account. Must be between 3 and 32 characters long. Cannot start with `user_`. Must be unique.
352+
* @param email The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.
353+
* @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.
354+
* @throws {Cloudnode.Error & {code: "INVALID_DATA"}}
355+
* @throws {Cloudnode.Error & {code: "IP_REJECTED"}}
356+
* @throws {Cloudnode.Error & {code: "RATE_LIMITED"}}
357+
* @throws {Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}}
358+
* @throws {Cloudnode.Error & {code: "MAINTENANCE"}}
359+
* @returns Session token. Also returned in `Set-Cookie` header.
360+
*/
361+
register: async (username: string, email: string, password: string): Promise<Cloudnode.ApiResponse<{session: string}>> => {
362+
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_`. 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});
363+
},
364+
} as const;
345365

346366
}
347367

0 commit comments

Comments
 (0)