@natsuneko-laboratory/catalyst-sdk 0.5.0 → 0.5.4
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/README.md +57 -0
- package/dist/index.d.mts +4 -6
- package/dist/index.d.ts +4 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# CatalystTS
|
|
2
|
+
|
|
3
|
+
Official Catalyst SDK for TypeScript / JavaScript / Node.js, built for both browser and server environments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ npm install @natsuneko-laboratory/catalyst-sdk --save
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// authentication
|
|
15
|
+
import { CatalystTS, PKCE } from "@natsuneko-laboratory/catalyst-sdk";
|
|
16
|
+
import { v4 } from "uuid";
|
|
17
|
+
|
|
18
|
+
const API_KEY = {
|
|
19
|
+
clientId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
20
|
+
clientSecret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
21
|
+
redirectUri: "https://example.com/callback",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const client = new CatalystTS({
|
|
25
|
+
clientId: API_KEY.clientId,
|
|
26
|
+
clientSecret: API_KEY.clientSecret,
|
|
27
|
+
accessToken: "",
|
|
28
|
+
refreshToken: "",
|
|
29
|
+
});
|
|
30
|
+
const pkce = await PKCE.create();
|
|
31
|
+
const state = v4();
|
|
32
|
+
const redirect = client.oauth.getAuthorizeURL(API_KEY.redirectUri, pkce, state);
|
|
33
|
+
|
|
34
|
+
// redirected to `redirectUri`
|
|
35
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
36
|
+
const code = searchParams.get("code");
|
|
37
|
+
const returnedState = searchParams.get("state");
|
|
38
|
+
|
|
39
|
+
if (code && returnedState === state) {
|
|
40
|
+
const { accessToken, refreshToken } = await client.oauth.getAccessTokenByCode(
|
|
41
|
+
code,
|
|
42
|
+
API_KEY.redirectUri,
|
|
43
|
+
pkce,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
console.log("accessToken:", accessToken);
|
|
47
|
+
console.log("refreshToken:", refreshToken);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// call user specified APIs
|
|
51
|
+
const me = await client.egeria.me();
|
|
52
|
+
console.log({ me });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT by [@6jz](https://twitter.com/6jz)
|
package/dist/index.d.mts
CHANGED
|
@@ -348,11 +348,9 @@ interface CatalystContest {
|
|
|
348
348
|
winnersOpenAt: string;
|
|
349
349
|
winnersMessageSendAt: string;
|
|
350
350
|
publishedAt: string;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
allowSensitive: boolean;
|
|
355
|
-
};
|
|
351
|
+
since: string;
|
|
352
|
+
until: string;
|
|
353
|
+
allowSensitive: boolean;
|
|
356
354
|
voting: {
|
|
357
355
|
since: string;
|
|
358
356
|
until: string;
|
|
@@ -411,7 +409,7 @@ interface CatalystUserVoteRights {
|
|
|
411
409
|
}
|
|
412
410
|
|
|
413
411
|
interface ReportRequest {
|
|
414
|
-
|
|
412
|
+
reason: "nsfw" | "tos_violation" | "harassment" | "spam" | "other";
|
|
415
413
|
description?: string;
|
|
416
414
|
}
|
|
417
415
|
|
package/dist/index.d.ts
CHANGED
|
@@ -348,11 +348,9 @@ interface CatalystContest {
|
|
|
348
348
|
winnersOpenAt: string;
|
|
349
349
|
winnersMessageSendAt: string;
|
|
350
350
|
publishedAt: string;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
allowSensitive: boolean;
|
|
355
|
-
};
|
|
351
|
+
since: string;
|
|
352
|
+
until: string;
|
|
353
|
+
allowSensitive: boolean;
|
|
356
354
|
voting: {
|
|
357
355
|
since: string;
|
|
358
356
|
until: string;
|
|
@@ -411,7 +409,7 @@ interface CatalystUserVoteRights {
|
|
|
411
409
|
}
|
|
412
410
|
|
|
413
411
|
interface ReportRequest {
|
|
414
|
-
|
|
412
|
+
reason: "nsfw" | "tos_violation" | "harassment" | "spam" | "other";
|
|
415
413
|
description?: string;
|
|
416
414
|
}
|
|
417
415
|
|