Skip to content

Commit

Permalink
fix auth when use toJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
KTNG-3 committed Aug 10, 2024
1 parent e53a164 commit af9b0d2
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NodeJS packages that make more easier to use Valorant API
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
10 changes: 10 additions & 0 deletions packages/@valapi/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 5.0.0-beta.2

Fix serializer

### Typescript

**Add**

- `RequestConfig.certificate`

# 5.0.0-beta.1

**_[Blocked by Cloudflare #9](https://github.com/valapi/node-valapi/issues/9)_**
Expand Down
9 changes: 6 additions & 3 deletions packages/@valapi/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Valorant Authentication
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down Expand Up @@ -66,6 +67,8 @@ const auth = new Auth();

### Captcha

_This is only an example function_

```typescript
const data = await auth.captcha();

Expand All @@ -76,8 +79,8 @@ const captchaResponse = await getCaptchaResponse(data); // P1_eyJ...

```typescript
await auth.login({
username: "BestUsername",
password: "SuperSecretPassword",
username: "BestUsername",
password: "SuperSecretPassword",
captcha: captchaResponse
});
```
Expand All @@ -96,7 +99,7 @@ if (auth.isMultifactor) {
const subject = auth.subject;
```

**Save**
**Serialize**

```typescript
const auth = new Auth({ user: oldAuth.toJSON() });
Expand Down
4 changes: 2 additions & 2 deletions packages/@valapi/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/auth",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://valapi.github.io/guide",
"dependencies": {
"@valapi/lib": "5.0.0-beta.1",
"@valapi/lib": "5.0.0-beta.2",
"axios": "^1.7.3",
"http-cookie-agent": "^6.0.5",
"selfsigned": "^2.4.1",
Expand Down
16 changes: 9 additions & 7 deletions packages/@valapi/auth/src/client/AuthRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export interface RequestConfig {
platform?: ClientPlatfrom;
axiosConfig?: AxiosRequestConfig;
agentConfig?: AgentOptions & CookieAgentOptions;
certificate?: selfsigned.GenerateResult;
cookie: CookieJar;
}

export class AuthRequest {
public readonly certificate: selfsigned.GenerateResult;

public readonly headers: AxiosHeaders;
public readonly agent: CookieAgent<Agent>;

Expand All @@ -57,12 +57,14 @@ export class AuthRequest {

this.defaultAxiosConfig = __config.axiosConfig;

this.certificate = selfsigned.generate([], {
days: 30,
pkcs7: true,
clientCertificate: true,
clientCertificateCN: ValEncryption.randomString(16)
});
this.certificate =
__config.certificate ??
selfsigned.generate([], {
days: 30,
pkcs7: true,
clientCertificate: true,
clientCertificateCN: ValEncryption.randomString(16)
});

this.headers = new AxiosHeaders()
.setContentType("application/json")
Expand Down
1 change: 1 addition & 0 deletions packages/@valapi/crosshair/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Valorant Crosshair Compiler
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/@valapi/crosshair/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/crosshair",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand All @@ -27,7 +27,7 @@
},
"homepage": "https://valapi.github.io/guide",
"dependencies": {
"@valapi/lib": "5.0.0-beta.1"
"@valapi/lib": "5.0.0-beta.2"
},
"directories": {
"lib": "build",
Expand Down
1 change: 1 addition & 0 deletions packages/@valapi/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Library of **@valapi**
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/@valapi/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/lib",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/@valapi/riot-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Official Api From Riot Games
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/@valapi/riot-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/riot-api",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand All @@ -27,7 +27,7 @@
},
"homepage": "https://valapi.github.io/guide",
"dependencies": {
"@valapi/lib": "5.0.0-beta.1",
"@valapi/lib": "5.0.0-beta.2",
"axios": "^1.7.3"
},
"directories": {
Expand Down
1 change: 1 addition & 0 deletions packages/@valapi/valorant-api.com/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/@valapi/valorant-api.com/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/valorant-api.com",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand All @@ -27,7 +27,7 @@
},
"homepage": "https://valapi.github.io/guide",
"dependencies": {
"@valapi/lib": "5.0.0-beta.1",
"@valapi/lib": "5.0.0-beta.2",
"axios": "^1.7.3"
},
"directories": {
Expand Down
1 change: 1 addition & 0 deletions packages/@valapi/web-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Web API
[![Discord][discord_image]][discord_url]

Documentation: [valapi.github.io/docs](https://valapi.github.io/docs)

Guide: [valapi.github.io/guide](https://valapi.github.io/guide)

</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/@valapi/web-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@valapi/web-client",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand Down Expand Up @@ -28,8 +28,8 @@
},
"homepage": "https://valapi.github.io/guide",
"dependencies": {
"@valapi/auth": "5.0.0-beta.1",
"@valapi/lib": "5.0.0-beta.1"
"@valapi/auth": "5.0.0-beta.2",
"@valapi/lib": "5.0.0-beta.2"
},
"directories": {
"lib": "build",
Expand Down

0 comments on commit af9b0d2

Please sign in to comment.