@burdenoff/sdk-libs 2026.501.6
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/LICENSE +4 -0
- package/README.md +52 -0
- package/dist/chunk-NEREAHJ6.js +1 -0
- package/dist/chunk-YGVAZ3D7.js +2 -0
- package/dist/core/index.cjs +2 -0
- package/dist/core/index.d.cts +52 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/module-JDbvil5h.d.cts +194 -0
- package/dist/module-JDbvil5h.d.ts +194 -0
- package/dist/modules/auth/index.cjs +71 -0
- package/dist/modules/auth/index.d.cts +94 -0
- package/dist/modules/auth/index.d.ts +94 -0
- package/dist/modules/auth/index.js +71 -0
- package/dist/modules/billing/index.cjs +203 -0
- package/dist/modules/billing/index.d.cts +377 -0
- package/dist/modules/billing/index.d.ts +377 -0
- package/dist/modules/billing/index.js +203 -0
- package/dist/modules/channels/index.cjs +108 -0
- package/dist/modules/channels/index.d.cts +146 -0
- package/dist/modules/channels/index.d.ts +146 -0
- package/dist/modules/channels/index.js +108 -0
- package/dist/modules/conversations/index.cjs +61 -0
- package/dist/modules/conversations/index.d.cts +112 -0
- package/dist/modules/conversations/index.d.ts +112 -0
- package/dist/modules/conversations/index.js +61 -0
- package/dist/modules/devportal/index.cjs +216 -0
- package/dist/modules/devportal/index.d.cts +303 -0
- package/dist/modules/devportal/index.d.ts +303 -0
- package/dist/modules/devportal/index.js +216 -0
- package/dist/modules/export/index.cjs +61 -0
- package/dist/modules/export/index.d.cts +169 -0
- package/dist/modules/export/index.d.ts +169 -0
- package/dist/modules/export/index.js +61 -0
- package/dist/modules/files/index.cjs +51 -0
- package/dist/modules/files/index.d.cts +102 -0
- package/dist/modules/files/index.d.ts +102 -0
- package/dist/modules/files/index.js +51 -0
- package/dist/modules/groups/index.cjs +80 -0
- package/dist/modules/groups/index.d.cts +168 -0
- package/dist/modules/groups/index.d.ts +168 -0
- package/dist/modules/groups/index.js +80 -0
- package/dist/modules/health/index.cjs +5 -0
- package/dist/modules/health/index.d.cts +18 -0
- package/dist/modules/health/index.d.ts +18 -0
- package/dist/modules/health/index.js +5 -0
- package/dist/modules/integrations/index.cjs +65 -0
- package/dist/modules/integrations/index.d.cts +120 -0
- package/dist/modules/integrations/index.d.ts +120 -0
- package/dist/modules/integrations/index.js +65 -0
- package/dist/modules/notifications/index.cjs +53 -0
- package/dist/modules/notifications/index.d.cts +140 -0
- package/dist/modules/notifications/index.d.ts +140 -0
- package/dist/modules/notifications/index.js +53 -0
- package/dist/modules/organizations/index.cjs +72 -0
- package/dist/modules/organizations/index.d.cts +88 -0
- package/dist/modules/organizations/index.d.ts +88 -0
- package/dist/modules/organizations/index.js +72 -0
- package/dist/modules/products/index.cjs +149 -0
- package/dist/modules/products/index.d.cts +361 -0
- package/dist/modules/products/index.d.ts +361 -0
- package/dist/modules/products/index.js +149 -0
- package/dist/modules/rbac/index.cjs +55 -0
- package/dist/modules/rbac/index.d.cts +100 -0
- package/dist/modules/rbac/index.d.ts +100 -0
- package/dist/modules/rbac/index.js +55 -0
- package/dist/modules/scheduler/index.cjs +61 -0
- package/dist/modules/scheduler/index.d.cts +121 -0
- package/dist/modules/scheduler/index.d.ts +121 -0
- package/dist/modules/scheduler/index.js +61 -0
- package/dist/modules/security/index.cjs +61 -0
- package/dist/modules/security/index.d.cts +110 -0
- package/dist/modules/security/index.d.ts +110 -0
- package/dist/modules/security/index.js +61 -0
- package/dist/modules/store/index.cjs +82 -0
- package/dist/modules/store/index.d.cts +139 -0
- package/dist/modules/store/index.d.ts +139 -0
- package/dist/modules/store/index.js +82 -0
- package/dist/modules/support/index.cjs +56 -0
- package/dist/modules/support/index.d.cts +147 -0
- package/dist/modules/support/index.d.ts +147 -0
- package/dist/modules/support/index.js +56 -0
- package/dist/modules/tags/index.cjs +55 -0
- package/dist/modules/tags/index.d.cts +131 -0
- package/dist/modules/tags/index.d.ts +131 -0
- package/dist/modules/tags/index.js +55 -0
- package/dist/modules/tours/index.cjs +37 -0
- package/dist/modules/tours/index.d.cts +61 -0
- package/dist/modules/tours/index.d.ts +61 -0
- package/dist/modules/tours/index.js +37 -0
- package/dist/modules/vibecontrols/index.cjs +1081 -0
- package/dist/modules/vibecontrols/index.d.cts +1483 -0
- package/dist/modules/vibecontrols/index.d.ts +1483 -0
- package/dist/modules/vibecontrols/index.js +1081 -0
- package/dist/modules/workspaces/index.cjs +91 -0
- package/dist/modules/workspaces/index.d.cts +128 -0
- package/dist/modules/workspaces/index.d.ts +128 -0
- package/dist/modules/workspaces/index.js +91 -0
- package/package.json +117 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var re=require('cross-fetch'),crypto=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var re__default=/*#__PURE__*/_interopDefault(re);var Q=["password","secret","clientSecret","apiKey","token","mfaCode","accessToken","refreshToken","workspaceToken","authorization"],ee=/\b(eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)\b/g;function te(u){let a=u.replace(ee,"<redacted-jwt>");for(let d of Q){let s=new RegExp(`("${d}"\\s*:\\s*")[^"]*(")`,"gi");a=a.replace(s,"$1<redacted>$2");}return a}var m=class extends Error{code;cause;constructor(a,d="SDK_ERROR",s){super(te(a)),this.name="SdkError",this.code=d,this.cause=s;}},c=class extends m{constructor(a="Authentication failed",d){super(a,"AUTHENTICATION_ERROR",d),this.name="AuthenticationError";}};var k=class extends m{constructor(a,d){super(a,"NETWORK_ERROR",d),this.name="NetworkError";}};var w=class extends m{constructor(a="Device code expired"){super(a,"DEVICE_CODE_EXPIRED"),this.name="DeviceCodeExpiredError";}},T=class extends m{constructor(a="Device authorization denied by user"){super(a,"DEVICE_CODE_DENIED"),this.name="DeviceCodeDeniedError";}};function I(u=64){return crypto.randomBytes(u).toString("base64url").slice(0,u)}function _(u){return crypto.createHash("sha256").update(u).digest("base64url")}function y(){return crypto.randomBytes(32).toString("base64url")}var P=`
|
|
2
|
+
fragment AuthUser on User {
|
|
3
|
+
id
|
|
4
|
+
email
|
|
5
|
+
username
|
|
6
|
+
}
|
|
7
|
+
`,U=`
|
|
8
|
+
${P}
|
|
9
|
+
mutation SignUp($input: SignUpInput!) {
|
|
10
|
+
signUp(input: $input) {
|
|
11
|
+
user { ...AuthUser }
|
|
12
|
+
accessToken
|
|
13
|
+
refreshToken
|
|
14
|
+
expiresIn
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`,R=`
|
|
18
|
+
${P}
|
|
19
|
+
mutation SignIn($input: SignInInput!) {
|
|
20
|
+
signIn(input: $input) {
|
|
21
|
+
user { ...AuthUser }
|
|
22
|
+
accessToken
|
|
23
|
+
refreshToken
|
|
24
|
+
expiresIn
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,v=`
|
|
28
|
+
${P}
|
|
29
|
+
mutation RefreshToken($token: String!) {
|
|
30
|
+
refreshToken(token: $token) {
|
|
31
|
+
user { ...AuthUser }
|
|
32
|
+
accessToken
|
|
33
|
+
refreshToken
|
|
34
|
+
expiresIn
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`,$=`
|
|
38
|
+
mutation SignOut {
|
|
39
|
+
signOut
|
|
40
|
+
}
|
|
41
|
+
`,D=`
|
|
42
|
+
mutation AuthenticateApp($input: AuthenticateAppInput!) {
|
|
43
|
+
authenticateApp(input: $input) {
|
|
44
|
+
accessToken
|
|
45
|
+
tokenType
|
|
46
|
+
expiresIn
|
|
47
|
+
scopes
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`,O=`
|
|
51
|
+
mutation IssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {
|
|
52
|
+
issueWorkspaceToken(input: $input) {
|
|
53
|
+
success
|
|
54
|
+
token
|
|
55
|
+
expiresAt
|
|
56
|
+
scopes
|
|
57
|
+
error { code message }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`,b=`
|
|
61
|
+
query MyWorkspaces($limit: Int) {
|
|
62
|
+
myWorkspaces(limit: $limit) {
|
|
63
|
+
items { id name slug tenantId organizationId }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`,W=`
|
|
67
|
+
query Me {
|
|
68
|
+
me { id email username isActive emailVerified }
|
|
69
|
+
}
|
|
70
|
+
`;var x=typeof fetch<"u"?fetch:re__default.default;function N(u){let{gql:a,auth:d,oidc:s,logger:q}=u;async function g(e){await d.setTokens(e);}async function M(e){let t=(await a.global.request(R,{input:e})).signIn;return await g({accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3}),t}async function K(e){let t=(await a.global.request(U,{input:e})).signUp;return await g({accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3}),t}async function j(){let e=await d.getTokens();if(!e?.refreshToken)throw new c("No refresh token available");let t=(await a.global.request(v,{token:e.refreshToken})).refreshToken,n={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3};return await g(n),n}async function z(){try{await a.global.request($);}catch(e){q.warn(`signOut server-side failed: ${e.message}`);}finally{await d.clearTokens();}}async function L(){return (await a.global.request(W)).me}async function V(){let e=await d.getTokens();return e?.accessToken?!(e.expiresAt&&Date.now()>=e.expiresAt):!!d.getApiKey()}async function G(e){d.setApiKey(e);}async function F(e,o){if(!s.issuer)throw new c("oidcIssuer required for client credentials flow");let t=`${s.issuer}/token`,n=new URLSearchParams({grant_type:"client_credentials",client_id:e,client_secret:o}).toString(),r;try{r=await x(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n});}catch(h){throw new k(`token endpoint unreachable: ${h.message}`,h)}if(!r.ok){let h=await r.text().catch(()=>"Unknown");throw new c(`client_credentials failed (${r.status}): ${h}`)}let i=await r.json(),l=i.expires_in??3600,p={accessToken:i.access_token,refreshToken:i.refresh_token??"",expiresAt:Date.now()+l*1e3};return await g(p),p}async function H(e,o,t){let r=(await a.global.request(D,{input:{clientId:e,clientSecret:o,scopes:t}})).authenticateApp;return await g({accessToken:r.accessToken,refreshToken:"",expiresAt:Date.now()+r.expiresIn*1e3}),r}async function C(e){if(!s.issuer)throw new c("oidcIssuer required for device code flow");if(!s.clientId)throw new c("clientId required for device code flow");let o=`${s.issuer}/oidc/device/code`,t=new URLSearchParams({client_id:s.clientId,...e&&e.length>0?{scope:e.join(" ")}:{}}).toString(),n;try{n=await x(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});}catch(i){throw new k(`device endpoint unreachable: ${i.message}`,i)}if(!n.ok){let i=await n.text().catch(()=>"Unknown");throw new c(`device code request failed (${n.status}): ${i}`)}let r=await n.json();return {deviceCode:r.device_code,userCode:r.user_code,verificationUri:r.verification_uri,verificationUriComplete:r.verification_uri_complete??null,expiresIn:r.expires_in,interval:r.interval??5}}async function E(e,o=5){if(!s.issuer)throw new c("oidcIssuer required");if(!s.clientId)throw new c("clientId required");let t=`${s.issuer}/oauth/device/token`,n=o;for(;;){await new Promise(p=>setTimeout(p,n*1e3));let r;try{r=await x(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e,client_id:s.clientId}).toString()});}catch(p){throw new k(`device poll failed: ${p.message}`,p)}let i=await r.json();if(r.ok&&i.access_token){let p=i.expires_in??3600,h={accessToken:i.access_token,refreshToken:i.refresh_token??"",expiresAt:Date.now()+p*1e3};return await g(h),h}let l=i.error;switch(l){case "authorization_pending":continue;case "slow_down":n+=5;continue;case "expired_token":throw new w;case "access_denied":throw new T;default:throw new c(`device code polling failed: ${i.error_description??l??"Unknown"}`)}}}async function Y(e){let o=await C(e),t=E(o.deviceCode,o.interval);return {userCode:o.userCode,verificationUri:o.verificationUri,promise:t}}function Z(e){if(!s.issuer)throw new c("oidcIssuer required");if(!s.clientId)throw new c("clientId required");let o=I(),t=_(o),n=e?.state??y(),r=e?.redirectUri??s.redirectUri??"http://localhost:8400/callback",i=e?.scopes??["openid","profile","email","offline_access"],l=new URLSearchParams({response_type:"code",client_id:s.clientId,redirect_uri:r,scope:i.join(" "),code_challenge:t,code_challenge_method:"S256",state:n});return {url:`${s.issuer}/oidc/auth?${l.toString()}`,state:n,codeVerifier:o,redirectUri:r}}async function B(e,o,t){if(!s.issuer)throw new c("oidcIssuer required");if(!s.clientId)throw new c("clientId required");let n=`${s.issuer}/oidc/token`,r=new URLSearchParams({grant_type:"authorization_code",code:e,redirect_uri:t??s.redirectUri??"http://localhost:8400/callback",client_id:s.clientId,code_verifier:o}).toString(),i;try{i=await x(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r});}catch(f){throw new k(`auth code exchange failed: ${f.message}`,f)}if(!i.ok){let f=await i.text().catch(()=>"Unknown");throw new c(`auth code exchange failed (${i.status}): ${f}`)}let l=await i.json(),p=l.expires_in??3600,h={accessToken:l.access_token,refreshToken:l.refresh_token??"",expiresAt:Date.now()+p*1e3};return await g(h),h}async function J(e=50){return (await a.global.request(b,{limit:e})).myWorkspaces.items}async function X(e,o){let n=(await a.workspaceAuthOnly.request(O,{input:{workspaceId:e,organizationId:o}})).issueWorkspaceToken;if(!n.success||!n.token)throw new c(`Workspace token issuance failed: ${n.error?.message??"Unknown"}`);return d.setWorkspaceToken(n.token),{token:n.token,expiresAt:n.expiresAt,scopes:n.scopes??[]}}return {signIn:M,signUp:K,refreshToken:j,signOut:z,getCurrentUser:L,isAuthenticated:V,loginWithApiKey:G,loginWithClientCredentials:F,authenticateApp:H,startDeviceCodeFlow:C,pollDeviceCodeAuth:E,loginWithDeviceCode:Y,buildAuthorizationUrl:Z,exchangeAuthCode:B,fetchWorkspaces:J,issueWorkspaceToken:X}}var se={id:"auth",version:"1.0.0",displayName:"Auth",attach(u){return N(u)}},Te=se;
|
|
71
|
+
exports.default=Te;exports.generateCodeChallenge=_;exports.generateCodeVerifier=I;exports.generateState=y;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { T as TokenPair, S as SdkModule } from '../../module-JDbvil5h.cjs';
|
|
2
|
+
import 'graphql-request';
|
|
3
|
+
|
|
4
|
+
interface User {
|
|
5
|
+
id: string;
|
|
6
|
+
email: string;
|
|
7
|
+
username: string;
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
emailVerified?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface AuthPayload {
|
|
12
|
+
user: User;
|
|
13
|
+
accessToken: string;
|
|
14
|
+
refreshToken: string;
|
|
15
|
+
expiresIn: number;
|
|
16
|
+
}
|
|
17
|
+
interface SignInInput {
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
}
|
|
21
|
+
interface SignUpInput {
|
|
22
|
+
email: string;
|
|
23
|
+
username: string;
|
|
24
|
+
password: string;
|
|
25
|
+
firstName?: string;
|
|
26
|
+
lastName?: string;
|
|
27
|
+
}
|
|
28
|
+
interface DeviceCodeResponse {
|
|
29
|
+
deviceCode: string;
|
|
30
|
+
userCode: string;
|
|
31
|
+
verificationUri: string;
|
|
32
|
+
verificationUriComplete: string | null;
|
|
33
|
+
expiresIn: number;
|
|
34
|
+
interval: number;
|
|
35
|
+
}
|
|
36
|
+
interface AuthCodeChallenge {
|
|
37
|
+
url: string;
|
|
38
|
+
state: string;
|
|
39
|
+
codeVerifier: string;
|
|
40
|
+
redirectUri: string;
|
|
41
|
+
}
|
|
42
|
+
interface AuthCodeExchangeResult {
|
|
43
|
+
accessToken: string;
|
|
44
|
+
tokenType: string;
|
|
45
|
+
expiresIn: number;
|
|
46
|
+
scopes: string[];
|
|
47
|
+
}
|
|
48
|
+
interface IssuedWorkspaceToken {
|
|
49
|
+
token: string;
|
|
50
|
+
expiresAt: string;
|
|
51
|
+
scopes: string[];
|
|
52
|
+
}
|
|
53
|
+
interface MyWorkspace {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
tenantId: string;
|
|
58
|
+
organizationId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface AuthApi {
|
|
62
|
+
signIn(input: SignInInput): Promise<AuthPayload>;
|
|
63
|
+
signUp(input: SignUpInput): Promise<AuthPayload>;
|
|
64
|
+
refreshToken(): Promise<TokenPair>;
|
|
65
|
+
signOut(): Promise<void>;
|
|
66
|
+
getCurrentUser(): Promise<User>;
|
|
67
|
+
isAuthenticated(): Promise<boolean>;
|
|
68
|
+
loginWithApiKey(apiKey: string): Promise<void>;
|
|
69
|
+
loginWithClientCredentials(clientId: string, clientSecret: string): Promise<TokenPair>;
|
|
70
|
+
authenticateApp(clientId: string, clientSecret: string, scopes?: string[]): Promise<AuthCodeExchangeResult>;
|
|
71
|
+
startDeviceCodeFlow(scopes?: string[]): Promise<DeviceCodeResponse>;
|
|
72
|
+
pollDeviceCodeAuth(deviceCode: string, interval?: number): Promise<TokenPair>;
|
|
73
|
+
loginWithDeviceCode(scopes?: string[]): Promise<{
|
|
74
|
+
userCode: string;
|
|
75
|
+
verificationUri: string;
|
|
76
|
+
promise: Promise<TokenPair>;
|
|
77
|
+
}>;
|
|
78
|
+
buildAuthorizationUrl(opts?: {
|
|
79
|
+
redirectUri?: string;
|
|
80
|
+
scopes?: string[];
|
|
81
|
+
state?: string;
|
|
82
|
+
}): AuthCodeChallenge;
|
|
83
|
+
exchangeAuthCode(code: string, codeVerifier: string, redirectUri?: string): Promise<TokenPair>;
|
|
84
|
+
fetchWorkspaces(limit?: number): Promise<MyWorkspace[]>;
|
|
85
|
+
issueWorkspaceToken(workspaceId: string, organizationId: string): Promise<IssuedWorkspaceToken>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare function generateCodeVerifier(length?: number): string;
|
|
89
|
+
declare function generateCodeChallenge(verifier: string): string;
|
|
90
|
+
declare function generateState(): string;
|
|
91
|
+
|
|
92
|
+
declare const authModule: SdkModule<AuthApi>;
|
|
93
|
+
|
|
94
|
+
export { type AuthApi, type AuthCodeChallenge, type AuthCodeExchangeResult, type AuthPayload, type DeviceCodeResponse, type IssuedWorkspaceToken, type MyWorkspace, type SignInInput, type SignUpInput, type User, authModule as default, generateCodeChallenge, generateCodeVerifier, generateState };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { T as TokenPair, S as SdkModule } from '../../module-JDbvil5h.js';
|
|
2
|
+
import 'graphql-request';
|
|
3
|
+
|
|
4
|
+
interface User {
|
|
5
|
+
id: string;
|
|
6
|
+
email: string;
|
|
7
|
+
username: string;
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
emailVerified?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface AuthPayload {
|
|
12
|
+
user: User;
|
|
13
|
+
accessToken: string;
|
|
14
|
+
refreshToken: string;
|
|
15
|
+
expiresIn: number;
|
|
16
|
+
}
|
|
17
|
+
interface SignInInput {
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
}
|
|
21
|
+
interface SignUpInput {
|
|
22
|
+
email: string;
|
|
23
|
+
username: string;
|
|
24
|
+
password: string;
|
|
25
|
+
firstName?: string;
|
|
26
|
+
lastName?: string;
|
|
27
|
+
}
|
|
28
|
+
interface DeviceCodeResponse {
|
|
29
|
+
deviceCode: string;
|
|
30
|
+
userCode: string;
|
|
31
|
+
verificationUri: string;
|
|
32
|
+
verificationUriComplete: string | null;
|
|
33
|
+
expiresIn: number;
|
|
34
|
+
interval: number;
|
|
35
|
+
}
|
|
36
|
+
interface AuthCodeChallenge {
|
|
37
|
+
url: string;
|
|
38
|
+
state: string;
|
|
39
|
+
codeVerifier: string;
|
|
40
|
+
redirectUri: string;
|
|
41
|
+
}
|
|
42
|
+
interface AuthCodeExchangeResult {
|
|
43
|
+
accessToken: string;
|
|
44
|
+
tokenType: string;
|
|
45
|
+
expiresIn: number;
|
|
46
|
+
scopes: string[];
|
|
47
|
+
}
|
|
48
|
+
interface IssuedWorkspaceToken {
|
|
49
|
+
token: string;
|
|
50
|
+
expiresAt: string;
|
|
51
|
+
scopes: string[];
|
|
52
|
+
}
|
|
53
|
+
interface MyWorkspace {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
tenantId: string;
|
|
58
|
+
organizationId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface AuthApi {
|
|
62
|
+
signIn(input: SignInInput): Promise<AuthPayload>;
|
|
63
|
+
signUp(input: SignUpInput): Promise<AuthPayload>;
|
|
64
|
+
refreshToken(): Promise<TokenPair>;
|
|
65
|
+
signOut(): Promise<void>;
|
|
66
|
+
getCurrentUser(): Promise<User>;
|
|
67
|
+
isAuthenticated(): Promise<boolean>;
|
|
68
|
+
loginWithApiKey(apiKey: string): Promise<void>;
|
|
69
|
+
loginWithClientCredentials(clientId: string, clientSecret: string): Promise<TokenPair>;
|
|
70
|
+
authenticateApp(clientId: string, clientSecret: string, scopes?: string[]): Promise<AuthCodeExchangeResult>;
|
|
71
|
+
startDeviceCodeFlow(scopes?: string[]): Promise<DeviceCodeResponse>;
|
|
72
|
+
pollDeviceCodeAuth(deviceCode: string, interval?: number): Promise<TokenPair>;
|
|
73
|
+
loginWithDeviceCode(scopes?: string[]): Promise<{
|
|
74
|
+
userCode: string;
|
|
75
|
+
verificationUri: string;
|
|
76
|
+
promise: Promise<TokenPair>;
|
|
77
|
+
}>;
|
|
78
|
+
buildAuthorizationUrl(opts?: {
|
|
79
|
+
redirectUri?: string;
|
|
80
|
+
scopes?: string[];
|
|
81
|
+
state?: string;
|
|
82
|
+
}): AuthCodeChallenge;
|
|
83
|
+
exchangeAuthCode(code: string, codeVerifier: string, redirectUri?: string): Promise<TokenPair>;
|
|
84
|
+
fetchWorkspaces(limit?: number): Promise<MyWorkspace[]>;
|
|
85
|
+
issueWorkspaceToken(workspaceId: string, organizationId: string): Promise<IssuedWorkspaceToken>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare function generateCodeVerifier(length?: number): string;
|
|
89
|
+
declare function generateCodeChallenge(verifier: string): string;
|
|
90
|
+
declare function generateState(): string;
|
|
91
|
+
|
|
92
|
+
declare const authModule: SdkModule<AuthApi>;
|
|
93
|
+
|
|
94
|
+
export { type AuthApi, type AuthCodeChallenge, type AuthCodeExchangeResult, type AuthPayload, type DeviceCodeResponse, type IssuedWorkspaceToken, type MyWorkspace, type SignInInput, type SignUpInput, type User, authModule as default, generateCodeChallenge, generateCodeVerifier, generateState };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {c,e,i,h}from'../../chunk-NEREAHJ6.js';import ee from'cross-fetch';import {randomBytes,createHash}from'crypto';function A(p=64){return randomBytes(p).toString("base64url").slice(0,p)}function P(p){return createHash("sha256").update(p).digest("base64url")}function y(){return randomBytes(32).toString("base64url")}var I=`
|
|
2
|
+
fragment AuthUser on User {
|
|
3
|
+
id
|
|
4
|
+
email
|
|
5
|
+
username
|
|
6
|
+
}
|
|
7
|
+
`,v=`
|
|
8
|
+
${I}
|
|
9
|
+
mutation SignUp($input: SignUpInput!) {
|
|
10
|
+
signUp(input: $input) {
|
|
11
|
+
user { ...AuthUser }
|
|
12
|
+
accessToken
|
|
13
|
+
refreshToken
|
|
14
|
+
expiresIn
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`,E=`
|
|
18
|
+
${I}
|
|
19
|
+
mutation SignIn($input: SignInInput!) {
|
|
20
|
+
signIn(input: $input) {
|
|
21
|
+
user { ...AuthUser }
|
|
22
|
+
accessToken
|
|
23
|
+
refreshToken
|
|
24
|
+
expiresIn
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,W=`
|
|
28
|
+
${I}
|
|
29
|
+
mutation RefreshToken($token: String!) {
|
|
30
|
+
refreshToken(token: $token) {
|
|
31
|
+
user { ...AuthUser }
|
|
32
|
+
accessToken
|
|
33
|
+
refreshToken
|
|
34
|
+
expiresIn
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`,$=`
|
|
38
|
+
mutation SignOut {
|
|
39
|
+
signOut
|
|
40
|
+
}
|
|
41
|
+
`,R=`
|
|
42
|
+
mutation AuthenticateApp($input: AuthenticateAppInput!) {
|
|
43
|
+
authenticateApp(input: $input) {
|
|
44
|
+
accessToken
|
|
45
|
+
tokenType
|
|
46
|
+
expiresIn
|
|
47
|
+
scopes
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`,b=`
|
|
51
|
+
mutation IssueWorkspaceToken($input: IssueWorkspaceTokenInput!) {
|
|
52
|
+
issueWorkspaceToken(input: $input) {
|
|
53
|
+
success
|
|
54
|
+
token
|
|
55
|
+
expiresAt
|
|
56
|
+
scopes
|
|
57
|
+
error { code message }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`,O=`
|
|
61
|
+
query MyWorkspaces($limit: Int) {
|
|
62
|
+
myWorkspaces(limit: $limit) {
|
|
63
|
+
items { id name slug tenantId organizationId }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`,q=`
|
|
67
|
+
query Me {
|
|
68
|
+
me { id email username isActive emailVerified }
|
|
69
|
+
}
|
|
70
|
+
`;var m=typeof fetch<"u"?fetch:ee;function D(p){let{gql:l,auth:h$1,oidc:i$1,logger:N}=p;async function g(e){await h$1.setTokens(e);}async function M(e){let t=(await l.global.request(E,{input:e})).signIn;return await g({accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3}),t}async function K(e){let t=(await l.global.request(v,{input:e})).signUp;return await g({accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3}),t}async function j(){let e=await h$1.getTokens();if(!e?.refreshToken)throw new c("No refresh token available");let t=(await l.global.request(W,{token:e.refreshToken})).refreshToken,n={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresAt:Date.now()+t.expiresIn*1e3};return await g(n),n}async function G(){try{await l.global.request($);}catch(e){N.warn(`signOut server-side failed: ${e.message}`);}finally{await h$1.clearTokens();}}async function z(){return (await l.global.request(q)).me}async function F(){let e=await h$1.getTokens();return e?.accessToken?!(e.expiresAt&&Date.now()>=e.expiresAt):!!h$1.getApiKey()}async function V(e){h$1.setApiKey(e);}async function H(e$1,s){if(!i$1.issuer)throw new c("oidcIssuer required for client credentials flow");let t=`${i$1.issuer}/token`,n=new URLSearchParams({grant_type:"client_credentials",client_id:e$1,client_secret:s}).toString(),r;try{r=await m(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n});}catch(d){throw new e(`token endpoint unreachable: ${d.message}`,d)}if(!r.ok){let d=await r.text().catch(()=>"Unknown");throw new c(`client_credentials failed (${r.status}): ${d}`)}let o=await r.json(),u=o.expires_in??3600,c$1={accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresAt:Date.now()+u*1e3};return await g(c$1),c$1}async function L(e,s,t){let r=(await l.global.request(R,{input:{clientId:e,clientSecret:s,scopes:t}})).authenticateApp;return await g({accessToken:r.accessToken,refreshToken:"",expiresAt:Date.now()+r.expiresIn*1e3}),r}async function x(e$1){if(!i$1.issuer)throw new c("oidcIssuer required for device code flow");if(!i$1.clientId)throw new c("clientId required for device code flow");let s=`${i$1.issuer}/oidc/device/code`,t=new URLSearchParams({client_id:i$1.clientId,...e$1&&e$1.length>0?{scope:e$1.join(" ")}:{}}).toString(),n;try{n=await m(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});}catch(o){throw new e(`device endpoint unreachable: ${o.message}`,o)}if(!n.ok){let o=await n.text().catch(()=>"Unknown");throw new c(`device code request failed (${n.status}): ${o}`)}let r=await n.json();return {deviceCode:r.device_code,userCode:r.user_code,verificationUri:r.verification_uri,verificationUriComplete:r.verification_uri_complete??null,expiresIn:r.expires_in,interval:r.interval??5}}async function _(e$1,s=5){if(!i$1.issuer)throw new c("oidcIssuer required");if(!i$1.clientId)throw new c("clientId required");let t=`${i$1.issuer}/oauth/device/token`,n=s;for(;;){await new Promise(c=>setTimeout(c,n*1e3));let r;try{r=await m(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e$1,client_id:i$1.clientId}).toString()});}catch(c){throw new e(`device poll failed: ${c.message}`,c)}let o=await r.json();if(r.ok&&o.access_token){let c=o.expires_in??3600,d={accessToken:o.access_token,refreshToken:o.refresh_token??"",expiresAt:Date.now()+c*1e3};return await g(d),d}let u=o.error;switch(u){case "authorization_pending":continue;case "slow_down":n+=5;continue;case "expired_token":throw new h;case "access_denied":throw new i;default:throw new c(`device code polling failed: ${o.error_description??u??"Unknown"}`)}}}async function B(e){let s=await x(e),t=_(s.deviceCode,s.interval);return {userCode:s.userCode,verificationUri:s.verificationUri,promise:t}}function Y(e){if(!i$1.issuer)throw new c("oidcIssuer required");if(!i$1.clientId)throw new c("clientId required");let s=A(),t=P(s),n=e?.state??y(),r=e?.redirectUri??i$1.redirectUri??"http://localhost:8400/callback",o=e?.scopes??["openid","profile","email","offline_access"],u=new URLSearchParams({response_type:"code",client_id:i$1.clientId,redirect_uri:r,scope:o.join(" "),code_challenge:t,code_challenge_method:"S256",state:n});return {url:`${i$1.issuer}/oidc/auth?${u.toString()}`,state:n,codeVerifier:s,redirectUri:r}}async function J(e$1,s,t){if(!i$1.issuer)throw new c("oidcIssuer required");if(!i$1.clientId)throw new c("clientId required");let n=`${i$1.issuer}/oidc/token`,r=new URLSearchParams({grant_type:"authorization_code",code:e$1,redirect_uri:t??i$1.redirectUri??"http://localhost:8400/callback",client_id:i$1.clientId,code_verifier:s}).toString(),o;try{o=await m(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r});}catch(f){throw new e(`auth code exchange failed: ${f.message}`,f)}if(!o.ok){let f=await o.text().catch(()=>"Unknown");throw new c(`auth code exchange failed (${o.status}): ${f}`)}let u=await o.json(),c$1=u.expires_in??3600,d={accessToken:u.access_token,refreshToken:u.refresh_token??"",expiresAt:Date.now()+c$1*1e3};return await g(d),d}async function Q(e=50){return (await l.global.request(O,{limit:e})).myWorkspaces.items}async function X(e,s){let n=(await l.workspaceAuthOnly.request(b,{input:{workspaceId:e,organizationId:s}})).issueWorkspaceToken;if(!n.success||!n.token)throw new c(`Workspace token issuance failed: ${n.error?.message??"Unknown"}`);return h$1.setWorkspaceToken(n.token),{token:n.token,expiresAt:n.expiresAt,scopes:n.scopes??[]}}return {signIn:M,signUp:K,refreshToken:j,signOut:G,getCurrentUser:z,isAuthenticated:F,loginWithApiKey:V,loginWithClientCredentials:H,authenticateApp:L,startDeviceCodeFlow:x,pollDeviceCodeAuth:_,loginWithDeviceCode:B,buildAuthorizationUrl:Y,exchangeAuthCode:J,fetchWorkspaces:Q,issueWorkspaceToken:X}}var te={id:"auth",version:"1.0.0",displayName:"Auth",attach(p){return D(p)}},ge=te;
|
|
71
|
+
export{ge as default,P as generateCodeChallenge,A as generateCodeVerifier,y as generateState};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';var r=`
|
|
2
|
+
query GetActiveSubscriptions($billingAccountId: ID!) {
|
|
3
|
+
getActiveSubscriptions(billingAccountId: $billingAccountId) {
|
|
4
|
+
id status seatCount nextBillingDate startDate endDate billingAccountId planId
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
`,s=`
|
|
8
|
+
query GetSubscription($id: ID!) {
|
|
9
|
+
getSubscription(id: $id) {
|
|
10
|
+
id status startDate endDate seatCount billingAccountId planId
|
|
11
|
+
autoRenewal canceledAt cancellationReason
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`,u=`
|
|
15
|
+
query GetPaginatedSubscriptions(
|
|
16
|
+
$billingAccountId: ID
|
|
17
|
+
$page: Int
|
|
18
|
+
$pageSize: Int
|
|
19
|
+
) {
|
|
20
|
+
getPaginatedSubscriptions(
|
|
21
|
+
billingAccountId: $billingAccountId
|
|
22
|
+
page: $page
|
|
23
|
+
pageSize: $pageSize
|
|
24
|
+
) {
|
|
25
|
+
subscriptions {
|
|
26
|
+
id billingAccountId planId status startDate endDate
|
|
27
|
+
recurrence autoRenewal seatCount lastSeatChangeAt paymentGateway
|
|
28
|
+
canceledAt cancellationReason canceledBy nextBillingDate
|
|
29
|
+
lastBillingDate lastRenewalDate context createdAt updatedAt
|
|
30
|
+
}
|
|
31
|
+
totalCount hasMore page pageSize totalPages
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`,d=`
|
|
35
|
+
mutation UpdateSubscriptionSeats($input: UpdateSubscriptionSeatsInput!) {
|
|
36
|
+
updateSubscriptionSeats(input: $input) {
|
|
37
|
+
id seatCount lastSeatChangeAt
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`,p=`
|
|
41
|
+
mutation CancelSubscription($input: CancelSubscriptionInput!) {
|
|
42
|
+
cancelSubscription(input: $input) {
|
|
43
|
+
id status canceledAt cancellationReason
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`,c=`
|
|
47
|
+
query GetAllPlans($filter: PlanFilterInput) {
|
|
48
|
+
getAllPlans(filter: $filter) {
|
|
49
|
+
id name description price currency duration productId isActive
|
|
50
|
+
features metadata createdAt updatedAt
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`,l=`
|
|
54
|
+
query GetPlan($id: ID!) {
|
|
55
|
+
getPlan(id: $id) {
|
|
56
|
+
id name description price currency duration productId isActive
|
|
57
|
+
features metadata createdAt updatedAt
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`,A=`
|
|
61
|
+
query GetAllAddOns($filter: AddOnFilterInput, $limit: Int) {
|
|
62
|
+
getAllAddOns(filter: $filter, limit: $limit) {
|
|
63
|
+
id name description price currency productId isActive createdAt updatedAt
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`,g=`
|
|
67
|
+
query GetAddOn($id: ID!) {
|
|
68
|
+
getAddOn(id: $id) {
|
|
69
|
+
id name description price currency productId isActive createdAt updatedAt
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`,m=`
|
|
73
|
+
query GetPaginatedInvoices($billingAccountId: ID!, $page: Int, $pageSize: Int) {
|
|
74
|
+
getPaginatedInvoices(billingAccountId: $billingAccountId, page: $page, pageSize: $pageSize) {
|
|
75
|
+
invoices {
|
|
76
|
+
id invoiceNumber billingAccountId status amount currency
|
|
77
|
+
dueDate paidAt pdfUrl metadata createdAt updatedAt
|
|
78
|
+
}
|
|
79
|
+
totalCount hasMore
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`,y=`
|
|
83
|
+
query GetInvoice($id: ID!) {
|
|
84
|
+
getInvoice(id: $id) {
|
|
85
|
+
id invoiceNumber billingAccountId status amount currency
|
|
86
|
+
dueDate paidAt pdfUrl metadata createdAt updatedAt
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`,I=`
|
|
90
|
+
query GetCoupons($filter: CouponFilterInput) {
|
|
91
|
+
getCoupons(filter: $filter) {
|
|
92
|
+
coupons {
|
|
93
|
+
id code description discountType discountValue currency
|
|
94
|
+
expiresAt maxRedemptions redemptions isActive createdAt updatedAt
|
|
95
|
+
}
|
|
96
|
+
totalCount
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`,S=`
|
|
100
|
+
query GetCoupon($code: String!) {
|
|
101
|
+
getCoupon(code: $code) {
|
|
102
|
+
id code description discountType discountValue currency
|
|
103
|
+
expiresAt maxRedemptions redemptions isActive
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`,C=`
|
|
107
|
+
mutation CreateCoupon($input: CreateCouponInput!) {
|
|
108
|
+
createCoupon(input: $input) {
|
|
109
|
+
id code discountType discountValue isActive
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`,P=`
|
|
113
|
+
mutation UpdateCoupon($id: ID!, $input: UpdateCouponInput!) {
|
|
114
|
+
updateCoupon(id: $id, input: $input) {
|
|
115
|
+
id code description discountValue isActive
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`,f=`
|
|
119
|
+
query GetPendingRefunds($page: Int, $pageSize: Int) {
|
|
120
|
+
getPendingRefunds(page: $page, pageSize: $pageSize) {
|
|
121
|
+
records { id paymentId invoiceId amount currency status reason createdAt updatedAt }
|
|
122
|
+
totalCount page pageSize totalPages
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`,b=`
|
|
126
|
+
mutation RequestRefund($input: RequestRefundInput!) {
|
|
127
|
+
requestRefund(input: $input) {
|
|
128
|
+
id paymentId invoiceId amount status reason
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`,R=`
|
|
132
|
+
query GetCreditBalance($billingAccountId: ID!) {
|
|
133
|
+
getCreditBalance(billingAccountId: $billingAccountId) {
|
|
134
|
+
total
|
|
135
|
+
byType { type balance }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
`,T=`
|
|
139
|
+
mutation SpendCredits($input: SpendCreditsInput!) {
|
|
140
|
+
spendCredits(input: $input) {
|
|
141
|
+
success remainingBalance transactionId error
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`,E=`
|
|
145
|
+
mutation RequestCreditWithdrawal($input: RequestCreditWithdrawalInput!) {
|
|
146
|
+
requestCreditWithdrawal(input: $input) {
|
|
147
|
+
id billingAccountId amount status createdAt
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
`,q=`
|
|
151
|
+
query GetUsageDashboard($period: AnalyticsPeriod!) {
|
|
152
|
+
getUsageDashboard(period: $period) {
|
|
153
|
+
period totalEvents byTag byResource
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`,x=`
|
|
157
|
+
query GetPaymentMethods($billingAccountId: ID!) {
|
|
158
|
+
getPaymentMethods(billingAccountId: $billingAccountId) {
|
|
159
|
+
id billingAccountId type brand last4 expiryMonth expiryYear
|
|
160
|
+
isDefault createdAt updatedAt
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`,D=`
|
|
164
|
+
mutation AddPaymentMethod($input: AddPaymentMethodInput!) {
|
|
165
|
+
addPaymentMethod(input: $input) {
|
|
166
|
+
id billingAccountId type brand last4 isDefault
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`,U=`
|
|
170
|
+
mutation DeletePaymentMethod($id: ID!) {
|
|
171
|
+
deletePaymentMethod(id: $id) { success }
|
|
172
|
+
}
|
|
173
|
+
`,_=`
|
|
174
|
+
query GetEarningsSummary($billingAccountId: ID!) {
|
|
175
|
+
getEarningsSummary(billingAccountId: $billingAccountId) {
|
|
176
|
+
billingAccountId totalEarned totalPaid pendingPayout currency
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
`,$=`
|
|
180
|
+
query GetPayoutAccounts($billingAccountId: ID!) {
|
|
181
|
+
getPayoutAccounts(billingAccountId: $billingAccountId) {
|
|
182
|
+
id billingAccountId type isDefault metadata createdAt
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`,h=`
|
|
186
|
+
mutation AddPayoutAccount($input: AddPayoutAccountInput!) {
|
|
187
|
+
addPayoutAccount(input: $input) {
|
|
188
|
+
id billingAccountId type isDefault
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
`,O=`
|
|
192
|
+
mutation RequestPayout($input: RequestPayoutInput!) {
|
|
193
|
+
requestPayout(input: $input) {
|
|
194
|
+
id billingAccountId amount status createdAt
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`,N=`
|
|
198
|
+
mutation CreateCheckoutSession($planId: ID!, $opts: CheckoutSessionInput) {
|
|
199
|
+
createCheckoutSession(planId: $planId, opts: $opts) {
|
|
200
|
+
url sessionId
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;function M(i){let{global:e}=i.gql;return {async list(t,n){return (await e.request(A,{filter:t,limit:n?.limit})).getAllAddOns},async get(t){return (await e.request(g,{id:t})).getAddOn}}}function v(i){let{global:e}=i.gql;return {async earnings(t){return (await e.request(_,{billingAccountId:t})).getEarningsSummary},async payoutAccounts(t){return (await e.request($,{billingAccountId:t})).getPayoutAccounts},async addPayoutAccount(t){return (await e.request(h,{input:t})).addPayoutAccount},async requestPayout(t){return (await e.request(O,{input:t})).requestPayout}}}function B(i){let{global:e}=i.gql;return {async list(t){return (await e.request(I,{filter:t})).getCoupons},async get(t){return (await e.request(S,{code:t})).getCoupon},async create(t){return (await e.request(C,{input:t})).createCoupon},async update(t,n){return (await e.request(P,{id:t,input:n})).updateCoupon}}}function G(i){let{global:e}=i.gql;return {async balance(t){return (await e.request(R,{billingAccountId:t})).getCreditBalance},async spend(t){return (await e.request(T,{input:t})).spendCredits},async withdraw(t){return (await e.request(E,{input:t})).requestCreditWithdrawal}}}function w(i){let{global:e}=i.gql;return {async list(t,n){return (await e.request(m,{billingAccountId:t,page:n?.page,pageSize:n?.pageSize})).getPaginatedInvoices},async get(t){return (await e.request(y,{id:t})).getInvoice}}}function k(i){let{global:e}=i.gql;return {async list(t){return (await e.request(x,{billingAccountId:t})).getPaymentMethods},async add(t){return (await e.request(D,{input:t})).addPaymentMethod},async delete(t){return (await e.request(U,{id:t})).deletePaymentMethod}}}function L(i){let{global:e}=i.gql;return {async list(t){return (await e.request(c,{filter:t})).getAllPlans},async get(t){return (await e.request(l,{id:t})).getPlan}}}function j(i){let{global:e}=i.gql;return {async list(t){return (await e.request(f,{page:t?.page,pageSize:t?.pageSize})).getPendingRefunds},async request(t){return (await e.request(b,{input:t})).requestRefund}}}function z(i){let{global:e}=i.gql;return {async list(t){return (await e.request(u,{billingAccountId:t?.billingAccountId,page:t?.page,pageSize:t?.pageSize})).getPaginatedSubscriptions},async get(t){return (await e.request(s,{id:t})).getSubscription},async active(t){return (await e.request(r,{billingAccountId:t})).getActiveSubscriptions},async updateSeats(t){return (await e.request(d,{input:t})).updateSubscriptionSeats},async cancel(t){return (await e.request(p,{input:t})).cancelSubscription}}}function F(i){let{global:e}=i.gql;return {async dashboard(t){return (await e.request(q,{period:t})).getUsageDashboard}}}var Y={id:"billing",version:"1.0.0",displayName:"Billing",dependsOn:["auth"],attach(i){let{global:e}=i.gql;return {subscriptions:z(i),plans:L(i),addons:M(i),invoices:w(i),coupons:B(i),refunds:j(i),credits:G(i),usage:F(i),paymentMethods:k(i),affiliate:v(i),async getCheckoutUrl(t,n){return (await e.request(N,{planId:t,opts:n})).createCheckoutSession}}}},Mt=Y;module.exports=Mt;
|