@duckity/js 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +21 -3
- package/src/options.ts +0 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,9 +13,22 @@ export interface GetDuckityChallengeOptions {
|
|
|
13
13
|
/**
|
|
14
14
|
* The base URL to the API endpoint. Defaults to `https://quack.duckity.com` if not provided.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* Only update this when self-hosting a Duckling.
|
|
17
17
|
*/
|
|
18
18
|
api?: string;
|
|
19
|
+
|
|
20
|
+
// /**
|
|
21
|
+
// * When this is `false`, the client will assume it is allowed to get a challenge the first time
|
|
22
|
+
// * one is requested. This may not always be true (when the client has an active penalty or used
|
|
23
|
+
// * all of their allowed requests in another session), case in which the client may be penalized.
|
|
24
|
+
// *
|
|
25
|
+
// * When this is `true`, an extra request will be made to the Duckling API to synchronize the
|
|
26
|
+
// * client's state with the server's state. This extra request will not issue a challenge, rather
|
|
27
|
+
// * only synchronize the client's state with the server's state. If the client is penalized or has
|
|
28
|
+
// * to wait before being allowed to get a challenge, the client will be informed of this. It'll
|
|
29
|
+
// * avoid getting it unnecessarily penalized at the cost of an extra request.
|
|
30
|
+
// */
|
|
31
|
+
// sync?: boolean;
|
|
19
32
|
}
|
|
20
33
|
|
|
21
34
|
/**
|
|
@@ -40,8 +53,13 @@ export async function solve(
|
|
|
40
53
|
protectionProfileId: string,
|
|
41
54
|
options?: GetDuckityChallengeOptions,
|
|
42
55
|
): Promise<string> {
|
|
56
|
+
if (options?.api && options.api.endsWith("/")) {
|
|
57
|
+
// Remove the trailing slash from the API URL if provided
|
|
58
|
+
options.api = options.api.slice(0, -1);
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
let response: ChallengeResponse = await post(
|
|
44
|
-
`${options?.api || "https://quack.duckity.com"}/v1/
|
|
62
|
+
`${options?.api || "https://quack.duckity.com"}/v1/challenges/${protectionProfileId}/issue`,
|
|
45
63
|
{
|
|
46
64
|
body: {
|
|
47
65
|
id: protectionProfileId,
|
|
@@ -55,4 +73,4 @@ export async function solve(
|
|
|
55
73
|
return solution;
|
|
56
74
|
}
|
|
57
75
|
|
|
58
|
-
export default { solve }
|
|
76
|
+
export default { solve };
|
package/src/options.ts
ADDED
|
File without changes
|