moss-partner-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,120 @@
1
+ MOSS PARTNER SDK LICENSE AGREEMENT
2
+
3
+ Copyright (c) 2026 MOSS Computing, Inc.
4
+ All Rights Reserved.
5
+
6
+ IMPORTANT: READ CAREFULLY BEFORE USING THIS SOFTWARE
7
+
8
+ This Partner SDK License Agreement ("Agreement") is a legal agreement between
9
+ you (either an individual or a single entity, "Partner") and MOSS Computing, Inc.
10
+ ("MOSS") for the use of the MOSS Partner Software Development Kit ("SDK").
11
+
12
+ BY INSTALLING, COPYING, OR OTHERWISE USING THE SDK, YOU AGREE TO BE BOUND BY
13
+ THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT USE THE SDK.
14
+
15
+ 1. DEFINITIONS
16
+
17
+ 1.1 "Partner" means an entity that has executed a valid MOSS Partner Agreement
18
+ with MOSS Computing, Inc. and maintains active partner status.
19
+
20
+ 1.2 "SDK" means the MOSS Partner Software Development Kit, including all
21
+ source code, documentation, and related materials.
22
+
23
+ 1.3 "Partner Agreement" means the separate commercial agreement between
24
+ Partner and MOSS governing the partnership relationship.
25
+
26
+ 2. GRANT OF LICENSE
27
+
28
+ 2.1 Subject to the terms of this Agreement and the Partner Agreement, MOSS
29
+ grants Partner a limited, non-exclusive, non-transferable, revocable
30
+ license to:
31
+
32
+ (a) Use the SDK solely to develop applications that integrate with the
33
+ MOSS Platform;
34
+ (b) Modify the SDK solely for Partner's internal use;
35
+ (c) Distribute the SDK to Partner's end customers solely as part of
36
+ Partner's applications.
37
+
38
+ 2.2 This license is CONDITIONAL upon:
39
+
40
+ (a) Partner maintaining active partner status with MOSS;
41
+ (b) Partner maintaining a valid Partner Agreement with MOSS;
42
+ (c) Partner's API key remaining active and in good standing.
43
+
44
+ 3. RESTRICTIONS
45
+
46
+ Partner shall NOT:
47
+
48
+ 3.1 Use the SDK without a valid, active Partner Agreement with MOSS;
49
+ 3.2 Distribute, sublicense, or transfer the SDK to any third party except
50
+ as expressly permitted in Section 2.1(c);
51
+ 3.3 Remove or modify any copyright, trademark, or other proprietary notices;
52
+ 3.4 Reverse engineer, decompile, or disassemble the SDK (except to the
53
+ extent prohibited by applicable law);
54
+ 3.5 Use the SDK to develop competing products or services;
55
+ 3.6 Use the SDK in any manner that violates applicable laws or regulations;
56
+ 3.7 Publish the SDK to public package repositories (npm, PyPI, etc.) without
57
+ MOSS's prior written consent.
58
+
59
+ 4. OWNERSHIP AND INTELLECTUAL PROPERTY
60
+
61
+ 4.1 MOSS retains all right, title, and interest in and to the SDK, including
62
+ all intellectual property rights.
63
+
64
+ 4.2 Partner retains all rights to applications developed using the SDK,
65
+ subject to MOSS's underlying intellectual property rights in the SDK.
66
+
67
+ 5. TERMINATION
68
+
69
+ 5.1 This license automatically terminates upon:
70
+
71
+ (a) Termination or expiration of the Partner Agreement;
72
+ (b) Suspension or revocation of Partner's API key;
73
+ (c) Partner's breach of this Agreement;
74
+ (d) Partner ceasing to maintain active partner status.
75
+
76
+ 5.2 Upon termination, Partner must immediately cease all use of the SDK
77
+ and destroy all copies in Partner's possession or control.
78
+
79
+ 5.3 Sections 3, 4, 6, and 7 survive termination.
80
+
81
+ 6. WARRANTY DISCLAIMER
82
+
83
+ THE SDK IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
84
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
85
+ A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
86
+
87
+ 7. LIMITATION OF LIABILITY
88
+
89
+ IN NO EVENT SHALL MOSS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
90
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
91
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
92
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
93
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
94
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SDK, EVEN IF ADVISED
95
+ OF THE POSSIBILITY OF SUCH DAMAGE.
96
+
97
+ 8. GOVERNING LAW
98
+
99
+ This Agreement shall be governed by the laws of the State of Delaware,
100
+ United States, without regard to its conflict of law provisions.
101
+
102
+ 9. ENTIRE AGREEMENT
103
+
104
+ This Agreement, together with the Partner Agreement, constitutes the entire
105
+ agreement between the parties concerning the SDK and supersedes all prior
106
+ or contemporaneous oral or written agreements.
107
+
108
+ 10. CONTACT
109
+
110
+ For questions regarding this license or to establish a Partner Agreement:
111
+
112
+ MOSS Computing, Inc.
113
+ Email: partners@mosscomputing.com
114
+ Website: https://mosscomputing.com/partners
115
+
116
+ ---
117
+
118
+ AUTHORIZATION REQUIRED: This SDK may only be used by authorized MOSS partners
119
+ with a valid Partner Agreement. To become a partner, visit:
120
+ https://mosscomputing.com/partners
package/README.md ADDED
@@ -0,0 +1,347 @@
1
+ # MOSS Partner SDK for TypeScript
2
+
3
+ Official TypeScript SDK for the MOSS Partner API. Manage customers, configure governance, and monitor compliance.
4
+
5
+ ## ⚠️ Authorization Required
6
+
7
+ This SDK is restricted to **authorized MOSS partners only**. You must have:
8
+ - A valid MOSS Partner Agreement
9
+ - An active partner API key (`prt_xxx`)
10
+
11
+ To become a partner, visit [https://mosscomputing.com/partners](https://mosscomputing.com/partners)
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @moss/partner-sdk
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { MossPartner } from '@moss/partner-sdk';
23
+
24
+ const moss = new MossPartner({
25
+ apiKey: process.env.MOSS_PARTNER_KEY, // prt_xxx
26
+ });
27
+
28
+ // Create a customer
29
+ const customer = await moss.customers.create({
30
+ externalId: 'acme_123',
31
+ name: 'Acme Corp',
32
+ email: 'admin@acme.com',
33
+ governance: {
34
+ jurisdictions: ['EU', 'US'],
35
+ frameworks: ['eu_ai_act', 'nist_ai_rmf'],
36
+ },
37
+ });
38
+
39
+ console.log(customer.sandboxToken); // Give this to your customer
40
+ ```
41
+
42
+ ## Features
43
+
44
+ - ✅ **Type-safe** - Full TypeScript types for all API operations
45
+ - ✅ **Async-first** - Modern async/await API
46
+ - ✅ **Zero-config** - Sensible defaults, works out of the box
47
+ - ✅ **Fail-safe** - Automatic retries with exponential backoff
48
+ - ✅ **Observable** - Built-in logging and metrics hooks
49
+ - ✅ **Testable** - Test mode for unit testing
50
+
51
+ ## API Reference
52
+
53
+ ### Configuration
54
+
55
+ ```typescript
56
+ const moss = new MossPartner({
57
+ apiKey: 'prt_xxx', // Required: Partner API key
58
+ baseUrl: 'https://api.mosscomputing.com', // Optional: API base URL
59
+ timeout: 30000, // Optional: Request timeout (ms)
60
+ retries: 3, // Optional: Number of retries
61
+ logger: console, // Optional: Custom logger
62
+ testMode: false, // Optional: Enable test mode
63
+ });
64
+ ```
65
+
66
+ ### Customer Management
67
+
68
+ #### Create Customer
69
+
70
+ ```typescript
71
+ const customer = await moss.customers.create({
72
+ externalId: 'acme_123',
73
+ name: 'Acme Corp',
74
+ email: 'admin@acme.com',
75
+ governance: {
76
+ jurisdictions: ['EU', 'US'],
77
+ frameworks: ['eu_ai_act', 'nist_ai_rmf'],
78
+ },
79
+ });
80
+ ```
81
+
82
+ #### List Customers
83
+
84
+ ```typescript
85
+ const result = await moss.customers.list({
86
+ status: 'production_active',
87
+ limit: 100,
88
+ });
89
+
90
+ for (const customer of result.data) {
91
+ console.log(`${customer.name}: ${customer.compliance.score}`);
92
+ }
93
+ ```
94
+
95
+ #### Get Customer
96
+
97
+ ```typescript
98
+ const customer = await moss.customers.get('cust_aaa');
99
+ ```
100
+
101
+ #### Update Customer
102
+
103
+ ```typescript
104
+ await moss.customers.update('cust_aaa', {
105
+ limits: { agents: 50 },
106
+ });
107
+ ```
108
+
109
+ #### Promote to Production
110
+
111
+ ```typescript
112
+ const promoted = await moss.customers.promote('cust_aaa', {
113
+ attestation: {
114
+ kycCompleted: true,
115
+ termsAccepted: true,
116
+ complianceReviewed: true,
117
+ attestedBy: 'compliance@emery.ai',
118
+ },
119
+ billing: {
120
+ tier: 'platform',
121
+ billingEmail: 'billing@acme.com',
122
+ },
123
+ });
124
+
125
+ console.log(promoted.productionToken);
126
+ ```
127
+
128
+ #### Suspend Customer
129
+
130
+ ```typescript
131
+ await moss.customers.suspend('cust_aaa', {
132
+ reason: 'payment_failed',
133
+ gracePeriodHours: 72,
134
+ });
135
+ ```
136
+
137
+ #### Reactivate Customer
138
+
139
+ ```typescript
140
+ await moss.customers.reactivate('cust_aaa', {
141
+ resolution: {
142
+ issueResolved: true,
143
+ resolutionType: 'payment_received',
144
+ },
145
+ });
146
+ ```
147
+
148
+ ### Session Tokens (M3)
149
+
150
+ Create short-lived session tokens for temporary customer delegation:
151
+
152
+ ```typescript
153
+ const session = await moss.customers.createSession('cust_aaa', {
154
+ purpose: 'Dashboard access',
155
+ ttlSeconds: 300, // 5 minutes (max 900)
156
+ });
157
+
158
+ console.log(session.sessionToken);
159
+ console.log(session.expiresAt);
160
+ ```
161
+
162
+ Revoke a session:
163
+
164
+ ```typescript
165
+ await moss.customers.revokeSession('cust_aaa', 'sess_token_xxx');
166
+ ```
167
+
168
+ ### Token Introspection (M3)
169
+
170
+ Validate tokens using RFC 7662:
171
+
172
+ ```typescript
173
+ const result = await moss.introspectToken({ token: 'cust_xxx' });
174
+
175
+ if (result.active) {
176
+ console.log(`Token valid for: ${result.sub}`);
177
+ console.log(`Expires: ${new Date(result.exp * 1000)}`);
178
+ } else {
179
+ console.log('Token inactive or invalid');
180
+ }
181
+ ```
182
+
183
+ ### Compliance Reports (M3)
184
+
185
+ Generate ML-DSA-44 signed compliance reports:
186
+
187
+ ```typescript
188
+ const report = await moss.customers.complianceReport('cust_aaa', {
189
+ format: 'pdf',
190
+ frameworks: ['eu_ai_act'],
191
+ });
192
+
193
+ console.log(report.downloadUrl); // Signed download URL
194
+ console.log(report.signature); // ML-DSA-44 signature
195
+ console.log(report.keyId); // Signing key ID
196
+ ```
197
+
198
+ ### Webhooks
199
+
200
+ #### Create Webhook
201
+
202
+ ```typescript
203
+ const webhook = await moss.webhooks.create({
204
+ url: 'https://emery.ai/webhooks/moss',
205
+ events: ['customer.*', 'agent.anomaly_detected', 'policy.violation'],
206
+ secret: 'whsec_xxx', // Optional, auto-generated if not provided
207
+ });
208
+ ```
209
+
210
+ #### List Webhooks
211
+
212
+ ```typescript
213
+ const webhooks = await moss.webhooks.list();
214
+ ```
215
+
216
+ #### Verify Webhook Signature
217
+
218
+ ```typescript
219
+ // Express example
220
+ app.post('/webhooks/moss', (req, res) => {
221
+ const signature = req.headers['x-moss-signature'];
222
+ const timestamp = req.headers['x-moss-timestamp'];
223
+ const body = JSON.stringify(req.body);
224
+
225
+ if (!moss.webhooks.verify(body, signature, timestamp, WEBHOOK_SECRET)) {
226
+ return res.status(401).json({ error: 'Invalid signature' });
227
+ }
228
+
229
+ const event = req.body;
230
+
231
+ // Handle event based on type
232
+ if (event.type === 'customer.compliance_changed') {
233
+ console.log(`Customer ${event.customerId} score: ${event.data.current.score}`);
234
+ }
235
+
236
+ res.json({ received: true });
237
+ });
238
+ ```
239
+
240
+ ### Analytics
241
+
242
+ #### Get Analytics
243
+
244
+ ```typescript
245
+ const analytics = await moss.analytics.get({
246
+ period: '2026-07',
247
+ granularity: 'daily',
248
+ });
249
+
250
+ console.log(`Total customers: ${analytics.customers.total}`);
251
+ console.log(`Average compliance: ${analytics.compliance.averageScore}`);
252
+ console.log(`MRR: $${analytics.billing.currentMrr}`);
253
+ ```
254
+
255
+ #### Stream Real-Time Events
256
+
257
+ ```typescript
258
+ const stream = moss.analytics.stream();
259
+
260
+ stream.on('signature', (event) => {
261
+ console.log(`Signature from ${event.agentId}`);
262
+ });
263
+
264
+ stream.on('violation', (event) => {
265
+ console.log(`Policy violation: ${event.data.policyId}`);
266
+ });
267
+
268
+ stream.on('anomaly', (event) => {
269
+ console.log(`Anomaly detected: ${event.data.type}`);
270
+ });
271
+
272
+ // Clean up when done
273
+ stream.close();
274
+ ```
275
+
276
+ ## Error Handling
277
+
278
+ ```typescript
279
+ import { MossAPIError, MossNetworkError } from '@moss/partner-sdk';
280
+
281
+ try {
282
+ const customer = await moss.customers.get('cust_xxx');
283
+ } catch (error) {
284
+ if (error instanceof MossAPIError) {
285
+ console.error(`API Error ${error.statusCode}: ${error.message}`);
286
+ console.error(`Code: ${error.code}`);
287
+ console.error(`Details:`, error.details);
288
+ } else if (error instanceof MossNetworkError) {
289
+ console.error('Network error:', error.message);
290
+ } else {
291
+ throw error;
292
+ }
293
+ }
294
+ ```
295
+
296
+ ## Test Mode
297
+
298
+ Use test mode for unit testing without making real API calls:
299
+
300
+ ```typescript
301
+ const moss = new MossPartner({
302
+ apiKey: 'test_key',
303
+ testMode: true,
304
+ });
305
+
306
+ // All operations return mock data
307
+ const customer = await moss.customers.create({...});
308
+ // Returns mock customer, no API call made
309
+ ```
310
+
311
+ ## Logging
312
+
313
+ Provide a custom logger for debugging:
314
+
315
+ ```typescript
316
+ const moss = new MossPartner({
317
+ apiKey: process.env.MOSS_PARTNER_KEY,
318
+ logger: {
319
+ debug: (msg, meta) => console.debug(msg, meta),
320
+ info: (msg, meta) => console.info(msg, meta),
321
+ warn: (msg, meta) => console.warn(msg, meta),
322
+ error: (msg, meta) => console.error(msg, meta),
323
+ },
324
+ });
325
+ ```
326
+
327
+ ## TypeScript Support
328
+
329
+ The SDK is written in TypeScript and provides full type definitions:
330
+
331
+ ```typescript
332
+ import type { Customer, Webhook, AnalyticsResponse } from '@moss/partner-sdk';
333
+
334
+ const customer: Customer = await moss.customers.get('cust_xxx');
335
+ const webhooks: Webhook[] = await moss.webhooks.list();
336
+ const analytics: AnalyticsResponse = await moss.analytics.get({ period: '2026-07' });
337
+ ```
338
+
339
+ ## License
340
+
341
+ MIT
342
+
343
+ ## Support
344
+
345
+ - Documentation: https://docs.mosscomputing.com
346
+ - GitHub Issues: https://github.com/mosscomputing/moss-partner-sdk-ts/issues
347
+ - Email: support@mosscomputing.com
@@ -0,0 +1,33 @@
1
+ export declare const TEST_CONFIG: {
2
+ baseUrl: string;
3
+ partnerKey: string;
4
+ testPrefix: string;
5
+ };
6
+ export declare const skipIfNoApiKey: () => boolean;
7
+ export declare const fixtures: {
8
+ customer: {
9
+ create: (suffix?: string) => {
10
+ externalId: string;
11
+ name: string;
12
+ email: string;
13
+ governance: {
14
+ jurisdictions: string[];
15
+ frameworks: string[];
16
+ };
17
+ };
18
+ };
19
+ webhook: {
20
+ create: () => {
21
+ url: string;
22
+ events: string[];
23
+ secret: string;
24
+ };
25
+ };
26
+ };
27
+ export declare const cleanup: {
28
+ customers: string[];
29
+ webhooks: string[];
30
+ addCustomer(id: string): void;
31
+ addWebhook(id: string): void;
32
+ };
33
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW;;;;CASvB,CAAC;AAGF,eAAO,MAAM,cAAc,eAK1B,CAAC;AASF,eAAO,MAAM,QAAQ;;0BAEA,MAAM;;;;;;;;;;;;;;;;;CAkB1B,CAAC;AAGF,eAAO,MAAM,OAAO;eACD,MAAM,EAAE;cACT,MAAM,EAAE;oBAER,MAAM;mBAIP,MAAM;CAGtB,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanup = exports.fixtures = exports.skipIfNoApiKey = exports.TEST_CONFIG = void 0;
4
+ const vitest_1 = require("vitest");
5
+ exports.TEST_CONFIG = {
6
+ baseUrl: process.env.MOSS_API_URL || 'https://api.mosscomputing.com',
7
+ partnerKey: process.env.MOSS_PARTNER_KEY || '',
8
+ testPrefix: `test_sdk_${Date.now()}`,
9
+ };
10
+ const skipIfNoApiKey = () => {
11
+ if (!exports.TEST_CONFIG.partnerKey) {
12
+ return true;
13
+ }
14
+ return false;
15
+ };
16
+ exports.skipIfNoApiKey = skipIfNoApiKey;
17
+ (0, vitest_1.beforeAll)(() => {
18
+ if (!exports.TEST_CONFIG.partnerKey) {
19
+ console.warn('⚠️ MOSS_PARTNER_KEY not set. Integration tests will be skipped.');
20
+ }
21
+ });
22
+ exports.fixtures = {
23
+ customer: {
24
+ create: (suffix = '001') => ({
25
+ externalId: `${exports.TEST_CONFIG.testPrefix}_${suffix}`,
26
+ name: `Test Corp ${suffix}`,
27
+ email: `test+${suffix}@example.com`,
28
+ governance: {
29
+ jurisdictions: ['US'],
30
+ frameworks: ['nist_ai_rmf'],
31
+ },
32
+ }),
33
+ },
34
+ webhook: {
35
+ create: () => ({
36
+ url: 'https://example.com/webhooks/moss',
37
+ events: ['customer.*', 'agent.*'],
38
+ secret: 'whsec_test_' + Math.random().toString(36).substring(7),
39
+ }),
40
+ },
41
+ };
42
+ exports.cleanup = {
43
+ customers: [],
44
+ webhooks: [],
45
+ addCustomer(id) {
46
+ this.customers.push(id);
47
+ },
48
+ addWebhook(id) {
49
+ this.webhooks.push(id);
50
+ },
51
+ };
52
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":";;;AAIA,mCAAmC;AAGtB,QAAA,WAAW,GAAG;IAEzB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,+BAA+B;IAGpE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE;IAG9C,UAAU,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE;CACrC,CAAC;AAGK,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC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0,0 +1,23 @@
1
+ import { HTTPClient } from './http';
2
+ import { AnalyticsResponse, AnalyticsStreamEvent } from './types';
3
+ export interface AnalyticsParams {
4
+ period: string;
5
+ granularity?: 'daily' | 'weekly' | 'monthly';
6
+ [key: string]: string | undefined;
7
+ }
8
+ export declare class AnalyticsResource {
9
+ private http;
10
+ constructor(http: HTTPClient);
11
+ get(params: AnalyticsParams): Promise<AnalyticsResponse>;
12
+ stream(): EventStream;
13
+ }
14
+ export declare class EventStream {
15
+ private handlers;
16
+ private ws;
17
+ constructor(_http: HTTPClient);
18
+ on(eventType: string, handler: (event: AnalyticsStreamEvent) => void): void;
19
+ off(eventType: string, handler: (event: AnalyticsStreamEvent) => void): void;
20
+ close(): void;
21
+ private connect;
22
+ }
23
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAElE,MAAM,WAAW,eAAe;IAE9B,MAAM,EAAE,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IAG7C,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAoB9B,GAAG,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAsC9D,MAAM,IAAI,WAAW;CAKtB;AAKD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAwE;IACxF,OAAO,CAAC,EAAE,CAA0B;gBAExB,KAAK,EAAE,UAAU;IAU7B,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,IAAI;IAmB3E,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,IAAI;IAa5E,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,OAAO;CAShB"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventStream = exports.AnalyticsResource = void 0;
4
+ class AnalyticsResource {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ async get(params) {
9
+ const response = await this.http.request({
10
+ method: 'GET',
11
+ path: '/v1/partner/analytics',
12
+ query: params,
13
+ });
14
+ return response.data;
15
+ }
16
+ stream() {
17
+ return new EventStream(this.http);
18
+ }
19
+ }
20
+ exports.AnalyticsResource = AnalyticsResource;
21
+ class EventStream {
22
+ constructor(_http) {
23
+ this.handlers = new Map();
24
+ this.ws = null;
25
+ }
26
+ on(eventType, handler) {
27
+ if (!this.handlers.has(eventType)) {
28
+ this.handlers.set(eventType, []);
29
+ }
30
+ this.handlers.get(eventType).push(handler);
31
+ if (!this.ws) {
32
+ this.connect();
33
+ }
34
+ }
35
+ off(eventType, handler) {
36
+ const handlers = this.handlers.get(eventType);
37
+ if (handlers) {
38
+ const index = handlers.indexOf(handler);
39
+ if (index !== -1) {
40
+ handlers.splice(index, 1);
41
+ }
42
+ }
43
+ }
44
+ close() {
45
+ if (this.ws) {
46
+ this.ws.close();
47
+ this.ws = null;
48
+ }
49
+ }
50
+ connect() {
51
+ console.warn('EventStream.connect() is not yet implemented');
52
+ }
53
+ }
54
+ exports.EventStream = EventStream;
55
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":";;;AAoBA,MAAa,iBAAiB;IAC5B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY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B,CAAC;QACH,CAAC;IACH,CAAC;IAKD,KAAK;QACH,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAEO,OAAO;QAOb,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IAC/D,CAAC;CACF;AA9DD,kCA8DC"}
@@ -0,0 +1,15 @@
1
+ import { CustomersResource } from './customers';
2
+ import { WebhooksResource } from './webhooks';
3
+ import { AnalyticsResource } from './analytics';
4
+ import { MossPartnerConfig, TokenIntrospectionRequest, TokenIntrospectionResponse } from './types';
5
+ export declare class MossPartner {
6
+ private http;
7
+ readonly customers: CustomersResource;
8
+ readonly webhooks: WebhooksResource;
9
+ readonly analytics: AnalyticsResource;
10
+ constructor(config: MossPartnerConfig);
11
+ introspectToken(request: TokenIntrospectionRequest): Promise<TokenIntrospectionResponse>;
12
+ asCustomer(_customerId: string): MossPartner;
13
+ ping(): Promise<boolean>;
14
+ }
15
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AA6BjB,qBAAa,WAAW;IACtB,OAAO,CAAC,IAAI,CAAa;IAGzB,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAG7C,SAAgB,QAAQ,EAAE,gBAAgB,CAAC;IAG3C,SAAgB,SAAS,EAAE,iBAAiB,CAAC;gBAOjC,MAAM,EAAE,iBAAiB;IAwC/B,eAAe,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IA4B9F,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW;IAsBtC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAY/B"}