moss-partner-sdk 0.1.0 → 0.2.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/__tests__/setup.d.ts +2 -13
- package/dist/__tests__/setup.d.ts.map +1 -1
- package/dist/__tests__/setup.js +3 -16
- package/dist/__tests__/setup.js.map +1 -1
- package/dist/analytics.d.ts +4 -15
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +1 -38
- package/dist/analytics.js.map +1 -1
- package/dist/billing.d.ts +13 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +18 -0
- package/dist/billing.js.map +1 -0
- package/dist/client.d.ts +5 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -14
- package/dist/client.js.map +1 -1
- package/dist/customers.d.ts +12 -11
- package/dist/customers.d.ts.map +1 -1
- package/dist/customers.js +116 -101
- package/dist/customers.js.map +1 -1
- package/dist/http.d.ts +3 -4
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +76 -91
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +343 -131
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -1
- package/dist/types.js.map +1 -1
- package/dist/usage.d.ts +19 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +26 -0
- package/dist/usage.js.map +1 -0
- package/dist/webhooks.d.ts +6 -6
- package/dist/webhooks.d.ts.map +1 -1
- package/dist/webhooks.js +28 -14
- package/dist/webhooks.js.map +1 -1
- package/package.json +2 -2
- package/dist/utils/case.d.ts +0 -5
- package/dist/utils/case.d.ts.map +0 -1
- package/dist/utils/case.js +0 -47
- package/dist/utils/case.js.map +0 -1
|
@@ -7,27 +7,16 @@ export declare const skipIfNoApiKey: () => boolean;
|
|
|
7
7
|
export declare const fixtures: {
|
|
8
8
|
customer: {
|
|
9
9
|
create: (suffix?: string) => {
|
|
10
|
-
|
|
10
|
+
external_id: string;
|
|
11
11
|
name: string;
|
|
12
|
-
email: string;
|
|
13
|
-
governance: {
|
|
14
|
-
jurisdictions: string[];
|
|
15
|
-
frameworks: string[];
|
|
16
|
-
};
|
|
17
12
|
};
|
|
18
13
|
};
|
|
19
14
|
webhook: {
|
|
20
|
-
|
|
21
|
-
url: string;
|
|
22
|
-
events: string[];
|
|
23
|
-
secret: string;
|
|
24
|
-
};
|
|
15
|
+
secret: () => string;
|
|
25
16
|
};
|
|
26
17
|
};
|
|
27
18
|
export declare const cleanup: {
|
|
28
19
|
customers: string[];
|
|
29
|
-
webhooks: string[];
|
|
30
20
|
addCustomer(id: string): void;
|
|
31
|
-
addWebhook(id: string): void;
|
|
32
21
|
};
|
|
33
22
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW;;;;CAIvB,CAAC;AAEF,eAAO,MAAM,cAAc,eAK1B,CAAC;AAQF,eAAO,MAAM,QAAQ;;0BAEA,MAAM;;;;;;;;CAQ1B,CAAC;AAEF,eAAO,MAAM,OAAO;eACD,MAAM,EAAE;oBAET,MAAM;CAGvB,CAAC"}
|
package/dist/__tests__/setup.js
CHANGED
|
@@ -16,37 +16,24 @@ const skipIfNoApiKey = () => {
|
|
|
16
16
|
exports.skipIfNoApiKey = skipIfNoApiKey;
|
|
17
17
|
(0, vitest_1.beforeAll)(() => {
|
|
18
18
|
if (!exports.TEST_CONFIG.partnerKey) {
|
|
19
|
-
console.warn('
|
|
19
|
+
console.warn('MOSS_PARTNER_KEY not set. Integration tests will be skipped.');
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
exports.fixtures = {
|
|
23
23
|
customer: {
|
|
24
24
|
create: (suffix = '001') => ({
|
|
25
|
-
|
|
25
|
+
external_id: `${exports.TEST_CONFIG.testPrefix}_${suffix}`,
|
|
26
26
|
name: `Test Corp ${suffix}`,
|
|
27
|
-
email: `test+${suffix}@example.com`,
|
|
28
|
-
governance: {
|
|
29
|
-
jurisdictions: ['US'],
|
|
30
|
-
frameworks: ['nist_ai_rmf'],
|
|
31
|
-
},
|
|
32
27
|
}),
|
|
33
28
|
},
|
|
34
29
|
webhook: {
|
|
35
|
-
|
|
36
|
-
url: 'https://example.com/webhooks/moss',
|
|
37
|
-
events: ['customer.*', 'agent.*'],
|
|
38
|
-
secret: 'whsec_test_' + Math.random().toString(36).substring(7),
|
|
39
|
-
}),
|
|
30
|
+
secret: () => 'whsec_test_' + Math.random().toString(36).substring(2, 15) + '_8chars',
|
|
40
31
|
},
|
|
41
32
|
};
|
|
42
33
|
exports.cleanup = {
|
|
43
34
|
customers: [],
|
|
44
|
-
webhooks: [],
|
|
45
35
|
addCustomer(id) {
|
|
46
36
|
this.customers.push(id);
|
|
47
37
|
},
|
|
48
|
-
addWebhook(id) {
|
|
49
|
-
this.webhooks.push(id);
|
|
50
|
-
},
|
|
51
38
|
};
|
|
52
39
|
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":";;;AAIA,mCAAmC;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":";;;AAIA,mCAAmC;AAEtB,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,+BAA+B;IACpE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE;IAC9C,UAAU,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE;CACrC,CAAC;AAEK,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,IAAI,CAAC,mBAAW,CAAC,UAAU,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEF,IAAA,kBAAS,EAAC,GAAG,EAAE;IACb,IAAI,CAAC,mBAAW,CAAC,UAAU,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC,CAAC,CAAC;AAEU,QAAA,QAAQ,GAAG;IACtB,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,SAAiB,KAAK,EAAE,EAAE,CAAC,CAAC;YACnC,WAAW,EAAE,GAAG,mBAAW,CAAC,UAAU,IAAI,MAAM,EAAE;YAClD,IAAI,EAAE,aAAa,MAAM,EAAE;SAC5B,CAAC;KACH;IACD,OAAO,EAAE;QACP,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS;KACtF;CACF,CAAC;AAEW,QAAA,OAAO,GAAG;IACrB,SAAS,EAAE,EAAc;IAEzB,WAAW,CAAC,EAAU;QACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;CACF,CAAC"}
|
package/dist/analytics.d.ts
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { HTTPClient } from './http';
|
|
2
|
-
import { AnalyticsResponse
|
|
2
|
+
import { AnalyticsResponse } from './types';
|
|
3
3
|
export interface AnalyticsParams {
|
|
4
|
-
period
|
|
5
|
-
granularity?:
|
|
6
|
-
[key: string]: string | undefined;
|
|
4
|
+
period?: string;
|
|
5
|
+
granularity?: string;
|
|
7
6
|
}
|
|
8
7
|
export declare class AnalyticsResource {
|
|
9
8
|
private http;
|
|
10
9
|
constructor(http: HTTPClient);
|
|
11
|
-
get(params
|
|
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;
|
|
10
|
+
get(params?: AnalyticsParams): Promise<AnalyticsResponse>;
|
|
22
11
|
}
|
|
23
12
|
//# sourceMappingURL=analytics.d.ts.map
|
package/dist/analytics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAe;IAE9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAQ9B,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAShE"}
|
package/dist/analytics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AnalyticsResource = void 0;
|
|
4
4
|
class AnalyticsResource {
|
|
5
5
|
constructor(http) {
|
|
6
6
|
this.http = http;
|
|
@@ -13,43 +13,6 @@ class AnalyticsResource {
|
|
|
13
13
|
});
|
|
14
14
|
return response.data;
|
|
15
15
|
}
|
|
16
|
-
stream() {
|
|
17
|
-
return new EventStream(this.http);
|
|
18
|
-
}
|
|
19
16
|
}
|
|
20
17
|
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
18
|
//# sourceMappingURL=analytics.js.map
|
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":";;;AAqBA,MAAa,iBAAiB;IAC5B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAQxC,KAAK,CAAC,GAAG,CAAC,MAAwB;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1D,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB;YAC7B,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAlBD,8CAkBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTTPClient } from './http';
|
|
2
|
+
import { BillingEarnings } from './types';
|
|
3
|
+
export interface BillingParams {
|
|
4
|
+
period?: string;
|
|
5
|
+
start_date?: string;
|
|
6
|
+
end_date?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class BillingResource {
|
|
9
|
+
private http;
|
|
10
|
+
constructor(http: HTTPClient);
|
|
11
|
+
earnings(params?: BillingParams): Promise<BillingEarnings>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,aAAa;IAE5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAU9B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;CASjE"}
|
package/dist/billing.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillingResource = void 0;
|
|
4
|
+
class BillingResource {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async earnings(params) {
|
|
9
|
+
const response = await this.http.request({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/v1/partner/billing/earnings',
|
|
12
|
+
query: params,
|
|
13
|
+
});
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.BillingResource = BillingResource;
|
|
18
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":";;;AAkBA,MAAa,eAAe;IAC1B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAUxC,KAAK,CAAC,QAAQ,CAAC,MAAsB;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB;YACxD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,8BAA8B;YACpC,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AApBD,0CAoBC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { CustomersResource } from './customers';
|
|
2
2
|
import { WebhooksResource } from './webhooks';
|
|
3
3
|
import { AnalyticsResource } from './analytics';
|
|
4
|
-
import {
|
|
4
|
+
import { BillingResource } from './billing';
|
|
5
|
+
import { UsageResource } from './usage';
|
|
6
|
+
import { MossPartnerConfig } from './types';
|
|
5
7
|
export declare class MossPartner {
|
|
6
8
|
private http;
|
|
7
9
|
readonly customers: CustomersResource;
|
|
8
10
|
readonly webhooks: WebhooksResource;
|
|
9
11
|
readonly analytics: AnalyticsResource;
|
|
12
|
+
readonly billing: BillingResource;
|
|
13
|
+
readonly usage: UsageResource;
|
|
10
14
|
constructor(config: MossPartnerConfig);
|
|
11
|
-
introspectToken(request: TokenIntrospectionRequest): Promise<TokenIntrospectionResponse>;
|
|
12
|
-
asCustomer(_customerId: string): MossPartner;
|
|
13
15
|
ping(): Promise<boolean>;
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAyB5C,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;IAG7C,SAAgB,OAAO,EAAE,eAAe,CAAC;IAGzC,SAAgB,KAAK,EAAE,aAAa,CAAC;gBAEzB,MAAM,EAAE,iBAAiB;IAsB/B,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAY/B"}
|
package/dist/client.js
CHANGED
|
@@ -5,30 +5,22 @@ const http_1 = require("./http");
|
|
|
5
5
|
const customers_1 = require("./customers");
|
|
6
6
|
const webhooks_1 = require("./webhooks");
|
|
7
7
|
const analytics_1 = require("./analytics");
|
|
8
|
+
const billing_1 = require("./billing");
|
|
9
|
+
const usage_1 = require("./usage");
|
|
8
10
|
class MossPartner {
|
|
9
11
|
constructor(config) {
|
|
10
12
|
if (!config.apiKey) {
|
|
11
13
|
throw new Error('apiKey is required');
|
|
12
14
|
}
|
|
13
|
-
if (!config.apiKey.startsWith('prt_')
|
|
15
|
+
if (!config.apiKey.startsWith('prt_')) {
|
|
14
16
|
throw new Error('apiKey must start with "prt_" (partner key)');
|
|
15
17
|
}
|
|
16
18
|
this.http = new http_1.HTTPClient(config);
|
|
17
19
|
this.customers = new customers_1.CustomersResource(this.http);
|
|
18
20
|
this.webhooks = new webhooks_1.WebhooksResource(this.http);
|
|
19
21
|
this.analytics = new analytics_1.AnalyticsResource(this.http);
|
|
20
|
-
|
|
21
|
-
|
|
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.');
|
|
22
|
+
this.billing = new billing_1.BillingResource(this.http);
|
|
23
|
+
this.usage = new usage_1.UsageResource(this.http);
|
|
32
24
|
}
|
|
33
25
|
async ping() {
|
|
34
26
|
try {
|
|
@@ -38,7 +30,7 @@ class MossPartner {
|
|
|
38
30
|
});
|
|
39
31
|
return response.status === 200;
|
|
40
32
|
}
|
|
41
|
-
catch
|
|
33
|
+
catch {
|
|
42
34
|
return false;
|
|
43
35
|
}
|
|
44
36
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAMA,iCAAoC;AACpC,2CAAgD;AAChD,yCAA8C;AAC9C,2CAAgD;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAMA,iCAAoC;AACpC,2CAAgD;AAChD,yCAA8C;AAC9C,2CAAgD;AAChD,uCAA4C;AAC5C,mCAAwC;AA0BxC,MAAa,WAAW;IAkBtB,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAU,CAAC,MAAM,CAAC,CAAC;QAEnC,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAMD,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;gBACvC,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AApDD,kCAoDC"}
|
package/dist/customers.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { HTTPClient } from './http';
|
|
2
|
-
import { Customer, CreateCustomerRequest, UpdateCustomerRequest, ListCustomersParams, ListCustomersResponse, PromoteCustomerRequest, SuspendCustomerRequest, ReactivateCustomerRequest,
|
|
2
|
+
import { Customer, CreateCustomerRequest, UpdateCustomerRequest, ListCustomersParams, ListCustomersResponse, PromoteCustomerRequest, SuspendCustomerRequest, ReactivateCustomerRequest, InviteCustomerRequest, InviteCustomerResponse, PromotionReadinessResponse, SessionResponse, ComplianceReportResponse } from './types';
|
|
3
3
|
export declare class CustomersResource {
|
|
4
4
|
private http;
|
|
5
5
|
constructor(http: HTTPClient);
|
|
6
|
-
|
|
7
|
-
private mapSessionResponse;
|
|
8
|
-
private parsePdfSignatureTrailer;
|
|
9
|
-
create(request: CreateCustomerRequest): Promise<Customer>;
|
|
6
|
+
create(request: CreateCustomerRequest, idempotencyKey?: string): Promise<Customer>;
|
|
10
7
|
list(params?: ListCustomersParams): Promise<ListCustomersResponse>;
|
|
11
8
|
get(customerId: string): Promise<Customer>;
|
|
12
9
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
promote(customerId: string, request: PromoteCustomerRequest, idempotencyKey?: string): Promise<Customer>;
|
|
11
|
+
suspend(customerId: string, request: SuspendCustomerRequest, idempotencyKey?: string): Promise<Customer>;
|
|
12
|
+
reactivate(customerId: string, request: ReactivateCustomerRequest, idempotencyKey?: string): Promise<Customer>;
|
|
13
|
+
delete(customerId: string): Promise<Customer>;
|
|
14
|
+
createSession(customerId: string, idempotencyKey?: string): Promise<SessionResponse>;
|
|
15
|
+
revokeSession(customerId: string, sessionId?: string): Promise<void>;
|
|
16
|
+
invite(customerId: string, request: InviteCustomerRequest): Promise<InviteCustomerResponse>;
|
|
17
|
+
promotionReadiness(customerId: string): Promise<PromotionReadinessResponse>;
|
|
18
|
+
complianceReport(customerId: string): Promise<ComplianceReportResponse>;
|
|
19
|
+
private parsePdfSignatureTrailer;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=customers.d.ts.map
|
package/dist/customers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../src/customers.ts"],"names":[],"mappings":"AAOA,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,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EAEzB,MAAM,SAAS,CAAC;AAEjB,qBAAa,iBAAiB;IAChB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAQ9B,MAAM,CACV,OAAO,EAAE,qBAAqB,EAC9B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,CAAC;IAuBd,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2BlE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAa1C,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,QAAQ,CAAC;IAiBd,OAAO,CACX,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,CAAC;IAsBd,OAAO,CACX,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,CAAC;IAsBd,UAAU,CACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,yBAAyB,EAClC,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,CAAC;IAsBd,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgB7C,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;IAsBrB,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAiBV,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IAc5B,kBAAkB,CACtB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,0BAA0B,CAAC;IAiBhC,gBAAgB,CACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,wBAAwB,CAAC;IAapC,OAAO,CAAC,wBAAwB;CA+CjC"}
|
package/dist/customers.js
CHANGED
|
@@ -1,74 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomersResource = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
class CustomersResource {
|
|
5
6
|
constructor(http) {
|
|
6
7
|
this.http = http;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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');
|
|
9
|
+
async create(request, idempotencyKey) {
|
|
10
|
+
const headers = {};
|
|
11
|
+
if (idempotencyKey) {
|
|
12
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
52
13
|
}
|
|
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
14
|
const response = await this.http.request({
|
|
67
15
|
method: 'POST',
|
|
68
16
|
path: '/v1/partner/customers',
|
|
69
17
|
body: request,
|
|
18
|
+
headers,
|
|
70
19
|
});
|
|
71
|
-
return
|
|
20
|
+
return response.data;
|
|
72
21
|
}
|
|
73
22
|
async list(params) {
|
|
74
23
|
const response = await this.http.request({
|
|
@@ -76,19 +25,18 @@ class CustomersResource {
|
|
|
76
25
|
path: '/v1/partner/customers',
|
|
77
26
|
query: params,
|
|
78
27
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
}
|
|
28
|
+
const customers = response.data.customers || [];
|
|
29
|
+
const limit = params?.limit || 100;
|
|
30
|
+
const offset = params?.offset || 0;
|
|
31
|
+
const total = customers.length;
|
|
89
32
|
return {
|
|
90
|
-
|
|
91
|
-
pagination:
|
|
33
|
+
customers,
|
|
34
|
+
pagination: {
|
|
35
|
+
total,
|
|
36
|
+
limit,
|
|
37
|
+
offset,
|
|
38
|
+
has_more: total === limit,
|
|
39
|
+
},
|
|
92
40
|
};
|
|
93
41
|
}
|
|
94
42
|
async get(customerId) {
|
|
@@ -96,7 +44,7 @@ class CustomersResource {
|
|
|
96
44
|
method: 'GET',
|
|
97
45
|
path: `/v1/partner/customers/${customerId}`,
|
|
98
46
|
});
|
|
99
|
-
return
|
|
47
|
+
return response.data;
|
|
100
48
|
}
|
|
101
49
|
async update(customerId, request) {
|
|
102
50
|
const response = await this.http.request({
|
|
@@ -104,68 +52,135 @@ class CustomersResource {
|
|
|
104
52
|
path: `/v1/partner/customers/${customerId}`,
|
|
105
53
|
body: request,
|
|
106
54
|
});
|
|
107
|
-
return
|
|
55
|
+
return response.data;
|
|
108
56
|
}
|
|
109
|
-
async promote(customerId, request) {
|
|
57
|
+
async promote(customerId, request, idempotencyKey) {
|
|
58
|
+
const headers = {};
|
|
59
|
+
if (idempotencyKey) {
|
|
60
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
61
|
+
}
|
|
110
62
|
const response = await this.http.request({
|
|
111
63
|
method: 'POST',
|
|
112
64
|
path: `/v1/partner/customers/${customerId}/promote`,
|
|
113
65
|
body: request,
|
|
66
|
+
headers,
|
|
114
67
|
});
|
|
115
|
-
return
|
|
68
|
+
return response.data;
|
|
116
69
|
}
|
|
117
|
-
async suspend(customerId, request) {
|
|
70
|
+
async suspend(customerId, request, idempotencyKey) {
|
|
71
|
+
const headers = {};
|
|
72
|
+
if (idempotencyKey) {
|
|
73
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
74
|
+
}
|
|
118
75
|
const response = await this.http.request({
|
|
119
76
|
method: 'POST',
|
|
120
77
|
path: `/v1/partner/customers/${customerId}/suspend`,
|
|
121
78
|
body: request,
|
|
79
|
+
headers,
|
|
122
80
|
});
|
|
123
|
-
return
|
|
81
|
+
return response.data;
|
|
124
82
|
}
|
|
125
|
-
async reactivate(customerId, request) {
|
|
83
|
+
async reactivate(customerId, request, idempotencyKey) {
|
|
84
|
+
const headers = {};
|
|
85
|
+
if (idempotencyKey) {
|
|
86
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
87
|
+
}
|
|
126
88
|
const response = await this.http.request({
|
|
127
89
|
method: 'POST',
|
|
128
90
|
path: `/v1/partner/customers/${customerId}/reactivate`,
|
|
129
91
|
body: request,
|
|
92
|
+
headers,
|
|
93
|
+
});
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
async delete(customerId) {
|
|
97
|
+
const response = await this.http.request({
|
|
98
|
+
method: 'DELETE',
|
|
99
|
+
path: `/v1/partner/customers/${customerId}`,
|
|
130
100
|
});
|
|
131
|
-
return
|
|
101
|
+
return response.data;
|
|
132
102
|
}
|
|
133
|
-
async createSession(customerId,
|
|
103
|
+
async createSession(customerId, idempotencyKey) {
|
|
104
|
+
const headers = {};
|
|
105
|
+
if (idempotencyKey) {
|
|
106
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
107
|
+
}
|
|
134
108
|
const response = await this.http.request({
|
|
135
109
|
method: 'POST',
|
|
136
110
|
path: `/v1/partner/customers/${customerId}/session`,
|
|
137
|
-
|
|
111
|
+
headers,
|
|
138
112
|
});
|
|
139
|
-
return
|
|
113
|
+
return response.data;
|
|
140
114
|
}
|
|
141
|
-
async revokeSession(customerId,
|
|
115
|
+
async revokeSession(customerId, sessionId) {
|
|
116
|
+
const body = {};
|
|
117
|
+
if (sessionId) {
|
|
118
|
+
body.session_id = sessionId;
|
|
119
|
+
}
|
|
142
120
|
await this.http.request({
|
|
143
121
|
method: 'DELETE',
|
|
144
122
|
path: `/v1/partner/customers/${customerId}/session`,
|
|
145
|
-
body
|
|
123
|
+
body,
|
|
146
124
|
});
|
|
147
125
|
}
|
|
148
|
-
async
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
},
|
|
126
|
+
async invite(customerId, request) {
|
|
127
|
+
const response = await this.http.request({
|
|
128
|
+
method: 'POST',
|
|
129
|
+
path: `/v1/partner/customers/${customerId}/invite`,
|
|
130
|
+
body: request,
|
|
162
131
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
async promotionReadiness(customerId) {
|
|
135
|
+
const response = await this.http.request({
|
|
136
|
+
method: 'GET',
|
|
137
|
+
path: `/v1/partner/customers/${customerId}/promotion-readiness`,
|
|
138
|
+
});
|
|
139
|
+
return response.data;
|
|
140
|
+
}
|
|
141
|
+
async complianceReport(customerId) {
|
|
142
|
+
const pdfBuffer = await this.http.requestBytes('GET', `/v1/partner/customers/${customerId}/compliance-report`);
|
|
167
143
|
return this.parsePdfSignatureTrailer(pdfBuffer);
|
|
168
144
|
}
|
|
145
|
+
parsePdfSignatureTrailer(pdfBuffer) {
|
|
146
|
+
const decoder = new TextDecoder('utf-8');
|
|
147
|
+
const pdfText = decoder.decode(pdfBuffer);
|
|
148
|
+
const endMarker = '%%MOSS-SIGNATURE-V1-END';
|
|
149
|
+
const endIndex = pdfText.lastIndexOf(endMarker);
|
|
150
|
+
if (endIndex === -1) {
|
|
151
|
+
throw new types_1.MossParseError('PDF does not contain MOSS signature trailer');
|
|
152
|
+
}
|
|
153
|
+
const beginMarker = '%%MOSS-SIGNATURE-V1-BEGIN';
|
|
154
|
+
const beginIndex = pdfText.lastIndexOf(beginMarker, endIndex);
|
|
155
|
+
if (beginIndex === -1) {
|
|
156
|
+
throw new types_1.MossParseError('Invalid MOSS signature trailer: begin marker not found');
|
|
157
|
+
}
|
|
158
|
+
const jsonStart = beginIndex + beginMarker.length;
|
|
159
|
+
const jsonEnd = endIndex;
|
|
160
|
+
const jsonText = pdfText.substring(jsonStart, jsonEnd).trim();
|
|
161
|
+
let trailer;
|
|
162
|
+
try {
|
|
163
|
+
trailer = JSON.parse(jsonText);
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
throw new types_1.MossParseError(`Invalid MOSS signature trailer JSON: ${e}`);
|
|
167
|
+
}
|
|
168
|
+
let signedPayload;
|
|
169
|
+
try {
|
|
170
|
+
signedPayload = JSON.parse(trailer.signed_payload);
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
throw new types_1.MossParseError(`Invalid signed_payload in trailer: ${e}`);
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
report_id: signedPayload.report_id,
|
|
177
|
+
signature: trailer.signature_hex,
|
|
178
|
+
key_id: signedPayload.key_id || trailer.key_id || 'moss_prod_2026_Q1',
|
|
179
|
+
generated_at: signedPayload.generated_at,
|
|
180
|
+
download_url: trailer.verify_url,
|
|
181
|
+
data: signedPayload,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
169
184
|
}
|
|
170
185
|
exports.CustomersResource = CustomersResource;
|
|
171
186
|
//# sourceMappingURL=customers.js.map
|