@rixl/sdk 0.4.1 → 0.5.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/dist/index.d.ts +5941 -1154
- package/dist/index.js +3715 -143
- package/dist/index.js.map +1 -1
- package/dist/providers-Cu3u1p1O.js +261 -0
- package/dist/providers-Cu3u1p1O.js.map +1 -0
- package/package.json +26 -12
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { _ as HTTP_STATUS, a as telegramConfig, b as __exportAll, c as appleConfig, d as microsoftConfig, f as updateMicrosoftAuthUrl, g as GLOBAL_PREFIX, h as updateGoogleAuthUrl, i as telegramAuthUrl, l as updateAppleAuthUrl, m as googleConfig, n as detectProvider, o as updateTelegramAuthUrl, p as googleAuthUrl, r as getProviderToken, s as appleAuthUrl, u as microsoftAuthUrl, v as SOCIAL_CONNECT_KEY_PREFIX, y as AuthProvider } from "./providers-Cu3u1p1O.js";
|
|
2
|
+
import { atom } from "nanostores";
|
|
3
|
+
import { decodeJwt } from "jose";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import "ky";
|
|
6
|
+
|
|
7
|
+
//#region src/generated/core/bodySerializer.gen.ts
|
|
2
8
|
const serializeFormDataPair = (data, key, value) => {
|
|
3
9
|
if (typeof value === "string" || value instanceof Blob) data.append(key, value);
|
|
4
10
|
else if (value instanceof Date) data.append(key, value.toISOString());
|
|
@@ -16,7 +22,7 @@ const formDataBodySerializer = { bodySerializer: (body) => {
|
|
|
16
22
|
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
17
23
|
|
|
18
24
|
//#endregion
|
|
19
|
-
//#region src/core/params.gen.ts
|
|
25
|
+
//#region src/generated/core/params.gen.ts
|
|
20
26
|
const extraPrefixes = Object.entries({
|
|
21
27
|
$body_: "body",
|
|
22
28
|
$headers_: "headers",
|
|
@@ -25,7 +31,7 @@ const extraPrefixes = Object.entries({
|
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
//#endregion
|
|
28
|
-
//#region src/core/serverSentEvents.gen.ts
|
|
34
|
+
//#region src/generated/core/serverSentEvents.gen.ts
|
|
29
35
|
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
30
36
|
let lastEventId;
|
|
31
37
|
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
@@ -110,7 +116,8 @@ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransforme
|
|
|
110
116
|
} catch (error) {
|
|
111
117
|
onSseError?.(error);
|
|
112
118
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
113
|
-
|
|
119
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
120
|
+
await sleep(backoff);
|
|
114
121
|
}
|
|
115
122
|
}
|
|
116
123
|
};
|
|
@@ -118,7 +125,7 @@ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransforme
|
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
//#endregion
|
|
121
|
-
//#region src/core/pathSerializer.gen.ts
|
|
128
|
+
//#region src/generated/core/pathSerializer.gen.ts
|
|
122
129
|
const separatorArrayExplode = (style) => {
|
|
123
130
|
switch (style) {
|
|
124
131
|
case "label": return ".";
|
|
@@ -198,7 +205,7 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
|
|
|
198
205
|
};
|
|
199
206
|
|
|
200
207
|
//#endregion
|
|
201
|
-
//#region src/core/utils.gen.ts
|
|
208
|
+
//#region src/generated/core/utils.gen.ts
|
|
202
209
|
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
203
210
|
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
204
211
|
let url = _url;
|
|
@@ -273,7 +280,7 @@ function getValidRequestBody(options) {
|
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
//#endregion
|
|
276
|
-
//#region src/core/auth.gen.ts
|
|
283
|
+
//#region src/generated/core/auth.gen.ts
|
|
277
284
|
const getAuthToken = async (auth, callback) => {
|
|
278
285
|
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
279
286
|
if (!token) return;
|
|
@@ -283,7 +290,7 @@ const getAuthToken = async (auth, callback) => {
|
|
|
283
290
|
};
|
|
284
291
|
|
|
285
292
|
//#endregion
|
|
286
|
-
//#region src/client/utils.gen.ts
|
|
293
|
+
//#region src/generated/client/utils.gen.ts
|
|
287
294
|
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
288
295
|
const querySerializer = (queryParams) => {
|
|
289
296
|
const search = [];
|
|
@@ -456,7 +463,7 @@ const createConfig = (override = {}) => ({
|
|
|
456
463
|
});
|
|
457
464
|
|
|
458
465
|
//#endregion
|
|
459
|
-
//#region src/client/client.gen.ts
|
|
466
|
+
//#region src/generated/client/client.gen.ts
|
|
460
467
|
const createClient = (config = {}) => {
|
|
461
468
|
let _config = mergeConfigs(createConfig(), config);
|
|
462
469
|
const getConfig = () => ({ ..._config });
|
|
@@ -630,236 +637,399 @@ const createClient = (config = {}) => {
|
|
|
630
637
|
};
|
|
631
638
|
|
|
632
639
|
//#endregion
|
|
633
|
-
//#region src/client.gen.ts
|
|
634
|
-
const client = createClient(createConfig(
|
|
640
|
+
//#region src/generated/client.gen.ts
|
|
641
|
+
const client = createClient(createConfig());
|
|
635
642
|
|
|
636
643
|
//#endregion
|
|
637
|
-
//#region src/sdk.gen.ts
|
|
644
|
+
//#region src/generated/sdk.gen.ts
|
|
638
645
|
/**
|
|
639
|
-
*
|
|
646
|
+
* Dashboard analytics
|
|
640
647
|
*
|
|
641
|
-
*
|
|
648
|
+
* Returns time-bucketed dashboard statistics
|
|
642
649
|
*/
|
|
643
|
-
const
|
|
644
|
-
|
|
650
|
+
const getAnalyticsV1Dashboard = (options) => (options.client ?? client).get({
|
|
651
|
+
security: [{
|
|
652
|
+
name: "X-API-Key",
|
|
653
|
+
type: "apiKey"
|
|
654
|
+
}],
|
|
655
|
+
url: "/analytics/v1/dashboard",
|
|
645
656
|
...options
|
|
646
657
|
});
|
|
647
658
|
/**
|
|
648
|
-
*
|
|
659
|
+
* Track analytics events
|
|
660
|
+
*
|
|
661
|
+
* Ingest a batch of analytics events for the authenticated organization
|
|
662
|
+
*/
|
|
663
|
+
const postAnalyticsV1Events = (options) => (options.client ?? client).post({
|
|
664
|
+
security: [{
|
|
665
|
+
name: "X-API-Key",
|
|
666
|
+
type: "apiKey"
|
|
667
|
+
}],
|
|
668
|
+
url: "/analytics/v1/events",
|
|
669
|
+
...options,
|
|
670
|
+
headers: {
|
|
671
|
+
"Content-Type": "application/json",
|
|
672
|
+
...options.headers
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
/**
|
|
676
|
+
* Get feed statistics
|
|
649
677
|
*
|
|
650
|
-
*
|
|
678
|
+
* Returns aggregated statistics for a feed over a date range
|
|
651
679
|
*/
|
|
652
|
-
const
|
|
653
|
-
|
|
680
|
+
const getAnalyticsV1FeedsByFeedIdStats = (options) => (options.client ?? client).get({
|
|
681
|
+
security: [{
|
|
682
|
+
name: "X-API-Key",
|
|
683
|
+
type: "apiKey"
|
|
684
|
+
}],
|
|
685
|
+
url: "/analytics/v1/feeds/{feedId}/stats",
|
|
654
686
|
...options
|
|
655
687
|
});
|
|
656
688
|
/**
|
|
657
|
-
*
|
|
689
|
+
* Funnel analytics
|
|
690
|
+
*
|
|
691
|
+
* Calculate funnel conversion across a sequence of steps
|
|
692
|
+
*/
|
|
693
|
+
const postAnalyticsV1Funnels = (options) => (options.client ?? client).post({
|
|
694
|
+
security: [{
|
|
695
|
+
name: "X-API-Key",
|
|
696
|
+
type: "apiKey"
|
|
697
|
+
}],
|
|
698
|
+
url: "/analytics/v1/funnels",
|
|
699
|
+
...options,
|
|
700
|
+
headers: {
|
|
701
|
+
"Content-Type": "application/json",
|
|
702
|
+
...options.headers
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
/**
|
|
706
|
+
* Get post statistics
|
|
658
707
|
*
|
|
659
|
-
*
|
|
708
|
+
* Returns aggregated statistics for a post
|
|
660
709
|
*/
|
|
661
|
-
const
|
|
662
|
-
|
|
710
|
+
const getAnalyticsV1PostsByPostIdStats = (options) => (options.client ?? client).get({
|
|
711
|
+
security: [{
|
|
712
|
+
name: "X-API-Key",
|
|
713
|
+
type: "apiKey"
|
|
714
|
+
}],
|
|
715
|
+
url: "/analytics/v1/posts/{postId}/stats",
|
|
663
716
|
...options
|
|
664
717
|
});
|
|
665
718
|
/**
|
|
666
|
-
*
|
|
719
|
+
* Realtime analytics
|
|
667
720
|
*
|
|
668
|
-
*
|
|
721
|
+
* Returns real-time analytics snapshot
|
|
669
722
|
*/
|
|
670
|
-
const
|
|
723
|
+
const getAnalyticsV1Realtime = (options) => (options?.client ?? client).get({
|
|
671
724
|
security: [{
|
|
672
725
|
name: "X-API-Key",
|
|
673
726
|
type: "apiKey"
|
|
674
727
|
}],
|
|
675
|
-
url: "/
|
|
728
|
+
url: "/analytics/v1/realtime",
|
|
676
729
|
...options
|
|
677
730
|
});
|
|
678
731
|
/**
|
|
679
|
-
*
|
|
732
|
+
* Retention analytics
|
|
680
733
|
*
|
|
681
|
-
*
|
|
734
|
+
* Returns retention cohorts over a date range
|
|
682
735
|
*/
|
|
683
|
-
const
|
|
736
|
+
const getAnalyticsV1Retention = (options) => (options?.client ?? client).get({
|
|
684
737
|
security: [{
|
|
685
738
|
name: "X-API-Key",
|
|
686
739
|
type: "apiKey"
|
|
687
740
|
}],
|
|
688
|
-
url: "/
|
|
741
|
+
url: "/analytics/v1/retention",
|
|
689
742
|
...options
|
|
690
743
|
});
|
|
691
744
|
/**
|
|
692
|
-
* Get
|
|
745
|
+
* Get top feeds
|
|
693
746
|
*
|
|
694
|
-
*
|
|
747
|
+
* Returns the top feeds over a date range
|
|
695
748
|
*/
|
|
696
|
-
const
|
|
749
|
+
const getAnalyticsV1TopFeeds = (options) => (options?.client ?? client).get({
|
|
697
750
|
security: [{
|
|
698
751
|
name: "X-API-Key",
|
|
699
752
|
type: "apiKey"
|
|
700
753
|
}],
|
|
701
|
-
url: "/
|
|
754
|
+
url: "/analytics/v1/top/feeds",
|
|
702
755
|
...options
|
|
703
756
|
});
|
|
704
757
|
/**
|
|
705
|
-
*
|
|
758
|
+
* Get top posts
|
|
706
759
|
*
|
|
707
|
-
*
|
|
760
|
+
* Returns the top posts over a date range
|
|
708
761
|
*/
|
|
709
|
-
const
|
|
762
|
+
const getAnalyticsV1TopPosts = (options) => (options?.client ?? client).get({
|
|
710
763
|
security: [{
|
|
711
764
|
name: "X-API-Key",
|
|
712
765
|
type: "apiKey"
|
|
713
766
|
}],
|
|
714
|
-
url: "/
|
|
715
|
-
...options
|
|
716
|
-
headers: {
|
|
717
|
-
"Content-Type": "application/json",
|
|
718
|
-
...options.headers
|
|
719
|
-
}
|
|
767
|
+
url: "/analytics/v1/top/posts",
|
|
768
|
+
...options
|
|
720
769
|
});
|
|
721
770
|
/**
|
|
722
|
-
*
|
|
771
|
+
* Get top videos
|
|
723
772
|
*
|
|
724
|
-
*
|
|
773
|
+
* Returns the top videos over a date range
|
|
725
774
|
*/
|
|
726
|
-
const
|
|
775
|
+
const getAnalyticsV1TopVideos = (options) => (options?.client ?? client).get({
|
|
727
776
|
security: [{
|
|
728
777
|
name: "X-API-Key",
|
|
729
778
|
type: "apiKey"
|
|
730
779
|
}],
|
|
731
|
-
url: "/
|
|
732
|
-
...options
|
|
733
|
-
headers: {
|
|
734
|
-
"Content-Type": "application/json",
|
|
735
|
-
...options.headers
|
|
736
|
-
}
|
|
780
|
+
url: "/analytics/v1/top/videos",
|
|
781
|
+
...options
|
|
737
782
|
});
|
|
738
783
|
/**
|
|
739
|
-
*
|
|
784
|
+
* Get video heatmap
|
|
740
785
|
*
|
|
741
|
-
*
|
|
786
|
+
* Returns the engagement heatmap for a video
|
|
742
787
|
*/
|
|
743
|
-
const
|
|
788
|
+
const getAnalyticsV1VideosByVideoIdHeatmap = (options) => (options.client ?? client).get({
|
|
744
789
|
security: [{
|
|
745
790
|
name: "X-API-Key",
|
|
746
791
|
type: "apiKey"
|
|
747
792
|
}],
|
|
748
|
-
url: "/videos",
|
|
793
|
+
url: "/analytics/v1/videos/{videoId}/heatmap",
|
|
749
794
|
...options
|
|
750
795
|
});
|
|
751
796
|
/**
|
|
752
|
-
* Get
|
|
797
|
+
* Get hot segments
|
|
753
798
|
*
|
|
754
|
-
*
|
|
799
|
+
* Returns the most engaging segments of a video
|
|
755
800
|
*/
|
|
756
|
-
const
|
|
801
|
+
const getAnalyticsV1VideosByVideoIdHotSegments = (options) => (options.client ?? client).get({
|
|
757
802
|
security: [{
|
|
758
803
|
name: "X-API-Key",
|
|
759
804
|
type: "apiKey"
|
|
760
805
|
}],
|
|
761
|
-
url: "/videos/{videoId}",
|
|
806
|
+
url: "/analytics/v1/videos/{videoId}/hot-segments",
|
|
762
807
|
...options
|
|
763
808
|
});
|
|
764
809
|
/**
|
|
765
|
-
*
|
|
810
|
+
* Get video statistics
|
|
766
811
|
*
|
|
767
|
-
*
|
|
812
|
+
* Returns aggregated statistics for a video over a date range
|
|
768
813
|
*/
|
|
769
|
-
const
|
|
814
|
+
const getAnalyticsV1VideosByVideoIdStats = (options) => (options.client ?? client).get({
|
|
770
815
|
security: [{
|
|
771
816
|
name: "X-API-Key",
|
|
772
817
|
type: "apiKey"
|
|
773
818
|
}],
|
|
774
|
-
url: "/videos/{videoId}/
|
|
819
|
+
url: "/analytics/v1/videos/{videoId}/stats",
|
|
775
820
|
...options
|
|
776
821
|
});
|
|
777
822
|
/**
|
|
778
|
-
*
|
|
823
|
+
* Subscribe to the blog
|
|
779
824
|
*
|
|
780
|
-
*
|
|
825
|
+
* Subscribes the authenticated user to the blog newsletter.
|
|
781
826
|
*/
|
|
782
|
-
const
|
|
783
|
-
|
|
827
|
+
const postAuthV1BlogSubscribe = (options) => (options?.client ?? client).post({
|
|
828
|
+
security: [{
|
|
829
|
+
name: "X-API-Key",
|
|
830
|
+
type: "apiKey"
|
|
831
|
+
}],
|
|
832
|
+
url: "/auth/v1/blog/subscribe",
|
|
833
|
+
...options
|
|
834
|
+
});
|
|
835
|
+
/**
|
|
836
|
+
* Get blog subscription status
|
|
837
|
+
*
|
|
838
|
+
* Returns whether the authenticated user is subscribed to the blog newsletter.
|
|
839
|
+
*/
|
|
840
|
+
const getAuthV1BlogSubscription = (options) => (options?.client ?? client).get({
|
|
841
|
+
security: [{
|
|
842
|
+
name: "X-API-Key",
|
|
843
|
+
type: "apiKey"
|
|
844
|
+
}],
|
|
845
|
+
url: "/auth/v1/blog/subscription",
|
|
846
|
+
...options
|
|
847
|
+
});
|
|
848
|
+
/**
|
|
849
|
+
* Unsubscribe from the blog
|
|
850
|
+
*
|
|
851
|
+
* Unsubscribes the authenticated user from the blog newsletter.
|
|
852
|
+
*/
|
|
853
|
+
const postAuthV1BlogUnsubscribe = (options) => (options?.client ?? client).post({
|
|
784
854
|
security: [{
|
|
785
855
|
name: "X-API-Key",
|
|
786
856
|
type: "apiKey"
|
|
787
857
|
}],
|
|
788
|
-
url: "/
|
|
858
|
+
url: "/auth/v1/blog/unsubscribe",
|
|
859
|
+
...options
|
|
860
|
+
});
|
|
861
|
+
/**
|
|
862
|
+
* Unsubscribe from the blog by email
|
|
863
|
+
*
|
|
864
|
+
* Unsubscribes a recipient using the user id and email from an email-footer link. No authentication required.
|
|
865
|
+
*/
|
|
866
|
+
const postAuthV1BlogUnsubscribeEmail = (options) => (options.client ?? client).post({
|
|
867
|
+
url: "/auth/v1/blog/unsubscribe/email",
|
|
789
868
|
...options,
|
|
790
869
|
headers: {
|
|
791
|
-
"Content-Type":
|
|
870
|
+
"Content-Type": "application/json",
|
|
871
|
+
...options.headers
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
/**
|
|
875
|
+
* Verify email with a code
|
|
876
|
+
*
|
|
877
|
+
* Verifies a user's email address using a verification id and the code sent to them.
|
|
878
|
+
*/
|
|
879
|
+
const postAuthV1EmailVerify = (options) => (options.client ?? client).post({
|
|
880
|
+
url: "/auth/v1/email/verify",
|
|
881
|
+
...options,
|
|
882
|
+
headers: {
|
|
883
|
+
"Content-Type": "application/json",
|
|
884
|
+
...options.headers
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
/**
|
|
888
|
+
* Resend email verification
|
|
889
|
+
*
|
|
890
|
+
* Resends the email verification message to the given email address.
|
|
891
|
+
*/
|
|
892
|
+
const postAuthV1EmailVerifyResend = (options) => (options.client ?? client).post({
|
|
893
|
+
url: "/auth/v1/email/verify/resend",
|
|
894
|
+
...options,
|
|
895
|
+
headers: {
|
|
896
|
+
"Content-Type": "application/json",
|
|
897
|
+
...options.headers
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
/**
|
|
901
|
+
* Accept an organization invitation
|
|
902
|
+
*
|
|
903
|
+
* Accepts the organization invitation identified by the provided token.
|
|
904
|
+
*/
|
|
905
|
+
const postAuthV1InvitationsByTokenAccept = (options) => (options.client ?? client).post({
|
|
906
|
+
url: "/auth/v1/invitations/{token}/accept",
|
|
907
|
+
...options
|
|
908
|
+
});
|
|
909
|
+
/**
|
|
910
|
+
* Decline an organization invitation
|
|
911
|
+
*
|
|
912
|
+
* Declines the organization invitation identified by the provided token.
|
|
913
|
+
*/
|
|
914
|
+
const postAuthV1InvitationsByTokenDecline = (options) => (options.client ?? client).post({
|
|
915
|
+
url: "/auth/v1/invitations/{token}/decline",
|
|
916
|
+
...options
|
|
917
|
+
});
|
|
918
|
+
/**
|
|
919
|
+
* Log in with email and password
|
|
920
|
+
*
|
|
921
|
+
* Authenticates a user by email and password and issues access and refresh tokens.
|
|
922
|
+
*/
|
|
923
|
+
const postAuthV1Login = (options) => (options.client ?? client).post({
|
|
924
|
+
url: "/auth/v1/login",
|
|
925
|
+
...options,
|
|
926
|
+
headers: {
|
|
927
|
+
"Content-Type": "application/json",
|
|
792
928
|
...options.headers
|
|
793
929
|
}
|
|
794
930
|
});
|
|
795
931
|
/**
|
|
796
|
-
*
|
|
932
|
+
* Log out (revoke the current access token)
|
|
933
|
+
*
|
|
934
|
+
* Revokes the current access token so it can no longer be used.
|
|
935
|
+
*/
|
|
936
|
+
const postAuthV1Logout = (options) => (options?.client ?? client).post({
|
|
937
|
+
url: "/auth/v1/logout",
|
|
938
|
+
...options
|
|
939
|
+
});
|
|
940
|
+
/**
|
|
941
|
+
* Set the active membership
|
|
797
942
|
*
|
|
798
|
-
*
|
|
943
|
+
* Sets the specified membership as the authenticated user's currently active organization.
|
|
799
944
|
*/
|
|
800
|
-
const
|
|
945
|
+
const putAuthV1MembershipsByOrgIdActive = (options) => (options.client ?? client).put({
|
|
801
946
|
security: [{
|
|
802
947
|
name: "X-API-Key",
|
|
803
948
|
type: "apiKey"
|
|
804
949
|
}],
|
|
805
|
-
url: "/
|
|
950
|
+
url: "/auth/v1/memberships/{orgId}/active",
|
|
806
951
|
...options
|
|
807
952
|
});
|
|
808
953
|
/**
|
|
809
|
-
*
|
|
954
|
+
* Check the current user's membership in an organization
|
|
810
955
|
*
|
|
811
|
-
*
|
|
956
|
+
* Checks whether the authenticated user is a member of the specified organization and returns their membership status.
|
|
812
957
|
*/
|
|
813
|
-
const
|
|
958
|
+
const getAuthV1MembershipsByOrgIdCheck = (options) => (options.client ?? client).get({
|
|
814
959
|
security: [{
|
|
815
960
|
name: "X-API-Key",
|
|
816
961
|
type: "apiKey"
|
|
817
962
|
}],
|
|
818
|
-
url: "/
|
|
963
|
+
url: "/auth/v1/memberships/{orgId}/check",
|
|
819
964
|
...options
|
|
820
965
|
});
|
|
821
966
|
/**
|
|
822
|
-
*
|
|
967
|
+
* Remove a custom domain
|
|
823
968
|
*
|
|
824
|
-
*
|
|
969
|
+
* Removes the custom domain from the organization and clears its verification.
|
|
825
970
|
*/
|
|
826
|
-
const
|
|
827
|
-
|
|
971
|
+
const deleteAuthV1MembershipsByOrgIdDomain = (options) => (options.client ?? client).delete({
|
|
972
|
+
security: [{
|
|
973
|
+
name: "X-API-Key",
|
|
974
|
+
type: "apiKey"
|
|
975
|
+
}],
|
|
976
|
+
url: "/auth/v1/memberships/{orgId}/domain",
|
|
977
|
+
...options
|
|
978
|
+
});
|
|
979
|
+
/**
|
|
980
|
+
* Get custom domain status
|
|
981
|
+
*
|
|
982
|
+
* Returns the current custom domain and its verification status for the organization.
|
|
983
|
+
*/
|
|
984
|
+
const getAuthV1MembershipsByOrgIdDomain = (options) => (options.client ?? client).get({
|
|
985
|
+
security: [{
|
|
986
|
+
name: "X-API-Key",
|
|
987
|
+
type: "apiKey"
|
|
988
|
+
}],
|
|
989
|
+
url: "/auth/v1/memberships/{orgId}/domain",
|
|
990
|
+
...options
|
|
991
|
+
});
|
|
992
|
+
/**
|
|
993
|
+
* Create a custom domain verification
|
|
994
|
+
*
|
|
995
|
+
* Registers a custom domain for the organization and issues verification details to prove ownership.
|
|
996
|
+
*/
|
|
997
|
+
const postAuthV1MembershipsByOrgIdDomain = (options) => (options.client ?? client).post({
|
|
828
998
|
security: [{
|
|
829
999
|
name: "X-API-Key",
|
|
830
1000
|
type: "apiKey"
|
|
831
1001
|
}],
|
|
832
|
-
url: "/
|
|
1002
|
+
url: "/auth/v1/memberships/{orgId}/domain",
|
|
833
1003
|
...options,
|
|
834
1004
|
headers: {
|
|
835
|
-
"Content-Type":
|
|
1005
|
+
"Content-Type": "application/json",
|
|
836
1006
|
...options.headers
|
|
837
1007
|
}
|
|
838
1008
|
});
|
|
839
1009
|
/**
|
|
840
|
-
*
|
|
1010
|
+
* Get domain auto-join setting
|
|
841
1011
|
*
|
|
842
|
-
*
|
|
1012
|
+
* Returns whether users with a matching verified domain email are automatically added to the organization.
|
|
843
1013
|
*/
|
|
844
|
-
const
|
|
1014
|
+
const getAuthV1MembershipsByOrgIdDomainAutoJoin = (options) => (options.client ?? client).get({
|
|
845
1015
|
security: [{
|
|
846
1016
|
name: "X-API-Key",
|
|
847
1017
|
type: "apiKey"
|
|
848
1018
|
}],
|
|
849
|
-
url: "/
|
|
1019
|
+
url: "/auth/v1/memberships/{orgId}/domain/auto-join",
|
|
850
1020
|
...options
|
|
851
1021
|
});
|
|
852
1022
|
/**
|
|
853
|
-
*
|
|
1023
|
+
* Set domain auto-join setting
|
|
854
1024
|
*
|
|
855
|
-
*
|
|
1025
|
+
* Enables or disables automatically adding users with a matching verified domain email to the organization.
|
|
856
1026
|
*/
|
|
857
|
-
const
|
|
1027
|
+
const putAuthV1MembershipsByOrgIdDomainAutoJoin = (options) => (options.client ?? client).put({
|
|
858
1028
|
security: [{
|
|
859
1029
|
name: "X-API-Key",
|
|
860
1030
|
type: "apiKey"
|
|
861
1031
|
}],
|
|
862
|
-
url: "/
|
|
1032
|
+
url: "/auth/v1/memberships/{orgId}/domain/auto-join",
|
|
863
1033
|
...options,
|
|
864
1034
|
headers: {
|
|
865
1035
|
"Content-Type": "application/json",
|
|
@@ -867,131 +1037,235 @@ const putVideosByVideoIdChapters = (options) => (options.client ?? client).put({
|
|
|
867
1037
|
}
|
|
868
1038
|
});
|
|
869
1039
|
/**
|
|
870
|
-
*
|
|
1040
|
+
* Check a custom domain verification
|
|
871
1041
|
*
|
|
872
|
-
*
|
|
1042
|
+
* Verifies the organization's pending custom domain and returns its updated verification status.
|
|
873
1043
|
*/
|
|
874
|
-
const
|
|
1044
|
+
const postAuthV1MembershipsByOrgIdDomainVerification = (options) => (options.client ?? client).post({
|
|
875
1045
|
security: [{
|
|
876
1046
|
name: "X-API-Key",
|
|
877
1047
|
type: "apiKey"
|
|
878
1048
|
}],
|
|
879
|
-
url: "/
|
|
1049
|
+
url: "/auth/v1/memberships/{orgId}/domain/verification",
|
|
880
1050
|
...options
|
|
881
1051
|
});
|
|
882
1052
|
/**
|
|
883
|
-
*
|
|
1053
|
+
* Get the caller's membership info in an organization
|
|
884
1054
|
*
|
|
885
|
-
*
|
|
1055
|
+
* Returns the authenticated user's membership info (email) for an organization, with permission-denied when not a member.
|
|
886
1056
|
*/
|
|
887
|
-
const
|
|
1057
|
+
const getAuthV1MembershipsByOrgIdInfo = (options) => (options.client ?? client).get({
|
|
888
1058
|
security: [{
|
|
889
1059
|
name: "X-API-Key",
|
|
890
1060
|
type: "apiKey"
|
|
891
1061
|
}],
|
|
892
|
-
url: "/
|
|
1062
|
+
url: "/auth/v1/memberships/{orgId}/info",
|
|
893
1063
|
...options
|
|
894
1064
|
});
|
|
895
1065
|
/**
|
|
896
|
-
*
|
|
1066
|
+
* Leave an organization
|
|
897
1067
|
*
|
|
898
|
-
*
|
|
1068
|
+
* Removes the authenticated user's own membership from the organization.
|
|
899
1069
|
*/
|
|
900
|
-
const
|
|
901
|
-
|
|
1070
|
+
const deleteAuthV1MembershipsByOrgIdLeave = (options) => (options.client ?? client).delete({
|
|
1071
|
+
security: [{
|
|
1072
|
+
name: "X-API-Key",
|
|
1073
|
+
type: "apiKey"
|
|
1074
|
+
}],
|
|
1075
|
+
url: "/auth/v1/memberships/{orgId}/leave",
|
|
1076
|
+
...options
|
|
1077
|
+
});
|
|
1078
|
+
/**
|
|
1079
|
+
* List members of an organization
|
|
1080
|
+
*
|
|
1081
|
+
* Returns a paginated list of the members belonging to the specified organization.
|
|
1082
|
+
*/
|
|
1083
|
+
const getAuthV1MembershipsByOrgIdMembers = (options) => (options.client ?? client).get({
|
|
1084
|
+
security: [{
|
|
1085
|
+
name: "X-API-Key",
|
|
1086
|
+
type: "apiKey"
|
|
1087
|
+
}],
|
|
1088
|
+
url: "/auth/v1/memberships/{orgId}/members",
|
|
1089
|
+
...options
|
|
1090
|
+
});
|
|
1091
|
+
/**
|
|
1092
|
+
* Remove a member from an organization
|
|
1093
|
+
*
|
|
1094
|
+
* Removes the specified member from the organization.
|
|
1095
|
+
*/
|
|
1096
|
+
const deleteAuthV1MembershipsByOrgIdMembersByUserId = (options) => (options.client ?? client).delete({
|
|
1097
|
+
security: [{
|
|
1098
|
+
name: "X-API-Key",
|
|
1099
|
+
type: "apiKey"
|
|
1100
|
+
}],
|
|
1101
|
+
url: "/auth/v1/memberships/{orgId}/members/{userId}",
|
|
1102
|
+
...options
|
|
1103
|
+
});
|
|
1104
|
+
/**
|
|
1105
|
+
* List a member's policies
|
|
1106
|
+
*
|
|
1107
|
+
* Returns all authorization policies attached to the specified organization member.
|
|
1108
|
+
*/
|
|
1109
|
+
const getAuthV1MembershipsByOrgIdMembersByUserIdPolicies = (options) => (options.client ?? client).get({
|
|
1110
|
+
security: [{
|
|
1111
|
+
name: "X-API-Key",
|
|
1112
|
+
type: "apiKey"
|
|
1113
|
+
}],
|
|
1114
|
+
url: "/auth/v1/memberships/{orgId}/members/{userId}/policies",
|
|
1115
|
+
...options
|
|
1116
|
+
});
|
|
1117
|
+
/**
|
|
1118
|
+
* Update a member's role
|
|
1119
|
+
*
|
|
1120
|
+
* Updates the specified member's role within the organization.
|
|
1121
|
+
*/
|
|
1122
|
+
const putAuthV1MembershipsByOrgIdMembersByUserIdRole = (options) => (options.client ?? client).put({
|
|
902
1123
|
security: [{
|
|
903
1124
|
name: "X-API-Key",
|
|
904
1125
|
type: "apiKey"
|
|
905
1126
|
}],
|
|
906
|
-
url: "/
|
|
1127
|
+
url: "/auth/v1/memberships/{orgId}/members/{userId}/role",
|
|
907
1128
|
...options,
|
|
908
1129
|
headers: {
|
|
909
|
-
"Content-Type":
|
|
1130
|
+
"Content-Type": "application/json",
|
|
910
1131
|
...options.headers
|
|
911
1132
|
}
|
|
912
1133
|
});
|
|
913
1134
|
/**
|
|
914
|
-
*
|
|
1135
|
+
* Invite a member to an organization
|
|
915
1136
|
*
|
|
916
|
-
*
|
|
1137
|
+
* Invites the user with the given username to the organization with the specified role.
|
|
917
1138
|
*/
|
|
918
|
-
const
|
|
1139
|
+
const postAuthV1MembershipsByOrgIdMembersInvite = (options) => (options.client ?? client).post({
|
|
919
1140
|
security: [{
|
|
920
1141
|
name: "X-API-Key",
|
|
921
1142
|
type: "apiKey"
|
|
922
1143
|
}],
|
|
923
|
-
url: "/
|
|
924
|
-
...options
|
|
1144
|
+
url: "/auth/v1/memberships/{orgId}/members/invite",
|
|
1145
|
+
...options,
|
|
1146
|
+
headers: {
|
|
1147
|
+
"Content-Type": "application/json",
|
|
1148
|
+
...options.headers
|
|
1149
|
+
}
|
|
925
1150
|
});
|
|
926
1151
|
/**
|
|
927
|
-
*
|
|
1152
|
+
* Resend an invitation
|
|
928
1153
|
*
|
|
929
|
-
*
|
|
1154
|
+
* Resends the pending organization invitation to the specified member.
|
|
930
1155
|
*/
|
|
931
|
-
const
|
|
1156
|
+
const postAuthV1MembershipsByOrgIdMembersInviteResend = (options) => (options.client ?? client).post({
|
|
932
1157
|
security: [{
|
|
933
1158
|
name: "X-API-Key",
|
|
934
1159
|
type: "apiKey"
|
|
935
1160
|
}],
|
|
936
|
-
url: "/
|
|
937
|
-
...options
|
|
1161
|
+
url: "/auth/v1/memberships/{orgId}/members/invite/resend",
|
|
1162
|
+
...options,
|
|
1163
|
+
headers: {
|
|
1164
|
+
"Content-Type": "application/json",
|
|
1165
|
+
...options.headers
|
|
1166
|
+
}
|
|
938
1167
|
});
|
|
939
1168
|
/**
|
|
940
|
-
*
|
|
1169
|
+
* Accept or decline a pending membership
|
|
941
1170
|
*
|
|
942
|
-
*
|
|
1171
|
+
* Accepts or declines the authenticated user's pending invitation to the organization. Used from inside the dashboard; the public token flow is /auth/v1/invitations/{token}/accept|decline.
|
|
943
1172
|
*/
|
|
944
|
-
const
|
|
945
|
-
...formDataBodySerializer,
|
|
1173
|
+
const putAuthV1MembershipsByOrgIdMembershipState = (options) => (options.client ?? client).put({
|
|
946
1174
|
security: [{
|
|
947
1175
|
name: "X-API-Key",
|
|
948
1176
|
type: "apiKey"
|
|
949
1177
|
}],
|
|
950
|
-
url: "/
|
|
1178
|
+
url: "/auth/v1/memberships/{orgId}/membership/state",
|
|
951
1179
|
...options,
|
|
952
1180
|
headers: {
|
|
953
|
-
"Content-Type":
|
|
1181
|
+
"Content-Type": "application/json",
|
|
954
1182
|
...options.headers
|
|
955
1183
|
}
|
|
956
1184
|
});
|
|
957
1185
|
/**
|
|
958
|
-
* Update
|
|
1186
|
+
* Update an organization's name
|
|
959
1187
|
*
|
|
960
|
-
*
|
|
1188
|
+
* Updates the display name of the specified organization.
|
|
961
1189
|
*/
|
|
962
|
-
const
|
|
963
|
-
...formDataBodySerializer,
|
|
1190
|
+
const putAuthV1MembershipsByOrgIdName = (options) => (options.client ?? client).put({
|
|
964
1191
|
security: [{
|
|
965
1192
|
name: "X-API-Key",
|
|
966
1193
|
type: "apiKey"
|
|
967
1194
|
}],
|
|
968
|
-
url: "/
|
|
1195
|
+
url: "/auth/v1/memberships/{orgId}/name",
|
|
969
1196
|
...options,
|
|
970
1197
|
headers: {
|
|
971
|
-
"Content-Type":
|
|
1198
|
+
"Content-Type": "application/json",
|
|
1199
|
+
...options.headers
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
/**
|
|
1203
|
+
* List policies
|
|
1204
|
+
*
|
|
1205
|
+
* Returns all authorization policies defined in the organization.
|
|
1206
|
+
*/
|
|
1207
|
+
const getAuthV1MembershipsByOrgIdPolicies = (options) => (options.client ?? client).get({
|
|
1208
|
+
security: [{
|
|
1209
|
+
name: "X-API-Key",
|
|
1210
|
+
type: "apiKey"
|
|
1211
|
+
}],
|
|
1212
|
+
url: "/auth/v1/memberships/{orgId}/policies",
|
|
1213
|
+
...options
|
|
1214
|
+
});
|
|
1215
|
+
/**
|
|
1216
|
+
* Create a policy
|
|
1217
|
+
*
|
|
1218
|
+
* Creates a new authorization policy in the organization with the given name, description, and permissions.
|
|
1219
|
+
*/
|
|
1220
|
+
const postAuthV1MembershipsByOrgIdPolicies = (options) => (options.client ?? client).post({
|
|
1221
|
+
security: [{
|
|
1222
|
+
name: "X-API-Key",
|
|
1223
|
+
type: "apiKey"
|
|
1224
|
+
}],
|
|
1225
|
+
url: "/auth/v1/memberships/{orgId}/policies",
|
|
1226
|
+
...options,
|
|
1227
|
+
headers: {
|
|
1228
|
+
"Content-Type": "application/json",
|
|
972
1229
|
...options.headers
|
|
973
1230
|
}
|
|
974
1231
|
});
|
|
975
1232
|
/**
|
|
976
|
-
*
|
|
1233
|
+
* Delete a policy
|
|
1234
|
+
*
|
|
1235
|
+
* Deletes an authorization policy from the organization by its ID.
|
|
1236
|
+
*/
|
|
1237
|
+
const deleteAuthV1MembershipsByOrgIdPoliciesByPolicyId = (options) => (options.client ?? client).delete({
|
|
1238
|
+
security: [{
|
|
1239
|
+
name: "X-API-Key",
|
|
1240
|
+
type: "apiKey"
|
|
1241
|
+
}],
|
|
1242
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}",
|
|
1243
|
+
...options
|
|
1244
|
+
});
|
|
1245
|
+
/**
|
|
1246
|
+
* Get a policy
|
|
977
1247
|
*
|
|
978
|
-
*
|
|
1248
|
+
* Returns the details of a single authorization policy in the organization by its ID.
|
|
979
1249
|
*/
|
|
980
|
-
const
|
|
981
|
-
|
|
1250
|
+
const getAuthV1MembershipsByOrgIdPoliciesByPolicyId = (options) => (options.client ?? client).get({
|
|
1251
|
+
security: [{
|
|
1252
|
+
name: "X-API-Key",
|
|
1253
|
+
type: "apiKey"
|
|
1254
|
+
}],
|
|
1255
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}",
|
|
982
1256
|
...options
|
|
983
1257
|
});
|
|
984
1258
|
/**
|
|
985
|
-
*
|
|
1259
|
+
* Update a policy
|
|
986
1260
|
*
|
|
987
|
-
*
|
|
1261
|
+
* Updates an existing authorization policy's name, description, and permissions.
|
|
988
1262
|
*/
|
|
989
|
-
const
|
|
1263
|
+
const putAuthV1MembershipsByOrgIdPoliciesByPolicyId = (options) => (options.client ?? client).put({
|
|
990
1264
|
security: [{
|
|
991
1265
|
name: "X-API-Key",
|
|
992
1266
|
type: "apiKey"
|
|
993
1267
|
}],
|
|
994
|
-
url: "/
|
|
1268
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}",
|
|
995
1269
|
...options,
|
|
996
1270
|
headers: {
|
|
997
1271
|
"Content-Type": "application/json",
|
|
@@ -999,23 +1273,3321 @@ const postVideosUploadComplete = (options) => (options.client ?? client).post({
|
|
|
999
1273
|
}
|
|
1000
1274
|
});
|
|
1001
1275
|
/**
|
|
1002
|
-
*
|
|
1276
|
+
* List policy attachments
|
|
1003
1277
|
*
|
|
1004
|
-
*
|
|
1278
|
+
* Returns all identities that the given policy is attached to within the organization.
|
|
1005
1279
|
*/
|
|
1006
|
-
const
|
|
1280
|
+
const getAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachments = (options) => (options.client ?? client).get({
|
|
1007
1281
|
security: [{
|
|
1008
1282
|
name: "X-API-Key",
|
|
1009
1283
|
type: "apiKey"
|
|
1010
1284
|
}],
|
|
1011
|
-
url: "/
|
|
1285
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}/attachments",
|
|
1286
|
+
...options
|
|
1287
|
+
});
|
|
1288
|
+
/**
|
|
1289
|
+
* Attach a policy to an identity
|
|
1290
|
+
*
|
|
1291
|
+
* Attaches the given policy to an identity so the policy's permissions apply to that identity.
|
|
1292
|
+
*/
|
|
1293
|
+
const postAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachments = (options) => (options.client ?? client).post({
|
|
1294
|
+
security: [{
|
|
1295
|
+
name: "X-API-Key",
|
|
1296
|
+
type: "apiKey"
|
|
1297
|
+
}],
|
|
1298
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}/attachments",
|
|
1012
1299
|
...options,
|
|
1013
1300
|
headers: {
|
|
1014
1301
|
"Content-Type": "application/json",
|
|
1015
1302
|
...options.headers
|
|
1016
1303
|
}
|
|
1017
1304
|
});
|
|
1305
|
+
/**
|
|
1306
|
+
* Detach a policy
|
|
1307
|
+
*
|
|
1308
|
+
* Detaches a policy from an identity by removing the specified attachment.
|
|
1309
|
+
*/
|
|
1310
|
+
const deleteAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachmentsByAttachmentId = (options) => (options.client ?? client).delete({
|
|
1311
|
+
security: [{
|
|
1312
|
+
name: "X-API-Key",
|
|
1313
|
+
type: "apiKey"
|
|
1314
|
+
}],
|
|
1315
|
+
url: "/auth/v1/memberships/{orgId}/policies/{policyId}/attachments/{attachmentId}",
|
|
1316
|
+
...options
|
|
1317
|
+
});
|
|
1318
|
+
/**
|
|
1319
|
+
* Update an organization's username
|
|
1320
|
+
*
|
|
1321
|
+
* Updates the unique username handle of the specified organization.
|
|
1322
|
+
*/
|
|
1323
|
+
const putAuthV1MembershipsByOrgIdUsername = (options) => (options.client ?? client).put({
|
|
1324
|
+
security: [{
|
|
1325
|
+
name: "X-API-Key",
|
|
1326
|
+
type: "apiKey"
|
|
1327
|
+
}],
|
|
1328
|
+
url: "/auth/v1/memberships/{orgId}/username",
|
|
1329
|
+
...options,
|
|
1330
|
+
headers: {
|
|
1331
|
+
"Content-Type": "application/json",
|
|
1332
|
+
...options.headers
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
/**
|
|
1336
|
+
* List the current user's active memberships
|
|
1337
|
+
*
|
|
1338
|
+
* Returns a paginated list of the organizations in which the authenticated user holds an active membership.
|
|
1339
|
+
*/
|
|
1340
|
+
const getAuthV1MembershipsActive = (options) => (options?.client ?? client).get({
|
|
1341
|
+
security: [{
|
|
1342
|
+
name: "X-API-Key",
|
|
1343
|
+
type: "apiKey"
|
|
1344
|
+
}],
|
|
1345
|
+
url: "/auth/v1/memberships/active",
|
|
1346
|
+
...options
|
|
1347
|
+
});
|
|
1348
|
+
/**
|
|
1349
|
+
* List the current user's pending memberships
|
|
1350
|
+
*
|
|
1351
|
+
* Returns a paginated list of the authenticated user's pending organization membership invitations that have not yet been accepted.
|
|
1352
|
+
*/
|
|
1353
|
+
const getAuthV1MembershipsPending = (options) => (options?.client ?? client).get({
|
|
1354
|
+
security: [{
|
|
1355
|
+
name: "X-API-Key",
|
|
1356
|
+
type: "apiKey"
|
|
1357
|
+
}],
|
|
1358
|
+
url: "/auth/v1/memberships/pending",
|
|
1359
|
+
...options
|
|
1360
|
+
});
|
|
1361
|
+
/**
|
|
1362
|
+
* Begin passkey login
|
|
1363
|
+
*
|
|
1364
|
+
* Begins a passkey login by returning a session_id and WebAuthn challenge options for the client to sign.
|
|
1365
|
+
*/
|
|
1366
|
+
const postAuthV1PasskeyLoginBegin = (options) => (options?.client ?? client).post({
|
|
1367
|
+
url: "/auth/v1/passkey/login/begin",
|
|
1368
|
+
...options
|
|
1369
|
+
});
|
|
1370
|
+
/**
|
|
1371
|
+
* Finish passkey login
|
|
1372
|
+
*
|
|
1373
|
+
* Completes a passkey login by verifying the signed WebAuthn credential against the session and returning authentication tokens.
|
|
1374
|
+
*/
|
|
1375
|
+
const postAuthV1PasskeyLoginFinish = (options) => (options.client ?? client).post({
|
|
1376
|
+
url: "/auth/v1/passkey/login/finish",
|
|
1377
|
+
...options,
|
|
1378
|
+
headers: {
|
|
1379
|
+
"Content-Type": "application/json",
|
|
1380
|
+
...options.headers
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
/**
|
|
1384
|
+
* Send a password reset email
|
|
1385
|
+
*
|
|
1386
|
+
* Sends a password reset email containing a reset token to the given email address.
|
|
1387
|
+
*/
|
|
1388
|
+
const postAuthV1PasswordReset = (options) => (options.client ?? client).post({
|
|
1389
|
+
url: "/auth/v1/password/reset",
|
|
1390
|
+
...options,
|
|
1391
|
+
headers: {
|
|
1392
|
+
"Content-Type": "application/json",
|
|
1393
|
+
...options.headers
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
/**
|
|
1397
|
+
* Reset password with a token
|
|
1398
|
+
*
|
|
1399
|
+
* Resets the user's password using a valid reset token and the supplied new password.
|
|
1400
|
+
*/
|
|
1401
|
+
const postAuthV1PasswordResetConfirm = (options) => (options.client ?? client).post({
|
|
1402
|
+
url: "/auth/v1/password/reset/confirm",
|
|
1403
|
+
...options,
|
|
1404
|
+
headers: {
|
|
1405
|
+
"Content-Type": "application/json",
|
|
1406
|
+
...options.headers
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
/**
|
|
1410
|
+
* List the permission registry
|
|
1411
|
+
*
|
|
1412
|
+
* Returns the registered permission names and their bit offsets.
|
|
1413
|
+
*/
|
|
1414
|
+
const getAuthV1PoliciesPermissions = (options) => (options?.client ?? client).get({
|
|
1415
|
+
security: [{
|
|
1416
|
+
name: "X-API-Key",
|
|
1417
|
+
type: "apiKey"
|
|
1418
|
+
}],
|
|
1419
|
+
url: "/auth/v1/policies/permissions",
|
|
1420
|
+
...options
|
|
1421
|
+
});
|
|
1422
|
+
/**
|
|
1423
|
+
* List connected social providers
|
|
1424
|
+
*
|
|
1425
|
+
* Returns the list of social providers connected to the authenticated user's account.
|
|
1426
|
+
*/
|
|
1427
|
+
const getAuthV1Providers = (options) => (options?.client ?? client).get({
|
|
1428
|
+
security: [{
|
|
1429
|
+
name: "X-API-Key",
|
|
1430
|
+
type: "apiKey"
|
|
1431
|
+
}],
|
|
1432
|
+
url: "/auth/v1/providers",
|
|
1433
|
+
...options
|
|
1434
|
+
});
|
|
1435
|
+
/**
|
|
1436
|
+
* Disconnect a social provider
|
|
1437
|
+
*
|
|
1438
|
+
* Disconnects the named social provider from the authenticated user's account.
|
|
1439
|
+
*/
|
|
1440
|
+
const deleteAuthV1ProvidersByProvider = (options) => (options.client ?? client).delete({
|
|
1441
|
+
security: [{
|
|
1442
|
+
name: "X-API-Key",
|
|
1443
|
+
type: "apiKey"
|
|
1444
|
+
}],
|
|
1445
|
+
url: "/auth/v1/providers/{provider}",
|
|
1446
|
+
...options
|
|
1447
|
+
});
|
|
1448
|
+
/**
|
|
1449
|
+
* Connect a social provider
|
|
1450
|
+
*
|
|
1451
|
+
* Connects a social provider to the authenticated user's account using the supplied provider token.
|
|
1452
|
+
*/
|
|
1453
|
+
const postAuthV1ProvidersConnect = (options) => (options.client ?? client).post({
|
|
1454
|
+
security: [{
|
|
1455
|
+
name: "X-API-Key",
|
|
1456
|
+
type: "apiKey"
|
|
1457
|
+
}],
|
|
1458
|
+
url: "/auth/v1/providers/connect",
|
|
1459
|
+
...options,
|
|
1460
|
+
headers: {
|
|
1461
|
+
"Content-Type": "application/json",
|
|
1462
|
+
...options.headers
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
/**
|
|
1466
|
+
* Register with email and password
|
|
1467
|
+
*
|
|
1468
|
+
* Registers a new user account from an email and password and starts email verification.
|
|
1469
|
+
*/
|
|
1470
|
+
const postAuthV1Register = (options) => (options.client ?? client).post({
|
|
1471
|
+
url: "/auth/v1/register",
|
|
1472
|
+
...options,
|
|
1473
|
+
headers: {
|
|
1474
|
+
"Content-Type": "application/json",
|
|
1475
|
+
...options.headers
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
/**
|
|
1479
|
+
* Refresh access token
|
|
1480
|
+
*
|
|
1481
|
+
* Exchanges a valid refresh token for a new access token.
|
|
1482
|
+
*/
|
|
1483
|
+
const postAuthV1Token = (options) => (options.client ?? client).post({
|
|
1484
|
+
url: "/auth/v1/token",
|
|
1485
|
+
...options
|
|
1486
|
+
});
|
|
1487
|
+
/**
|
|
1488
|
+
* Get current user info
|
|
1489
|
+
*
|
|
1490
|
+
* Returns the profile information of the authenticated user.
|
|
1491
|
+
*/
|
|
1492
|
+
const getAuthV1Userinfo = (options) => (options?.client ?? client).get({
|
|
1493
|
+
security: [{
|
|
1494
|
+
name: "X-API-Key",
|
|
1495
|
+
type: "apiKey"
|
|
1496
|
+
}],
|
|
1497
|
+
url: "/auth/v1/userinfo",
|
|
1498
|
+
...options
|
|
1499
|
+
});
|
|
1500
|
+
/**
|
|
1501
|
+
* Get current user info
|
|
1502
|
+
*
|
|
1503
|
+
* Returns the profile information of the authenticated user.
|
|
1504
|
+
*/
|
|
1505
|
+
const getAuthV1UsersCurrent = (options) => (options?.client ?? client).get({
|
|
1506
|
+
security: [{
|
|
1507
|
+
name: "X-API-Key",
|
|
1508
|
+
type: "apiKey"
|
|
1509
|
+
}],
|
|
1510
|
+
url: "/auth/v1/users/current",
|
|
1511
|
+
...options
|
|
1512
|
+
});
|
|
1513
|
+
/**
|
|
1514
|
+
* Add an email address
|
|
1515
|
+
*
|
|
1516
|
+
* Adds an email address to the authenticated account and sends a verification
|
|
1517
|
+
* code to it. The address becomes active only once it has been verified via
|
|
1518
|
+
* `POST /auth/v1/email/verify`. Subject to rate limiting per account.
|
|
1519
|
+
*/
|
|
1520
|
+
const postAuthV1UsersCurrentEmails = (options) => (options.client ?? client).post({
|
|
1521
|
+
security: [{
|
|
1522
|
+
name: "X-API-Key",
|
|
1523
|
+
type: "apiKey"
|
|
1524
|
+
}],
|
|
1525
|
+
url: "/auth/v1/users/current/emails",
|
|
1526
|
+
...options,
|
|
1527
|
+
headers: {
|
|
1528
|
+
"Content-Type": "application/json",
|
|
1529
|
+
...options.headers
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
/**
|
|
1533
|
+
* Change the account email
|
|
1534
|
+
*
|
|
1535
|
+
* Starts changing the authenticated account's email address. A verification
|
|
1536
|
+
* code is sent to the new address; the change is applied only after the code
|
|
1537
|
+
* is confirmed via `POST /auth/v1/email/verify`. Subject to rate limiting per account.
|
|
1538
|
+
*/
|
|
1539
|
+
const putAuthV1UsersCurrentEmailsChange = (options) => (options.client ?? client).put({
|
|
1540
|
+
security: [{
|
|
1541
|
+
name: "X-API-Key",
|
|
1542
|
+
type: "apiKey"
|
|
1543
|
+
}],
|
|
1544
|
+
url: "/auth/v1/users/current/emails/change",
|
|
1545
|
+
...options,
|
|
1546
|
+
headers: {
|
|
1547
|
+
"Content-Type": "application/json",
|
|
1548
|
+
...options.headers
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
/**
|
|
1552
|
+
* Get email status
|
|
1553
|
+
*
|
|
1554
|
+
* Returns the authenticated account's current email address together with
|
|
1555
|
+
* whether an email is set and whether it has been verified.
|
|
1556
|
+
*/
|
|
1557
|
+
const getAuthV1UsersCurrentEmailsStatus = (options) => (options?.client ?? client).get({
|
|
1558
|
+
security: [{
|
|
1559
|
+
name: "X-API-Key",
|
|
1560
|
+
type: "apiKey"
|
|
1561
|
+
}],
|
|
1562
|
+
url: "/auth/v1/users/current/emails/status",
|
|
1563
|
+
...options
|
|
1564
|
+
});
|
|
1565
|
+
/**
|
|
1566
|
+
* Update the current user's name
|
|
1567
|
+
*
|
|
1568
|
+
* Updates the authenticated user's full name to the provided value.
|
|
1569
|
+
*/
|
|
1570
|
+
const patchAuthV1UsersCurrentName = (options) => (options.client ?? client).patch({
|
|
1571
|
+
security: [{
|
|
1572
|
+
name: "X-API-Key",
|
|
1573
|
+
type: "apiKey"
|
|
1574
|
+
}],
|
|
1575
|
+
url: "/auth/v1/users/current/name",
|
|
1576
|
+
...options,
|
|
1577
|
+
headers: {
|
|
1578
|
+
"Content-Type": "application/json",
|
|
1579
|
+
...options.headers
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
/**
|
|
1583
|
+
* List the current user's passkeys
|
|
1584
|
+
*
|
|
1585
|
+
* Returns all passkeys registered to the authenticated user.
|
|
1586
|
+
*/
|
|
1587
|
+
const getAuthV1UsersCurrentPasskeys = (options) => (options?.client ?? client).get({
|
|
1588
|
+
security: [{
|
|
1589
|
+
name: "X-API-Key",
|
|
1590
|
+
type: "apiKey"
|
|
1591
|
+
}],
|
|
1592
|
+
url: "/auth/v1/users/current/passkeys",
|
|
1593
|
+
...options
|
|
1594
|
+
});
|
|
1595
|
+
/**
|
|
1596
|
+
* Delete a passkey
|
|
1597
|
+
*
|
|
1598
|
+
* Deletes the authenticated user's passkey identified by the path ID.
|
|
1599
|
+
*/
|
|
1600
|
+
const deleteAuthV1UsersCurrentPasskeysById = (options) => (options.client ?? client).delete({
|
|
1601
|
+
security: [{
|
|
1602
|
+
name: "X-API-Key",
|
|
1603
|
+
type: "apiKey"
|
|
1604
|
+
}],
|
|
1605
|
+
url: "/auth/v1/users/current/passkeys/{id}",
|
|
1606
|
+
...options
|
|
1607
|
+
});
|
|
1608
|
+
/**
|
|
1609
|
+
* Rename a passkey
|
|
1610
|
+
*
|
|
1611
|
+
* Renames the authenticated user's passkey identified by the path ID to the supplied name.
|
|
1612
|
+
*/
|
|
1613
|
+
const patchAuthV1UsersCurrentPasskeysById = (options) => (options.client ?? client).patch({
|
|
1614
|
+
security: [{
|
|
1615
|
+
name: "X-API-Key",
|
|
1616
|
+
type: "apiKey"
|
|
1617
|
+
}],
|
|
1618
|
+
url: "/auth/v1/users/current/passkeys/{id}",
|
|
1619
|
+
...options,
|
|
1620
|
+
headers: {
|
|
1621
|
+
"Content-Type": "application/json",
|
|
1622
|
+
...options.headers
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
/**
|
|
1626
|
+
* Begin passkey registration
|
|
1627
|
+
*
|
|
1628
|
+
* Begins registering a new passkey for the authenticated user by returning a session_id and WebAuthn creation options.
|
|
1629
|
+
*/
|
|
1630
|
+
const postAuthV1UsersCurrentPasskeysRegisterBegin = (options) => (options?.client ?? client).post({
|
|
1631
|
+
security: [{
|
|
1632
|
+
name: "X-API-Key",
|
|
1633
|
+
type: "apiKey"
|
|
1634
|
+
}],
|
|
1635
|
+
url: "/auth/v1/users/current/passkeys/register/begin",
|
|
1636
|
+
...options
|
|
1637
|
+
});
|
|
1638
|
+
/**
|
|
1639
|
+
* Finish passkey registration
|
|
1640
|
+
*
|
|
1641
|
+
* Completes passkey registration by verifying the signed WebAuthn credential and storing it under the given name for the authenticated user.
|
|
1642
|
+
*/
|
|
1643
|
+
const postAuthV1UsersCurrentPasskeysRegisterFinish = (options) => (options.client ?? client).post({
|
|
1644
|
+
security: [{
|
|
1645
|
+
name: "X-API-Key",
|
|
1646
|
+
type: "apiKey"
|
|
1647
|
+
}],
|
|
1648
|
+
url: "/auth/v1/users/current/passkeys/register/finish",
|
|
1649
|
+
...options,
|
|
1650
|
+
headers: {
|
|
1651
|
+
"Content-Type": "application/json",
|
|
1652
|
+
...options.headers
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
/**
|
|
1656
|
+
* Disable TOTP
|
|
1657
|
+
*
|
|
1658
|
+
* Disables TOTP two-factor authentication for the authenticated user and removes their stored TOTP secret.
|
|
1659
|
+
*/
|
|
1660
|
+
const deleteAuthV1UsersCurrentTotpDelete = (options) => (options?.client ?? client).delete({
|
|
1661
|
+
security: [{
|
|
1662
|
+
name: "X-API-Key",
|
|
1663
|
+
type: "apiKey"
|
|
1664
|
+
}],
|
|
1665
|
+
url: "/auth/v1/users/current/totp/delete",
|
|
1666
|
+
...options
|
|
1667
|
+
});
|
|
1668
|
+
/**
|
|
1669
|
+
* Begin TOTP setup
|
|
1670
|
+
*
|
|
1671
|
+
* Begins TOTP setup for the authenticated user by generating and returning a provisioning secret and QR code that have not yet been enabled.
|
|
1672
|
+
*/
|
|
1673
|
+
const postAuthV1UsersCurrentTotpSetup = (options) => (options?.client ?? client).post({
|
|
1674
|
+
security: [{
|
|
1675
|
+
name: "X-API-Key",
|
|
1676
|
+
type: "apiKey"
|
|
1677
|
+
}],
|
|
1678
|
+
url: "/auth/v1/users/current/totp/setup",
|
|
1679
|
+
...options
|
|
1680
|
+
});
|
|
1681
|
+
/**
|
|
1682
|
+
* Get TOTP status
|
|
1683
|
+
*
|
|
1684
|
+
* Returns whether the authenticated user currently has TOTP two-factor authentication enabled.
|
|
1685
|
+
*/
|
|
1686
|
+
const getAuthV1UsersCurrentTotpStatus = (options) => (options?.client ?? client).get({
|
|
1687
|
+
security: [{
|
|
1688
|
+
name: "X-API-Key",
|
|
1689
|
+
type: "apiKey"
|
|
1690
|
+
}],
|
|
1691
|
+
url: "/auth/v1/users/current/totp/status",
|
|
1692
|
+
...options
|
|
1693
|
+
});
|
|
1694
|
+
/**
|
|
1695
|
+
* Verify and enable TOTP
|
|
1696
|
+
*
|
|
1697
|
+
* Verifies the submitted TOTP code against the user's pending setup secret and, if valid, enables TOTP two-factor authentication and returns refreshed tokens.
|
|
1698
|
+
*/
|
|
1699
|
+
const postAuthV1UsersCurrentTotpVerify = (options) => (options.client ?? client).post({
|
|
1700
|
+
security: [{
|
|
1701
|
+
name: "X-API-Key",
|
|
1702
|
+
type: "apiKey"
|
|
1703
|
+
}],
|
|
1704
|
+
url: "/auth/v1/users/current/totp/verify",
|
|
1705
|
+
...options,
|
|
1706
|
+
headers: {
|
|
1707
|
+
"Content-Type": "application/json",
|
|
1708
|
+
...options.headers
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
/**
|
|
1712
|
+
* Update the current user's username
|
|
1713
|
+
*
|
|
1714
|
+
* Updates the authenticated user's username to the provided value.
|
|
1715
|
+
*/
|
|
1716
|
+
const patchAuthV1UsersCurrentUsername = (options) => (options.client ?? client).patch({
|
|
1717
|
+
security: [{
|
|
1718
|
+
name: "X-API-Key",
|
|
1719
|
+
type: "apiKey"
|
|
1720
|
+
}],
|
|
1721
|
+
url: "/auth/v1/users/current/username",
|
|
1722
|
+
...options,
|
|
1723
|
+
headers: {
|
|
1724
|
+
"Content-Type": "application/json",
|
|
1725
|
+
...options.headers
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
/**
|
|
1729
|
+
* Verify passkey as 2FA after password login
|
|
1730
|
+
*
|
|
1731
|
+
* Completes the passkey step of a password login's 2FA challenge. Verifies the signed WebAuthn assertion against the challenge stored in the login session (from POST /auth/v1/login with status "2fa_required") and returns authentication tokens.
|
|
1732
|
+
*/
|
|
1733
|
+
const postAuthV1VerifyPasskey = (options) => (options.client ?? client).post({
|
|
1734
|
+
url: "/auth/v1/verify-passkey",
|
|
1735
|
+
...options,
|
|
1736
|
+
headers: {
|
|
1737
|
+
"Content-Type": "application/json",
|
|
1738
|
+
...options.headers
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
/**
|
|
1742
|
+
* Verify TOTP during login
|
|
1743
|
+
*
|
|
1744
|
+
* Verifies the submitted TOTP code for a pending login session and, if valid, completes authentication and returns access tokens.
|
|
1745
|
+
*/
|
|
1746
|
+
const postAuthV1VerifyTotp = (options) => (options.client ?? client).post({
|
|
1747
|
+
url: "/auth/v1/verify-totp",
|
|
1748
|
+
...options,
|
|
1749
|
+
headers: {
|
|
1750
|
+
"Content-Type": "application/json",
|
|
1751
|
+
...options.headers
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
/**
|
|
1755
|
+
* Get billing address
|
|
1756
|
+
*
|
|
1757
|
+
* Returns the organization's billing address
|
|
1758
|
+
*/
|
|
1759
|
+
const getBillingV1Address = (options) => (options?.client ?? client).get({
|
|
1760
|
+
security: [{
|
|
1761
|
+
name: "X-API-Key",
|
|
1762
|
+
type: "apiKey"
|
|
1763
|
+
}],
|
|
1764
|
+
url: "/billing/v1/address",
|
|
1765
|
+
...options
|
|
1766
|
+
});
|
|
1767
|
+
/**
|
|
1768
|
+
* Set billing address
|
|
1769
|
+
*
|
|
1770
|
+
* Create or update the organization's billing address
|
|
1771
|
+
*/
|
|
1772
|
+
const postBillingV1Address = (options) => (options.client ?? client).post({
|
|
1773
|
+
security: [{
|
|
1774
|
+
name: "X-API-Key",
|
|
1775
|
+
type: "apiKey"
|
|
1776
|
+
}],
|
|
1777
|
+
url: "/billing/v1/address",
|
|
1778
|
+
...options,
|
|
1779
|
+
headers: {
|
|
1780
|
+
"Content-Type": "application/json",
|
|
1781
|
+
...options.headers
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
/**
|
|
1785
|
+
* Get bandwidth usage
|
|
1786
|
+
*
|
|
1787
|
+
* Returns the organization's bandwidth usage.
|
|
1788
|
+
*/
|
|
1789
|
+
const getBillingV1BandwidthUsage = (options) => (options?.client ?? client).get({
|
|
1790
|
+
security: [{
|
|
1791
|
+
name: "X-API-Key",
|
|
1792
|
+
type: "apiKey"
|
|
1793
|
+
}],
|
|
1794
|
+
url: "/billing/v1/bandwidth-usage",
|
|
1795
|
+
...options
|
|
1796
|
+
});
|
|
1797
|
+
/**
|
|
1798
|
+
* Bandwidth usage history
|
|
1799
|
+
*
|
|
1800
|
+
* Returns the organization's bandwidth usage history
|
|
1801
|
+
*/
|
|
1802
|
+
const getBillingV1BandwidthUsageHistory = (options) => (options?.client ?? client).get({
|
|
1803
|
+
security: [{
|
|
1804
|
+
name: "X-API-Key",
|
|
1805
|
+
type: "apiKey"
|
|
1806
|
+
}],
|
|
1807
|
+
url: "/billing/v1/bandwidth-usage/history",
|
|
1808
|
+
...options
|
|
1809
|
+
});
|
|
1810
|
+
/**
|
|
1811
|
+
* Refresh bandwidth usage
|
|
1812
|
+
*
|
|
1813
|
+
* Recalculate and persist the organization's bandwidth usage
|
|
1814
|
+
*/
|
|
1815
|
+
const postBillingV1BandwidthUsageRefresh = (options) => (options?.client ?? client).post({
|
|
1816
|
+
security: [{
|
|
1817
|
+
name: "X-API-Key",
|
|
1818
|
+
type: "apiKey"
|
|
1819
|
+
}],
|
|
1820
|
+
url: "/billing/v1/bandwidth-usage/refresh",
|
|
1821
|
+
...options
|
|
1822
|
+
});
|
|
1823
|
+
/**
|
|
1824
|
+
* Create checkout session
|
|
1825
|
+
*
|
|
1826
|
+
* Create a Stripe hosted checkout session
|
|
1827
|
+
*/
|
|
1828
|
+
const postBillingV1Checkout = (options) => (options.client ?? client).post({
|
|
1829
|
+
security: [{
|
|
1830
|
+
name: "X-API-Key",
|
|
1831
|
+
type: "apiKey"
|
|
1832
|
+
}],
|
|
1833
|
+
url: "/billing/v1/checkout",
|
|
1834
|
+
...options,
|
|
1835
|
+
headers: {
|
|
1836
|
+
"Content-Type": "application/json",
|
|
1837
|
+
...options.headers
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
/**
|
|
1841
|
+
* Contact sales
|
|
1842
|
+
*
|
|
1843
|
+
* Submits a sales contact request for the organization.
|
|
1844
|
+
*/
|
|
1845
|
+
const postBillingV1ContactSales = (options) => (options.client ?? client).post({
|
|
1846
|
+
security: [{
|
|
1847
|
+
name: "X-API-Key",
|
|
1848
|
+
type: "apiKey"
|
|
1849
|
+
}],
|
|
1850
|
+
url: "/billing/v1/contact-sales",
|
|
1851
|
+
...options,
|
|
1852
|
+
headers: {
|
|
1853
|
+
"Content-Type": "application/json",
|
|
1854
|
+
...options.headers
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
/**
|
|
1858
|
+
* List invoices
|
|
1859
|
+
*
|
|
1860
|
+
* Returns the organization's invoices.
|
|
1861
|
+
*/
|
|
1862
|
+
const getBillingV1Invoices = (options) => (options?.client ?? client).get({
|
|
1863
|
+
security: [{
|
|
1864
|
+
name: "X-API-Key",
|
|
1865
|
+
type: "apiKey"
|
|
1866
|
+
}],
|
|
1867
|
+
url: "/billing/v1/invoices",
|
|
1868
|
+
...options
|
|
1869
|
+
});
|
|
1870
|
+
/**
|
|
1871
|
+
* Update invoice status
|
|
1872
|
+
*
|
|
1873
|
+
* Updates the status of an invoice (admin).
|
|
1874
|
+
*/
|
|
1875
|
+
const putBillingV1InvoicesByInvoiceIdStatus = (options) => (options.client ?? client).put({
|
|
1876
|
+
security: [{
|
|
1877
|
+
name: "X-API-Key",
|
|
1878
|
+
type: "apiKey"
|
|
1879
|
+
}],
|
|
1880
|
+
url: "/billing/v1/invoices/{invoiceId}/status",
|
|
1881
|
+
...options,
|
|
1882
|
+
headers: {
|
|
1883
|
+
"Content-Type": "application/json",
|
|
1884
|
+
...options.headers
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
/**
|
|
1888
|
+
* Cleanup old bandwidth snapshots
|
|
1889
|
+
*
|
|
1890
|
+
* Trigger the cleanup of old bandwidth usage records
|
|
1891
|
+
*/
|
|
1892
|
+
const postBillingV1JobsCleanupBandwidthSnapshots = (options) => (options?.client ?? client).post({
|
|
1893
|
+
security: [{
|
|
1894
|
+
name: "X-API-Key",
|
|
1895
|
+
type: "apiKey"
|
|
1896
|
+
}],
|
|
1897
|
+
url: "/billing/v1/jobs/cleanup-bandwidth-snapshots",
|
|
1898
|
+
...options
|
|
1899
|
+
});
|
|
1900
|
+
/**
|
|
1901
|
+
* Run daily bandwidth calculation
|
|
1902
|
+
*
|
|
1903
|
+
* Trigger the daily bandwidth usage calculation job for all organizations
|
|
1904
|
+
*/
|
|
1905
|
+
const postBillingV1JobsDailyBandwidthCalculation = (options) => (options?.client ?? client).post({
|
|
1906
|
+
security: [{
|
|
1907
|
+
name: "X-API-Key",
|
|
1908
|
+
type: "apiKey"
|
|
1909
|
+
}],
|
|
1910
|
+
url: "/billing/v1/jobs/daily-bandwidth-calculation",
|
|
1911
|
+
...options
|
|
1912
|
+
});
|
|
1913
|
+
/**
|
|
1914
|
+
* Run monthly bandwidth calculation
|
|
1915
|
+
*
|
|
1916
|
+
* Trigger the monthly bandwidth usage calculation job for all organizations
|
|
1917
|
+
*/
|
|
1918
|
+
const postBillingV1JobsMonthlyBandwidthCalculation = (options) => (options?.client ?? client).post({
|
|
1919
|
+
security: [{
|
|
1920
|
+
name: "X-API-Key",
|
|
1921
|
+
type: "apiKey"
|
|
1922
|
+
}],
|
|
1923
|
+
url: "/billing/v1/jobs/monthly-bandwidth-calculation",
|
|
1924
|
+
...options
|
|
1925
|
+
});
|
|
1926
|
+
/**
|
|
1927
|
+
* List payment methods
|
|
1928
|
+
*
|
|
1929
|
+
* Returns the organization's payment methods.
|
|
1930
|
+
*/
|
|
1931
|
+
const getBillingV1PaymentMethods = (options) => (options?.client ?? client).get({
|
|
1932
|
+
security: [{
|
|
1933
|
+
name: "X-API-Key",
|
|
1934
|
+
type: "apiKey"
|
|
1935
|
+
}],
|
|
1936
|
+
url: "/billing/v1/payment-methods",
|
|
1937
|
+
...options
|
|
1938
|
+
});
|
|
1939
|
+
/**
|
|
1940
|
+
* Add or update payment method
|
|
1941
|
+
*
|
|
1942
|
+
* Attach a payment method to the organization
|
|
1943
|
+
*/
|
|
1944
|
+
const postBillingV1PaymentMethods = (options) => (options.client ?? client).post({
|
|
1945
|
+
security: [{
|
|
1946
|
+
name: "X-API-Key",
|
|
1947
|
+
type: "apiKey"
|
|
1948
|
+
}],
|
|
1949
|
+
url: "/billing/v1/payment-methods",
|
|
1950
|
+
...options,
|
|
1951
|
+
headers: {
|
|
1952
|
+
"Content-Type": "application/json",
|
|
1953
|
+
...options.headers
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
/**
|
|
1957
|
+
* Delete payment method
|
|
1958
|
+
*
|
|
1959
|
+
* Remove a payment method from the organization
|
|
1960
|
+
*/
|
|
1961
|
+
const deleteBillingV1PaymentMethodsByPaymentMethodId = (options) => (options.client ?? client).delete({
|
|
1962
|
+
security: [{
|
|
1963
|
+
name: "X-API-Key",
|
|
1964
|
+
type: "apiKey"
|
|
1965
|
+
}],
|
|
1966
|
+
url: "/billing/v1/payment-methods/{paymentMethodId}",
|
|
1967
|
+
...options
|
|
1968
|
+
});
|
|
1969
|
+
/**
|
|
1970
|
+
* Resolve payment method from payment intent
|
|
1971
|
+
*
|
|
1972
|
+
* Returns the payment method ID associated with a payment intent
|
|
1973
|
+
*/
|
|
1974
|
+
const getBillingV1PaymentMethodsFromPaymentIntent = (options) => (options.client ?? client).get({
|
|
1975
|
+
security: [{
|
|
1976
|
+
name: "X-API-Key",
|
|
1977
|
+
type: "apiKey"
|
|
1978
|
+
}],
|
|
1979
|
+
url: "/billing/v1/payment-methods/from-payment-intent",
|
|
1980
|
+
...options
|
|
1981
|
+
});
|
|
1982
|
+
/**
|
|
1983
|
+
* Resolve payment method from setup intent
|
|
1984
|
+
*
|
|
1985
|
+
* Returns the payment method ID associated with a setup intent
|
|
1986
|
+
*/
|
|
1987
|
+
const getBillingV1PaymentMethodsFromSetupIntent = (options) => (options.client ?? client).get({
|
|
1988
|
+
security: [{
|
|
1989
|
+
name: "X-API-Key",
|
|
1990
|
+
type: "apiKey"
|
|
1991
|
+
}],
|
|
1992
|
+
url: "/billing/v1/payment-methods/from-setup-intent",
|
|
1993
|
+
...options
|
|
1994
|
+
});
|
|
1995
|
+
/**
|
|
1996
|
+
* List billing plans
|
|
1997
|
+
*
|
|
1998
|
+
* Returns the available billing plans.
|
|
1999
|
+
*/
|
|
2000
|
+
const getBillingV1Plans = (options) => (options?.client ?? client).get({
|
|
2001
|
+
url: "/billing/v1/plans",
|
|
2002
|
+
...options
|
|
2003
|
+
});
|
|
2004
|
+
/**
|
|
2005
|
+
* Get a billing plan
|
|
2006
|
+
*
|
|
2007
|
+
* Returns a single billing plan by ID.
|
|
2008
|
+
*/
|
|
2009
|
+
const getBillingV1PlansByPlanId = (options) => (options.client ?? client).get({
|
|
2010
|
+
url: "/billing/v1/plans/{planId}",
|
|
2011
|
+
...options
|
|
2012
|
+
});
|
|
2013
|
+
/**
|
|
2014
|
+
* Create setup intent
|
|
2015
|
+
*
|
|
2016
|
+
* Create a Stripe setup intent for adding a payment method
|
|
2017
|
+
*/
|
|
2018
|
+
const postBillingV1SetupIntent = (options) => (options?.client ?? client).post({
|
|
2019
|
+
security: [{
|
|
2020
|
+
name: "X-API-Key",
|
|
2021
|
+
type: "apiKey"
|
|
2022
|
+
}],
|
|
2023
|
+
url: "/billing/v1/setup-intent",
|
|
2024
|
+
...options
|
|
2025
|
+
});
|
|
2026
|
+
/**
|
|
2027
|
+
* Get storage usage
|
|
2028
|
+
*
|
|
2029
|
+
* Returns the organization's storage usage.
|
|
2030
|
+
*/
|
|
2031
|
+
const getBillingV1StorageUsage = (options) => (options?.client ?? client).get({
|
|
2032
|
+
security: [{
|
|
2033
|
+
name: "X-API-Key",
|
|
2034
|
+
type: "apiKey"
|
|
2035
|
+
}],
|
|
2036
|
+
url: "/billing/v1/storage-usage",
|
|
2037
|
+
...options
|
|
2038
|
+
});
|
|
2039
|
+
/**
|
|
2040
|
+
* Storage usage history
|
|
2041
|
+
*
|
|
2042
|
+
* Returns the organization's storage usage history
|
|
2043
|
+
*/
|
|
2044
|
+
const getBillingV1StorageUsageHistory = (options) => (options?.client ?? client).get({
|
|
2045
|
+
security: [{
|
|
2046
|
+
name: "X-API-Key",
|
|
2047
|
+
type: "apiKey"
|
|
2048
|
+
}],
|
|
2049
|
+
url: "/billing/v1/storage-usage/history",
|
|
2050
|
+
...options
|
|
2051
|
+
});
|
|
2052
|
+
/**
|
|
2053
|
+
* Refresh storage usage
|
|
2054
|
+
*
|
|
2055
|
+
* Recalculate and persist the organization's storage usage
|
|
2056
|
+
*/
|
|
2057
|
+
const postBillingV1StorageUsageRefresh = (options) => (options?.client ?? client).post({
|
|
2058
|
+
security: [{
|
|
2059
|
+
name: "X-API-Key",
|
|
2060
|
+
type: "apiKey"
|
|
2061
|
+
}],
|
|
2062
|
+
url: "/billing/v1/storage-usage/refresh",
|
|
2063
|
+
...options
|
|
2064
|
+
});
|
|
2065
|
+
/**
|
|
2066
|
+
* Get current subscription
|
|
2067
|
+
*
|
|
2068
|
+
* Returns the current organization subscription.
|
|
2069
|
+
*/
|
|
2070
|
+
const getBillingV1Subscription = (options) => (options?.client ?? client).get({
|
|
2071
|
+
security: [{
|
|
2072
|
+
name: "X-API-Key",
|
|
2073
|
+
type: "apiKey"
|
|
2074
|
+
}],
|
|
2075
|
+
url: "/billing/v1/subscription",
|
|
2076
|
+
...options
|
|
2077
|
+
});
|
|
2078
|
+
/**
|
|
2079
|
+
* Create subscription
|
|
2080
|
+
*
|
|
2081
|
+
* Create a subscription for the authenticated organization
|
|
2082
|
+
*/
|
|
2083
|
+
const postBillingV1Subscription = (options) => (options.client ?? client).post({
|
|
2084
|
+
security: [{
|
|
2085
|
+
name: "X-API-Key",
|
|
2086
|
+
type: "apiKey"
|
|
2087
|
+
}],
|
|
2088
|
+
url: "/billing/v1/subscription",
|
|
2089
|
+
...options,
|
|
2090
|
+
headers: {
|
|
2091
|
+
"Content-Type": "application/json",
|
|
2092
|
+
...options.headers
|
|
2093
|
+
}
|
|
2094
|
+
});
|
|
2095
|
+
/**
|
|
2096
|
+
* Cancel subscription
|
|
2097
|
+
*
|
|
2098
|
+
* Cancel the organization's subscription at the end of the current period
|
|
2099
|
+
*/
|
|
2100
|
+
const putBillingV1SubscriptionCancel = (options) => (options?.client ?? client).put({
|
|
2101
|
+
security: [{
|
|
2102
|
+
name: "X-API-Key",
|
|
2103
|
+
type: "apiKey"
|
|
2104
|
+
}],
|
|
2105
|
+
url: "/billing/v1/subscription/cancel",
|
|
2106
|
+
...options
|
|
2107
|
+
});
|
|
2108
|
+
/**
|
|
2109
|
+
* Get subscription history
|
|
2110
|
+
*
|
|
2111
|
+
* Returns the organization's subscription history.
|
|
2112
|
+
*/
|
|
2113
|
+
const getBillingV1SubscriptionHistory = (options) => (options?.client ?? client).get({
|
|
2114
|
+
security: [{
|
|
2115
|
+
name: "X-API-Key",
|
|
2116
|
+
type: "apiKey"
|
|
2117
|
+
}],
|
|
2118
|
+
url: "/billing/v1/subscription/history",
|
|
2119
|
+
...options
|
|
2120
|
+
});
|
|
2121
|
+
/**
|
|
2122
|
+
* Reactivate subscription
|
|
2123
|
+
*
|
|
2124
|
+
* Reactivate a subscription scheduled for cancellation
|
|
2125
|
+
*/
|
|
2126
|
+
const putBillingV1SubscriptionReactivate = (options) => (options?.client ?? client).put({
|
|
2127
|
+
security: [{
|
|
2128
|
+
name: "X-API-Key",
|
|
2129
|
+
type: "apiKey"
|
|
2130
|
+
}],
|
|
2131
|
+
url: "/billing/v1/subscription/reactivate",
|
|
2132
|
+
...options
|
|
2133
|
+
});
|
|
2134
|
+
/**
|
|
2135
|
+
* Upgrade subscription
|
|
2136
|
+
*
|
|
2137
|
+
* Upgrade the organization's subscription to a new plan
|
|
2138
|
+
*/
|
|
2139
|
+
const postBillingV1SubscriptionUpgrade = (options) => (options.client ?? client).post({
|
|
2140
|
+
security: [{
|
|
2141
|
+
name: "X-API-Key",
|
|
2142
|
+
type: "apiKey"
|
|
2143
|
+
}],
|
|
2144
|
+
url: "/billing/v1/subscription/upgrade",
|
|
2145
|
+
...options,
|
|
2146
|
+
headers: {
|
|
2147
|
+
"Content-Type": "application/json",
|
|
2148
|
+
...options.headers
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2151
|
+
/**
|
|
2152
|
+
* Calculate tax
|
|
2153
|
+
*
|
|
2154
|
+
* Calculate tax for a plan purchase
|
|
2155
|
+
*/
|
|
2156
|
+
const postBillingV1TaxCalculate = (options) => (options.client ?? client).post({
|
|
2157
|
+
security: [{
|
|
2158
|
+
name: "X-API-Key",
|
|
2159
|
+
type: "apiKey"
|
|
2160
|
+
}],
|
|
2161
|
+
url: "/billing/v1/tax/calculate",
|
|
2162
|
+
...options,
|
|
2163
|
+
headers: {
|
|
2164
|
+
"Content-Type": "application/json",
|
|
2165
|
+
...options.headers
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
/**
|
|
2169
|
+
* Stripe webhook
|
|
2170
|
+
*
|
|
2171
|
+
* Receives Stripe webhook events. The raw payload and signature are forwarded to the billing service for verification and processing.
|
|
2172
|
+
*/
|
|
2173
|
+
const postBillingWebhooksStripe = (options) => (options?.client ?? client).post({
|
|
2174
|
+
url: "/billing/webhooks/stripe",
|
|
2175
|
+
...options,
|
|
2176
|
+
headers: {
|
|
2177
|
+
"Content-Type": "application/json",
|
|
2178
|
+
...options?.headers
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
/**
|
|
2182
|
+
* Get an image
|
|
2183
|
+
*
|
|
2184
|
+
* Returns a single image by ID.
|
|
2185
|
+
*/
|
|
2186
|
+
const getMediaV1ImagesByImageId = (options) => (options.client ?? client).get({
|
|
2187
|
+
url: "/media/v1/images/{imageId}",
|
|
2188
|
+
...options
|
|
2189
|
+
});
|
|
2190
|
+
/**
|
|
2191
|
+
* List supported languages
|
|
2192
|
+
*
|
|
2193
|
+
* Returns the language codes supported for audio tracks and subtitles.
|
|
2194
|
+
*/
|
|
2195
|
+
const getMediaV1Languages = (options) => (options?.client ?? client).get({
|
|
2196
|
+
url: "/media/v1/languages",
|
|
2197
|
+
...options
|
|
2198
|
+
});
|
|
2199
|
+
/**
|
|
2200
|
+
* List images
|
|
2201
|
+
*
|
|
2202
|
+
* Returns the images in a project.
|
|
2203
|
+
*/
|
|
2204
|
+
const getMediaV1ProjectsByProjectIdImages = (options) => (options.client ?? client).get({
|
|
2205
|
+
security: [{
|
|
2206
|
+
name: "X-API-Key",
|
|
2207
|
+
type: "apiKey"
|
|
2208
|
+
}],
|
|
2209
|
+
url: "/media/v1/projects/{projectId}/images",
|
|
2210
|
+
...options
|
|
2211
|
+
});
|
|
2212
|
+
/**
|
|
2213
|
+
* Delete an image
|
|
2214
|
+
*
|
|
2215
|
+
* Deletes an image from a project.
|
|
2216
|
+
*/
|
|
2217
|
+
const deleteMediaV1ProjectsByProjectIdImagesByImageId = (options) => (options.client ?? client).delete({
|
|
2218
|
+
security: [{
|
|
2219
|
+
name: "X-API-Key",
|
|
2220
|
+
type: "apiKey"
|
|
2221
|
+
}],
|
|
2222
|
+
url: "/media/v1/projects/{projectId}/images/{imageId}",
|
|
2223
|
+
...options
|
|
2224
|
+
});
|
|
2225
|
+
/**
|
|
2226
|
+
* Get an image (project-scoped)
|
|
2227
|
+
*
|
|
2228
|
+
* Returns a single image within a project, including private media. Requires project access.
|
|
2229
|
+
*/
|
|
2230
|
+
const getMediaV1ProjectsByProjectIdImagesByImageId = (options) => (options.client ?? client).get({
|
|
2231
|
+
security: [{
|
|
2232
|
+
name: "X-API-Key",
|
|
2233
|
+
type: "apiKey"
|
|
2234
|
+
}],
|
|
2235
|
+
url: "/media/v1/projects/{projectId}/images/{imageId}",
|
|
2236
|
+
...options
|
|
2237
|
+
});
|
|
2238
|
+
/**
|
|
2239
|
+
* Complete an image upload
|
|
2240
|
+
*
|
|
2241
|
+
* Finalizes a previously initiated image upload.
|
|
2242
|
+
*/
|
|
2243
|
+
const postMediaV1ProjectsByProjectIdImagesByImageIdUploadComplete = (options) => (options.client ?? client).post({
|
|
2244
|
+
security: [{
|
|
2245
|
+
name: "X-API-Key",
|
|
2246
|
+
type: "apiKey"
|
|
2247
|
+
}],
|
|
2248
|
+
url: "/media/v1/projects/{projectId}/images/{imageId}/upload/complete",
|
|
2249
|
+
...options
|
|
2250
|
+
});
|
|
2251
|
+
/**
|
|
2252
|
+
* Set an image's visibility
|
|
2253
|
+
*
|
|
2254
|
+
* Updates an image's visibility (public, unlisted, or private). Requires project access.
|
|
2255
|
+
*/
|
|
2256
|
+
const putMediaV1ProjectsByProjectIdImagesByImageIdVisibility = (options) => (options.client ?? client).put({
|
|
2257
|
+
security: [{
|
|
2258
|
+
name: "X-API-Key",
|
|
2259
|
+
type: "apiKey"
|
|
2260
|
+
}],
|
|
2261
|
+
url: "/media/v1/projects/{projectId}/images/{imageId}/visibility",
|
|
2262
|
+
...options,
|
|
2263
|
+
headers: {
|
|
2264
|
+
"Content-Type": "application/json",
|
|
2265
|
+
...options.headers
|
|
2266
|
+
}
|
|
2267
|
+
});
|
|
2268
|
+
/**
|
|
2269
|
+
* Create an image upload
|
|
2270
|
+
*
|
|
2271
|
+
* Initiates an image upload and returns upload details.
|
|
2272
|
+
*/
|
|
2273
|
+
const postMediaV1ProjectsByProjectIdImagesUpload = (options) => (options.client ?? client).post({
|
|
2274
|
+
security: [{
|
|
2275
|
+
name: "X-API-Key",
|
|
2276
|
+
type: "apiKey"
|
|
2277
|
+
}],
|
|
2278
|
+
url: "/media/v1/projects/{projectId}/images/upload",
|
|
2279
|
+
...options,
|
|
2280
|
+
headers: {
|
|
2281
|
+
"Content-Type": "application/json",
|
|
2282
|
+
...options.headers
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
/**
|
|
2286
|
+
* List videos in a project
|
|
2287
|
+
*
|
|
2288
|
+
* Returns the videos belonging to a project.
|
|
2289
|
+
*/
|
|
2290
|
+
const getMediaV1ProjectsByProjectIdVideos = (options) => (options.client ?? client).get({
|
|
2291
|
+
security: [{
|
|
2292
|
+
name: "X-API-Key",
|
|
2293
|
+
type: "apiKey"
|
|
2294
|
+
}],
|
|
2295
|
+
url: "/media/v1/projects/{projectId}/videos",
|
|
2296
|
+
...options
|
|
2297
|
+
});
|
|
2298
|
+
/**
|
|
2299
|
+
* Delete a video
|
|
2300
|
+
*
|
|
2301
|
+
* Deletes a video from a project.
|
|
2302
|
+
*/
|
|
2303
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoId = (options) => (options.client ?? client).delete({
|
|
2304
|
+
security: [{
|
|
2305
|
+
name: "X-API-Key",
|
|
2306
|
+
type: "apiKey"
|
|
2307
|
+
}],
|
|
2308
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}",
|
|
2309
|
+
...options
|
|
2310
|
+
});
|
|
2311
|
+
/**
|
|
2312
|
+
* Get a video (project-scoped)
|
|
2313
|
+
*
|
|
2314
|
+
* Returns a single video within a project, including private media. Requires project access.
|
|
2315
|
+
*/
|
|
2316
|
+
const getMediaV1ProjectsByProjectIdVideosByVideoId = (options) => (options.client ?? client).get({
|
|
2317
|
+
security: [{
|
|
2318
|
+
name: "X-API-Key",
|
|
2319
|
+
type: "apiKey"
|
|
2320
|
+
}],
|
|
2321
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}",
|
|
2322
|
+
...options
|
|
2323
|
+
});
|
|
2324
|
+
/**
|
|
2325
|
+
* Delete all audio tracks
|
|
2326
|
+
*
|
|
2327
|
+
* Deletes all audio tracks for a video.
|
|
2328
|
+
*/
|
|
2329
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracks = (options) => (options.client ?? client).delete({
|
|
2330
|
+
security: [{
|
|
2331
|
+
name: "X-API-Key",
|
|
2332
|
+
type: "apiKey"
|
|
2333
|
+
}],
|
|
2334
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks",
|
|
2335
|
+
...options
|
|
2336
|
+
});
|
|
2337
|
+
/**
|
|
2338
|
+
* List audio tracks (project-scoped)
|
|
2339
|
+
*
|
|
2340
|
+
* Returns a video's audio tracks within a project, including for private media. Requires project access.
|
|
2341
|
+
*/
|
|
2342
|
+
const getMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracks = (options) => (options.client ?? client).get({
|
|
2343
|
+
security: [{
|
|
2344
|
+
name: "X-API-Key",
|
|
2345
|
+
type: "apiKey"
|
|
2346
|
+
}],
|
|
2347
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks",
|
|
2348
|
+
...options
|
|
2349
|
+
});
|
|
2350
|
+
/**
|
|
2351
|
+
* Delete an audio track
|
|
2352
|
+
*
|
|
2353
|
+
* Deletes a single audio track from a video.
|
|
2354
|
+
*/
|
|
2355
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksByTrackId = (options) => (options.client ?? client).delete({
|
|
2356
|
+
security: [{
|
|
2357
|
+
name: "X-API-Key",
|
|
2358
|
+
type: "apiKey"
|
|
2359
|
+
}],
|
|
2360
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks/{trackId}",
|
|
2361
|
+
...options
|
|
2362
|
+
});
|
|
2363
|
+
/**
|
|
2364
|
+
* Delete audio tracks by language
|
|
2365
|
+
*
|
|
2366
|
+
* Deletes all audio tracks for a video in a given language.
|
|
2367
|
+
*/
|
|
2368
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksLanguageByLang = (options) => (options.client ?? client).delete({
|
|
2369
|
+
security: [{
|
|
2370
|
+
name: "X-API-Key",
|
|
2371
|
+
type: "apiKey"
|
|
2372
|
+
}],
|
|
2373
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks/language/{lang}",
|
|
2374
|
+
...options
|
|
2375
|
+
});
|
|
2376
|
+
/**
|
|
2377
|
+
* Initiate audio track uploads
|
|
2378
|
+
*
|
|
2379
|
+
* Initiates one or more audio track uploads for a video.
|
|
2380
|
+
*/
|
|
2381
|
+
const postMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksUpload = (options) => (options.client ?? client).post({
|
|
2382
|
+
security: [{
|
|
2383
|
+
name: "X-API-Key",
|
|
2384
|
+
type: "apiKey"
|
|
2385
|
+
}],
|
|
2386
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks/upload",
|
|
2387
|
+
...options,
|
|
2388
|
+
headers: {
|
|
2389
|
+
"Content-Type": "application/json",
|
|
2390
|
+
...options.headers
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
/**
|
|
2394
|
+
* Complete audio track uploads
|
|
2395
|
+
*
|
|
2396
|
+
* Finalizes previously initiated audio track uploads.
|
|
2397
|
+
*/
|
|
2398
|
+
const postMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksUploadComplete = (options) => (options.client ?? client).post({
|
|
2399
|
+
security: [{
|
|
2400
|
+
name: "X-API-Key",
|
|
2401
|
+
type: "apiKey"
|
|
2402
|
+
}],
|
|
2403
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/audio-tracks/upload/complete",
|
|
2404
|
+
...options,
|
|
2405
|
+
headers: {
|
|
2406
|
+
"Content-Type": "application/json",
|
|
2407
|
+
...options.headers
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
/**
|
|
2411
|
+
* Delete all video chapters
|
|
2412
|
+
*
|
|
2413
|
+
* Removes every chapter from a video.
|
|
2414
|
+
*/
|
|
2415
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdChapters = (options) => (options.client ?? client).delete({
|
|
2416
|
+
security: [{
|
|
2417
|
+
name: "X-API-Key",
|
|
2418
|
+
type: "apiKey"
|
|
2419
|
+
}],
|
|
2420
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/chapters",
|
|
2421
|
+
...options
|
|
2422
|
+
});
|
|
2423
|
+
/**
|
|
2424
|
+
* Get video chapters
|
|
2425
|
+
*
|
|
2426
|
+
* Returns the chapters of a video.
|
|
2427
|
+
*/
|
|
2428
|
+
const getMediaV1ProjectsByProjectIdVideosByVideoIdChapters = (options) => (options.client ?? client).get({
|
|
2429
|
+
security: [{
|
|
2430
|
+
name: "X-API-Key",
|
|
2431
|
+
type: "apiKey"
|
|
2432
|
+
}],
|
|
2433
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/chapters",
|
|
2434
|
+
...options
|
|
2435
|
+
});
|
|
2436
|
+
/**
|
|
2437
|
+
* Update video chapters
|
|
2438
|
+
*
|
|
2439
|
+
* Replaces the chapters of a video.
|
|
2440
|
+
*/
|
|
2441
|
+
const putMediaV1ProjectsByProjectIdVideosByVideoIdChapters = (options) => (options.client ?? client).put({
|
|
2442
|
+
security: [{
|
|
2443
|
+
name: "X-API-Key",
|
|
2444
|
+
type: "apiKey"
|
|
2445
|
+
}],
|
|
2446
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/chapters",
|
|
2447
|
+
...options,
|
|
2448
|
+
headers: {
|
|
2449
|
+
"Content-Type": "application/json",
|
|
2450
|
+
...options.headers
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
/**
|
|
2454
|
+
* Delete a single video chapter
|
|
2455
|
+
*
|
|
2456
|
+
* Removes one chapter identified by its start time (seconds).
|
|
2457
|
+
*/
|
|
2458
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdChaptersByStartTimeSec = (options) => (options.client ?? client).delete({
|
|
2459
|
+
security: [{
|
|
2460
|
+
name: "X-API-Key",
|
|
2461
|
+
type: "apiKey"
|
|
2462
|
+
}],
|
|
2463
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/chapters/{startTimeSec}",
|
|
2464
|
+
...options
|
|
2465
|
+
});
|
|
2466
|
+
/**
|
|
2467
|
+
* Delete all subtitles
|
|
2468
|
+
*
|
|
2469
|
+
* Deletes all subtitles for a video.
|
|
2470
|
+
*/
|
|
2471
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitles = (options) => (options.client ?? client).delete({
|
|
2472
|
+
security: [{
|
|
2473
|
+
name: "X-API-Key",
|
|
2474
|
+
type: "apiKey"
|
|
2475
|
+
}],
|
|
2476
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles",
|
|
2477
|
+
...options
|
|
2478
|
+
});
|
|
2479
|
+
/**
|
|
2480
|
+
* List subtitles (project-scoped)
|
|
2481
|
+
*
|
|
2482
|
+
* Returns a video's subtitles within a project, including for private media. Requires project access.
|
|
2483
|
+
*/
|
|
2484
|
+
const getMediaV1ProjectsByProjectIdVideosByVideoIdSubtitles = (options) => (options.client ?? client).get({
|
|
2485
|
+
security: [{
|
|
2486
|
+
name: "X-API-Key",
|
|
2487
|
+
type: "apiKey"
|
|
2488
|
+
}],
|
|
2489
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles",
|
|
2490
|
+
...options
|
|
2491
|
+
});
|
|
2492
|
+
/**
|
|
2493
|
+
* Delete a subtitle
|
|
2494
|
+
*
|
|
2495
|
+
* Deletes a single subtitle from a video.
|
|
2496
|
+
*/
|
|
2497
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesBySubtitleId = (options) => (options.client ?? client).delete({
|
|
2498
|
+
security: [{
|
|
2499
|
+
name: "X-API-Key",
|
|
2500
|
+
type: "apiKey"
|
|
2501
|
+
}],
|
|
2502
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles/{subtitleId}",
|
|
2503
|
+
...options
|
|
2504
|
+
});
|
|
2505
|
+
/**
|
|
2506
|
+
* Delete subtitles by language
|
|
2507
|
+
*
|
|
2508
|
+
* Deletes all subtitles for a video in a given language.
|
|
2509
|
+
*/
|
|
2510
|
+
const deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesLanguageByLang = (options) => (options.client ?? client).delete({
|
|
2511
|
+
security: [{
|
|
2512
|
+
name: "X-API-Key",
|
|
2513
|
+
type: "apiKey"
|
|
2514
|
+
}],
|
|
2515
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles/language/{lang}",
|
|
2516
|
+
...options
|
|
2517
|
+
});
|
|
2518
|
+
/**
|
|
2519
|
+
* Initiate subtitle uploads
|
|
2520
|
+
*
|
|
2521
|
+
* Initiates one or more subtitle uploads for a video.
|
|
2522
|
+
*/
|
|
2523
|
+
const postMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesUpload = (options) => (options.client ?? client).post({
|
|
2524
|
+
security: [{
|
|
2525
|
+
name: "X-API-Key",
|
|
2526
|
+
type: "apiKey"
|
|
2527
|
+
}],
|
|
2528
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles/upload",
|
|
2529
|
+
...options,
|
|
2530
|
+
headers: {
|
|
2531
|
+
"Content-Type": "application/json",
|
|
2532
|
+
...options.headers
|
|
2533
|
+
}
|
|
2534
|
+
});
|
|
2535
|
+
/**
|
|
2536
|
+
* Complete subtitle uploads
|
|
2537
|
+
*
|
|
2538
|
+
* Finalizes previously initiated subtitle uploads.
|
|
2539
|
+
*/
|
|
2540
|
+
const postMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesUploadComplete = (options) => (options.client ?? client).post({
|
|
2541
|
+
security: [{
|
|
2542
|
+
name: "X-API-Key",
|
|
2543
|
+
type: "apiKey"
|
|
2544
|
+
}],
|
|
2545
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/subtitles/upload/complete",
|
|
2546
|
+
...options,
|
|
2547
|
+
headers: {
|
|
2548
|
+
"Content-Type": "application/json",
|
|
2549
|
+
...options.headers
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
/**
|
|
2553
|
+
* Update video thumbnail
|
|
2554
|
+
*
|
|
2555
|
+
* Replaces the thumbnail image for an existing video.
|
|
2556
|
+
*/
|
|
2557
|
+
const putMediaV1ProjectsByProjectIdVideosByVideoIdThumbnail = (options) => (options.client ?? client).put({
|
|
2558
|
+
...formDataBodySerializer,
|
|
2559
|
+
security: [{
|
|
2560
|
+
name: "X-API-Key",
|
|
2561
|
+
type: "apiKey"
|
|
2562
|
+
}],
|
|
2563
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/thumbnail",
|
|
2564
|
+
...options,
|
|
2565
|
+
headers: {
|
|
2566
|
+
"Content-Type": null,
|
|
2567
|
+
...options.headers
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
/**
|
|
2571
|
+
* Complete a video upload
|
|
2572
|
+
*
|
|
2573
|
+
* Finalizes a previously initiated video upload.
|
|
2574
|
+
*/
|
|
2575
|
+
const postMediaV1ProjectsByProjectIdVideosByVideoIdUploadComplete = (options) => (options.client ?? client).post({
|
|
2576
|
+
security: [{
|
|
2577
|
+
name: "X-API-Key",
|
|
2578
|
+
type: "apiKey"
|
|
2579
|
+
}],
|
|
2580
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/upload/complete",
|
|
2581
|
+
...options
|
|
2582
|
+
});
|
|
2583
|
+
/**
|
|
2584
|
+
* Set a video's visibility
|
|
2585
|
+
*
|
|
2586
|
+
* Updates a video's visibility (public, unlisted, or private). Requires project access.
|
|
2587
|
+
*/
|
|
2588
|
+
const putMediaV1ProjectsByProjectIdVideosByVideoIdVisibility = (options) => (options.client ?? client).put({
|
|
2589
|
+
security: [{
|
|
2590
|
+
name: "X-API-Key",
|
|
2591
|
+
type: "apiKey"
|
|
2592
|
+
}],
|
|
2593
|
+
url: "/media/v1/projects/{projectId}/videos/{videoId}/visibility",
|
|
2594
|
+
...options,
|
|
2595
|
+
headers: {
|
|
2596
|
+
"Content-Type": "application/json",
|
|
2597
|
+
...options.headers
|
|
2598
|
+
}
|
|
2599
|
+
});
|
|
2600
|
+
/**
|
|
2601
|
+
* Create a video upload
|
|
2602
|
+
*
|
|
2603
|
+
* Initiates a video upload and returns upload details.
|
|
2604
|
+
*/
|
|
2605
|
+
const postMediaV1ProjectsByProjectIdVideosUpload = (options) => (options.client ?? client).post({
|
|
2606
|
+
security: [{
|
|
2607
|
+
name: "X-API-Key",
|
|
2608
|
+
type: "apiKey"
|
|
2609
|
+
}],
|
|
2610
|
+
url: "/media/v1/projects/{projectId}/videos/upload",
|
|
2611
|
+
...options,
|
|
2612
|
+
headers: {
|
|
2613
|
+
"Content-Type": "application/json",
|
|
2614
|
+
...options.headers
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
/**
|
|
2618
|
+
* Get a video
|
|
2619
|
+
*
|
|
2620
|
+
* Returns a single video by ID.
|
|
2621
|
+
*/
|
|
2622
|
+
const getMediaV1VideosByVideoId = (options) => (options.client ?? client).get({
|
|
2623
|
+
url: "/media/v1/videos/{videoId}",
|
|
2624
|
+
...options
|
|
2625
|
+
});
|
|
2626
|
+
/**
|
|
2627
|
+
* List audio tracks for a video
|
|
2628
|
+
*
|
|
2629
|
+
* Returns the audio tracks associated with a video.
|
|
2630
|
+
*/
|
|
2631
|
+
const getMediaV1VideosByVideoIdAudioTracks = (options) => (options.client ?? client).get({
|
|
2632
|
+
url: "/media/v1/videos/{videoId}/audio-tracks",
|
|
2633
|
+
...options
|
|
2634
|
+
});
|
|
2635
|
+
/**
|
|
2636
|
+
* List subtitles for a video
|
|
2637
|
+
*
|
|
2638
|
+
* Returns the subtitles associated with a video.
|
|
2639
|
+
*/
|
|
2640
|
+
const getMediaV1VideosByVideoIdSubtitles = (options) => (options.client ?? client).get({
|
|
2641
|
+
url: "/media/v1/videos/{videoId}/subtitles",
|
|
2642
|
+
...options
|
|
2643
|
+
});
|
|
2644
|
+
/**
|
|
2645
|
+
* List organization projects
|
|
2646
|
+
*
|
|
2647
|
+
* Get all projects for a specific organization
|
|
2648
|
+
*/
|
|
2649
|
+
const listProjectsByOrgid = (options) => (options.client ?? client).get({
|
|
2650
|
+
security: [{
|
|
2651
|
+
name: "X-API-Key",
|
|
2652
|
+
type: "apiKey"
|
|
2653
|
+
}],
|
|
2654
|
+
url: "/organization/{orgId}/projects",
|
|
2655
|
+
...options
|
|
2656
|
+
});
|
|
2657
|
+
/**
|
|
2658
|
+
* Create project
|
|
2659
|
+
*
|
|
2660
|
+
* Create a new project under the given organization with specified video quality
|
|
2661
|
+
*/
|
|
2662
|
+
const createProjectsByOrgid = (options) => (options.client ?? client).post({
|
|
2663
|
+
security: [{
|
|
2664
|
+
name: "X-API-Key",
|
|
2665
|
+
type: "apiKey"
|
|
2666
|
+
}],
|
|
2667
|
+
url: "/organization/{orgId}/projects",
|
|
2668
|
+
...options,
|
|
2669
|
+
headers: {
|
|
2670
|
+
"Content-Type": "application/json",
|
|
2671
|
+
...options.headers
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
/**
|
|
2675
|
+
* Delete project (soft)
|
|
2676
|
+
*
|
|
2677
|
+
* Soft delete a project (marks it as deleted)
|
|
2678
|
+
*/
|
|
2679
|
+
const deleteProjects = (options) => (options.client ?? client).delete({
|
|
2680
|
+
security: [{
|
|
2681
|
+
name: "X-API-Key",
|
|
2682
|
+
type: "apiKey"
|
|
2683
|
+
}],
|
|
2684
|
+
url: "/organization/{orgId}/projects/{projectId}",
|
|
2685
|
+
...options
|
|
2686
|
+
});
|
|
2687
|
+
/**
|
|
2688
|
+
* Get project
|
|
2689
|
+
*
|
|
2690
|
+
* Retrieve a specific project under an organization
|
|
2691
|
+
*/
|
|
2692
|
+
const getProjects = (options) => (options.client ?? client).get({
|
|
2693
|
+
security: [{
|
|
2694
|
+
name: "X-API-Key",
|
|
2695
|
+
type: "apiKey"
|
|
2696
|
+
}],
|
|
2697
|
+
url: "/organization/{orgId}/projects/{projectId}",
|
|
2698
|
+
...options
|
|
2699
|
+
});
|
|
2700
|
+
/**
|
|
2701
|
+
* Remove custom domain
|
|
2702
|
+
*
|
|
2703
|
+
* Remove the custom domain from a specific project
|
|
2704
|
+
*/
|
|
2705
|
+
const deleteCustomDomainByProjectid = (options) => (options.client ?? client).delete({
|
|
2706
|
+
security: [{
|
|
2707
|
+
name: "X-API-Key",
|
|
2708
|
+
type: "apiKey"
|
|
2709
|
+
}],
|
|
2710
|
+
url: "/organization/{orgId}/projects/{projectId}/custom-domain",
|
|
2711
|
+
...options
|
|
2712
|
+
});
|
|
2713
|
+
/**
|
|
2714
|
+
* Set or update custom domain
|
|
2715
|
+
*
|
|
2716
|
+
* Set or update a custom domain for a specific project
|
|
2717
|
+
*/
|
|
2718
|
+
const updateCustomDomainByProjectid = (options) => (options.client ?? client).put({
|
|
2719
|
+
security: [{
|
|
2720
|
+
name: "X-API-Key",
|
|
2721
|
+
type: "apiKey"
|
|
2722
|
+
}],
|
|
2723
|
+
url: "/organization/{orgId}/projects/{projectId}/custom-domain",
|
|
2724
|
+
...options,
|
|
2725
|
+
headers: {
|
|
2726
|
+
"Content-Type": "application/json",
|
|
2727
|
+
...options.headers
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
/**
|
|
2731
|
+
* Move project to another organization
|
|
2732
|
+
*
|
|
2733
|
+
* Move a project from one organization to another (if user has access to both)
|
|
2734
|
+
*/
|
|
2735
|
+
const createMoveByProjectid = (options) => (options.client ?? client).post({
|
|
2736
|
+
security: [{
|
|
2737
|
+
name: "X-API-Key",
|
|
2738
|
+
type: "apiKey"
|
|
2739
|
+
}],
|
|
2740
|
+
url: "/organization/{orgId}/projects/{projectId}/move",
|
|
2741
|
+
...options,
|
|
2742
|
+
headers: {
|
|
2743
|
+
"Content-Type": "application/json",
|
|
2744
|
+
...options.headers
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
2747
|
+
/**
|
|
2748
|
+
* Update project name
|
|
2749
|
+
*
|
|
2750
|
+
* Update the name of a specific project
|
|
2751
|
+
*/
|
|
2752
|
+
const patchNameByProjectid = (options) => (options.client ?? client).patch({
|
|
2753
|
+
security: [{
|
|
2754
|
+
name: "X-API-Key",
|
|
2755
|
+
type: "apiKey"
|
|
2756
|
+
}],
|
|
2757
|
+
url: "/organization/{orgId}/projects/{projectId}/name",
|
|
2758
|
+
...options,
|
|
2759
|
+
headers: {
|
|
2760
|
+
"Content-Type": "application/json",
|
|
2761
|
+
...options.headers
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
/**
|
|
2765
|
+
* Update project video quality
|
|
2766
|
+
*
|
|
2767
|
+
* Update the default video quality setting for a project
|
|
2768
|
+
*/
|
|
2769
|
+
const patchVideoQualityByProjectid = (options) => (options.client ?? client).patch({
|
|
2770
|
+
security: [{
|
|
2771
|
+
name: "X-API-Key",
|
|
2772
|
+
type: "apiKey"
|
|
2773
|
+
}],
|
|
2774
|
+
url: "/organization/{orgId}/projects/{projectId}/video-quality",
|
|
2775
|
+
...options,
|
|
2776
|
+
headers: {
|
|
2777
|
+
"Content-Type": "application/json",
|
|
2778
|
+
...options.headers
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
/**
|
|
2782
|
+
* List organization API keys
|
|
2783
|
+
*
|
|
2784
|
+
* Get all API keys for a specific organization
|
|
2785
|
+
*/
|
|
2786
|
+
const listApiKeysByOrgid = (options) => (options?.client ?? client).get({
|
|
2787
|
+
security: [{
|
|
2788
|
+
name: "X-API-Key",
|
|
2789
|
+
type: "apiKey"
|
|
2790
|
+
}],
|
|
2791
|
+
url: "/platform/api-keys",
|
|
2792
|
+
...options
|
|
2793
|
+
});
|
|
2794
|
+
/**
|
|
2795
|
+
* Create API key
|
|
2796
|
+
*
|
|
2797
|
+
* Create a new API key for a project in the authenticated organization
|
|
2798
|
+
*/
|
|
2799
|
+
const createApiKeyByOrgid = (options) => (options.client ?? client).post({
|
|
2800
|
+
security: [{
|
|
2801
|
+
name: "X-API-Key",
|
|
2802
|
+
type: "apiKey"
|
|
2803
|
+
}],
|
|
2804
|
+
url: "/platform/api-keys",
|
|
2805
|
+
...options,
|
|
2806
|
+
headers: {
|
|
2807
|
+
"Content-Type": "application/json",
|
|
2808
|
+
...options.headers
|
|
2809
|
+
}
|
|
2810
|
+
});
|
|
2811
|
+
/**
|
|
2812
|
+
* Delete API key
|
|
2813
|
+
*
|
|
2814
|
+
* Delete an API key owned by the authenticated organization
|
|
2815
|
+
*/
|
|
2816
|
+
const deleteApiKeyByKeyid = (options) => (options.client ?? client).delete({
|
|
2817
|
+
security: [{
|
|
2818
|
+
name: "X-API-Key",
|
|
2819
|
+
type: "apiKey"
|
|
2820
|
+
}],
|
|
2821
|
+
url: "/platform/api-keys/{keyId}",
|
|
2822
|
+
...options
|
|
2823
|
+
});
|
|
2824
|
+
/**
|
|
2825
|
+
* Rotate API key
|
|
2826
|
+
*
|
|
2827
|
+
* Rotate an API key, returning a new secret
|
|
2828
|
+
*/
|
|
2829
|
+
const rotateApiKeyByKeyid = (options) => (options.client ?? client).post({
|
|
2830
|
+
security: [{
|
|
2831
|
+
name: "X-API-Key",
|
|
2832
|
+
type: "apiKey"
|
|
2833
|
+
}],
|
|
2834
|
+
url: "/platform/api-keys/{keyId}/rotate",
|
|
2835
|
+
...options
|
|
2836
|
+
});
|
|
2837
|
+
/**
|
|
2838
|
+
* Refresh a platform access token
|
|
2839
|
+
*
|
|
2840
|
+
* Trades a refresh token for a fresh access/refresh pair.
|
|
2841
|
+
*/
|
|
2842
|
+
const postPlatformAuthRefresh = (options) => (options.client ?? client).post({
|
|
2843
|
+
url: "/platform/auth/refresh",
|
|
2844
|
+
...options,
|
|
2845
|
+
headers: {
|
|
2846
|
+
"Content-Type": "application/json",
|
|
2847
|
+
...options.headers
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
/**
|
|
2851
|
+
* Exchange an API key for a platform access token
|
|
2852
|
+
*
|
|
2853
|
+
* Trades an API key (`<keyId>_<secret>`) for a short-lived platform access token plus a refresh token.
|
|
2854
|
+
*/
|
|
2855
|
+
const postPlatformAuthToken = (options) => (options.client ?? client).post({
|
|
2856
|
+
url: "/platform/auth/token",
|
|
2857
|
+
...options,
|
|
2858
|
+
headers: {
|
|
2859
|
+
"Content-Type": "application/json",
|
|
2860
|
+
...options.headers
|
|
2861
|
+
}
|
|
2862
|
+
});
|
|
2863
|
+
/**
|
|
2864
|
+
* List client credentials
|
|
2865
|
+
*
|
|
2866
|
+
* List client credentials for the specified organization
|
|
2867
|
+
*/
|
|
2868
|
+
const listCredentialsByOrgid = (options) => (options?.client ?? client).get({
|
|
2869
|
+
security: [{
|
|
2870
|
+
name: "X-API-Key",
|
|
2871
|
+
type: "apiKey"
|
|
2872
|
+
}],
|
|
2873
|
+
url: "/platform/clientauth/credentials",
|
|
2874
|
+
...options
|
|
2875
|
+
});
|
|
2876
|
+
/**
|
|
2877
|
+
* Create client credential
|
|
2878
|
+
*
|
|
2879
|
+
* Create a new client credential for the authenticated organization
|
|
2880
|
+
*/
|
|
2881
|
+
const createCredentialByOrgid = (options) => (options.client ?? client).post({
|
|
2882
|
+
security: [{
|
|
2883
|
+
name: "X-API-Key",
|
|
2884
|
+
type: "apiKey"
|
|
2885
|
+
}],
|
|
2886
|
+
url: "/platform/clientauth/credentials",
|
|
2887
|
+
...options,
|
|
2888
|
+
headers: {
|
|
2889
|
+
"Content-Type": "application/json",
|
|
2890
|
+
...options.headers
|
|
2891
|
+
}
|
|
2892
|
+
});
|
|
2893
|
+
/**
|
|
2894
|
+
* Revoke client credential
|
|
2895
|
+
*
|
|
2896
|
+
* Revoke a client credential owned by the authenticated organization
|
|
2897
|
+
*/
|
|
2898
|
+
const revokeCredentialByCredentialid = (options) => (options.client ?? client).post({
|
|
2899
|
+
security: [{
|
|
2900
|
+
name: "X-API-Key",
|
|
2901
|
+
type: "apiKey"
|
|
2902
|
+
}],
|
|
2903
|
+
url: "/platform/clientauth/credentials/{credentialId}/revoke",
|
|
2904
|
+
...options
|
|
2905
|
+
});
|
|
2906
|
+
/**
|
|
2907
|
+
* Mint client access token
|
|
2908
|
+
*
|
|
2909
|
+
* Exchange client_id/client_secret for a short-lived access token. The request subject is an opaque client-defined label and is not treated as authoritative user identity for authorization.
|
|
2910
|
+
*/
|
|
2911
|
+
const createToken = (options) => (options.client ?? client).post({
|
|
2912
|
+
url: "/platform/clientauth/token",
|
|
2913
|
+
...options,
|
|
2914
|
+
headers: {
|
|
2915
|
+
"Content-Type": "application/json",
|
|
2916
|
+
...options.headers
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
/**
|
|
2920
|
+
* List posts in a feed
|
|
2921
|
+
*
|
|
2922
|
+
* Public, unauthenticated listing of posts in a feed, with pagination.
|
|
2923
|
+
*/
|
|
2924
|
+
const listPublicPosts = (options) => (options.client ?? client).get({
|
|
2925
|
+
url: "/posts/v1/feeds/{feedId}",
|
|
2926
|
+
...options
|
|
2927
|
+
});
|
|
2928
|
+
/**
|
|
2929
|
+
* Get a post
|
|
2930
|
+
*
|
|
2931
|
+
* Public, unauthenticated retrieval of a single post by ID.
|
|
2932
|
+
*/
|
|
2933
|
+
const getPublicPost = (options) => (options.client ?? client).get({
|
|
2934
|
+
url: "/posts/v1/feeds/{feedId}/{postId}",
|
|
2935
|
+
...options
|
|
2936
|
+
});
|
|
2937
|
+
/**
|
|
2938
|
+
* List posts by creator
|
|
2939
|
+
*
|
|
2940
|
+
* Public, unauthenticated listing of posts in a feed by a specific creator, with pagination.
|
|
2941
|
+
*/
|
|
2942
|
+
const listPublicPostsByCreator = (options) => (options.client ?? client).get({
|
|
2943
|
+
url: "/posts/v1/feeds/{feedId}/creators/{creatorId}",
|
|
2944
|
+
...options
|
|
2945
|
+
});
|
|
2946
|
+
/**
|
|
2947
|
+
* List posts
|
|
2948
|
+
*
|
|
2949
|
+
* List posts in a feed
|
|
2950
|
+
*/
|
|
2951
|
+
const listPosts = (options) => (options.client ?? client).get({
|
|
2952
|
+
security: [{
|
|
2953
|
+
name: "X-API-Key",
|
|
2954
|
+
type: "apiKey"
|
|
2955
|
+
}],
|
|
2956
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts",
|
|
2957
|
+
...options
|
|
2958
|
+
});
|
|
2959
|
+
/**
|
|
2960
|
+
* Create a post
|
|
2961
|
+
*
|
|
2962
|
+
* Create a new post in a feed
|
|
2963
|
+
*/
|
|
2964
|
+
const createPost = (options) => (options.client ?? client).post({
|
|
2965
|
+
security: [{
|
|
2966
|
+
name: "X-API-Key",
|
|
2967
|
+
type: "apiKey"
|
|
2968
|
+
}],
|
|
2969
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts",
|
|
2970
|
+
...options,
|
|
2971
|
+
headers: {
|
|
2972
|
+
"Content-Type": "application/json",
|
|
2973
|
+
...options.headers
|
|
2974
|
+
}
|
|
2975
|
+
});
|
|
2976
|
+
/**
|
|
2977
|
+
* Delete a post
|
|
2978
|
+
*
|
|
2979
|
+
* Delete a post by ID
|
|
2980
|
+
*/
|
|
2981
|
+
const deletePost = (options) => (options.client ?? client).delete({
|
|
2982
|
+
security: [{
|
|
2983
|
+
name: "X-API-Key",
|
|
2984
|
+
type: "apiKey"
|
|
2985
|
+
}],
|
|
2986
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts/{postId}",
|
|
2987
|
+
...options
|
|
2988
|
+
});
|
|
2989
|
+
/**
|
|
2990
|
+
* Get a post
|
|
2991
|
+
*
|
|
2992
|
+
* Get a single post by ID
|
|
2993
|
+
*/
|
|
2994
|
+
const getPost = (options) => (options.client ?? client).get({
|
|
2995
|
+
security: [{
|
|
2996
|
+
name: "X-API-Key",
|
|
2997
|
+
type: "apiKey"
|
|
2998
|
+
}],
|
|
2999
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts/{postId}",
|
|
3000
|
+
...options
|
|
3001
|
+
});
|
|
3002
|
+
/**
|
|
3003
|
+
* List posts by creator
|
|
3004
|
+
*
|
|
3005
|
+
* List posts in a feed authored by a specific creator
|
|
3006
|
+
*/
|
|
3007
|
+
const listPostsByCreator = (options) => (options.client ?? client).get({
|
|
3008
|
+
security: [{
|
|
3009
|
+
name: "X-API-Key",
|
|
3010
|
+
type: "apiKey"
|
|
3011
|
+
}],
|
|
3012
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts/creators/{creatorId}",
|
|
3013
|
+
...options
|
|
3014
|
+
});
|
|
3015
|
+
/**
|
|
3016
|
+
* Complete a post upload
|
|
3017
|
+
*
|
|
3018
|
+
* Finalize a media upload and publish the post
|
|
3019
|
+
*/
|
|
3020
|
+
const completePostUpload = (options) => (options.client ?? client).post({
|
|
3021
|
+
security: [{
|
|
3022
|
+
name: "X-API-Key",
|
|
3023
|
+
type: "apiKey"
|
|
3024
|
+
}],
|
|
3025
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts/upload/complete",
|
|
3026
|
+
...options,
|
|
3027
|
+
headers: {
|
|
3028
|
+
"Content-Type": "application/json",
|
|
3029
|
+
...options.headers
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
/**
|
|
3033
|
+
* Initialize a post upload
|
|
3034
|
+
*
|
|
3035
|
+
* Begin a media upload and create a draft post
|
|
3036
|
+
*/
|
|
3037
|
+
const initPostUpload = (options) => (options.client ?? client).post({
|
|
3038
|
+
security: [{
|
|
3039
|
+
name: "X-API-Key",
|
|
3040
|
+
type: "apiKey"
|
|
3041
|
+
}],
|
|
3042
|
+
url: "/posts/v1/projects/{projectId}/feeds/{feedId}/posts/upload/init",
|
|
3043
|
+
...options,
|
|
3044
|
+
headers: {
|
|
3045
|
+
"Content-Type": "application/json",
|
|
3046
|
+
...options.headers
|
|
3047
|
+
}
|
|
3048
|
+
});
|
|
3049
|
+
/**
|
|
3050
|
+
* List feeds
|
|
3051
|
+
*
|
|
3052
|
+
* Lists all feeds for the active project with pagination.
|
|
3053
|
+
*/
|
|
3054
|
+
const listFeeds = (options) => (options.client ?? client).get({
|
|
3055
|
+
security: [{
|
|
3056
|
+
name: "X-API-Key",
|
|
3057
|
+
type: "apiKey"
|
|
3058
|
+
}],
|
|
3059
|
+
url: "/projects/{projectId}/feeds",
|
|
3060
|
+
...options,
|
|
3061
|
+
headers: {
|
|
3062
|
+
"Content-Type": "application/json",
|
|
3063
|
+
...options.headers
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
/**
|
|
3067
|
+
* Create a feed
|
|
3068
|
+
*
|
|
3069
|
+
* Creates a new feed under the active project.
|
|
3070
|
+
*/
|
|
3071
|
+
const createFeed = (options) => (options.client ?? client).post({
|
|
3072
|
+
security: [{
|
|
3073
|
+
name: "X-API-Key",
|
|
3074
|
+
type: "apiKey"
|
|
3075
|
+
}],
|
|
3076
|
+
url: "/projects/{projectId}/feeds",
|
|
3077
|
+
...options,
|
|
3078
|
+
headers: {
|
|
3079
|
+
"Content-Type": "application/json",
|
|
3080
|
+
...options.headers
|
|
3081
|
+
}
|
|
3082
|
+
});
|
|
3083
|
+
/**
|
|
3084
|
+
* Delete a feed
|
|
3085
|
+
*
|
|
3086
|
+
* Deletes a feed in the active project.
|
|
3087
|
+
*/
|
|
3088
|
+
const deleteFeed = (options) => (options.client ?? client).delete({
|
|
3089
|
+
security: [{
|
|
3090
|
+
name: "X-API-Key",
|
|
3091
|
+
type: "apiKey"
|
|
3092
|
+
}],
|
|
3093
|
+
url: "/projects/{projectId}/feeds/{feedId}",
|
|
3094
|
+
...options,
|
|
3095
|
+
headers: {
|
|
3096
|
+
"Content-Type": "application/json",
|
|
3097
|
+
...options.headers
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
/**
|
|
3101
|
+
* Get a feed
|
|
3102
|
+
*
|
|
3103
|
+
* Retrieves a feed by ID under the active project.
|
|
3104
|
+
*/
|
|
3105
|
+
const getFeed = (options) => (options.client ?? client).get({
|
|
3106
|
+
security: [{
|
|
3107
|
+
name: "X-API-Key",
|
|
3108
|
+
type: "apiKey"
|
|
3109
|
+
}],
|
|
3110
|
+
url: "/projects/{projectId}/feeds/{feedId}",
|
|
3111
|
+
...options,
|
|
3112
|
+
headers: {
|
|
3113
|
+
"Content-Type": "application/json",
|
|
3114
|
+
...options.headers
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
/**
|
|
3118
|
+
* Update a feed
|
|
3119
|
+
*
|
|
3120
|
+
* Updates an existing feed in the active project.
|
|
3121
|
+
*/
|
|
3122
|
+
const updateFeed = (options) => (options.client ?? client).put({
|
|
3123
|
+
security: [{
|
|
3124
|
+
name: "X-API-Key",
|
|
3125
|
+
type: "apiKey"
|
|
3126
|
+
}],
|
|
3127
|
+
url: "/projects/{projectId}/feeds/{feedId}",
|
|
3128
|
+
...options,
|
|
3129
|
+
headers: {
|
|
3130
|
+
"Content-Type": "application/json",
|
|
3131
|
+
...options.headers
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
|
|
3135
|
+
//#endregion
|
|
3136
|
+
//#region src/connect.ts
|
|
3137
|
+
const connect = async (config) => {
|
|
3138
|
+
client.setConfig({ baseUrl: config.baseUrl });
|
|
3139
|
+
if (config.apiKey) client.interceptors.request.use(async (request) => {
|
|
3140
|
+
request.headers.set("X-API-Key", config.apiKey);
|
|
3141
|
+
return request;
|
|
3142
|
+
});
|
|
3143
|
+
if (config.auth) {
|
|
3144
|
+
const { initClient } = await Promise.resolve().then(() => init_exports);
|
|
3145
|
+
return initClient({
|
|
3146
|
+
apiUrl: config.baseUrl,
|
|
3147
|
+
loginRedirectUrl: config.auth.loginRedirectUrl,
|
|
3148
|
+
googleProvider: config.auth.google,
|
|
3149
|
+
appleProvider: config.auth.apple,
|
|
3150
|
+
microsoftProvider: config.auth.microsoft,
|
|
3151
|
+
telegramProvider: config.auth.telegram
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
|
|
3156
|
+
//#endregion
|
|
3157
|
+
//#region src/auth/api/refresh-tokens.ts
|
|
3158
|
+
const refreshTokens = async (provider, token) => {
|
|
3159
|
+
const { data } = await postAuthV1Token({
|
|
3160
|
+
headers: { Authorization: `${provider} ${token}` },
|
|
3161
|
+
throwOnError: true
|
|
3162
|
+
});
|
|
3163
|
+
return data;
|
|
3164
|
+
};
|
|
3165
|
+
|
|
3166
|
+
//#endregion
|
|
3167
|
+
//#region src/auth/initialization.ts
|
|
3168
|
+
/**
|
|
3169
|
+
* Creates a deferred promise that can be resolved or rejected externally
|
|
3170
|
+
* @returns A deferred promise object
|
|
3171
|
+
*/
|
|
3172
|
+
function createDeferred() {
|
|
3173
|
+
let resolve;
|
|
3174
|
+
let reject;
|
|
3175
|
+
return {
|
|
3176
|
+
promise: new Promise((res, rej) => {
|
|
3177
|
+
resolve = res;
|
|
3178
|
+
reject = rej;
|
|
3179
|
+
}),
|
|
3180
|
+
resolve,
|
|
3181
|
+
reject
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
/**
|
|
3185
|
+
* Global deferred promise that tracks the initialization status of the auth library
|
|
3186
|
+
* This is resolved when initClient is called
|
|
3187
|
+
*/
|
|
3188
|
+
const initDeferred = createDeferred();
|
|
3189
|
+
|
|
3190
|
+
//#endregion
|
|
3191
|
+
//#region src/auth/cookie/util.ts
|
|
3192
|
+
const getAllCookiesStartWith = (startWithKey) => {
|
|
3193
|
+
if (typeof document === "undefined") return {};
|
|
3194
|
+
return document.cookie.split(";").map((cv) => cv.split("=").map((v) => v.trim())).filter(([key]) => key && key !== startWithKey && key.startsWith(startWithKey)).reduce((ac, [key, value]) => Object.assign(ac, { [key.slice(startWithKey.length + 1)]: value }), {});
|
|
3195
|
+
};
|
|
3196
|
+
function setCookie(name, value, options) {
|
|
3197
|
+
if (typeof document === "undefined") return;
|
|
3198
|
+
let cookieString = `${encodeName(name)}=${encodeValue(value)}`;
|
|
3199
|
+
if (options) {
|
|
3200
|
+
if (options.expires) if (typeof options.expires === "number") {
|
|
3201
|
+
const date = /* @__PURE__ */ new Date();
|
|
3202
|
+
date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1e3);
|
|
3203
|
+
cookieString += `; expires=${date.toUTCString()}`;
|
|
3204
|
+
} else cookieString += `; expires=${options.expires.toUTCString()}`;
|
|
3205
|
+
if (options.path) cookieString += `; path=${options.path}`;
|
|
3206
|
+
if (options.domain) cookieString += `; domain=${options.domain}`;
|
|
3207
|
+
if (options.secure) cookieString += `; secure`;
|
|
3208
|
+
if (options.sameSite) cookieString += `; samesite=${options.sameSite}`;
|
|
3209
|
+
}
|
|
3210
|
+
document.cookie = cookieString;
|
|
3211
|
+
}
|
|
3212
|
+
function deleteCookie(name) {
|
|
3213
|
+
if (typeof document === "undefined") return;
|
|
3214
|
+
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
3215
|
+
}
|
|
3216
|
+
const encodeName = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
|
|
3217
|
+
const encodeValue = (value) => encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
3218
|
+
|
|
3219
|
+
//#endregion
|
|
3220
|
+
//#region src/auth/cookie/index.ts
|
|
3221
|
+
const initVals = getAllCookiesStartWith(GLOBAL_PREFIX);
|
|
3222
|
+
const setStoreCookie = (key, value) => {
|
|
3223
|
+
const expires = /* @__PURE__ */ new Date();
|
|
3224
|
+
expires.setTime(expires.getTime() + 30 * 24 * 60 * 60 * 1e3);
|
|
3225
|
+
const cookieKey = `${GLOBAL_PREFIX}_${key}`;
|
|
3226
|
+
if (!value || value === "") {
|
|
3227
|
+
deleteCookie(cookieKey);
|
|
3228
|
+
return;
|
|
3229
|
+
}
|
|
3230
|
+
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
3231
|
+
setCookie(`${GLOBAL_PREFIX}_${key}`, stringValue, {
|
|
3232
|
+
expires,
|
|
3233
|
+
path: "/",
|
|
3234
|
+
sameSite: "Lax"
|
|
3235
|
+
});
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
//#endregion
|
|
3239
|
+
//#region src/auth/userStore.ts
|
|
3240
|
+
const userPath = GLOBAL_PREFIX + "_user";
|
|
3241
|
+
const parseUser = () => {
|
|
3242
|
+
if (typeof localStorage === "undefined" || !localStorage || typeof localStorage.getItem !== "function") return;
|
|
3243
|
+
const value = localStorage.getItem(userPath);
|
|
3244
|
+
if (value && value != "undefined") try {
|
|
3245
|
+
return JSON.parse(value);
|
|
3246
|
+
} catch (err) {
|
|
3247
|
+
console.warn("Can't parse user data, error: ", err);
|
|
3248
|
+
return;
|
|
3249
|
+
}
|
|
3250
|
+
};
|
|
3251
|
+
const user = atom(parseUser());
|
|
3252
|
+
user.subscribe((value) => {
|
|
3253
|
+
if (typeof localStorage === "undefined" || !localStorage || typeof localStorage.setItem !== "function") return;
|
|
3254
|
+
if (value) localStorage.setItem(userPath, JSON.stringify(value));
|
|
3255
|
+
else localStorage.removeItem(userPath);
|
|
3256
|
+
});
|
|
3257
|
+
|
|
3258
|
+
//#endregion
|
|
3259
|
+
//#region src/auth/utils/jwt.ts
|
|
3260
|
+
/**
|
|
3261
|
+
* Decodes a JWT token and extracts user information
|
|
3262
|
+
* Uses jose library for modern, secure JWT handling
|
|
3263
|
+
* @param token The JWT token to decode
|
|
3264
|
+
* @returns The decoded user data or undefined if decoding fails
|
|
3265
|
+
*/
|
|
3266
|
+
const decodeToken = (token) => {
|
|
3267
|
+
try {
|
|
3268
|
+
const decodedUser = decodeJwt(token);
|
|
3269
|
+
return {
|
|
3270
|
+
id: decodedUser.id,
|
|
3271
|
+
email: decodedUser.email,
|
|
3272
|
+
first_name: decodedUser.first_name,
|
|
3273
|
+
last_name: decodedUser.last_name,
|
|
3274
|
+
username: decodedUser.username,
|
|
3275
|
+
image_url: decodedUser.image_url,
|
|
3276
|
+
language_code: decodedUser.language_code,
|
|
3277
|
+
org_id: decodedUser.org_id
|
|
3278
|
+
};
|
|
3279
|
+
} catch (error) {
|
|
3280
|
+
console.warn("Failed to decode JWT token. Error: ", error);
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
};
|
|
3284
|
+
/**
|
|
3285
|
+
* Decodes a JWT token and sets the user in the store
|
|
3286
|
+
* @param token The JWT token to decode
|
|
3287
|
+
* @returns True if user was successfully decoded and set, false otherwise
|
|
3288
|
+
*/
|
|
3289
|
+
const decodeAndSetUser = (token) => {
|
|
3290
|
+
const userData = decodeToken(token);
|
|
3291
|
+
if (userData) {
|
|
3292
|
+
user.set(userData);
|
|
3293
|
+
return true;
|
|
3294
|
+
}
|
|
3295
|
+
return false;
|
|
3296
|
+
};
|
|
3297
|
+
/**
|
|
3298
|
+
* Checks if a token is expired based on the expiration timestamp
|
|
3299
|
+
* @param expireAt The expiration timestamp in milliseconds
|
|
3300
|
+
* @returns True if the token is expired, false otherwise
|
|
3301
|
+
*/
|
|
3302
|
+
const isTokenExpired = (expireAt) => {
|
|
3303
|
+
if (!expireAt) return true;
|
|
3304
|
+
return Date.now() >= expireAt;
|
|
3305
|
+
};
|
|
3306
|
+
|
|
3307
|
+
//#endregion
|
|
3308
|
+
//#region src/auth/authStore.ts
|
|
3309
|
+
const isLogged = atom(initVals["isLogged"] === "true" || detectProvider() !== void 0);
|
|
3310
|
+
const accessToken = atom(initVals["accessToken"]);
|
|
3311
|
+
const refreshToken = atom(initVals["refreshToken"]);
|
|
3312
|
+
const expireAt = atom(Number(initVals["expireAt"]));
|
|
3313
|
+
const authError = atom(null);
|
|
3314
|
+
const requiresAction = atom(initVals["requiresAction"] || null);
|
|
3315
|
+
const limitedAccessToken = atom(initVals["limitedAccessToken"] || null);
|
|
3316
|
+
let currentTokenPromise = null;
|
|
3317
|
+
const PROVIDER_URL_MAP = {
|
|
3318
|
+
google: googleAuthUrl,
|
|
3319
|
+
apple: appleAuthUrl,
|
|
3320
|
+
microsoft: microsoftAuthUrl,
|
|
3321
|
+
telegram: telegramAuthUrl
|
|
3322
|
+
};
|
|
3323
|
+
const login = async (provider) => {
|
|
3324
|
+
await initDeferred.promise;
|
|
3325
|
+
const authUrlAtom = PROVIDER_URL_MAP[provider];
|
|
3326
|
+
if (!authUrlAtom) throw new Error(`Unsupported provider: ${provider}`);
|
|
3327
|
+
const authUrl = authUrlAtom.get();
|
|
3328
|
+
if (authUrl) window.location.href = authUrl;
|
|
3329
|
+
else throw new Error(`${provider} provider is not configured. Please check your initClient configuration.`);
|
|
3330
|
+
};
|
|
3331
|
+
const refreshAccessToken = async (refresh) => {
|
|
3332
|
+
const result = await refreshTokens("Bearer", refresh);
|
|
3333
|
+
if (!("requires_action" in result)) setTokens(result.access_token, result.refresh_token, result.expires_in);
|
|
3334
|
+
};
|
|
3335
|
+
const ensureValidAccessToken = async (refresh) => {
|
|
3336
|
+
if (accessToken.get() && !isTokenExpired(expireAt.get())) return;
|
|
3337
|
+
try {
|
|
3338
|
+
await refreshAccessToken(refresh);
|
|
3339
|
+
} catch (refreshError) {
|
|
3340
|
+
console.error("Token refresh failed in getToken:", refreshError);
|
|
3341
|
+
removeTokens();
|
|
3342
|
+
throw refreshError;
|
|
3343
|
+
}
|
|
3344
|
+
};
|
|
3345
|
+
const getToken = async () => {
|
|
3346
|
+
if (currentTokenPromise) return currentTokenPromise;
|
|
3347
|
+
currentTokenPromise = (async () => {
|
|
3348
|
+
try {
|
|
3349
|
+
await initDeferred.promise;
|
|
3350
|
+
if (requiresAction.get()) return void 0;
|
|
3351
|
+
const currentRefreshToken = refreshToken.get();
|
|
3352
|
+
if (!currentRefreshToken) return void 0;
|
|
3353
|
+
await ensureValidAccessToken(currentRefreshToken);
|
|
3354
|
+
const token = accessToken.get();
|
|
3355
|
+
if (token) decodeAndSetUser(token);
|
|
3356
|
+
return token;
|
|
3357
|
+
} catch (error) {
|
|
3358
|
+
console.warn("Failed to getToken(). Error: ", error);
|
|
3359
|
+
throw error;
|
|
3360
|
+
} finally {
|
|
3361
|
+
currentTokenPromise = null;
|
|
3362
|
+
}
|
|
3363
|
+
})();
|
|
3364
|
+
return currentTokenPromise;
|
|
3365
|
+
};
|
|
3366
|
+
/**
|
|
3367
|
+
* Sets authentication tokens in the store
|
|
3368
|
+
* @param access The access token
|
|
3369
|
+
* @param refresh The refresh token
|
|
3370
|
+
* @param expiresIn The token expiration time in seconds
|
|
3371
|
+
*/
|
|
3372
|
+
const setTokens = (access, refresh, expiresIn) => {
|
|
3373
|
+
accessToken.set(access);
|
|
3374
|
+
refreshToken.set(refresh);
|
|
3375
|
+
expireAt.set(Date.now() + expiresIn * 1e3);
|
|
3376
|
+
isLogged.set(true);
|
|
3377
|
+
limitedAccessToken.set(null);
|
|
3378
|
+
requiresAction.set(null);
|
|
3379
|
+
authError.set(null);
|
|
3380
|
+
decodeAndSetUser(access);
|
|
3381
|
+
};
|
|
3382
|
+
/**
|
|
3383
|
+
* Removes authentication tokens from the store
|
|
3384
|
+
*/
|
|
3385
|
+
const removeTokens = () => {
|
|
3386
|
+
accessToken.set("");
|
|
3387
|
+
refreshToken.set("");
|
|
3388
|
+
expireAt.set(0);
|
|
3389
|
+
isLogged.set(false);
|
|
3390
|
+
user.set(void 0);
|
|
3391
|
+
limitedAccessToken.set(null);
|
|
3392
|
+
requiresAction.set(null);
|
|
3393
|
+
authError.set(null);
|
|
3394
|
+
};
|
|
3395
|
+
/**
|
|
3396
|
+
* Clears the auth error from the store
|
|
3397
|
+
*/
|
|
3398
|
+
const clearAuthError = () => {
|
|
3399
|
+
authError.set(null);
|
|
3400
|
+
};
|
|
3401
|
+
/**
|
|
3402
|
+
* Sets limited access state for users requiring additional action (e.g., Telegram users without email)
|
|
3403
|
+
* @param token The limited scope access token
|
|
3404
|
+
* @param action The required action (e.g., "add_email")
|
|
3405
|
+
*/
|
|
3406
|
+
const setLimitedAccessState = (token, action) => {
|
|
3407
|
+
limitedAccessToken.set(token);
|
|
3408
|
+
requiresAction.set(action);
|
|
3409
|
+
authError.set(null);
|
|
3410
|
+
isLogged.set(true);
|
|
3411
|
+
};
|
|
3412
|
+
/**
|
|
3413
|
+
* Clears the limited access state (after email verification completes or user logs out)
|
|
3414
|
+
*/
|
|
3415
|
+
const clearLimitedAccessState = () => {
|
|
3416
|
+
limitedAccessToken.set(null);
|
|
3417
|
+
requiresAction.set(null);
|
|
3418
|
+
if (!(!!accessToken.get() && !!refreshToken.get())) isLogged.set(false);
|
|
3419
|
+
};
|
|
3420
|
+
isLogged.subscribe((value) => setStoreCookie("isLogged", value));
|
|
3421
|
+
accessToken.subscribe((value) => setStoreCookie("accessToken", value));
|
|
3422
|
+
refreshToken.subscribe((value) => setStoreCookie("refreshToken", value));
|
|
3423
|
+
expireAt.subscribe((value) => setStoreCookie("expireAt", value));
|
|
3424
|
+
requiresAction.subscribe((value) => setStoreCookie("requiresAction", value));
|
|
3425
|
+
limitedAccessToken.subscribe((value) => setStoreCookie("limitedAccessToken", value));
|
|
3426
|
+
|
|
3427
|
+
//#endregion
|
|
3428
|
+
//#region src/auth/auth/logout.ts
|
|
3429
|
+
const logout = async () => {
|
|
3430
|
+
try {
|
|
3431
|
+
await postAuthV1Logout({ throwOnError: true });
|
|
3432
|
+
} catch {} finally {
|
|
3433
|
+
removeTokens();
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3436
|
+
|
|
3437
|
+
//#endregion
|
|
3438
|
+
//#region src/auth/api/types.ts
|
|
3439
|
+
/**
|
|
3440
|
+
* Generic API error class - wraps ky's HTTPError for consistency
|
|
3441
|
+
*/
|
|
3442
|
+
var ApiError = class extends Error {
|
|
3443
|
+
status;
|
|
3444
|
+
endpoint;
|
|
3445
|
+
data;
|
|
3446
|
+
constructor(message, ...rest) {
|
|
3447
|
+
super(message);
|
|
3448
|
+
this.name = "ApiError";
|
|
3449
|
+
const firstArg = rest[0];
|
|
3450
|
+
if (typeof firstArg === "number") {
|
|
3451
|
+
this.status = firstArg;
|
|
3452
|
+
this.endpoint = rest[1] ?? "";
|
|
3453
|
+
this.data = rest[2];
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
this.status = firstArg.status;
|
|
3457
|
+
this.endpoint = firstArg.endpoint;
|
|
3458
|
+
this.data = firstArg.data;
|
|
3459
|
+
}
|
|
3460
|
+
};
|
|
3461
|
+
|
|
3462
|
+
//#endregion
|
|
3463
|
+
//#region src/auth/api-url.ts
|
|
3464
|
+
/**
|
|
3465
|
+
* Global API base URL store
|
|
3466
|
+
*/
|
|
3467
|
+
const apiURL = atom("");
|
|
3468
|
+
|
|
3469
|
+
//#endregion
|
|
3470
|
+
//#region src/auth/api/sdk-client.ts
|
|
3471
|
+
let configured = false;
|
|
3472
|
+
function configureSdkClient() {
|
|
3473
|
+
if (configured) return;
|
|
3474
|
+
configured = true;
|
|
3475
|
+
client.setConfig({ baseUrl: apiURL.get() });
|
|
3476
|
+
apiURL.subscribe((url) => {
|
|
3477
|
+
client.setConfig({ baseUrl: url });
|
|
3478
|
+
});
|
|
3479
|
+
client.interceptors.request.use(async (request) => {
|
|
3480
|
+
if (request.headers.has("Authorization")) return request;
|
|
3481
|
+
const token = await getToken();
|
|
3482
|
+
if (token) request.headers.set("Authorization", `Bearer ${token}`);
|
|
3483
|
+
return request;
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
//#endregion
|
|
3488
|
+
//#region src/auth/social/socialState.ts
|
|
3489
|
+
const socialStoragePath = (provider) => SOCIAL_CONNECT_KEY_PREFIX + provider;
|
|
3490
|
+
/**
|
|
3491
|
+
* Sets a flag indicating that a social provider connection is being attempted
|
|
3492
|
+
* @param provider The provider identifier
|
|
3493
|
+
*/
|
|
3494
|
+
function setSocialConnectAttempt(provider) {
|
|
3495
|
+
sessionStorage.setItem(socialStoragePath(provider), "true");
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* Checks if there's a pending social provider connection attempt
|
|
3499
|
+
* @param provider The provider identifier
|
|
3500
|
+
* @returns True if there's a pending connection attempt, false otherwise
|
|
3501
|
+
*/
|
|
3502
|
+
function hasSocialConnectAttempt(provider) {
|
|
3503
|
+
return sessionStorage.getItem(socialStoragePath(provider)) === "true";
|
|
3504
|
+
}
|
|
3505
|
+
/**
|
|
3506
|
+
* Clears the social provider connection attempt flag
|
|
3507
|
+
* @param provider The provider identifier
|
|
3508
|
+
*/
|
|
3509
|
+
function clearSocialConnectAttempt(provider) {
|
|
3510
|
+
sessionStorage.removeItem(socialStoragePath(provider));
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
//#endregion
|
|
3514
|
+
//#region src/auth/api/error-handlers.ts
|
|
3515
|
+
/**
|
|
3516
|
+
* Helper to create error functions - reduces bundle size by reusing error creation logic
|
|
3517
|
+
*/
|
|
3518
|
+
const err = (message) => () => new Error(message);
|
|
3519
|
+
/** Reusable error handlers for common cases - reduces repetitive error messages */
|
|
3520
|
+
const commonErrors = {
|
|
3521
|
+
unauthorized: err("User is not authorized"),
|
|
3522
|
+
badRequest: err("Bad request"),
|
|
3523
|
+
notFound: err("Not found"),
|
|
3524
|
+
conflict: err("Resource already exists"),
|
|
3525
|
+
forbidden: err("Forbidden"),
|
|
3526
|
+
tooManyRequests: err("Too many requests")
|
|
3527
|
+
};
|
|
3528
|
+
/**
|
|
3529
|
+
* Standard error handler for API errors with custom status code handling
|
|
3530
|
+
*/
|
|
3531
|
+
const handleApiError = (error, statusHandlers) => {
|
|
3532
|
+
if (error instanceof ApiError) {
|
|
3533
|
+
const handler = statusHandlers[error.status];
|
|
3534
|
+
if (handler) throw new ApiError(handler().message, error.status, error.endpoint, error.data);
|
|
3535
|
+
throw error;
|
|
3536
|
+
}
|
|
3537
|
+
throw error;
|
|
3538
|
+
};
|
|
3539
|
+
|
|
3540
|
+
//#endregion
|
|
3541
|
+
//#region src/auth/api/utils.ts
|
|
3542
|
+
/**
|
|
3543
|
+
* Generic helper for API calls to handle initialization and error handling
|
|
3544
|
+
* @param fn The async function to execute
|
|
3545
|
+
* @param errorMap A map of status codes to error functions
|
|
3546
|
+
* @returns The result of the function execution
|
|
3547
|
+
*/
|
|
3548
|
+
const apiCall = async (fn, errorMap = {}) => {
|
|
3549
|
+
await initDeferred.promise;
|
|
3550
|
+
try {
|
|
3551
|
+
return await fn();
|
|
3552
|
+
} catch (error) {
|
|
3553
|
+
return handleApiError(error, errorMap);
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
|
|
3557
|
+
//#endregion
|
|
3558
|
+
//#region src/auth/validation/base.ts
|
|
3559
|
+
/**
|
|
3560
|
+
* 🛡️ INPUT VALIDATION UTILITY
|
|
3561
|
+
* Validates data before API calls and throws user-friendly errors
|
|
3562
|
+
*/
|
|
3563
|
+
const validateInput = (schema, data) => {
|
|
3564
|
+
try {
|
|
3565
|
+
return v.parse(schema, data);
|
|
3566
|
+
} catch (error) {
|
|
3567
|
+
if (error instanceof v.ValiError) {
|
|
3568
|
+
const firstError = error.issues[0];
|
|
3569
|
+
throw new Error(firstError.message);
|
|
3570
|
+
}
|
|
3571
|
+
throw error;
|
|
3572
|
+
}
|
|
3573
|
+
};
|
|
3574
|
+
const EmailSchema = v.pipe(v.string("Email must be text"), v.email("Please enter a valid email address"), v.minLength(1, "Email is required"));
|
|
3575
|
+
const PasswordSchema = v.pipe(v.string("Password must be text"), v.minLength(8, "Password must be at least 8 characters long"), v.regex(/[A-Z]/, "Password must contain at least one uppercase letter"), v.regex(/[a-z]/, "Password must contain at least one lowercase letter"), v.regex(/[0-9]/, "Password must contain at least one number"));
|
|
3576
|
+
/**
|
|
3577
|
+
* Username validation schema
|
|
3578
|
+
* - Must be 4-24 characters
|
|
3579
|
+
* - Only letters, numbers, underscores, and periods
|
|
3580
|
+
*/
|
|
3581
|
+
const UsernameSchema = v.pipe(v.string("Username must be text"), v.minLength(4, "Username must be 4-24 characters long"), v.maxLength(24, "Username must be 4-24 characters long"), v.regex(/^[a-z0-9_.]+$/, "Username can only contain lowercase letters, numbers, dots and underscores"));
|
|
3582
|
+
/**
|
|
3583
|
+
* Name validation schema
|
|
3584
|
+
* - Must be 1-30 characters
|
|
3585
|
+
*/
|
|
3586
|
+
const NameSchema = v.pipe(v.string("Name must be text"), v.minLength(1, "Name must be 1-30 characters long"), v.maxLength(30, "Name must be 1-30 characters long"));
|
|
3587
|
+
/**
|
|
3588
|
+
* Domain validation schema
|
|
3589
|
+
* - Must be lowercase
|
|
3590
|
+
* - Must contain at least one dot
|
|
3591
|
+
* - Only alphanumeric characters, hyphens, and dots
|
|
3592
|
+
* - Cannot start or end with hyphen in any part
|
|
3593
|
+
*/
|
|
3594
|
+
const DomainSchema = v.pipe(v.string("Domain must be text"), v.trim(), v.toLowerCase(), v.minLength(1, "Domain is required"), v.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/, "Invalid domain format. Please enter a valid domain like company.com"));
|
|
3595
|
+
|
|
3596
|
+
//#endregion
|
|
3597
|
+
//#region src/auth/validation/auth.ts
|
|
3598
|
+
const EmailAuthRequestSchema = v.object({
|
|
3599
|
+
email: EmailSchema,
|
|
3600
|
+
password: PasswordSchema,
|
|
3601
|
+
subscribe_to_blog: v.optional(v.boolean())
|
|
3602
|
+
});
|
|
3603
|
+
const ResetPasswordRequestSchema = v.object({
|
|
3604
|
+
token: v.string(),
|
|
3605
|
+
new_password: PasswordSchema
|
|
3606
|
+
});
|
|
3607
|
+
const LoginOTPVerifyRequestSchema = v.object({
|
|
3608
|
+
code: v.pipe(v.string("OTP code must be text"), v.maxLength(8, "OTP code must be at most 6 characters"), v.regex(/^\d+$/, "OTP code must contain only numbers")),
|
|
3609
|
+
session_id: v.pipe(v.string("Session ID must be text"), v.minLength(1, "Session ID is required"))
|
|
3610
|
+
});
|
|
3611
|
+
const ResendEmailRequestSchema = v.object({ email: EmailSchema });
|
|
3612
|
+
const ChangeEmailRequestSchema = v.object({ new_email: EmailSchema });
|
|
3613
|
+
const verifyEmailChangeRequestSchema = v.object({
|
|
3614
|
+
code: v.pipe(v.string("OTP code must be text"), v.minLength(6, "OTP code must be at least 6 characters"), v.maxLength(8, "OTP code must be at most 8 characters"), v.regex(/^\d+$/, "OTP code must contain only numbers")),
|
|
3615
|
+
new_email: v.optional(EmailSchema),
|
|
3616
|
+
type: v.union([v.literal("verification"), v.literal("email_change")]),
|
|
3617
|
+
verification_id: v.string("Verification ID is required")
|
|
3618
|
+
});
|
|
3619
|
+
/**
|
|
3620
|
+
* Social provider schemas
|
|
3621
|
+
*/
|
|
3622
|
+
const ConnectProviderSchema = v.object({
|
|
3623
|
+
provider: v.pipe(v.string("Provider must be text"), v.minLength(1, "Provider is required")),
|
|
3624
|
+
token: v.pipe(v.string("Token must be text"), v.minLength(1, "Token is required"))
|
|
3625
|
+
});
|
|
3626
|
+
/**
|
|
3627
|
+
* OTP verification schema (for user OTP operations)
|
|
3628
|
+
*/
|
|
3629
|
+
const VerifyOTPCodeSchema = v.object({ code: v.pipe(v.string("OTP code must be text"), v.minLength(6, "OTP code must be at least 6 characters"), v.regex(/^\d+$/, "OTP code must contain only numbers")) });
|
|
3630
|
+
|
|
3631
|
+
//#endregion
|
|
3632
|
+
//#region src/auth/social/socialConnections.ts
|
|
3633
|
+
const listSocials = async () => {
|
|
3634
|
+
return apiCall(async () => {
|
|
3635
|
+
const { data } = await getAuthV1Providers({ throwOnError: true });
|
|
3636
|
+
return data.providers ?? [];
|
|
3637
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to list providers!") });
|
|
3638
|
+
};
|
|
3639
|
+
const connectSocialInternal = async (provider, token) => {
|
|
3640
|
+
return apiCall(async () => {
|
|
3641
|
+
const { data } = await postAuthV1ProvidersConnect({
|
|
3642
|
+
body: validateInput(ConnectProviderSchema, {
|
|
3643
|
+
provider,
|
|
3644
|
+
token
|
|
3645
|
+
}),
|
|
3646
|
+
throwOnError: true
|
|
3647
|
+
});
|
|
3648
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
3649
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to connect provider!") });
|
|
3650
|
+
};
|
|
3651
|
+
const disconnectSocial = async (providerId) => {
|
|
3652
|
+
return apiCall(async () => {
|
|
3653
|
+
await deleteAuthV1ProvidersByProvider({
|
|
3654
|
+
path: { provider: providerId },
|
|
3655
|
+
throwOnError: true
|
|
3656
|
+
});
|
|
3657
|
+
}, {
|
|
3658
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to disconnect provider!"),
|
|
3659
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Provider not found!"),
|
|
3660
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Cannot disconnect the last social provider!")
|
|
3661
|
+
});
|
|
3662
|
+
};
|
|
3663
|
+
const connectSocial = (provider) => {
|
|
3664
|
+
setSocialConnectAttempt(provider);
|
|
3665
|
+
login(provider);
|
|
3666
|
+
};
|
|
3667
|
+
|
|
3668
|
+
//#endregion
|
|
3669
|
+
//#region src/auth/api/client-core.ts
|
|
3670
|
+
let tokenRefreshFunction = null;
|
|
3671
|
+
/**
|
|
3672
|
+
* Sets the token refresh function used by the API client
|
|
3673
|
+
* This should be called during initialization
|
|
3674
|
+
*/
|
|
3675
|
+
const setTokenRefreshFunction = (fn) => {
|
|
3676
|
+
tokenRefreshFunction = fn ?? null;
|
|
3677
|
+
};
|
|
3678
|
+
|
|
3679
|
+
//#endregion
|
|
3680
|
+
//#region src/auth/authConfig.ts
|
|
3681
|
+
let loginRedirectUrl;
|
|
3682
|
+
const setLoginRedirectUrl = (url) => {
|
|
3683
|
+
loginRedirectUrl = url;
|
|
3684
|
+
};
|
|
3685
|
+
|
|
3686
|
+
//#endregion
|
|
3687
|
+
//#region src/auth/init.ts
|
|
3688
|
+
var init_exports = /* @__PURE__ */ __exportAll({ initClient: () => initClient });
|
|
3689
|
+
/**
|
|
3690
|
+
* Initializes the authentication client with the provided configuration
|
|
3691
|
+
* @param config The authentication client configuration
|
|
3692
|
+
* @returns A promise that resolves to the current access token (if available)
|
|
3693
|
+
*/
|
|
3694
|
+
const initClient = async (config) => {
|
|
3695
|
+
await initConfig(config);
|
|
3696
|
+
await initPage();
|
|
3697
|
+
initDeferred.resolve();
|
|
3698
|
+
await initSocials();
|
|
3699
|
+
return getToken();
|
|
3700
|
+
};
|
|
3701
|
+
const initConfig = async (config) => {
|
|
3702
|
+
apiURL.set(config.apiUrl);
|
|
3703
|
+
configureSdkClient();
|
|
3704
|
+
setLoginRedirectUrl(config.loginRedirectUrl);
|
|
3705
|
+
setTokenRefreshFunction(async () => {
|
|
3706
|
+
const currentRefreshToken = refreshToken.get();
|
|
3707
|
+
if (currentRefreshToken) {
|
|
3708
|
+
const { AuthProvider } = await import("./providers-Cu3u1p1O.js").then((n) => n.t);
|
|
3709
|
+
const result = await refreshTokens(AuthProvider.BEARER, currentRefreshToken);
|
|
3710
|
+
if (result && !("requires_action" in result)) setTokens(result.access_token, result.refresh_token, result.expires_in);
|
|
3711
|
+
return getToken();
|
|
3712
|
+
}
|
|
3713
|
+
});
|
|
3714
|
+
if (config.googleProvider) {
|
|
3715
|
+
googleConfig.set(config.googleProvider);
|
|
3716
|
+
updateGoogleAuthUrl();
|
|
3717
|
+
}
|
|
3718
|
+
if (config.appleProvider) {
|
|
3719
|
+
appleConfig.set(config.appleProvider);
|
|
3720
|
+
updateAppleAuthUrl();
|
|
3721
|
+
}
|
|
3722
|
+
if (config.microsoftProvider) {
|
|
3723
|
+
microsoftConfig.set(config.microsoftProvider);
|
|
3724
|
+
updateMicrosoftAuthUrl();
|
|
3725
|
+
}
|
|
3726
|
+
if (config.telegramProvider) {
|
|
3727
|
+
telegramConfig.set(config.telegramProvider);
|
|
3728
|
+
updateTelegramAuthUrl();
|
|
3729
|
+
}
|
|
3730
|
+
};
|
|
3731
|
+
const isLimitedScopeTokenResponse = (result) => {
|
|
3732
|
+
return "requires_action" in result;
|
|
3733
|
+
};
|
|
3734
|
+
const applyTokenExchangeResult = (result) => {
|
|
3735
|
+
if (isLimitedScopeTokenResponse(result)) {
|
|
3736
|
+
setLimitedAccessState(result.access_token, result.requires_action);
|
|
3737
|
+
return;
|
|
3738
|
+
}
|
|
3739
|
+
const fullResult = result;
|
|
3740
|
+
setTokens(fullResult.access_token, fullResult.refresh_token, fullResult.expires_in);
|
|
3741
|
+
};
|
|
3742
|
+
const setAuthErrorAndClear = (error_code, message, email) => {
|
|
3743
|
+
clearLimitedAccessState();
|
|
3744
|
+
authError.set({
|
|
3745
|
+
error_code,
|
|
3746
|
+
message,
|
|
3747
|
+
email
|
|
3748
|
+
});
|
|
3749
|
+
return true;
|
|
3750
|
+
};
|
|
3751
|
+
const extractAuthErrorInfo = (error) => {
|
|
3752
|
+
const data = error.data;
|
|
3753
|
+
return {
|
|
3754
|
+
error: data?.error ?? "",
|
|
3755
|
+
description: data?.error_description ?? error.message ?? "",
|
|
3756
|
+
email: data?.email ?? ""
|
|
3757
|
+
};
|
|
3758
|
+
};
|
|
3759
|
+
const handleInitPageApiError = (error) => {
|
|
3760
|
+
const info = extractAuthErrorInfo(error);
|
|
3761
|
+
if (error.status === HTTP_STATUS.BAD_REQUEST && info.error === "invalid_grant") return setAuthErrorAndClear("email_not_verified", info.description, info.email);
|
|
3762
|
+
if (error.status === HTTP_STATUS.CONFLICT) return setAuthErrorAndClear("provider_conflict", info.description, info.email);
|
|
3763
|
+
return false;
|
|
3764
|
+
};
|
|
3765
|
+
const exchangeProviderToken = async (provider, token) => {
|
|
3766
|
+
const result = await refreshTokens(provider, token);
|
|
3767
|
+
applyTokenExchangeResult(result);
|
|
3768
|
+
};
|
|
3769
|
+
const initPage = async () => {
|
|
3770
|
+
const provider = detectProvider();
|
|
3771
|
+
if (!provider) return void 0;
|
|
3772
|
+
const token = getProviderToken(provider);
|
|
3773
|
+
if (!token) return void 0;
|
|
3774
|
+
if (refreshToken.get()) return void 0;
|
|
3775
|
+
try {
|
|
3776
|
+
await exchangeProviderToken(provider, token);
|
|
3777
|
+
} catch (error) {
|
|
3778
|
+
if (error instanceof ApiError && handleInitPageApiError(error)) return;
|
|
3779
|
+
throw error;
|
|
3780
|
+
}
|
|
3781
|
+
};
|
|
3782
|
+
const initSocials = async () => {
|
|
3783
|
+
const provider = detectProvider();
|
|
3784
|
+
if (!provider) return void 0;
|
|
3785
|
+
const token = getProviderToken(provider);
|
|
3786
|
+
if (!token) return void 0;
|
|
3787
|
+
try {
|
|
3788
|
+
if (hasSocialConnectAttempt(provider)) await connectSocialInternal(provider, token);
|
|
3789
|
+
} finally {
|
|
3790
|
+
clearSocialConnectAttempt(provider);
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
|
|
3794
|
+
//#endregion
|
|
3795
|
+
//#region src/auth/membership/types.ts
|
|
3796
|
+
let MembershipRole = /* @__PURE__ */ function(MembershipRole) {
|
|
3797
|
+
MembershipRole["OWNER"] = "owner";
|
|
3798
|
+
MembershipRole["ADMIN"] = "admin";
|
|
3799
|
+
MembershipRole["MEMBER"] = "member";
|
|
3800
|
+
return MembershipRole;
|
|
3801
|
+
}({});
|
|
3802
|
+
let MembershipState = /* @__PURE__ */ function(MembershipState) {
|
|
3803
|
+
MembershipState["ACCEPTED"] = "accepted";
|
|
3804
|
+
MembershipState["PENDING"] = "pending";
|
|
3805
|
+
MembershipState["DECLINED"] = "declined";
|
|
3806
|
+
MembershipState["ACCEPT"] = "accept";
|
|
3807
|
+
MembershipState["DECLINE"] = "decline";
|
|
3808
|
+
return MembershipState;
|
|
3809
|
+
}({});
|
|
3810
|
+
|
|
3811
|
+
//#endregion
|
|
3812
|
+
//#region src/auth/membership/list.ts
|
|
3813
|
+
const listActiveMemberships = async (paginationParams) => {
|
|
3814
|
+
return apiCall(async () => {
|
|
3815
|
+
const { data } = await getAuthV1MembershipsActive({
|
|
3816
|
+
query: paginationParams,
|
|
3817
|
+
throwOnError: true
|
|
3818
|
+
});
|
|
3819
|
+
return data.memberships || [];
|
|
3820
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to list memberships!") });
|
|
3821
|
+
};
|
|
3822
|
+
const listPendingMemberships = async (paginationParams) => {
|
|
3823
|
+
return apiCall(async () => {
|
|
3824
|
+
const { data } = await getAuthV1MembershipsPending({
|
|
3825
|
+
query: paginationParams,
|
|
3826
|
+
throwOnError: true
|
|
3827
|
+
});
|
|
3828
|
+
return data.memberships || [];
|
|
3829
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to list memberships!") });
|
|
3830
|
+
};
|
|
3831
|
+
const listOrganizationMembers = async (orgId, paginationParams) => {
|
|
3832
|
+
return apiCall(async () => {
|
|
3833
|
+
const { data } = await getAuthV1MembershipsByOrgIdMembers({
|
|
3834
|
+
path: { orgId },
|
|
3835
|
+
query: paginationParams,
|
|
3836
|
+
throwOnError: true
|
|
3837
|
+
});
|
|
3838
|
+
return data.members || [];
|
|
3839
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to list organization members!") });
|
|
3840
|
+
};
|
|
3841
|
+
|
|
3842
|
+
//#endregion
|
|
3843
|
+
//#region src/auth/validation/membership.ts
|
|
3844
|
+
/**
|
|
3845
|
+
* Membership state schemas
|
|
3846
|
+
*/
|
|
3847
|
+
const AcceptDeclineMembershipSchema = v.object({ state: v.union([v.literal("accepted"), v.literal("declined")]) });
|
|
3848
|
+
const PublicInviteResponseSchema = v.object({ state: v.union([v.literal("accept"), v.literal("decline")]) });
|
|
3849
|
+
/**
|
|
3850
|
+
* Membership management schemas
|
|
3851
|
+
*/
|
|
3852
|
+
const InviteMemberSchema = v.object({
|
|
3853
|
+
username: UsernameSchema,
|
|
3854
|
+
role: v.union([v.literal("admin"), v.literal("member")])
|
|
3855
|
+
});
|
|
3856
|
+
const UpdateMemberRoleSchema = v.object({ role: v.union([v.literal("admin"), v.literal("member")]) });
|
|
3857
|
+
const ResendInviteSchema = v.object({ user_id: v.pipe(v.string("User ID must be text"), v.minLength(1, "User ID is required")) });
|
|
3858
|
+
|
|
3859
|
+
//#endregion
|
|
3860
|
+
//#region src/auth/membership/invite.ts
|
|
3861
|
+
const inviteMember = async (orgId, username, role) => {
|
|
3862
|
+
return apiCall(async () => {
|
|
3863
|
+
const requestBody = validateInput(InviteMemberSchema, {
|
|
3864
|
+
username,
|
|
3865
|
+
role
|
|
3866
|
+
});
|
|
3867
|
+
await postAuthV1MembershipsByOrgIdMembersInvite({
|
|
3868
|
+
path: { orgId },
|
|
3869
|
+
body: requestBody,
|
|
3870
|
+
throwOnError: true
|
|
3871
|
+
});
|
|
3872
|
+
}, {
|
|
3873
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to invite members!"),
|
|
3874
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error(`User with username ${username} not found!`),
|
|
3875
|
+
[HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error(`User with username ${username} already exists!`)
|
|
3876
|
+
});
|
|
3877
|
+
};
|
|
3878
|
+
const resendMemberInvite = async (orgId, userId) => {
|
|
3879
|
+
return apiCall(async () => {
|
|
3880
|
+
const requestBody = validateInput(ResendInviteSchema, { user_id: userId });
|
|
3881
|
+
await postAuthV1MembershipsByOrgIdMembersInviteResend({
|
|
3882
|
+
path: { orgId },
|
|
3883
|
+
body: requestBody,
|
|
3884
|
+
throwOnError: true
|
|
3885
|
+
});
|
|
3886
|
+
}, {
|
|
3887
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to invite members!"),
|
|
3888
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error(`User with ID ${userId} not found!`),
|
|
3889
|
+
[HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error(`User with ID ${userId} already exists!`)
|
|
3890
|
+
});
|
|
3891
|
+
};
|
|
3892
|
+
const respondToInvitation = async (orgId, state) => {
|
|
3893
|
+
return apiCall(async () => {
|
|
3894
|
+
const requestBody = validateInput(AcceptDeclineMembershipSchema, { state });
|
|
3895
|
+
await putAuthV1MembershipsByOrgIdMembershipState({
|
|
3896
|
+
path: { orgId },
|
|
3897
|
+
body: requestBody,
|
|
3898
|
+
throwOnError: true
|
|
3899
|
+
});
|
|
3900
|
+
}, {
|
|
3901
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to accept/decline an Invite!"),
|
|
3902
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Invite not found!")
|
|
3903
|
+
});
|
|
3904
|
+
};
|
|
3905
|
+
const publicRespondToInvitation = async (token, state) => {
|
|
3906
|
+
return apiCall(async () => {
|
|
3907
|
+
validateInput(PublicInviteResponseSchema, { state });
|
|
3908
|
+
if (state === "accept") await postAuthV1InvitationsByTokenAccept({
|
|
3909
|
+
path: { token },
|
|
3910
|
+
throwOnError: true
|
|
3911
|
+
});
|
|
3912
|
+
else await postAuthV1InvitationsByTokenDecline({
|
|
3913
|
+
path: { token },
|
|
3914
|
+
throwOnError: true
|
|
3915
|
+
});
|
|
3916
|
+
}, { [HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid invitation token!") });
|
|
3917
|
+
};
|
|
3918
|
+
|
|
3919
|
+
//#endregion
|
|
3920
|
+
//#region src/auth/membership/manage.ts
|
|
3921
|
+
const updateActiveMembership = async (orgId) => {
|
|
3922
|
+
return apiCall(async () => {
|
|
3923
|
+
await putAuthV1MembershipsByOrgIdActive({
|
|
3924
|
+
path: { orgId },
|
|
3925
|
+
throwOnError: true
|
|
3926
|
+
});
|
|
3927
|
+
accessToken.set(void 0);
|
|
3928
|
+
expireAt.set(0);
|
|
3929
|
+
await getToken();
|
|
3930
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to update active membership!") });
|
|
3931
|
+
};
|
|
3932
|
+
const updateMemberRole = async (orgId, userId, role) => {
|
|
3933
|
+
return apiCall(async () => {
|
|
3934
|
+
const requestBody = validateInput(UpdateMemberRoleSchema, { role });
|
|
3935
|
+
await putAuthV1MembershipsByOrgIdMembersByUserIdRole({
|
|
3936
|
+
path: {
|
|
3937
|
+
orgId,
|
|
3938
|
+
userId
|
|
3939
|
+
},
|
|
3940
|
+
body: requestBody,
|
|
3941
|
+
throwOnError: true
|
|
3942
|
+
});
|
|
3943
|
+
}, {
|
|
3944
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to update member roles!"),
|
|
3945
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Member not found!"),
|
|
3946
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Cannot change role of organization owner!")
|
|
3947
|
+
});
|
|
3948
|
+
};
|
|
3949
|
+
const deleteMember = async (orgId, userId) => {
|
|
3950
|
+
return apiCall(async () => {
|
|
3951
|
+
await deleteAuthV1MembershipsByOrgIdMembersByUserId({
|
|
3952
|
+
path: {
|
|
3953
|
+
orgId,
|
|
3954
|
+
userId
|
|
3955
|
+
},
|
|
3956
|
+
throwOnError: true
|
|
3957
|
+
});
|
|
3958
|
+
}, {
|
|
3959
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to delete members!"),
|
|
3960
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Member not found!"),
|
|
3961
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Cannot remove organization owner!")
|
|
3962
|
+
});
|
|
3963
|
+
};
|
|
3964
|
+
const leaveOrganization = async (orgId) => {
|
|
3965
|
+
return apiCall(async () => {
|
|
3966
|
+
await deleteAuthV1MembershipsByOrgIdLeave({
|
|
3967
|
+
path: { orgId },
|
|
3968
|
+
throwOnError: true
|
|
3969
|
+
});
|
|
3970
|
+
}, {
|
|
3971
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to leave an organization!"),
|
|
3972
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Cannot leave organization as you are the last member!"),
|
|
3973
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Organization not found!")
|
|
3974
|
+
});
|
|
3975
|
+
};
|
|
3976
|
+
|
|
3977
|
+
//#endregion
|
|
3978
|
+
//#region src/auth/validation/user.ts
|
|
3979
|
+
/**
|
|
3980
|
+
* Update username request schema
|
|
3981
|
+
*/
|
|
3982
|
+
const UpdateUsernameSchema = v.object({ username: UsernameSchema });
|
|
3983
|
+
/**
|
|
3984
|
+
* Update name request schema
|
|
3985
|
+
*/
|
|
3986
|
+
const UpdateNameSchema = v.object({ full_name: NameSchema });
|
|
3987
|
+
|
|
3988
|
+
//#endregion
|
|
3989
|
+
//#region src/auth/user.ts
|
|
3990
|
+
const updateFullName = async (fullName) => {
|
|
3991
|
+
return apiCall(async () => {
|
|
3992
|
+
await patchAuthV1UsersCurrentName({
|
|
3993
|
+
body: validateInput(UpdateNameSchema, { full_name: fullName }),
|
|
3994
|
+
throwOnError: true
|
|
3995
|
+
});
|
|
3996
|
+
}, {
|
|
3997
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid name format"),
|
|
3998
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to update name"),
|
|
3999
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Name can only be changed once every 7 days.")
|
|
4000
|
+
});
|
|
4001
|
+
};
|
|
4002
|
+
const updateUsername = async (username) => {
|
|
4003
|
+
return apiCall(async () => {
|
|
4004
|
+
await patchAuthV1UsersCurrentUsername({
|
|
4005
|
+
body: validateInput(UpdateUsernameSchema, { username }),
|
|
4006
|
+
throwOnError: true
|
|
4007
|
+
});
|
|
4008
|
+
}, {
|
|
4009
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid username format"),
|
|
4010
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to update username"),
|
|
4011
|
+
[HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error("Username is not unique. Choose another one!"),
|
|
4012
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Username can only be changed once every 30 days.")
|
|
4013
|
+
});
|
|
4014
|
+
};
|
|
4015
|
+
const getOTPStatus = async () => {
|
|
4016
|
+
return apiCall(async () => {
|
|
4017
|
+
const { data } = await getAuthV1UsersCurrentTotpStatus({ throwOnError: true });
|
|
4018
|
+
return {
|
|
4019
|
+
is_setup: data.is_setup ?? false,
|
|
4020
|
+
created_at: data.created_at,
|
|
4021
|
+
message: data.message
|
|
4022
|
+
};
|
|
4023
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.") });
|
|
4024
|
+
};
|
|
4025
|
+
const setupUserOTP = async () => {
|
|
4026
|
+
return apiCall(async () => {
|
|
4027
|
+
const { data } = await postAuthV1UsersCurrentTotpSetup({ throwOnError: true });
|
|
4028
|
+
return {
|
|
4029
|
+
qrCodeUrl: data.qr_code_url || "",
|
|
4030
|
+
secret: data.secret || ""
|
|
4031
|
+
};
|
|
4032
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.") });
|
|
4033
|
+
};
|
|
4034
|
+
const verifyUserOTP = async (code) => {
|
|
4035
|
+
return apiCall(async () => {
|
|
4036
|
+
const { data } = await postAuthV1UsersCurrentTotpVerify({
|
|
4037
|
+
body: validateInput(VerifyOTPCodeSchema, { code }),
|
|
4038
|
+
throwOnError: true
|
|
4039
|
+
});
|
|
4040
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
4041
|
+
}, {
|
|
4042
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid request format"),
|
|
4043
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.")
|
|
4044
|
+
});
|
|
4045
|
+
};
|
|
4046
|
+
const deleteUserOTP = async () => {
|
|
4047
|
+
return apiCall(async () => {
|
|
4048
|
+
await deleteAuthV1UsersCurrentTotpDelete({ throwOnError: true });
|
|
4049
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.") });
|
|
4050
|
+
};
|
|
4051
|
+
|
|
4052
|
+
//#endregion
|
|
4053
|
+
//#region src/auth/organization.ts
|
|
4054
|
+
const updateOrgName = async (fullName, orgId) => {
|
|
4055
|
+
return apiCall(async () => {
|
|
4056
|
+
const requestBody = validateInput(UpdateNameSchema, { full_name: fullName });
|
|
4057
|
+
await putAuthV1MembershipsByOrgIdName({
|
|
4058
|
+
path: { orgId },
|
|
4059
|
+
body: requestBody,
|
|
4060
|
+
throwOnError: true
|
|
4061
|
+
});
|
|
4062
|
+
}, {
|
|
4063
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Only owners and admins can update name"),
|
|
4064
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Name can only be changed once every 7 days.")
|
|
4065
|
+
});
|
|
4066
|
+
};
|
|
4067
|
+
const updateOrgUsername = async (username, orgId) => {
|
|
4068
|
+
return apiCall(async () => {
|
|
4069
|
+
const requestBody = validateInput(UpdateUsernameSchema, { username });
|
|
4070
|
+
await putAuthV1MembershipsByOrgIdUsername({
|
|
4071
|
+
path: { orgId },
|
|
4072
|
+
body: requestBody,
|
|
4073
|
+
throwOnError: true
|
|
4074
|
+
});
|
|
4075
|
+
}, {
|
|
4076
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Only owners and admins can update username"),
|
|
4077
|
+
[HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error("Username is not unique. Choose another one!"),
|
|
4078
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Username can only be changed once every 30 days.")
|
|
4079
|
+
});
|
|
4080
|
+
};
|
|
4081
|
+
|
|
4082
|
+
//#endregion
|
|
4083
|
+
//#region src/auth/auth/login.ts
|
|
4084
|
+
const loginWithEmail = async (email, password) => {
|
|
4085
|
+
return apiCall(async () => {
|
|
4086
|
+
const validatedInput = validateInput(EmailAuthRequestSchema, {
|
|
4087
|
+
email,
|
|
4088
|
+
password
|
|
4089
|
+
});
|
|
4090
|
+
try {
|
|
4091
|
+
const { data } = await postAuthV1Login({
|
|
4092
|
+
body: validatedInput,
|
|
4093
|
+
throwOnError: true
|
|
4094
|
+
});
|
|
4095
|
+
return handleLoginResponse(data, email);
|
|
4096
|
+
} catch (error) {
|
|
4097
|
+
return handleLoginError(error, email);
|
|
4098
|
+
}
|
|
4099
|
+
}, {
|
|
4100
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Incorrect email or password"),
|
|
4101
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Account access is restricted")
|
|
4102
|
+
});
|
|
4103
|
+
};
|
|
4104
|
+
const verifyTOTPForLogin = async (code, session_id) => {
|
|
4105
|
+
return apiCall(async () => {
|
|
4106
|
+
const { data } = await postAuthV1VerifyTotp({
|
|
4107
|
+
body: validateInput(LoginOTPVerifyRequestSchema, {
|
|
4108
|
+
code,
|
|
4109
|
+
session_id
|
|
4110
|
+
}),
|
|
4111
|
+
throwOnError: true
|
|
4112
|
+
});
|
|
4113
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
4114
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Invalid or expired TOTP code") });
|
|
4115
|
+
};
|
|
4116
|
+
function handleLoginResponse(data, email) {
|
|
4117
|
+
switch (data.status) {
|
|
4118
|
+
case "ok":
|
|
4119
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
4120
|
+
return;
|
|
4121
|
+
case "2fa_required": {
|
|
4122
|
+
const response = data;
|
|
4123
|
+
return {
|
|
4124
|
+
session_id: response.session_id,
|
|
4125
|
+
email,
|
|
4126
|
+
authentication: response.authentication,
|
|
4127
|
+
passkey_options: response.passkey_options
|
|
4128
|
+
};
|
|
4129
|
+
}
|
|
4130
|
+
case "otp_required": return {
|
|
4131
|
+
session_id: data.session_id,
|
|
4132
|
+
email,
|
|
4133
|
+
authentication: ["totp"]
|
|
4134
|
+
};
|
|
4135
|
+
case "email_not_verified": return {
|
|
4136
|
+
error_code: "email_not_verified",
|
|
4137
|
+
message: "Email not verified",
|
|
4138
|
+
email: data.email || email
|
|
4139
|
+
};
|
|
4140
|
+
default: return;
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
function handleLoginError(error, email) {
|
|
4144
|
+
if (isApiErrorBody(error)) {
|
|
4145
|
+
if (error.error === "email_not_verified") return {
|
|
4146
|
+
error_code: "email_not_verified",
|
|
4147
|
+
message: error.details || "Email not verified",
|
|
4148
|
+
email
|
|
4149
|
+
};
|
|
4150
|
+
if (error.error === "provider_conflict") return {
|
|
4151
|
+
error_code: "provider_conflict",
|
|
4152
|
+
message: error.details || "Email registered with different provider",
|
|
4153
|
+
email
|
|
4154
|
+
};
|
|
4155
|
+
throw new ApiError(error.error || "Login failed", error.code || 500, "/auth/v1/login", error);
|
|
4156
|
+
}
|
|
4157
|
+
throw error;
|
|
4158
|
+
}
|
|
4159
|
+
function isApiErrorBody(error) {
|
|
4160
|
+
return typeof error === "object" && error !== null && "error" in error;
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
//#endregion
|
|
4164
|
+
//#region src/auth/auth/register.ts
|
|
4165
|
+
const registerWithEmail = async (email, password, subscribeToBlog) => {
|
|
4166
|
+
return apiCall(async () => {
|
|
4167
|
+
const { data } = await postAuthV1Register({
|
|
4168
|
+
body: validateInput(EmailAuthRequestSchema, {
|
|
4169
|
+
email,
|
|
4170
|
+
password,
|
|
4171
|
+
subscribe_to_blog: subscribeToBlog
|
|
4172
|
+
}),
|
|
4173
|
+
throwOnError: true
|
|
4174
|
+
});
|
|
4175
|
+
if (data.verification_id) return {
|
|
4176
|
+
message: data.message || "Registration successful",
|
|
4177
|
+
verification_id: data.verification_id,
|
|
4178
|
+
email_verification_sent: data.email_verification_sent,
|
|
4179
|
+
user_id: data.user_id
|
|
4180
|
+
};
|
|
4181
|
+
}, { [HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error("Email address is already registered") });
|
|
4182
|
+
};
|
|
4183
|
+
const resendEmailVerificationCode = async (email) => {
|
|
4184
|
+
return apiCall(async () => {
|
|
4185
|
+
const { data } = await postAuthV1EmailVerifyResend({
|
|
4186
|
+
body: validateInput(ResendEmailRequestSchema, { email }),
|
|
4187
|
+
throwOnError: true
|
|
4188
|
+
});
|
|
4189
|
+
if (data.verification_id) return {
|
|
4190
|
+
message: data.message || "Verification code resent",
|
|
4191
|
+
verification_id: data.verification_id,
|
|
4192
|
+
code_sent: data.code_sent
|
|
4193
|
+
};
|
|
4194
|
+
}, {
|
|
4195
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid email or validation error"),
|
|
4196
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Too many requests - rate limit exceeded")
|
|
4197
|
+
});
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
//#endregion
|
|
4201
|
+
//#region src/auth/auth/password.ts
|
|
4202
|
+
const sendPasswordResetEmail = async (email) => {
|
|
4203
|
+
return apiCall(async () => {
|
|
4204
|
+
await postAuthV1PasswordReset({
|
|
4205
|
+
body: validateInput(ResendEmailRequestSchema, { email }),
|
|
4206
|
+
throwOnError: true
|
|
4207
|
+
});
|
|
4208
|
+
}, { [HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Bad request - invalid email or validation error") });
|
|
4209
|
+
};
|
|
4210
|
+
const confirmPasswordReset = async (token, password) => {
|
|
4211
|
+
return apiCall(async () => {
|
|
4212
|
+
await postAuthV1PasswordResetConfirm({
|
|
4213
|
+
body: validateInput(ResetPasswordRequestSchema, {
|
|
4214
|
+
token,
|
|
4215
|
+
new_password: password
|
|
4216
|
+
}),
|
|
4217
|
+
throwOnError: true
|
|
4218
|
+
});
|
|
4219
|
+
}, { [HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Bad request - invalid token or password") });
|
|
4220
|
+
};
|
|
4221
|
+
|
|
4222
|
+
//#endregion
|
|
4223
|
+
//#region src/auth/auth/email.ts
|
|
4224
|
+
const initiateEmailChange = async (email) => {
|
|
4225
|
+
return apiCall(async () => {
|
|
4226
|
+
const { data } = await putAuthV1UsersCurrentEmailsChange({
|
|
4227
|
+
body: validateInput(ChangeEmailRequestSchema, { new_email: email }),
|
|
4228
|
+
throwOnError: true
|
|
4229
|
+
});
|
|
4230
|
+
if (data.verification_id) return {
|
|
4231
|
+
message: data.message || "Verification code sent",
|
|
4232
|
+
verification_id: data.verification_id,
|
|
4233
|
+
can_resend_at: data.can_resend_at,
|
|
4234
|
+
code_sent: data.code_sent
|
|
4235
|
+
};
|
|
4236
|
+
}, {
|
|
4237
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid email or email already in use"),
|
|
4238
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Unauthorized - invalid or missing token"),
|
|
4239
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Too many requests - please try again later")
|
|
4240
|
+
});
|
|
4241
|
+
};
|
|
4242
|
+
const addEmail = async (email) => {
|
|
4243
|
+
return apiCall(async () => {
|
|
4244
|
+
const { data } = await postAuthV1UsersCurrentEmails({
|
|
4245
|
+
body: validateInput(ResendEmailRequestSchema, { email }),
|
|
4246
|
+
throwOnError: true
|
|
4247
|
+
});
|
|
4248
|
+
if (data.verification_id) return {
|
|
4249
|
+
message: data.message || "Verification code sent",
|
|
4250
|
+
verification_id: data.verification_id,
|
|
4251
|
+
can_resend_at: data.can_resend_at,
|
|
4252
|
+
code_sent: data.code_sent
|
|
4253
|
+
};
|
|
4254
|
+
}, {
|
|
4255
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid email address"),
|
|
4256
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Session expired - please login again"),
|
|
4257
|
+
[HTTP_STATUS.CONFLICT]: () => /* @__PURE__ */ new Error("Email address is already in use"),
|
|
4258
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Too many requests - please try again later")
|
|
4259
|
+
});
|
|
4260
|
+
};
|
|
4261
|
+
const normalizeVerifyEmailArgs = (args) => {
|
|
4262
|
+
if (isLegacyVerifyEmailArgs(args)) {
|
|
4263
|
+
const [code, type, verification_id, new_email] = args;
|
|
4264
|
+
return {
|
|
4265
|
+
code,
|
|
4266
|
+
type,
|
|
4267
|
+
verification_id,
|
|
4268
|
+
new_email
|
|
4269
|
+
};
|
|
4270
|
+
}
|
|
4271
|
+
return args[0];
|
|
4272
|
+
};
|
|
4273
|
+
const isLegacyVerifyEmailArgs = (args) => typeof args[0] === "string";
|
|
4274
|
+
const verifyEmailWithCode = async (...args) => {
|
|
4275
|
+
return apiCall(async () => {
|
|
4276
|
+
const payload = normalizeVerifyEmailArgs(args);
|
|
4277
|
+
validateInput(verifyEmailChangeRequestSchema, payload);
|
|
4278
|
+
const { data } = await postAuthV1EmailVerify({
|
|
4279
|
+
body: {
|
|
4280
|
+
code: payload.code,
|
|
4281
|
+
verification_id: payload.verification_id
|
|
4282
|
+
},
|
|
4283
|
+
throwOnError: true
|
|
4284
|
+
});
|
|
4285
|
+
if (data.tokens?.access_token && data.tokens?.refresh_token && data.tokens?.expires_in) setTokens(data.tokens.access_token, data.tokens.refresh_token, data.tokens.expires_in);
|
|
4286
|
+
return {
|
|
4287
|
+
email: data.email || "",
|
|
4288
|
+
message: data.message || "Email verified",
|
|
4289
|
+
verified: data.verified || false,
|
|
4290
|
+
tokens: data.tokens ? {
|
|
4291
|
+
access_token: data.tokens.access_token,
|
|
4292
|
+
refresh_token: data.tokens.refresh_token,
|
|
4293
|
+
expires_in: data.tokens.expires_in
|
|
4294
|
+
} : void 0
|
|
4295
|
+
};
|
|
4296
|
+
}, { [HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid code or verification ID") });
|
|
4297
|
+
};
|
|
4298
|
+
const getEmailVerificationStatus = async () => {
|
|
4299
|
+
return apiCall(async () => {
|
|
4300
|
+
const { data } = await getAuthV1UsersCurrentEmailsStatus({ throwOnError: true });
|
|
4301
|
+
return {
|
|
4302
|
+
email: data.email || "",
|
|
4303
|
+
has_email: data.has_email ?? false,
|
|
4304
|
+
verified: data.verified || false
|
|
4305
|
+
};
|
|
4306
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Unauthorized - invalid or missing token") });
|
|
4307
|
+
};
|
|
4308
|
+
|
|
4309
|
+
//#endregion
|
|
4310
|
+
//#region src/auth/validation/domain.ts
|
|
4311
|
+
/**
|
|
4312
|
+
* Add domain request schema
|
|
4313
|
+
*/
|
|
4314
|
+
const AddDomainSchema = v.object({ domain: DomainSchema });
|
|
4315
|
+
/**
|
|
4316
|
+
* Update auto-join setting schema
|
|
4317
|
+
*/
|
|
4318
|
+
const UpdateAutoJoinSchema = v.object({ enabled: v.boolean("Auto-join setting must be a boolean") });
|
|
4319
|
+
|
|
4320
|
+
//#endregion
|
|
4321
|
+
//#region src/auth/domain/types.ts
|
|
4322
|
+
let DomainStatus = /* @__PURE__ */ function(DomainStatus) {
|
|
4323
|
+
DomainStatus["PENDING"] = "pending";
|
|
4324
|
+
DomainStatus["VERIFIED"] = "verified";
|
|
4325
|
+
DomainStatus["EXPIRED"] = "expired";
|
|
4326
|
+
return DomainStatus;
|
|
4327
|
+
}({});
|
|
4328
|
+
|
|
4329
|
+
//#endregion
|
|
4330
|
+
//#region src/auth/domain/index.ts
|
|
4331
|
+
const getDomainStatus = async (orgId) => {
|
|
4332
|
+
return apiCall(async () => {
|
|
4333
|
+
try {
|
|
4334
|
+
const { data } = await getAuthV1MembershipsByOrgIdDomain({
|
|
4335
|
+
path: { orgId },
|
|
4336
|
+
throwOnError: true
|
|
4337
|
+
});
|
|
4338
|
+
return data;
|
|
4339
|
+
} catch (error) {
|
|
4340
|
+
if (error?.code === HTTP_STATUS.NOT_FOUND) return null;
|
|
4341
|
+
throw error;
|
|
4342
|
+
}
|
|
4343
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Not authorized to view domain settings") });
|
|
4344
|
+
};
|
|
4345
|
+
const initiateDomainVerification = async (orgId, domain) => {
|
|
4346
|
+
return apiCall(async () => {
|
|
4347
|
+
const requestBody = validateInput(AddDomainSchema, { domain });
|
|
4348
|
+
const { data } = await postAuthV1MembershipsByOrgIdDomain({
|
|
4349
|
+
path: { orgId },
|
|
4350
|
+
body: requestBody,
|
|
4351
|
+
throwOnError: true
|
|
4352
|
+
});
|
|
4353
|
+
return data;
|
|
4354
|
+
}, {
|
|
4355
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid domain format or public domains like gmail.com are not allowed"),
|
|
4356
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Not authorized to configure domain settings")
|
|
4357
|
+
});
|
|
4358
|
+
};
|
|
4359
|
+
const checkDomainVerification = async (orgId) => {
|
|
4360
|
+
return apiCall(async () => {
|
|
4361
|
+
const { data } = await postAuthV1MembershipsByOrgIdDomainVerification({
|
|
4362
|
+
path: { orgId },
|
|
4363
|
+
throwOnError: true
|
|
4364
|
+
});
|
|
4365
|
+
return data;
|
|
4366
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Not authorized to check domain verification") });
|
|
4367
|
+
};
|
|
4368
|
+
const updateAutoJoin = async (orgId, enabled) => {
|
|
4369
|
+
return apiCall(async () => {
|
|
4370
|
+
const requestBody = validateInput(UpdateAutoJoinSchema, { enabled });
|
|
4371
|
+
const { data } = await putAuthV1MembershipsByOrgIdDomainAutoJoin({
|
|
4372
|
+
path: { orgId },
|
|
4373
|
+
body: requestBody,
|
|
4374
|
+
throwOnError: true
|
|
4375
|
+
});
|
|
4376
|
+
return data;
|
|
4377
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Not authorized to update auto-join settings") });
|
|
4378
|
+
};
|
|
4379
|
+
const removeDomain = async (orgId) => {
|
|
4380
|
+
return apiCall(async () => {
|
|
4381
|
+
await deleteAuthV1MembershipsByOrgIdDomain({
|
|
4382
|
+
path: { orgId },
|
|
4383
|
+
throwOnError: true
|
|
4384
|
+
});
|
|
4385
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Not authorized to remove domain") });
|
|
4386
|
+
};
|
|
4387
|
+
|
|
4388
|
+
//#endregion
|
|
4389
|
+
//#region src/auth/blog/index.ts
|
|
4390
|
+
const BLOG_SUBSCRIPTION_ERRORS = {
|
|
4391
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("User is not authorized to manage blog subscription"),
|
|
4392
|
+
[HTTP_STATUS.FORBIDDEN]: () => /* @__PURE__ */ new Error("Account is inactive"),
|
|
4393
|
+
[HTTP_STATUS.TOO_MANY_REQUESTS]: () => /* @__PURE__ */ new Error("Too many requests - please try again later")
|
|
4394
|
+
};
|
|
4395
|
+
const getBlogSubscriptionStatus = async () => {
|
|
4396
|
+
return apiCall(async () => {
|
|
4397
|
+
const { data } = await getAuthV1BlogSubscription({ throwOnError: true });
|
|
4398
|
+
return data;
|
|
4399
|
+
}, BLOG_SUBSCRIPTION_ERRORS);
|
|
4400
|
+
};
|
|
4401
|
+
const subscribeToBlog = async () => {
|
|
4402
|
+
return apiCall(async () => {
|
|
4403
|
+
await postAuthV1BlogSubscribe({ throwOnError: true });
|
|
4404
|
+
}, {
|
|
4405
|
+
...BLOG_SUBSCRIPTION_ERRORS,
|
|
4406
|
+
[HTTP_STATUS.INTERNAL_SERVER_ERROR]: () => /* @__PURE__ */ new Error("Failed to subscribe to blog updates")
|
|
4407
|
+
});
|
|
4408
|
+
};
|
|
4409
|
+
const unsubscribeFromBlog = async () => {
|
|
4410
|
+
return apiCall(async () => {
|
|
4411
|
+
await postAuthV1BlogUnsubscribe({ throwOnError: true });
|
|
4412
|
+
}, {
|
|
4413
|
+
...BLOG_SUBSCRIPTION_ERRORS,
|
|
4414
|
+
[HTTP_STATUS.INTERNAL_SERVER_ERROR]: () => /* @__PURE__ */ new Error("Failed to unsubscribe from blog updates")
|
|
4415
|
+
});
|
|
4416
|
+
};
|
|
4417
|
+
|
|
4418
|
+
//#endregion
|
|
4419
|
+
//#region src/auth/passkey.ts
|
|
4420
|
+
function base64urlToBuffer(base64url) {
|
|
4421
|
+
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
4422
|
+
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
|
4423
|
+
const binary = atob(padded);
|
|
4424
|
+
const bytes = new Uint8Array(binary.length);
|
|
4425
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
4426
|
+
return bytes.buffer;
|
|
4427
|
+
}
|
|
4428
|
+
function bufferToBase64url(buffer) {
|
|
4429
|
+
const bytes = new Uint8Array(buffer);
|
|
4430
|
+
let binary = "";
|
|
4431
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
4432
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
4433
|
+
}
|
|
4434
|
+
function decodeCreationOptions(raw) {
|
|
4435
|
+
const pk = raw.publicKey ?? raw;
|
|
4436
|
+
return {
|
|
4437
|
+
...pk,
|
|
4438
|
+
challenge: base64urlToBuffer(pk.challenge),
|
|
4439
|
+
user: {
|
|
4440
|
+
...pk.user,
|
|
4441
|
+
id: base64urlToBuffer(pk.user.id)
|
|
4442
|
+
},
|
|
4443
|
+
excludeCredentials: (pk.excludeCredentials ?? []).map((c) => ({
|
|
4444
|
+
...c,
|
|
4445
|
+
id: base64urlToBuffer(c.id)
|
|
4446
|
+
}))
|
|
4447
|
+
};
|
|
4448
|
+
}
|
|
4449
|
+
function decodeRequestOptions(raw) {
|
|
4450
|
+
const pk = raw.publicKey ?? raw;
|
|
4451
|
+
return {
|
|
4452
|
+
...pk,
|
|
4453
|
+
challenge: base64urlToBuffer(pk.challenge),
|
|
4454
|
+
allowCredentials: (pk.allowCredentials ?? []).map((c) => ({
|
|
4455
|
+
...c,
|
|
4456
|
+
id: base64urlToBuffer(c.id)
|
|
4457
|
+
}))
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4460
|
+
function serializeLoginCredential(cred) {
|
|
4461
|
+
const response = cred.response;
|
|
4462
|
+
return {
|
|
4463
|
+
id: cred.id,
|
|
4464
|
+
rawId: bufferToBase64url(cred.rawId),
|
|
4465
|
+
type: cred.type,
|
|
4466
|
+
response: {
|
|
4467
|
+
authenticatorData: bufferToBase64url(response.authenticatorData),
|
|
4468
|
+
clientDataJSON: bufferToBase64url(response.clientDataJSON),
|
|
4469
|
+
signature: bufferToBase64url(response.signature),
|
|
4470
|
+
userHandle: response.userHandle ? bufferToBase64url(response.userHandle) : null
|
|
4471
|
+
}
|
|
4472
|
+
};
|
|
4473
|
+
}
|
|
4474
|
+
function serializeRegistrationCredential(cred) {
|
|
4475
|
+
const response = cred.response;
|
|
4476
|
+
return {
|
|
4477
|
+
id: cred.id,
|
|
4478
|
+
rawId: bufferToBase64url(cred.rawId),
|
|
4479
|
+
type: cred.type,
|
|
4480
|
+
response: {
|
|
4481
|
+
attestationObject: bufferToBase64url(response.attestationObject),
|
|
4482
|
+
clientDataJSON: bufferToBase64url(response.clientDataJSON)
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
const finishPasskeyLogin = async (session_id, credential) => {
|
|
4487
|
+
return apiCall(async () => {
|
|
4488
|
+
const { data } = await postAuthV1PasskeyLoginFinish({
|
|
4489
|
+
body: {
|
|
4490
|
+
session_id,
|
|
4491
|
+
credential: serializeLoginCredential(credential)
|
|
4492
|
+
},
|
|
4493
|
+
throwOnError: true
|
|
4494
|
+
});
|
|
4495
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
4496
|
+
}, {
|
|
4497
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid passkey credential"),
|
|
4498
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Passkey authentication failed")
|
|
4499
|
+
});
|
|
4500
|
+
};
|
|
4501
|
+
const beginPasskeyLogin = async () => {
|
|
4502
|
+
return apiCall(async () => {
|
|
4503
|
+
const { data } = await postAuthV1PasskeyLoginBegin({ throwOnError: true });
|
|
4504
|
+
if (!data.session_id || !data.options) throw new Error("No passkeys available for this account");
|
|
4505
|
+
const options = decodeRequestOptions(data.options);
|
|
4506
|
+
return {
|
|
4507
|
+
session_id: data.session_id,
|
|
4508
|
+
options
|
|
4509
|
+
};
|
|
4510
|
+
}, {});
|
|
4511
|
+
};
|
|
4512
|
+
const beginPasskeyRegistration = async () => {
|
|
4513
|
+
return apiCall(async () => {
|
|
4514
|
+
const { data } = await postAuthV1UsersCurrentPasskeysRegisterBegin({ throwOnError: true });
|
|
4515
|
+
if (!data.session_id || !data.options) throw new Error("Invalid response from server");
|
|
4516
|
+
const options = decodeCreationOptions(data.options);
|
|
4517
|
+
return {
|
|
4518
|
+
session_id: data.session_id,
|
|
4519
|
+
options
|
|
4520
|
+
};
|
|
4521
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.") });
|
|
4522
|
+
};
|
|
4523
|
+
const finishPasskeyRegistration = async (session_id, name, credential) => {
|
|
4524
|
+
return apiCall(async () => {
|
|
4525
|
+
const { data } = await postAuthV1UsersCurrentPasskeysRegisterFinish({
|
|
4526
|
+
body: {
|
|
4527
|
+
session_id,
|
|
4528
|
+
name,
|
|
4529
|
+
credential: serializeRegistrationCredential(credential)
|
|
4530
|
+
},
|
|
4531
|
+
throwOnError: true
|
|
4532
|
+
});
|
|
4533
|
+
return {
|
|
4534
|
+
passkey_id: data.passkey_id ?? "",
|
|
4535
|
+
name: data.name ?? ""
|
|
4536
|
+
};
|
|
4537
|
+
}, {
|
|
4538
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid passkey credential"),
|
|
4539
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.")
|
|
4540
|
+
});
|
|
4541
|
+
};
|
|
4542
|
+
const renamePasskey = async (id, name) => {
|
|
4543
|
+
return apiCall(async () => {
|
|
4544
|
+
await patchAuthV1UsersCurrentPasskeysById({
|
|
4545
|
+
path: { id },
|
|
4546
|
+
body: { name },
|
|
4547
|
+
throwOnError: true
|
|
4548
|
+
});
|
|
4549
|
+
}, { [HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Passkey not found") });
|
|
4550
|
+
};
|
|
4551
|
+
const deletePasskey = async (id) => {
|
|
4552
|
+
return apiCall(async () => {
|
|
4553
|
+
await deleteAuthV1UsersCurrentPasskeysById({
|
|
4554
|
+
path: { id },
|
|
4555
|
+
throwOnError: true
|
|
4556
|
+
});
|
|
4557
|
+
}, { [HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Passkey not found") });
|
|
4558
|
+
};
|
|
4559
|
+
const listPasskeys = async () => {
|
|
4560
|
+
return apiCall(async () => {
|
|
4561
|
+
const { data } = await getAuthV1UsersCurrentPasskeys({ throwOnError: true });
|
|
4562
|
+
return (data.passkeys ?? []).map((p) => ({
|
|
4563
|
+
id: p.id ?? "",
|
|
4564
|
+
name: p.name ?? "",
|
|
4565
|
+
credential_id: p.credential_id ?? "",
|
|
4566
|
+
aaguid: p.aaguid ?? "",
|
|
4567
|
+
backup_state: p.backup_state ?? false,
|
|
4568
|
+
created_at: p.created_at ?? "",
|
|
4569
|
+
last_used_at: p.last_used_at ?? "",
|
|
4570
|
+
transports: p.transports ?? []
|
|
4571
|
+
}));
|
|
4572
|
+
}, { [HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Token is missing or invalid; user is not authenticated.") });
|
|
4573
|
+
};
|
|
4574
|
+
const verifyPasskeyForLogin = async (session_id, credential) => {
|
|
4575
|
+
return apiCall(async () => {
|
|
4576
|
+
const { data } = await postAuthV1VerifyPasskey({
|
|
4577
|
+
body: {
|
|
4578
|
+
session_id,
|
|
4579
|
+
credential: serializeLoginCredential(credential)
|
|
4580
|
+
},
|
|
4581
|
+
throwOnError: true
|
|
4582
|
+
});
|
|
4583
|
+
if (data.access_token && data.refresh_token && data.expires_in) setTokens(data.access_token, data.refresh_token, data.expires_in);
|
|
4584
|
+
}, {
|
|
4585
|
+
[HTTP_STATUS.BAD_REQUEST]: () => /* @__PURE__ */ new Error("Invalid passkey credential"),
|
|
4586
|
+
[HTTP_STATUS.UNAUTHORIZED]: () => /* @__PURE__ */ new Error("Passkey verification failed"),
|
|
4587
|
+
[HTTP_STATUS.NOT_FOUND]: () => /* @__PURE__ */ new Error("Session not found")
|
|
4588
|
+
});
|
|
4589
|
+
};
|
|
1018
4590
|
|
|
1019
4591
|
//#endregion
|
|
1020
|
-
export { createClient,
|
|
4592
|
+
export { DomainStatus, MembershipRole, MembershipState, addEmail, authError, beginPasskeyLogin, beginPasskeyRegistration, checkDomainVerification, clearAuthError, clearLimitedAccessState, client, completePostUpload, confirmPasswordReset, connect, connectSocial, createApiKeyByOrgid, createClient, createCredentialByOrgid, createFeed, createMoveByProjectid, createPost, createProjectsByOrgid, createToken, decodeRequestOptions, deleteApiKeyByKeyid, deleteAuthV1MembershipsByOrgIdDomain, deleteAuthV1MembershipsByOrgIdLeave, deleteAuthV1MembershipsByOrgIdMembersByUserId, deleteAuthV1MembershipsByOrgIdPoliciesByPolicyId, deleteAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachmentsByAttachmentId, deleteAuthV1ProvidersByProvider, deleteAuthV1UsersCurrentPasskeysById, deleteAuthV1UsersCurrentTotpDelete, deleteBillingV1PaymentMethodsByPaymentMethodId, deleteCustomDomainByProjectid, deleteFeed, deleteMediaV1ProjectsByProjectIdImagesByImageId, deleteMediaV1ProjectsByProjectIdVideosByVideoId, deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracks, deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksByTrackId, deleteMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksLanguageByLang, deleteMediaV1ProjectsByProjectIdVideosByVideoIdChapters, deleteMediaV1ProjectsByProjectIdVideosByVideoIdChaptersByStartTimeSec, deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitles, deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesBySubtitleId, deleteMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesLanguageByLang, deleteMember, deletePasskey, deletePost, deleteProjects, deleteUserOTP, disconnectSocial, finishPasskeyLogin, finishPasskeyRegistration, getAnalyticsV1Dashboard, getAnalyticsV1FeedsByFeedIdStats, getAnalyticsV1PostsByPostIdStats, getAnalyticsV1Realtime, getAnalyticsV1Retention, getAnalyticsV1TopFeeds, getAnalyticsV1TopPosts, getAnalyticsV1TopVideos, getAnalyticsV1VideosByVideoIdHeatmap, getAnalyticsV1VideosByVideoIdHotSegments, getAnalyticsV1VideosByVideoIdStats, getAuthV1BlogSubscription, getAuthV1MembershipsActive, getAuthV1MembershipsByOrgIdCheck, getAuthV1MembershipsByOrgIdDomain, getAuthV1MembershipsByOrgIdDomainAutoJoin, getAuthV1MembershipsByOrgIdInfo, getAuthV1MembershipsByOrgIdMembers, getAuthV1MembershipsByOrgIdMembersByUserIdPolicies, getAuthV1MembershipsByOrgIdPolicies, getAuthV1MembershipsByOrgIdPoliciesByPolicyId, getAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachments, getAuthV1MembershipsPending, getAuthV1PoliciesPermissions, getAuthV1Providers, getAuthV1Userinfo, getAuthV1UsersCurrent, getAuthV1UsersCurrentEmailsStatus, getAuthV1UsersCurrentPasskeys, getAuthV1UsersCurrentTotpStatus, getBillingV1Address, getBillingV1BandwidthUsage, getBillingV1BandwidthUsageHistory, getBillingV1Invoices, getBillingV1PaymentMethods, getBillingV1PaymentMethodsFromPaymentIntent, getBillingV1PaymentMethodsFromSetupIntent, getBillingV1Plans, getBillingV1PlansByPlanId, getBillingV1StorageUsage, getBillingV1StorageUsageHistory, getBillingV1Subscription, getBillingV1SubscriptionHistory, getBlogSubscriptionStatus, getDomainStatus, getEmailVerificationStatus, getFeed, getMediaV1ImagesByImageId, getMediaV1Languages, getMediaV1ProjectsByProjectIdImages, getMediaV1ProjectsByProjectIdImagesByImageId, getMediaV1ProjectsByProjectIdVideos, getMediaV1ProjectsByProjectIdVideosByVideoId, getMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracks, getMediaV1ProjectsByProjectIdVideosByVideoIdChapters, getMediaV1ProjectsByProjectIdVideosByVideoIdSubtitles, getMediaV1VideosByVideoId, getMediaV1VideosByVideoIdAudioTracks, getMediaV1VideosByVideoIdSubtitles, getOTPStatus, getPost, getProjects, getPublicPost, getToken, initClient, initPostUpload, initiateDomainVerification, initiateEmailChange, inviteMember, isLogged, leaveOrganization, limitedAccessToken, listActiveMemberships, listApiKeysByOrgid, listCredentialsByOrgid, listFeeds, listOrganizationMembers, listPasskeys, listPendingMemberships, listPosts, listPostsByCreator, listProjectsByOrgid, listPublicPosts, listPublicPostsByCreator, listSocials, login, loginWithEmail, logout, patchAuthV1UsersCurrentName, patchAuthV1UsersCurrentPasskeysById, patchAuthV1UsersCurrentUsername, patchNameByProjectid, patchVideoQualityByProjectid, postAnalyticsV1Events, postAnalyticsV1Funnels, postAuthV1BlogSubscribe, postAuthV1BlogUnsubscribe, postAuthV1BlogUnsubscribeEmail, postAuthV1EmailVerify, postAuthV1EmailVerifyResend, postAuthV1InvitationsByTokenAccept, postAuthV1InvitationsByTokenDecline, postAuthV1Login, postAuthV1Logout, postAuthV1MembershipsByOrgIdDomain, postAuthV1MembershipsByOrgIdDomainVerification, postAuthV1MembershipsByOrgIdMembersInvite, postAuthV1MembershipsByOrgIdMembersInviteResend, postAuthV1MembershipsByOrgIdPolicies, postAuthV1MembershipsByOrgIdPoliciesByPolicyIdAttachments, postAuthV1PasskeyLoginBegin, postAuthV1PasskeyLoginFinish, postAuthV1PasswordReset, postAuthV1PasswordResetConfirm, postAuthV1ProvidersConnect, postAuthV1Register, postAuthV1Token, postAuthV1UsersCurrentEmails, postAuthV1UsersCurrentPasskeysRegisterBegin, postAuthV1UsersCurrentPasskeysRegisterFinish, postAuthV1UsersCurrentTotpSetup, postAuthV1UsersCurrentTotpVerify, postAuthV1VerifyPasskey, postAuthV1VerifyTotp, postBillingV1Address, postBillingV1BandwidthUsageRefresh, postBillingV1Checkout, postBillingV1ContactSales, postBillingV1JobsCleanupBandwidthSnapshots, postBillingV1JobsDailyBandwidthCalculation, postBillingV1JobsMonthlyBandwidthCalculation, postBillingV1PaymentMethods, postBillingV1SetupIntent, postBillingV1StorageUsageRefresh, postBillingV1Subscription, postBillingV1SubscriptionUpgrade, postBillingV1TaxCalculate, postBillingWebhooksStripe, postMediaV1ProjectsByProjectIdImagesByImageIdUploadComplete, postMediaV1ProjectsByProjectIdImagesUpload, postMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksUpload, postMediaV1ProjectsByProjectIdVideosByVideoIdAudioTracksUploadComplete, postMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesUpload, postMediaV1ProjectsByProjectIdVideosByVideoIdSubtitlesUploadComplete, postMediaV1ProjectsByProjectIdVideosByVideoIdUploadComplete, postMediaV1ProjectsByProjectIdVideosUpload, postPlatformAuthRefresh, postPlatformAuthToken, publicRespondToInvitation, putAuthV1MembershipsByOrgIdActive, putAuthV1MembershipsByOrgIdDomainAutoJoin, putAuthV1MembershipsByOrgIdMembersByUserIdRole, putAuthV1MembershipsByOrgIdMembershipState, putAuthV1MembershipsByOrgIdName, putAuthV1MembershipsByOrgIdPoliciesByPolicyId, putAuthV1MembershipsByOrgIdUsername, putAuthV1UsersCurrentEmailsChange, putBillingV1InvoicesByInvoiceIdStatus, putBillingV1SubscriptionCancel, putBillingV1SubscriptionReactivate, putMediaV1ProjectsByProjectIdImagesByImageIdVisibility, putMediaV1ProjectsByProjectIdVideosByVideoIdChapters, putMediaV1ProjectsByProjectIdVideosByVideoIdThumbnail, putMediaV1ProjectsByProjectIdVideosByVideoIdVisibility, registerWithEmail, removeDomain, renamePasskey, requiresAction, resendEmailVerificationCode, resendMemberInvite, respondToInvitation, revokeCredentialByCredentialid, rotateApiKeyByKeyid, sendPasswordResetEmail, setLimitedAccessState, setupUserOTP, subscribeToBlog, unsubscribeFromBlog, updateActiveMembership, updateAutoJoin, updateCustomDomainByProjectid, updateFeed, updateFullName, updateMemberRole, updateOrgName, updateOrgUsername, updateUsername, user, verifyEmailWithCode, verifyPasskeyForLogin, verifyTOTPForLogin, verifyUserOTP };
|
|
1021
4593
|
//# sourceMappingURL=index.js.map
|