@shadowob/oauth 1.1.4 → 1.1.6-dev.311
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 +26 -0
- package/dist/index.d.cts +67 -2
- package/dist/index.d.ts +67 -2
- package/dist/index.js +26 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -204,6 +204,32 @@ var ShadowOAuth = class {
|
|
|
204
204
|
data
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Check the current user's entitlement for this OAuth app.
|
|
209
|
+
* Requires `commerce:read` scope.
|
|
210
|
+
*/
|
|
211
|
+
async getCommerceEntitlementAccess(accessToken, params) {
|
|
212
|
+
const qs = new URLSearchParams();
|
|
213
|
+
if (params?.resourceType) qs.set("resourceType", params.resourceType);
|
|
214
|
+
if (params?.resourceId) qs.set("resourceId", params.resourceId);
|
|
215
|
+
if (params?.capability) qs.set("capability", params.capability);
|
|
216
|
+
const query = qs.toString();
|
|
217
|
+
return this.oauthGet(
|
|
218
|
+
`/api/oauth/commerce/entitlements${query ? `?${query}` : ""}`,
|
|
219
|
+
accessToken
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Redeem one current-user entitlement for this OAuth app.
|
|
224
|
+
* Requires `commerce:write` scope.
|
|
225
|
+
*/
|
|
226
|
+
async redeemCommerceEntitlement(accessToken, data) {
|
|
227
|
+
return this.oauthPost(
|
|
228
|
+
"/api/oauth/commerce/entitlements/redeem",
|
|
229
|
+
accessToken,
|
|
230
|
+
data
|
|
231
|
+
);
|
|
232
|
+
}
|
|
207
233
|
// ─── Private helpers ─────────────────────────────
|
|
208
234
|
async oauthGet(path, accessToken) {
|
|
209
235
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
package/dist/index.d.cts
CHANGED
|
@@ -22,7 +22,7 @@ interface ShadowOAuthUser {
|
|
|
22
22
|
avatarUrl: string | null;
|
|
23
23
|
email?: string;
|
|
24
24
|
}
|
|
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';
|
|
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' | 'commerce:read' | 'commerce:write';
|
|
26
26
|
interface ShadowOAuthServer {
|
|
27
27
|
id: string;
|
|
28
28
|
name: string;
|
|
@@ -54,6 +54,57 @@ interface ShadowOAuthBuddy {
|
|
|
54
54
|
userId: string;
|
|
55
55
|
agentId: string;
|
|
56
56
|
}
|
|
57
|
+
interface ShadowOAuthCommerceEntitlementSummary {
|
|
58
|
+
id: string;
|
|
59
|
+
status: string;
|
|
60
|
+
capability: string;
|
|
61
|
+
resourceType: string;
|
|
62
|
+
resourceId: string;
|
|
63
|
+
productId?: string | null;
|
|
64
|
+
shopId?: string | null;
|
|
65
|
+
orderId?: string | null;
|
|
66
|
+
offerId?: string | null;
|
|
67
|
+
expiresAt?: string | null;
|
|
68
|
+
}
|
|
69
|
+
interface ShadowOAuthCommerceEntitlementAccess {
|
|
70
|
+
allowed: boolean;
|
|
71
|
+
status: string;
|
|
72
|
+
reasonCode?: string | null;
|
|
73
|
+
resourceType: string;
|
|
74
|
+
resourceId: string;
|
|
75
|
+
capability: string;
|
|
76
|
+
app: {
|
|
77
|
+
id: string;
|
|
78
|
+
};
|
|
79
|
+
entitlement?: ShadowOAuthCommerceEntitlementSummary | null;
|
|
80
|
+
}
|
|
81
|
+
interface ShadowOAuthCommerceEntitlementRedeemInput {
|
|
82
|
+
idempotencyKey: string;
|
|
83
|
+
resourceType?: string;
|
|
84
|
+
resourceId?: string;
|
|
85
|
+
capability?: string;
|
|
86
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
87
|
+
}
|
|
88
|
+
interface ShadowOAuthCommerceEntitlementRedemption {
|
|
89
|
+
appId: string;
|
|
90
|
+
resourceType: string;
|
|
91
|
+
resourceId: string;
|
|
92
|
+
capability: string;
|
|
93
|
+
idempotencyKey: string;
|
|
94
|
+
redeemedAt: string;
|
|
95
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
96
|
+
}
|
|
97
|
+
interface ShadowOAuthCommerceEntitlementRedeemResult {
|
|
98
|
+
redeemed: true;
|
|
99
|
+
resourceType: string;
|
|
100
|
+
resourceId: string;
|
|
101
|
+
capability: string;
|
|
102
|
+
app: {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
entitlement: ShadowOAuthCommerceEntitlementSummary;
|
|
106
|
+
redemption: ShadowOAuthCommerceEntitlementRedemption;
|
|
107
|
+
}
|
|
57
108
|
|
|
58
109
|
/**
|
|
59
110
|
* Shadow OAuth SDK client.
|
|
@@ -169,8 +220,22 @@ declare class ShadowOAuth {
|
|
|
169
220
|
channelId: string;
|
|
170
221
|
content: string;
|
|
171
222
|
}): Promise<ShadowOAuthMessage>;
|
|
223
|
+
/**
|
|
224
|
+
* Check the current user's entitlement for this OAuth app.
|
|
225
|
+
* Requires `commerce:read` scope.
|
|
226
|
+
*/
|
|
227
|
+
getCommerceEntitlementAccess(accessToken: string, params?: {
|
|
228
|
+
resourceType?: string;
|
|
229
|
+
resourceId?: string;
|
|
230
|
+
capability?: string;
|
|
231
|
+
}): Promise<ShadowOAuthCommerceEntitlementAccess>;
|
|
232
|
+
/**
|
|
233
|
+
* Redeem one current-user entitlement for this OAuth app.
|
|
234
|
+
* Requires `commerce:write` scope.
|
|
235
|
+
*/
|
|
236
|
+
redeemCommerceEntitlement(accessToken: string, data: ShadowOAuthCommerceEntitlementRedeemInput): Promise<ShadowOAuthCommerceEntitlementRedeemResult>;
|
|
172
237
|
private oauthGet;
|
|
173
238
|
private oauthPost;
|
|
174
239
|
}
|
|
175
240
|
|
|
176
|
-
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
|
241
|
+
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthCommerceEntitlementAccess, type ShadowOAuthCommerceEntitlementRedeemInput, type ShadowOAuthCommerceEntitlementRedeemResult, type ShadowOAuthCommerceEntitlementRedemption, type ShadowOAuthCommerceEntitlementSummary, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface ShadowOAuthUser {
|
|
|
22
22
|
avatarUrl: string | null;
|
|
23
23
|
email?: string;
|
|
24
24
|
}
|
|
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';
|
|
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' | 'commerce:read' | 'commerce:write';
|
|
26
26
|
interface ShadowOAuthServer {
|
|
27
27
|
id: string;
|
|
28
28
|
name: string;
|
|
@@ -54,6 +54,57 @@ interface ShadowOAuthBuddy {
|
|
|
54
54
|
userId: string;
|
|
55
55
|
agentId: string;
|
|
56
56
|
}
|
|
57
|
+
interface ShadowOAuthCommerceEntitlementSummary {
|
|
58
|
+
id: string;
|
|
59
|
+
status: string;
|
|
60
|
+
capability: string;
|
|
61
|
+
resourceType: string;
|
|
62
|
+
resourceId: string;
|
|
63
|
+
productId?: string | null;
|
|
64
|
+
shopId?: string | null;
|
|
65
|
+
orderId?: string | null;
|
|
66
|
+
offerId?: string | null;
|
|
67
|
+
expiresAt?: string | null;
|
|
68
|
+
}
|
|
69
|
+
interface ShadowOAuthCommerceEntitlementAccess {
|
|
70
|
+
allowed: boolean;
|
|
71
|
+
status: string;
|
|
72
|
+
reasonCode?: string | null;
|
|
73
|
+
resourceType: string;
|
|
74
|
+
resourceId: string;
|
|
75
|
+
capability: string;
|
|
76
|
+
app: {
|
|
77
|
+
id: string;
|
|
78
|
+
};
|
|
79
|
+
entitlement?: ShadowOAuthCommerceEntitlementSummary | null;
|
|
80
|
+
}
|
|
81
|
+
interface ShadowOAuthCommerceEntitlementRedeemInput {
|
|
82
|
+
idempotencyKey: string;
|
|
83
|
+
resourceType?: string;
|
|
84
|
+
resourceId?: string;
|
|
85
|
+
capability?: string;
|
|
86
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
87
|
+
}
|
|
88
|
+
interface ShadowOAuthCommerceEntitlementRedemption {
|
|
89
|
+
appId: string;
|
|
90
|
+
resourceType: string;
|
|
91
|
+
resourceId: string;
|
|
92
|
+
capability: string;
|
|
93
|
+
idempotencyKey: string;
|
|
94
|
+
redeemedAt: string;
|
|
95
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
96
|
+
}
|
|
97
|
+
interface ShadowOAuthCommerceEntitlementRedeemResult {
|
|
98
|
+
redeemed: true;
|
|
99
|
+
resourceType: string;
|
|
100
|
+
resourceId: string;
|
|
101
|
+
capability: string;
|
|
102
|
+
app: {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
entitlement: ShadowOAuthCommerceEntitlementSummary;
|
|
106
|
+
redemption: ShadowOAuthCommerceEntitlementRedemption;
|
|
107
|
+
}
|
|
57
108
|
|
|
58
109
|
/**
|
|
59
110
|
* Shadow OAuth SDK client.
|
|
@@ -169,8 +220,22 @@ declare class ShadowOAuth {
|
|
|
169
220
|
channelId: string;
|
|
170
221
|
content: string;
|
|
171
222
|
}): Promise<ShadowOAuthMessage>;
|
|
223
|
+
/**
|
|
224
|
+
* Check the current user's entitlement for this OAuth app.
|
|
225
|
+
* Requires `commerce:read` scope.
|
|
226
|
+
*/
|
|
227
|
+
getCommerceEntitlementAccess(accessToken: string, params?: {
|
|
228
|
+
resourceType?: string;
|
|
229
|
+
resourceId?: string;
|
|
230
|
+
capability?: string;
|
|
231
|
+
}): Promise<ShadowOAuthCommerceEntitlementAccess>;
|
|
232
|
+
/**
|
|
233
|
+
* Redeem one current-user entitlement for this OAuth app.
|
|
234
|
+
* Requires `commerce:write` scope.
|
|
235
|
+
*/
|
|
236
|
+
redeemCommerceEntitlement(accessToken: string, data: ShadowOAuthCommerceEntitlementRedeemInput): Promise<ShadowOAuthCommerceEntitlementRedeemResult>;
|
|
172
237
|
private oauthGet;
|
|
173
238
|
private oauthPost;
|
|
174
239
|
}
|
|
175
240
|
|
|
176
|
-
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
|
241
|
+
export { ShadowOAuth, type ShadowOAuthBuddy, type ShadowOAuthChannel, type ShadowOAuthCommerceEntitlementAccess, type ShadowOAuthCommerceEntitlementRedeemInput, type ShadowOAuthCommerceEntitlementRedeemResult, type ShadowOAuthCommerceEntitlementRedemption, type ShadowOAuthCommerceEntitlementSummary, type ShadowOAuthConfig, type ShadowOAuthMessage, type ShadowOAuthScope, type ShadowOAuthServer, type ShadowOAuthTokens, type ShadowOAuthUser, type ShadowOAuthWorkspace };
|
package/dist/index.js
CHANGED
|
@@ -178,6 +178,32 @@ var ShadowOAuth = class {
|
|
|
178
178
|
data
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Check the current user's entitlement for this OAuth app.
|
|
183
|
+
* Requires `commerce:read` scope.
|
|
184
|
+
*/
|
|
185
|
+
async getCommerceEntitlementAccess(accessToken, params) {
|
|
186
|
+
const qs = new URLSearchParams();
|
|
187
|
+
if (params?.resourceType) qs.set("resourceType", params.resourceType);
|
|
188
|
+
if (params?.resourceId) qs.set("resourceId", params.resourceId);
|
|
189
|
+
if (params?.capability) qs.set("capability", params.capability);
|
|
190
|
+
const query = qs.toString();
|
|
191
|
+
return this.oauthGet(
|
|
192
|
+
`/api/oauth/commerce/entitlements${query ? `?${query}` : ""}`,
|
|
193
|
+
accessToken
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Redeem one current-user entitlement for this OAuth app.
|
|
198
|
+
* Requires `commerce:write` scope.
|
|
199
|
+
*/
|
|
200
|
+
async redeemCommerceEntitlement(accessToken, data) {
|
|
201
|
+
return this.oauthPost(
|
|
202
|
+
"/api/oauth/commerce/entitlements/redeem",
|
|
203
|
+
accessToken,
|
|
204
|
+
data
|
|
205
|
+
);
|
|
206
|
+
}
|
|
181
207
|
// ─── Private helpers ─────────────────────────────
|
|
182
208
|
async oauthGet(path, accessToken) {
|
|
183
209
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
package/package.json
CHANGED