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/dist/client.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MossPartner = void 0;
4
+ const http_1 = require("./http");
5
+ const customers_1 = require("./customers");
6
+ const webhooks_1 = require("./webhooks");
7
+ const analytics_1 = require("./analytics");
8
+ class MossPartner {
9
+ constructor(config) {
10
+ if (!config.apiKey) {
11
+ throw new Error('apiKey is required');
12
+ }
13
+ if (!config.apiKey.startsWith('prt_') && !config.testMode) {
14
+ throw new Error('apiKey must start with "prt_" (partner key)');
15
+ }
16
+ this.http = new http_1.HTTPClient(config);
17
+ this.customers = new customers_1.CustomersResource(this.http);
18
+ this.webhooks = new webhooks_1.WebhooksResource(this.http);
19
+ this.analytics = new analytics_1.AnalyticsResource(this.http);
20
+ }
21
+ async introspectToken(request) {
22
+ const response = await this.http.request({
23
+ method: 'POST',
24
+ path: '/v1/tokens/introspect',
25
+ body: request,
26
+ });
27
+ return response.data;
28
+ }
29
+ asCustomer(_customerId) {
30
+ throw new Error('asCustomer() is not yet implemented. ' +
31
+ 'Use customer tokens directly or contact support for delegation features.');
32
+ }
33
+ async ping() {
34
+ try {
35
+ const response = await this.http.request({
36
+ method: 'GET',
37
+ path: '/health',
38
+ });
39
+ return response.status === 200;
40
+ }
41
+ catch (error) {
42
+ return false;
43
+ }
44
+ }
45
+ }
46
+ exports.MossPartner = MossPartner;
47
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAMA,iCAAoC;AACpC,2CAAgD;AAChD,yCAA8C;AAC9C,2CAAgD;AAkChD,MAAa,WAAW;IAiBtB,YAAY,MAAyB;QAEnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MA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"}
@@ -0,0 +1,20 @@
1
+ import { HTTPClient } from './http';
2
+ import { Customer, CreateCustomerRequest, UpdateCustomerRequest, ListCustomersParams, ListCustomersResponse, PromoteCustomerRequest, SuspendCustomerRequest, ReactivateCustomerRequest, SessionResponse, CreateSessionRequest, ComplianceReportRequest, ComplianceReportResponse } from './types';
3
+ export declare class CustomersResource {
4
+ private http;
5
+ constructor(http: HTTPClient);
6
+ private mapCustomer;
7
+ private mapSessionResponse;
8
+ private parsePdfSignatureTrailer;
9
+ create(request: CreateCustomerRequest): Promise<Customer>;
10
+ list(params?: ListCustomersParams): Promise<ListCustomersResponse>;
11
+ get(customerId: string): Promise<Customer>;
12
+ update(customerId: string, request: UpdateCustomerRequest): Promise<Customer>;
13
+ promote(customerId: string, request: PromoteCustomerRequest): Promise<Customer>;
14
+ suspend(customerId: string, request: SuspendCustomerRequest): Promise<Customer>;
15
+ reactivate(customerId: string, request: ReactivateCustomerRequest): Promise<Customer>;
16
+ createSession(customerId: string, request: CreateSessionRequest): Promise<SessionResponse>;
17
+ revokeSession(customerId: string, sessionToken: string): Promise<void>;
18
+ complianceReport(customerId: string, request?: ComplianceReportRequest): Promise<ComplianceReportResponse>;
19
+ }
20
+ //# sourceMappingURL=customers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,qBAAa,iBAAiB;IAChB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAOpC,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,wBAAwB;IAkE1B,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA4BzD,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAqClE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuB1C,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAqC7E,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2B/E,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2B/E,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8BrF,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAqB1F,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BtE,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CA6BjH"}
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomersResource = void 0;
4
+ class CustomersResource {
5
+ constructor(http) {
6
+ this.http = http;
7
+ }
8
+ mapCustomer(apiResponse) {
9
+ return {
10
+ id: apiResponse.customerId,
11
+ externalId: apiResponse.externalId,
12
+ name: apiResponse.name,
13
+ email: apiResponse.email || '',
14
+ status: apiResponse.status,
15
+ sandboxToken: apiResponse.credentials?.customerToken?.token,
16
+ productionToken: apiResponse.credentials?.productionToken?.token,
17
+ governance: apiResponse.governance || { jurisdictions: [], frameworks: [] },
18
+ limits: apiResponse.limits || { agents: 0 },
19
+ compliance: apiResponse.compliance || {
20
+ score: 0,
21
+ status: 'unknown',
22
+ issues: [],
23
+ lastAssessment: new Date().toISOString()
24
+ },
25
+ createdAt: apiResponse.createdAt,
26
+ updatedAt: apiResponse.updatedAt,
27
+ };
28
+ }
29
+ mapSessionResponse(apiResponse) {
30
+ return {
31
+ sessionToken: apiResponse.token || apiResponse.sessionToken,
32
+ expiresAt: apiResponse.expiresAt,
33
+ metadata: apiResponse.metadata,
34
+ };
35
+ }
36
+ parsePdfSignatureTrailer(pdfBuffer) {
37
+ const decoder = new TextDecoder('utf-8');
38
+ const pdfText = decoder.decode(pdfBuffer);
39
+ const endMarker = '%%MOSS-SIGNATURE-V1-END';
40
+ const endIndex = pdfText.lastIndexOf(endMarker);
41
+ if (endIndex === -1) {
42
+ throw new Error('PDF does not contain MOSS signature trailer');
43
+ }
44
+ const jsonEndIndex = pdfText.lastIndexOf('}', endIndex);
45
+ if (jsonEndIndex === -1) {
46
+ throw new Error('Invalid MOSS signature trailer format: no closing brace found');
47
+ }
48
+ const jsonStartPattern = '{"algorithm":';
49
+ const jsonStartIndex = pdfText.lastIndexOf(jsonStartPattern, endIndex);
50
+ if (jsonStartIndex === -1) {
51
+ throw new Error('Invalid MOSS signature trailer format: algorithm marker not found');
52
+ }
53
+ const jsonText = pdfText.substring(jsonStartIndex, jsonEndIndex + 1).trim();
54
+ const trailerMetadata = JSON.parse(jsonText);
55
+ const signedPayload = JSON.parse(trailerMetadata.signed_payload);
56
+ return {
57
+ reportId: signedPayload.report_id,
58
+ signature: trailerMetadata.signature_hex,
59
+ keyId: signedPayload.key_id || trailerMetadata.key_id || 'moss_prod_2026_Q1',
60
+ generatedAt: signedPayload.generated_at,
61
+ downloadUrl: trailerMetadata.verify_url,
62
+ data: signedPayload,
63
+ };
64
+ }
65
+ async create(request) {
66
+ const response = await this.http.request({
67
+ method: 'POST',
68
+ path: '/v1/partner/customers',
69
+ body: request,
70
+ });
71
+ return this.mapCustomer(response.data);
72
+ }
73
+ async list(params) {
74
+ const response = await this.http.request({
75
+ method: 'GET',
76
+ path: '/v1/partner/customers',
77
+ query: params,
78
+ });
79
+ let customers = [];
80
+ if (response.data.data && Array.isArray(response.data.data)) {
81
+ customers = response.data.data.map((customer) => this.mapCustomer(customer));
82
+ }
83
+ else if (response.data.customers && Array.isArray(response.data.customers)) {
84
+ customers = response.data.customers.map((customer) => this.mapCustomer(customer));
85
+ }
86
+ else if (Array.isArray(response.data)) {
87
+ customers = response.data.map((customer) => this.mapCustomer(customer));
88
+ }
89
+ return {
90
+ data: customers,
91
+ pagination: response.data.pagination || { hasMore: false },
92
+ };
93
+ }
94
+ async get(customerId) {
95
+ const response = await this.http.request({
96
+ method: 'GET',
97
+ path: `/v1/partner/customers/${customerId}`,
98
+ });
99
+ return this.mapCustomer(response.data);
100
+ }
101
+ async update(customerId, request) {
102
+ const response = await this.http.request({
103
+ method: 'PATCH',
104
+ path: `/v1/partner/customers/${customerId}`,
105
+ body: request,
106
+ });
107
+ return this.mapCustomer(response.data);
108
+ }
109
+ async promote(customerId, request) {
110
+ const response = await this.http.request({
111
+ method: 'POST',
112
+ path: `/v1/partner/customers/${customerId}/promote`,
113
+ body: request,
114
+ });
115
+ return this.mapCustomer(response.data);
116
+ }
117
+ async suspend(customerId, request) {
118
+ const response = await this.http.request({
119
+ method: 'POST',
120
+ path: `/v1/partner/customers/${customerId}/suspend`,
121
+ body: request,
122
+ });
123
+ return this.mapCustomer(response.data);
124
+ }
125
+ async reactivate(customerId, request) {
126
+ const response = await this.http.request({
127
+ method: 'POST',
128
+ path: `/v1/partner/customers/${customerId}/reactivate`,
129
+ body: request,
130
+ });
131
+ return this.mapCustomer(response.data);
132
+ }
133
+ async createSession(customerId, request) {
134
+ const response = await this.http.request({
135
+ method: 'POST',
136
+ path: `/v1/partner/customers/${customerId}/session`,
137
+ body: request,
138
+ });
139
+ return this.mapSessionResponse(response.data);
140
+ }
141
+ async revokeSession(customerId, sessionToken) {
142
+ await this.http.request({
143
+ method: 'DELETE',
144
+ path: `/v1/partner/customers/${customerId}/session`,
145
+ body: { sessionToken },
146
+ });
147
+ }
148
+ async complianceReport(customerId, request) {
149
+ const params = new URLSearchParams();
150
+ if (request?.format)
151
+ params.append('format', request.format);
152
+ if (request?.frameworks)
153
+ params.append('frameworks', request.frameworks.join(','));
154
+ const path = `/v1/partner/customers/${customerId}/compliance-report`;
155
+ const queryString = params.toString();
156
+ const url = `${this.http.baseUrl}${path}${queryString ? `?${queryString}` : ''}`;
157
+ const response = await fetch(url, {
158
+ headers: {
159
+ 'Authorization': `Bearer ${this.http.apiKey}`,
160
+ 'User-Agent': 'moss-partner-sdk-ts/0.1.0',
161
+ },
162
+ });
163
+ if (!response.ok) {
164
+ throw new Error(`Failed to fetch compliance report: ${response.status} ${response.statusText}`);
165
+ }
166
+ const pdfBuffer = await response.arrayBuffer();
167
+ return this.parsePdfSignatureTrailer(pdfBuffer);
168
+ }
169
+ }
170
+ exports.CustomersResource = CustomersResource;
171
+ //# sourceMappingURL=customers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customers.js","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":";;;AAsBA,MAAa,iBAAiB;IAC5B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAOhC,WAAW,CAAC,WAAgB;QAClC,OAAO;YACL,EAAE,EAAE,WAAW,CAAC,UAAU;YAC1B,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,KAAK,EAAE,WAAW,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,YAAY,EAAE,WAAW,CAAC,WAAW,EAAE,aAAa,EAAE,KAAK;YAC3D,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OAAO,EAAE;gBACP,eAAe,EAAE,UAAW,IAAI,CAAC,IAAY,CAAC,MAAM,EAAE;gBACtD,YAAY,EAAE,2BAA2B;aAC1C;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAClG,CAAC;QAGD,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;QAG/C,OAAO,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF;AAhZD,8CAgZC"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { MossPartnerConfig } from './types';
2
+ export interface HTTPRequestOptions {
3
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
+ path: string;
5
+ body?: any;
6
+ query?: Record<string, string | number | boolean | undefined>;
7
+ headers?: Record<string, string>;
8
+ }
9
+ export interface HTTPResponse<T = any> {
10
+ data: T;
11
+ status: number;
12
+ headers: Record<string, string>;
13
+ }
14
+ export declare class HTTPClient {
15
+ private baseUrl;
16
+ private apiKey;
17
+ private timeout;
18
+ private retries;
19
+ private logger?;
20
+ private testMode;
21
+ constructor(config: MossPartnerConfig);
22
+ request<T = any>(options: HTTPRequestOptions): Promise<HTTPResponse<T>>;
23
+ private executeRequest;
24
+ private buildURL;
25
+ private buildHeaders;
26
+ private extractHeaders;
27
+ private getRetryDelay;
28
+ private sleep;
29
+ private mockRequest;
30
+ }
31
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAA0C,MAAM,SAAS,CAAC;AAGpF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAU;gBAEd,MAAM,EAAE,iBAAiB;IAY/B,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YA6D/D,cAAc;IAoE5B,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,WAAW;CAqDpB"}
package/dist/http.js ADDED
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTPClient = void 0;
4
+ const types_1 = require("./types");
5
+ const case_1 = require("./utils/case");
6
+ class HTTPClient {
7
+ constructor(config) {
8
+ this.baseUrl = config.baseUrl || 'https://api.mosscomputing.com';
9
+ this.apiKey = config.apiKey;
10
+ this.timeout = config.timeout || 30000;
11
+ this.retries = config.retries || 3;
12
+ this.logger = config.logger;
13
+ this.testMode = config.testMode || false;
14
+ this.baseUrl = this.baseUrl.replace(/\/$/, '');
15
+ }
16
+ async request(options) {
17
+ if (this.testMode) {
18
+ return this.mockRequest(options);
19
+ }
20
+ let lastError = null;
21
+ const startTime = Date.now();
22
+ for (let attempt = 0; attempt <= this.retries; attempt++) {
23
+ try {
24
+ if (attempt > 0) {
25
+ const delay = this.getRetryDelay(attempt);
26
+ this.logger?.debug(`Retrying request (attempt ${attempt + 1}/${this.retries + 1}) after ${delay}ms`, {
27
+ path: options.path,
28
+ });
29
+ await this.sleep(delay);
30
+ }
31
+ const response = await this.executeRequest(options);
32
+ const duration = Date.now() - startTime;
33
+ this.logger?.debug(`Request successful`, {
34
+ path: options.path,
35
+ method: options.method,
36
+ status: response.status,
37
+ duration,
38
+ attempt: attempt + 1,
39
+ });
40
+ return response;
41
+ }
42
+ catch (error) {
43
+ lastError = error;
44
+ if (error instanceof types_1.MossAPIError && error.statusCode && error.statusCode < 500) {
45
+ throw error;
46
+ }
47
+ if (attempt === this.retries) {
48
+ break;
49
+ }
50
+ this.logger?.warn(`Request failed, will retry`, {
51
+ path: options.path,
52
+ attempt: attempt + 1,
53
+ error: error.message,
54
+ });
55
+ }
56
+ }
57
+ const duration = Date.now() - startTime;
58
+ this.logger?.error(`Request failed after ${this.retries + 1} attempts`, {
59
+ path: options.path,
60
+ duration,
61
+ error: lastError?.message,
62
+ });
63
+ throw lastError;
64
+ }
65
+ async executeRequest(options) {
66
+ const url = this.buildURL(options.path, options.query);
67
+ const headers = this.buildHeaders(options.headers);
68
+ const controller = new AbortController();
69
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
70
+ try {
71
+ const requestBody = options.body ? (0, case_1.keysToSnakeCase)(options.body) : undefined;
72
+ const response = await fetch(url, {
73
+ method: options.method,
74
+ headers,
75
+ body: requestBody ? JSON.stringify(requestBody) : undefined,
76
+ signal: controller.signal,
77
+ });
78
+ clearTimeout(timeoutId);
79
+ const responseHeaders = this.extractHeaders(response.headers);
80
+ const contentType = response.headers.get('content-type');
81
+ const isJson = contentType?.includes('application/json');
82
+ let data;
83
+ if (isJson) {
84
+ data = await response.json();
85
+ data = (0, case_1.keysToCamelCase)(data);
86
+ }
87
+ else {
88
+ data = await response.text();
89
+ }
90
+ if (!response.ok) {
91
+ throw new types_1.MossAPIError(data?.message || data?.error?.message || `HTTP ${response.status}`, response.status, data?.error || data?.error?.code || 'api_error', data?.details || data?.error?.details);
92
+ }
93
+ return {
94
+ data: data,
95
+ status: response.status,
96
+ headers: responseHeaders,
97
+ };
98
+ }
99
+ catch (error) {
100
+ clearTimeout(timeoutId);
101
+ if (error instanceof types_1.MossAPIError) {
102
+ throw error;
103
+ }
104
+ if (error.name === 'AbortError') {
105
+ throw new types_1.MossNetworkError(`Request timeout after ${this.timeout}ms`, error);
106
+ }
107
+ throw new types_1.MossNetworkError(`Network error: ${error.message}`, error);
108
+ }
109
+ }
110
+ buildURL(path, query) {
111
+ let url = `${this.baseUrl}${path}`;
112
+ if (query) {
113
+ const params = new URLSearchParams();
114
+ for (const [key, value] of Object.entries(query)) {
115
+ if (value !== undefined) {
116
+ params.append(key, String(value));
117
+ }
118
+ }
119
+ const queryString = params.toString();
120
+ if (queryString) {
121
+ url += `?${queryString}`;
122
+ }
123
+ }
124
+ return url;
125
+ }
126
+ buildHeaders(customHeaders) {
127
+ return {
128
+ 'Content-Type': 'application/json',
129
+ 'Authorization': `Bearer ${this.apiKey}`,
130
+ 'User-Agent': 'moss-partner-sdk-ts/0.1.0',
131
+ ...customHeaders,
132
+ };
133
+ }
134
+ extractHeaders(headers) {
135
+ const result = {};
136
+ headers.forEach((value, key) => {
137
+ result[key] = value;
138
+ });
139
+ return result;
140
+ }
141
+ getRetryDelay(attempt) {
142
+ return Math.min(1000 * Math.pow(2, attempt - 1), 4000);
143
+ }
144
+ sleep(ms) {
145
+ return new Promise((resolve) => setTimeout(resolve, ms));
146
+ }
147
+ mockRequest(options) {
148
+ this.logger?.debug(`Mock request (test mode)`, {
149
+ path: options.path,
150
+ method: options.method,
151
+ });
152
+ let mockData = { success: true };
153
+ if (options.path.includes('/customers')) {
154
+ if (options.method === 'POST') {
155
+ mockData = {
156
+ id: 'cust_test_' + Date.now(),
157
+ externalId: options.body?.externalId || 'test_ext',
158
+ name: options.body?.name || 'Test Corp',
159
+ email: options.body?.email || 'test@example.com',
160
+ status: 'sandbox_active',
161
+ sandboxToken: 'cust_test_token_' + Date.now(),
162
+ governance: options.body?.governance || { jurisdictions: [], frameworks: [] },
163
+ limits: { agents: 10 },
164
+ compliance: { score: 85, status: 'compliant', issues: [], lastAssessment: new Date().toISOString() },
165
+ createdAt: new Date().toISOString(),
166
+ updatedAt: new Date().toISOString(),
167
+ };
168
+ }
169
+ else if (options.method === 'GET' && options.path.match(/\/customers\/[^/]+$/)) {
170
+ mockData = {
171
+ id: 'cust_test_123',
172
+ externalId: 'test_ext',
173
+ name: 'Test Corp',
174
+ email: 'test@example.com',
175
+ status: 'production_active',
176
+ sandboxToken: 'cust_test_token',
177
+ productionToken: 'cust_prod_token',
178
+ governance: { jurisdictions: ['US'], frameworks: ['nist_ai_rmf'] },
179
+ limits: { agents: 50 },
180
+ compliance: { score: 90, status: 'compliant', issues: [], lastAssessment: new Date().toISOString() },
181
+ createdAt: new Date().toISOString(),
182
+ updatedAt: new Date().toISOString(),
183
+ };
184
+ }
185
+ else if (options.method === 'GET') {
186
+ mockData = {
187
+ data: [],
188
+ pagination: { hasMore: false },
189
+ };
190
+ }
191
+ }
192
+ return Promise.resolve({
193
+ data: mockData,
194
+ status: 200,
195
+ headers: { 'content-type': 'application/json' },
196
+ });
197
+ }
198
+ }
199
+ exports.HTTPClient = HTTPClient;
200
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAMA,mCAAoF;AACpF,uCAAgE;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IAAI,EAAE,WAAW;oBACjB,KAAK,EAAE,kBAAkB;oBACzB,MAAM,EAAE,mBAAmB;oBAC3B,YAAY,EAAE,iBAAiB;oBAC/B,eAAe,EAAE,iBAAiB;oBAClC,UAAU,EAAE,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAE;oBAClE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;oBACtB,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;oBACpG,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;oBACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACpC,CAAC;YACJ,CAAC;iBAAM,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;gBACpC,QAAQ,GAAG;oBACT,IAAI,EAAE,EAAE;oBACR,UAAU,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,QAAa;YACnB,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AAxPD,gCAwPC"}
@@ -0,0 +1,7 @@
1
+ export { MossPartner } from './client';
2
+ export { CustomersResource } from './customers';
3
+ export { WebhooksResource } from './webhooks';
4
+ export { AnalyticsResource, EventStream } from './analytics';
5
+ export type { MossPartnerConfig, Logger, MetricsExporter, Customer, CustomerStatus, Governance, ResourceLimits, ComplianceInfo, ComplianceIssue, BillingInfo, CreateCustomerRequest, UpdateCustomerRequest, ListCustomersParams, ListCustomersResponse, PromoteCustomerRequest, SuspendCustomerRequest, ReactivateCustomerRequest, CreateSessionRequest, SessionResponse, TokenIntrospectionRequest, TokenIntrospectionResponse, ComplianceReportRequest, ComplianceReportResponse, Webhook, CreateWebhookRequest, WebhookEvent, AnalyticsResponse, AnalyticsStreamEvent, MossError, MossAPIError, MossNetworkError, MossValidationError, } from './types';
6
+ export declare const VERSION = "0.1.0";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG7D,YAAY,EAEV,iBAAiB,EACjB,MAAM,EACN,eAAe,EAGf,QAAQ,EACR,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EAGX,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EAGzB,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EAGxB,OAAO,EACP,oBAAoB,EACpB,YAAY,EAGZ,iBAAiB,EACjB,oBAAoB,EAGpB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = exports.EventStream = exports.AnalyticsResource = exports.WebhooksResource = exports.CustomersResource = exports.MossPartner = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "MossPartner", { enumerable: true, get: function () { return client_1.MossPartner; } });
6
+ var customers_1 = require("./customers");
7
+ Object.defineProperty(exports, "CustomersResource", { enumerable: true, get: function () { return customers_1.CustomersResource; } });
8
+ var webhooks_1 = require("./webhooks");
9
+ Object.defineProperty(exports, "WebhooksResource", { enumerable: true, get: function () { return webhooks_1.WebhooksResource; } });
10
+ var analytics_1 = require("./analytics");
11
+ Object.defineProperty(exports, "AnalyticsResource", { enumerable: true, get: function () { return analytics_1.AnalyticsResource; } });
12
+ Object.defineProperty(exports, "EventStream", { enumerable: true, get: function () { return analytics_1.EventStream; } });
13
+ exports.VERSION = '0.1.0';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA+BA,mCAAuC;AAA9B,qGAAA,WAAW,OAAA;AAGpB,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAC1B,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,yCAA6D;AAApD,8GAAA,iBAAiB,OAAA;AAAE,wGAAA,WAAW,OAAA;AAoD1B,QAAA,OAAO,GAAG,OAAO,CAAC"}