@shadowob/oauth 1.1.1 → 1.1.3-dev.251
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.cjs +110 -0
- package/dist/index.d.cts +100 -2
- package/dist/index.d.ts +100 -2
- package/dist/index.js +110 -0
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -124,6 +124,116 @@ var ShadowOAuth = class {
|
|
|
124
124
|
}
|
|
125
125
|
return res.json();
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Get user's server list. Requires `servers:read` scope.
|
|
129
|
+
*/
|
|
130
|
+
async getServers(accessToken) {
|
|
131
|
+
return this.oauthGet("/api/oauth/servers", accessToken);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a server. Requires `servers:write` scope.
|
|
135
|
+
*/
|
|
136
|
+
async createServer(accessToken, data) {
|
|
137
|
+
return this.oauthPost("/api/oauth/servers", accessToken, data);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Invite a user to a server. Requires `servers:write` scope.
|
|
141
|
+
*/
|
|
142
|
+
async inviteToServer(accessToken, serverId, data) {
|
|
143
|
+
return this.oauthPost(
|
|
144
|
+
`/api/oauth/servers/${serverId}/invite`,
|
|
145
|
+
accessToken,
|
|
146
|
+
data
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get channels for a server. Requires `channels:read` scope.
|
|
151
|
+
*/
|
|
152
|
+
async getChannels(accessToken, serverId) {
|
|
153
|
+
return this.oauthGet(
|
|
154
|
+
`/api/oauth/servers/${serverId}/channels`,
|
|
155
|
+
accessToken
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Create a channel in a server. Requires `channels:write` scope.
|
|
160
|
+
*/
|
|
161
|
+
async createChannel(accessToken, data) {
|
|
162
|
+
return this.oauthPost("/api/oauth/channels", accessToken, data);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get message history for a channel. Requires `messages:read` scope.
|
|
166
|
+
*/
|
|
167
|
+
async getMessages(accessToken, channelId, options) {
|
|
168
|
+
const params = new URLSearchParams();
|
|
169
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
170
|
+
if (options?.cursor) params.set("cursor", options.cursor);
|
|
171
|
+
const qs = params.toString();
|
|
172
|
+
const path = `/api/oauth/channels/${channelId}/messages${qs ? `?${qs}` : ""}`;
|
|
173
|
+
return this.oauthGet(path, accessToken);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Send a message to a channel. Requires `messages:write` scope.
|
|
177
|
+
*/
|
|
178
|
+
async sendMessage(accessToken, channelId, data) {
|
|
179
|
+
return this.oauthPost(
|
|
180
|
+
`/api/oauth/channels/${channelId}/messages`,
|
|
181
|
+
accessToken,
|
|
182
|
+
data
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get workspace info. Requires `workspaces:read` scope.
|
|
187
|
+
*/
|
|
188
|
+
async getWorkspace(accessToken, workspaceId) {
|
|
189
|
+
return this.oauthGet(`/api/oauth/workspaces/${workspaceId}`, accessToken);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Create a Buddy bot. Requires `buddies:create` scope.
|
|
193
|
+
*/
|
|
194
|
+
async createBuddy(accessToken, data) {
|
|
195
|
+
return this.oauthPost("/api/oauth/buddies", accessToken, data);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Send a message as a Buddy. Requires `buddies:manage` scope.
|
|
199
|
+
*/
|
|
200
|
+
async sendBuddyMessage(accessToken, buddyId, data) {
|
|
201
|
+
return this.oauthPost(
|
|
202
|
+
`/api/oauth/buddies/${buddyId}/messages`,
|
|
203
|
+
accessToken,
|
|
204
|
+
data
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
// ─── Private helpers ─────────────────────────────
|
|
208
|
+
async oauthGet(path, accessToken) {
|
|
209
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
210
|
+
headers: {
|
|
211
|
+
Authorization: `Bearer ${accessToken}`,
|
|
212
|
+
Accept: "application/json"
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
if (!res.ok) {
|
|
216
|
+
const body = await res.text().catch(() => "");
|
|
217
|
+
throw new Error(`Shadow OAuth API failed (${res.status}): ${body}`);
|
|
218
|
+
}
|
|
219
|
+
return res.json();
|
|
220
|
+
}
|
|
221
|
+
async oauthPost(path, accessToken, data) {
|
|
222
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
223
|
+
method: "POST",
|
|
224
|
+
headers: {
|
|
225
|
+
Authorization: `Bearer ${accessToken}`,
|
|
226
|
+
"Content-Type": "application/json",
|
|
227
|
+
Accept: "application/json"
|
|
228
|
+
},
|
|
229
|
+
body: JSON.stringify(data)
|
|
230
|
+
});
|
|
231
|
+
if (!res.ok) {
|
|
232
|
+
const body = await res.text().catch(() => "");
|
|
233
|
+
throw new Error(`Shadow OAuth API failed (${res.status}): ${body}`);
|
|
234
|
+
}
|
|
235
|
+
return res.json();
|
|
236
|
+
}
|
|
127
237
|
};
|
|
128
238
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
239
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -22,7 +22,38 @@ interface ShadowOAuthUser {
|
|
|
22
22
|
avatarUrl: string | null;
|
|
23
23
|
email?: string;
|
|
24
24
|
}
|
|
25
|
-
type ShadowOAuthScope = 'user:read' | 'user:email';
|
|
25
|
+
type ShadowOAuthScope = 'user:read' | 'user:email' | 'servers:read' | 'servers:write' | 'channels:read' | 'channels:write' | 'messages:read' | 'messages:write' | 'attachments:read' | 'attachments:write' | 'workspaces:read' | 'workspaces:write' | 'buddies:create' | 'buddies:manage';
|
|
26
|
+
interface ShadowOAuthServer {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
slug: string | null;
|
|
30
|
+
iconUrl: string | null;
|
|
31
|
+
isPublic: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface ShadowOAuthChannel {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
topic: string | null;
|
|
38
|
+
}
|
|
39
|
+
interface ShadowOAuthMessage {
|
|
40
|
+
id: string;
|
|
41
|
+
content: string;
|
|
42
|
+
channelId: string;
|
|
43
|
+
authorId: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
}
|
|
46
|
+
interface ShadowOAuthWorkspace {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string | null;
|
|
50
|
+
serverId: string;
|
|
51
|
+
}
|
|
52
|
+
interface ShadowOAuthBuddy {
|
|
53
|
+
id: string;
|
|
54
|
+
userId: string;
|
|
55
|
+
agentId: string;
|
|
56
|
+
}
|
|
26
57
|
|
|
27
58
|
/**
|
|
28
59
|
* Shadow OAuth SDK client.
|
|
@@ -73,6 +104,73 @@ declare class ShadowOAuth {
|
|
|
73
104
|
* Get the authenticated user's information using an access token.
|
|
74
105
|
*/
|
|
75
106
|
getUser(accessToken: string): Promise<ShadowOAuthUser>;
|
|
107
|
+
/**
|
|
108
|
+
* Get user's server list. Requires `servers:read` scope.
|
|
109
|
+
*/
|
|
110
|
+
getServers(accessToken: string): Promise<ShadowOAuthServer[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Create a server. Requires `servers:write` scope.
|
|
113
|
+
*/
|
|
114
|
+
createServer(accessToken: string, data: {
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
}): Promise<ShadowOAuthServer>;
|
|
118
|
+
/**
|
|
119
|
+
* Invite a user to a server. Requires `servers:write` scope.
|
|
120
|
+
*/
|
|
121
|
+
inviteToServer(accessToken: string, serverId: string, data: {
|
|
122
|
+
userId: string;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
ok: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Get channels for a server. Requires `channels:read` scope.
|
|
128
|
+
*/
|
|
129
|
+
getChannels(accessToken: string, serverId: string): Promise<ShadowOAuthChannel[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Create a channel in a server. Requires `channels:write` scope.
|
|
132
|
+
*/
|
|
133
|
+
createChannel(accessToken: string, data: {
|
|
134
|
+
serverId: string;
|
|
135
|
+
name: string;
|
|
136
|
+
type?: string;
|
|
137
|
+
}): Promise<ShadowOAuthChannel>;
|
|
138
|
+
/**
|
|
139
|
+
* Get message history for a channel. Requires `messages:read` scope.
|
|
140
|
+
*/
|
|
141
|
+
getMessages(accessToken: string, channelId: string, options?: {
|
|
142
|
+
limit?: number;
|
|
143
|
+
cursor?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
messages: ShadowOAuthMessage[];
|
|
146
|
+
hasMore: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Send a message to a channel. Requires `messages:write` scope.
|
|
150
|
+
*/
|
|
151
|
+
sendMessage(accessToken: string, channelId: string, data: {
|
|
152
|
+
content: string;
|
|
153
|
+
}): Promise<ShadowOAuthMessage>;
|
|
154
|
+
/**
|
|
155
|
+
* Get workspace info. Requires `workspaces:read` scope.
|
|
156
|
+
*/
|
|
157
|
+
getWorkspace(accessToken: string, workspaceId: string): Promise<ShadowOAuthWorkspace>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a Buddy bot. Requires `buddies:create` scope.
|
|
160
|
+
*/
|
|
161
|
+
createBuddy(accessToken: string, data: {
|
|
162
|
+
name: string;
|
|
163
|
+
kernelType?: string;
|
|
164
|
+
}): Promise<ShadowOAuthBuddy>;
|
|
165
|
+
/**
|
|
166
|
+
* Send a message as a Buddy. Requires `buddies:manage` scope.
|
|
167
|
+
*/
|
|
168
|
+
sendBuddyMessage(accessToken: string, buddyId: string, data: {
|
|
169
|
+
channelId: string;
|
|
170
|
+
content: string;
|
|
171
|
+
}): Promise<ShadowOAuthMessage>;
|
|
172
|
+
private oauthGet;
|
|
173
|
+
private oauthPost;
|
|
76
174
|
}
|
|
77
175
|
|
|
78
|
-
export { ShadowOAuth, type ShadowOAuthConfig, type ShadowOAuthScope, type ShadowOAuthTokens, type ShadowOAuthUser };
|
|
176
|
+
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,38 @@ interface ShadowOAuthUser {
|
|
|
22
22
|
avatarUrl: string | null;
|
|
23
23
|
email?: string;
|
|
24
24
|
}
|
|
25
|
-
type ShadowOAuthScope = 'user:read' | 'user:email';
|
|
25
|
+
type ShadowOAuthScope = 'user:read' | 'user:email' | 'servers:read' | 'servers:write' | 'channels:read' | 'channels:write' | 'messages:read' | 'messages:write' | 'attachments:read' | 'attachments:write' | 'workspaces:read' | 'workspaces:write' | 'buddies:create' | 'buddies:manage';
|
|
26
|
+
interface ShadowOAuthServer {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
slug: string | null;
|
|
30
|
+
iconUrl: string | null;
|
|
31
|
+
isPublic: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface ShadowOAuthChannel {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
topic: string | null;
|
|
38
|
+
}
|
|
39
|
+
interface ShadowOAuthMessage {
|
|
40
|
+
id: string;
|
|
41
|
+
content: string;
|
|
42
|
+
channelId: string;
|
|
43
|
+
authorId: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
}
|
|
46
|
+
interface ShadowOAuthWorkspace {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string | null;
|
|
50
|
+
serverId: string;
|
|
51
|
+
}
|
|
52
|
+
interface ShadowOAuthBuddy {
|
|
53
|
+
id: string;
|
|
54
|
+
userId: string;
|
|
55
|
+
agentId: string;
|
|
56
|
+
}
|
|
26
57
|
|
|
27
58
|
/**
|
|
28
59
|
* Shadow OAuth SDK client.
|
|
@@ -73,6 +104,73 @@ declare class ShadowOAuth {
|
|
|
73
104
|
* Get the authenticated user's information using an access token.
|
|
74
105
|
*/
|
|
75
106
|
getUser(accessToken: string): Promise<ShadowOAuthUser>;
|
|
107
|
+
/**
|
|
108
|
+
* Get user's server list. Requires `servers:read` scope.
|
|
109
|
+
*/
|
|
110
|
+
getServers(accessToken: string): Promise<ShadowOAuthServer[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Create a server. Requires `servers:write` scope.
|
|
113
|
+
*/
|
|
114
|
+
createServer(accessToken: string, data: {
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
}): Promise<ShadowOAuthServer>;
|
|
118
|
+
/**
|
|
119
|
+
* Invite a user to a server. Requires `servers:write` scope.
|
|
120
|
+
*/
|
|
121
|
+
inviteToServer(accessToken: string, serverId: string, data: {
|
|
122
|
+
userId: string;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
ok: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Get channels for a server. Requires `channels:read` scope.
|
|
128
|
+
*/
|
|
129
|
+
getChannels(accessToken: string, serverId: string): Promise<ShadowOAuthChannel[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Create a channel in a server. Requires `channels:write` scope.
|
|
132
|
+
*/
|
|
133
|
+
createChannel(accessToken: string, data: {
|
|
134
|
+
serverId: string;
|
|
135
|
+
name: string;
|
|
136
|
+
type?: string;
|
|
137
|
+
}): Promise<ShadowOAuthChannel>;
|
|
138
|
+
/**
|
|
139
|
+
* Get message history for a channel. Requires `messages:read` scope.
|
|
140
|
+
*/
|
|
141
|
+
getMessages(accessToken: string, channelId: string, options?: {
|
|
142
|
+
limit?: number;
|
|
143
|
+
cursor?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
messages: ShadowOAuthMessage[];
|
|
146
|
+
hasMore: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Send a message to a channel. Requires `messages:write` scope.
|
|
150
|
+
*/
|
|
151
|
+
sendMessage(accessToken: string, channelId: string, data: {
|
|
152
|
+
content: string;
|
|
153
|
+
}): Promise<ShadowOAuthMessage>;
|
|
154
|
+
/**
|
|
155
|
+
* Get workspace info. Requires `workspaces:read` scope.
|
|
156
|
+
*/
|
|
157
|
+
getWorkspace(accessToken: string, workspaceId: string): Promise<ShadowOAuthWorkspace>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a Buddy bot. Requires `buddies:create` scope.
|
|
160
|
+
*/
|
|
161
|
+
createBuddy(accessToken: string, data: {
|
|
162
|
+
name: string;
|
|
163
|
+
kernelType?: string;
|
|
164
|
+
}): Promise<ShadowOAuthBuddy>;
|
|
165
|
+
/**
|
|
166
|
+
* Send a message as a Buddy. Requires `buddies:manage` scope.
|
|
167
|
+
*/
|
|
168
|
+
sendBuddyMessage(accessToken: string, buddyId: string, data: {
|
|
169
|
+
channelId: string;
|
|
170
|
+
content: string;
|
|
171
|
+
}): Promise<ShadowOAuthMessage>;
|
|
172
|
+
private oauthGet;
|
|
173
|
+
private oauthPost;
|
|
76
174
|
}
|
|
77
175
|
|
|
78
|
-
export { ShadowOAuth, type ShadowOAuthConfig, type ShadowOAuthScope, type ShadowOAuthTokens, type ShadowOAuthUser };
|
|
176
|
+
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
package/dist/index.js
CHANGED
|
@@ -98,6 +98,116 @@ var ShadowOAuth = class {
|
|
|
98
98
|
}
|
|
99
99
|
return res.json();
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Get user's server list. Requires `servers:read` scope.
|
|
103
|
+
*/
|
|
104
|
+
async getServers(accessToken) {
|
|
105
|
+
return this.oauthGet("/api/oauth/servers", accessToken);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a server. Requires `servers:write` scope.
|
|
109
|
+
*/
|
|
110
|
+
async createServer(accessToken, data) {
|
|
111
|
+
return this.oauthPost("/api/oauth/servers", accessToken, data);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Invite a user to a server. Requires `servers:write` scope.
|
|
115
|
+
*/
|
|
116
|
+
async inviteToServer(accessToken, serverId, data) {
|
|
117
|
+
return this.oauthPost(
|
|
118
|
+
`/api/oauth/servers/${serverId}/invite`,
|
|
119
|
+
accessToken,
|
|
120
|
+
data
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get channels for a server. Requires `channels:read` scope.
|
|
125
|
+
*/
|
|
126
|
+
async getChannels(accessToken, serverId) {
|
|
127
|
+
return this.oauthGet(
|
|
128
|
+
`/api/oauth/servers/${serverId}/channels`,
|
|
129
|
+
accessToken
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Create a channel in a server. Requires `channels:write` scope.
|
|
134
|
+
*/
|
|
135
|
+
async createChannel(accessToken, data) {
|
|
136
|
+
return this.oauthPost("/api/oauth/channels", accessToken, data);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get message history for a channel. Requires `messages:read` scope.
|
|
140
|
+
*/
|
|
141
|
+
async getMessages(accessToken, channelId, options) {
|
|
142
|
+
const params = new URLSearchParams();
|
|
143
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
144
|
+
if (options?.cursor) params.set("cursor", options.cursor);
|
|
145
|
+
const qs = params.toString();
|
|
146
|
+
const path = `/api/oauth/channels/${channelId}/messages${qs ? `?${qs}` : ""}`;
|
|
147
|
+
return this.oauthGet(path, accessToken);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Send a message to a channel. Requires `messages:write` scope.
|
|
151
|
+
*/
|
|
152
|
+
async sendMessage(accessToken, channelId, data) {
|
|
153
|
+
return this.oauthPost(
|
|
154
|
+
`/api/oauth/channels/${channelId}/messages`,
|
|
155
|
+
accessToken,
|
|
156
|
+
data
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get workspace info. Requires `workspaces:read` scope.
|
|
161
|
+
*/
|
|
162
|
+
async getWorkspace(accessToken, workspaceId) {
|
|
163
|
+
return this.oauthGet(`/api/oauth/workspaces/${workspaceId}`, accessToken);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a Buddy bot. Requires `buddies:create` scope.
|
|
167
|
+
*/
|
|
168
|
+
async createBuddy(accessToken, data) {
|
|
169
|
+
return this.oauthPost("/api/oauth/buddies", accessToken, data);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Send a message as a Buddy. Requires `buddies:manage` scope.
|
|
173
|
+
*/
|
|
174
|
+
async sendBuddyMessage(accessToken, buddyId, data) {
|
|
175
|
+
return this.oauthPost(
|
|
176
|
+
`/api/oauth/buddies/${buddyId}/messages`,
|
|
177
|
+
accessToken,
|
|
178
|
+
data
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
// ─── Private helpers ─────────────────────────────
|
|
182
|
+
async oauthGet(path, accessToken) {
|
|
183
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
184
|
+
headers: {
|
|
185
|
+
Authorization: `Bearer ${accessToken}`,
|
|
186
|
+
Accept: "application/json"
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
if (!res.ok) {
|
|
190
|
+
const body = await res.text().catch(() => "");
|
|
191
|
+
throw new Error(`Shadow OAuth API failed (${res.status}): ${body}`);
|
|
192
|
+
}
|
|
193
|
+
return res.json();
|
|
194
|
+
}
|
|
195
|
+
async oauthPost(path, accessToken, data) {
|
|
196
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
197
|
+
method: "POST",
|
|
198
|
+
headers: {
|
|
199
|
+
Authorization: `Bearer ${accessToken}`,
|
|
200
|
+
"Content-Type": "application/json",
|
|
201
|
+
Accept: "application/json"
|
|
202
|
+
},
|
|
203
|
+
body: JSON.stringify(data)
|
|
204
|
+
});
|
|
205
|
+
if (!res.ok) {
|
|
206
|
+
const body = await res.text().catch(() => "");
|
|
207
|
+
throw new Error(`Shadow OAuth API failed (${res.status}): ${body}`);
|
|
208
|
+
}
|
|
209
|
+
return res.json();
|
|
210
|
+
}
|
|
101
211
|
};
|
|
102
212
|
export {
|
|
103
213
|
ShadowOAuth
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadowob/oauth",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3-dev.251",
|
|
4
4
|
"description": "Shadow OAuth SDK — typed client for integrating Shadow OAuth login into third-party applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsup",
|
|
32
32
|
"dev": "tsup --watch",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
33
34
|
"test": "vitest run",
|
|
34
35
|
"test:watch": "vitest"
|
|
35
36
|
}
|