@yaelouuu/fortnite-api 1.0.0 → 1.1.0

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 CHANGED
@@ -44,4 +44,5 @@ const season = await client.calendar.getCurrentSeason();
44
44
 
45
45
  ## Documentation
46
46
 
47
- Full API documentation: https://api.api-fortnite.com/documentation
47
+ Full API documentation (swagger): https://documentation.api-fortnite.com/documentation
48
+ SDK documentation: https://api-fortnite.com/sdk-doc
package/dist/client.d.ts CHANGED
@@ -3,6 +3,7 @@ import { TournamentsResource } from "./resources/tournaments";
3
3
  import { ProfilesResource } from "./resources/profiles";
4
4
  import { CalendarResource } from "./resources/calendar";
5
5
  import { BundlesResource } from "./resources/bundles";
6
+ import { OauthResource } from "./resources/oauth";
6
7
  export interface ClientOptions {
7
8
  apiKey: string;
8
9
  baseUrl?: string;
@@ -15,6 +16,7 @@ export declare class FortniteAPI {
15
16
  profiles: ProfilesResource;
16
17
  calendar: CalendarResource;
17
18
  bundles: BundlesResource;
19
+ oauth: OauthResource;
18
20
  constructor(options: ClientOptions);
19
21
  /**
20
22
  * Internal method to make HTTP requests
package/dist/client.js CHANGED
@@ -7,6 +7,7 @@ const profiles_1 = require("./resources/profiles");
7
7
  const calendar_1 = require("./resources/calendar");
8
8
  const errors_1 = require("./errors");
9
9
  const bundles_1 = require("./resources/bundles");
10
+ const oauth_1 = require("./resources/oauth");
10
11
  class FortniteAPI {
11
12
  constructor(options) {
12
13
  this.apiKey = options.apiKey;
@@ -18,6 +19,7 @@ class FortniteAPI {
18
19
  this.profiles = new profiles_1.ProfilesResource(this);
19
20
  this.calendar = new calendar_1.CalendarResource(this);
20
21
  this.bundles = new bundles_1.BundlesResource(this);
22
+ this.oauth = new oauth_1.OauthResource(this);
21
23
  }
22
24
  /**
23
25
  * Internal method to make HTTP requests
@@ -0,0 +1,30 @@
1
+ import { FortniteAPI } from "../client";
2
+ import { OAuthCompleteResponse, OAuthDeviceRefreshResponse, OAuthFlowResponse, OAuthRefreshResponse } from "../types";
3
+ export declare class OauthResource {
4
+ private client;
5
+ constructor(client: FortniteAPI);
6
+ /**
7
+ * Initiate OAuth flow - GET /oauth/get-token
8
+ * Returns a verification URL for the user to authenticate
9
+ */
10
+ getToken(): Promise<OAuthFlowResponse>;
11
+ /**
12
+ * Complete OAuth flow - POST /oauth/complete
13
+ * Call this after user has visited the verification URL
14
+ */
15
+ completeOauth(flowId: string): Promise<OAuthCompleteResponse>;
16
+ /**
17
+ * Refresh access token - POST /oauth/refresh-token
18
+ * Use when access token expires (~2 hours)
19
+ */
20
+ refreshToken(refreshToken: string): Promise<OAuthRefreshResponse>;
21
+ /**
22
+ * Refresh with device auth - POST /oauth/refresh-device
23
+ * Use device auth credentials to get fresh tokens (never expires)
24
+ */
25
+ refreshDevice(params: {
26
+ accountId: string;
27
+ deviceId: string;
28
+ secret: string;
29
+ }): Promise<OAuthDeviceRefreshResponse>;
30
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OauthResource = void 0;
4
+ class OauthResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Initiate OAuth flow - GET /oauth/get-token
10
+ * Returns a verification URL for the user to authenticate
11
+ */
12
+ async getToken() {
13
+ return this.client.request("/oauth/get-token");
14
+ }
15
+ /**
16
+ * Complete OAuth flow - POST /oauth/complete
17
+ * Call this after user has visited the verification URL
18
+ */
19
+ async completeOauth(flowId) {
20
+ return this.client.request("/oauth/complete", {
21
+ method: "POST",
22
+ body: JSON.stringify({ flowId }),
23
+ });
24
+ }
25
+ /**
26
+ * Refresh access token - POST /oauth/refresh-token
27
+ * Use when access token expires (~2 hours)
28
+ */
29
+ async refreshToken(refreshToken) {
30
+ return this.client.request("/oauth/refresh-token", {
31
+ method: "POST",
32
+ body: JSON.stringify({ refreshToken }),
33
+ });
34
+ }
35
+ /**
36
+ * Refresh with device auth - POST /oauth/refresh-device
37
+ * Use device auth credentials to get fresh tokens (never expires)
38
+ */
39
+ async refreshDevice(params) {
40
+ return this.client.request("/oauth/refresh-device", {
41
+ method: "POST",
42
+ body: JSON.stringify(params),
43
+ });
44
+ }
45
+ }
46
+ exports.OauthResource = OauthResource;
@@ -58,3 +58,38 @@ export interface SeasonInfo {
58
58
  seasonNumber: number;
59
59
  exTime: number;
60
60
  }
61
+ export interface OAuthFlowResponse {
62
+ success: boolean;
63
+ flowId: string;
64
+ verificationUri: string;
65
+ expiresIn: number;
66
+ }
67
+ export interface OAuthCompleteResponse {
68
+ success: boolean;
69
+ accessToken: string;
70
+ refreshToken: string;
71
+ expiresIn: number;
72
+ accountId: string;
73
+ displayName: string;
74
+ deviceAuth: {
75
+ accountId: string;
76
+ deviceId: string;
77
+ secret: string;
78
+ };
79
+ }
80
+ export interface OAuthRefreshResponse {
81
+ success: boolean;
82
+ accessToken: string;
83
+ refreshToken: string;
84
+ expiresIn: number;
85
+ accountId: string;
86
+ tokenChanged: boolean;
87
+ }
88
+ export interface OAuthDeviceRefreshResponse {
89
+ success: boolean;
90
+ accessToken: string;
91
+ refreshToken: string;
92
+ expiresIn: number;
93
+ accountId: string;
94
+ displayName: string;
95
+ }
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Oauth types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaelouuu/fortnite-api",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "SDK for Fortnite Tournaments API by Royal Arena - Author : yaelouuu",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",