@metronome/sdk 0.1.0-alpha.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/CHANGELOG.md +24 -0
- package/LICENSE +201 -0
- package/README.md +313 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +90 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +237 -0
- package/core.d.ts.map +1 -0
- package/core.js +868 -0
- package/core.js.map +1 -0
- package/core.mjs +837 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +210 -0
- package/index.d.ts +210 -0
- package/index.d.ts.map +1 -0
- package/index.js +133 -0
- package/index.js.map +1 -0
- package/index.mjs +105 -0
- package/index.mjs.map +1 -0
- package/package.json +106 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/alerts.d.ts +103 -0
- package/resources/alerts.d.ts.map +1 -0
- package/resources/alerts.js +23 -0
- package/resources/alerts.js.map +1 -0
- package/resources/alerts.mjs +19 -0
- package/resources/alerts.mjs.map +1 -0
- package/resources/audit-logs.d.ts +83 -0
- package/resources/audit-logs.d.ts.map +1 -0
- package/resources/audit-logs.js +18 -0
- package/resources/audit-logs.js.map +1 -0
- package/resources/audit-logs.mjs +14 -0
- package/resources/audit-logs.mjs.map +1 -0
- package/resources/billable-metrics.d.ts +236 -0
- package/resources/billable-metrics.d.ts.map +1 -0
- package/resources/billable-metrics.js +36 -0
- package/resources/billable-metrics.js.map +1 -0
- package/resources/billable-metrics.mjs +32 -0
- package/resources/billable-metrics.mjs.map +1 -0
- package/resources/credit-grants.d.ts +469 -0
- package/resources/credit-grants.d.ts.map +1 -0
- package/resources/credit-grants.js +50 -0
- package/resources/credit-grants.js.map +1 -0
- package/resources/credit-grants.mjs +46 -0
- package/resources/credit-grants.mjs.map +1 -0
- package/resources/custom-fields.d.ts +82 -0
- package/resources/custom-fields.d.ts.map +1 -0
- package/resources/custom-fields.js +66 -0
- package/resources/custom-fields.js.map +1 -0
- package/resources/custom-fields.mjs +62 -0
- package/resources/custom-fields.mjs.map +1 -0
- package/resources/customers/alerts.d.ts +146 -0
- package/resources/customers/alerts.d.ts.map +1 -0
- package/resources/customers/alerts.js +35 -0
- package/resources/customers/alerts.js.map +1 -0
- package/resources/customers/alerts.mjs +31 -0
- package/resources/customers/alerts.mjs.map +1 -0
- package/resources/customers/billing-config.d.ts +64 -0
- package/resources/customers/billing-config.d.ts.map +1 -0
- package/resources/customers/billing-config.js +37 -0
- package/resources/customers/billing-config.js.map +1 -0
- package/resources/customers/billing-config.mjs +33 -0
- package/resources/customers/billing-config.mjs.map +1 -0
- package/resources/customers/customers.d.ts +313 -0
- package/resources/customers/customers.d.ts.map +1 -0
- package/resources/customers/customers.js +116 -0
- package/resources/customers/customers.js.map +1 -0
- package/resources/customers/customers.mjs +89 -0
- package/resources/customers/customers.mjs.map +1 -0
- package/resources/customers/index.d.ts +6 -0
- package/resources/customers/index.d.ts.map +1 -0
- package/resources/customers/index.js +15 -0
- package/resources/customers/index.js.map +1 -0
- package/resources/customers/index.mjs +7 -0
- package/resources/customers/index.mjs.map +1 -0
- package/resources/customers/invoices.d.ts +331 -0
- package/resources/customers/invoices.d.ts.map +1 -0
- package/resources/customers/invoices.js +30 -0
- package/resources/customers/invoices.js.map +1 -0
- package/resources/customers/invoices.mjs +26 -0
- package/resources/customers/invoices.mjs.map +1 -0
- package/resources/customers/plans.d.ts +239 -0
- package/resources/customers/plans.d.ts.map +1 -0
- package/resources/customers/plans.js +41 -0
- package/resources/customers/plans.js.map +1 -0
- package/resources/customers/plans.mjs +37 -0
- package/resources/customers/plans.mjs.map +1 -0
- package/resources/dashboards.d.ts +61 -0
- package/resources/dashboards.d.ts.map +1 -0
- package/resources/dashboards.js +19 -0
- package/resources/dashboards.js.map +1 -0
- package/resources/dashboards.mjs +15 -0
- package/resources/dashboards.mjs.map +1 -0
- package/resources/index.d.ts +13 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +42 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +14 -0
- package/resources/index.mjs.map +1 -0
- package/resources/plans.d.ts +217 -0
- package/resources/plans.d.ts.map +1 -0
- package/resources/plans.js +36 -0
- package/resources/plans.js.map +1 -0
- package/resources/plans.mjs +32 -0
- package/resources/plans.mjs.map +1 -0
- package/resources/services.d.ts +26 -0
- package/resources/services.d.ts.map +1 -0
- package/resources/services.js +20 -0
- package/resources/services.js.map +1 -0
- package/resources/services.mjs +16 -0
- package/resources/services.mjs.map +1 -0
- package/resources/shared.d.ts +540 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/resources/usage.d.ts +182 -0
- package/resources/usage.d.ts.map +1 -0
- package/resources/usage.js +41 -0
- package/resources/usage.js.map +1 -0
- package/resources/usage.mjs +37 -0
- package/resources/usage.mjs.map +1 -0
- package/resources/webhooks.d.ts +22 -0
- package/resources/webhooks.d.ts.map +1 -0
- package/resources/webhooks.js +91 -0
- package/resources/webhooks.js.map +1 -0
- package/resources/webhooks.mjs +87 -0
- package/resources/webhooks.mjs.map +1 -0
- package/shims/node.d.ts +29 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +83 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1146 -0
- package/src/error.ts +146 -0
- package/src/index.ts +303 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/alerts.ts +144 -0
- package/src/resources/audit-logs.ts +116 -0
- package/src/resources/billable-metrics.ts +341 -0
- package/src/resources/credit-grants.ts +627 -0
- package/src/resources/custom-fields.ts +242 -0
- package/src/resources/customers/alerts.ts +214 -0
- package/src/resources/customers/billing-config.ts +183 -0
- package/src/resources/customers/customers.ts +500 -0
- package/src/resources/customers/index.ts +53 -0
- package/src/resources/customers/invoices.ts +533 -0
- package/src/resources/customers/plans.ts +363 -0
- package/src/resources/dashboards.ts +98 -0
- package/src/resources/index.ts +90 -0
- package/src/resources/plans.ts +333 -0
- package/src/resources/services.ts +35 -0
- package/src/resources/shared.ts +849 -0
- package/src/resources/usage.ts +245 -0
- package/src/resources/webhooks.ts +120 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +248 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +165 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +152 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as Core from '@metronome/sdk/core';
|
|
2
|
+
import { APIResource } from '@metronome/sdk/resource';
|
|
3
|
+
import * as UsageAPI from '@metronome/sdk/resources/usage';
|
|
4
|
+
export declare class Usage extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Fetch aggregated usage data for multiple customers and billable-metrics, broken
|
|
7
|
+
* into intervals of the specified length.
|
|
8
|
+
*/
|
|
9
|
+
list(params: UsageListParams, options?: Core.RequestOptions): Core.APIPromise<UsageListResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Send usage events to Metronome. The body of this request is expected to be a
|
|
12
|
+
* JSON array of between 1 and 100 usage events. Compressed request bodies are
|
|
13
|
+
* supported with a `Content-Encoding: gzip` header. See
|
|
14
|
+
* [Getting usage into Metronome](https://docs.metronome.com/getting-usage-data-into-metronome/overview)
|
|
15
|
+
* to learn more about usage events.
|
|
16
|
+
*/
|
|
17
|
+
ingest(body: UsageIngestParams, options?: Core.RequestOptions): Core.APIPromise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch aggregated usage data for the specified customer, billable-metric, and
|
|
20
|
+
* optional group, broken into intervals of the specified length.
|
|
21
|
+
*/
|
|
22
|
+
listWithGroups(params: UsageListWithGroupsParams, options?: Core.RequestOptions): Core.APIPromise<UsageListWithGroupsResponse>;
|
|
23
|
+
}
|
|
24
|
+
export interface UsageListResponse {
|
|
25
|
+
data: Array<UsageListResponse.Data>;
|
|
26
|
+
next_page: string | null;
|
|
27
|
+
}
|
|
28
|
+
export declare namespace UsageListResponse {
|
|
29
|
+
interface Data {
|
|
30
|
+
billable_metric_id: string;
|
|
31
|
+
billable_metric_name: string;
|
|
32
|
+
customer_id: string;
|
|
33
|
+
end_timestamp: string;
|
|
34
|
+
start_timestamp: string;
|
|
35
|
+
value: number | null;
|
|
36
|
+
/**
|
|
37
|
+
* Values will be either a number or null. Null indicates that there were no
|
|
38
|
+
* matches for the group_by value.
|
|
39
|
+
*/
|
|
40
|
+
groups?: Record<string, number | null>;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export interface UsageListWithGroupsResponse {
|
|
44
|
+
data: Array<UsageListWithGroupsResponse.Data>;
|
|
45
|
+
next_page: string | null;
|
|
46
|
+
}
|
|
47
|
+
export declare namespace UsageListWithGroupsResponse {
|
|
48
|
+
interface Data {
|
|
49
|
+
ending_before: string;
|
|
50
|
+
group_key: string | null;
|
|
51
|
+
group_value: string | null;
|
|
52
|
+
starting_on: string;
|
|
53
|
+
value: number | null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export interface UsageListParams {
|
|
57
|
+
/**
|
|
58
|
+
* Body param:
|
|
59
|
+
*/
|
|
60
|
+
ending_before: string;
|
|
61
|
+
/**
|
|
62
|
+
* Body param:
|
|
63
|
+
*/
|
|
64
|
+
starting_on: string;
|
|
65
|
+
/**
|
|
66
|
+
* Body param: A window_size of "day" or "hour" will return the usage for the
|
|
67
|
+
* specified period segmented into daily or hourly aggregates. A window_size of
|
|
68
|
+
* "none" will return a single usage aggregate for the entirety of the specified
|
|
69
|
+
* period.
|
|
70
|
+
*/
|
|
71
|
+
window_size: 'hour' | 'day' | 'none' | 'HOUR' | 'DAY' | 'NONE' | 'Hour' | 'Day' | 'None';
|
|
72
|
+
/**
|
|
73
|
+
* Query param: Cursor that indicates where the next page of results should start.
|
|
74
|
+
*/
|
|
75
|
+
next_page?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Body param: A list of billable metrics to fetch usage for. If absent, all
|
|
78
|
+
* billable metrics will be returned.
|
|
79
|
+
*/
|
|
80
|
+
billable_metrics?: Array<UsageListParams.BillableMetric>;
|
|
81
|
+
/**
|
|
82
|
+
* Body param: A list of Metronome customer IDs to fetch usage for. If absent,
|
|
83
|
+
* usage for all customers will be returned.
|
|
84
|
+
*/
|
|
85
|
+
customer_ids?: Array<string>;
|
|
86
|
+
}
|
|
87
|
+
export declare namespace UsageListParams {
|
|
88
|
+
interface BillableMetric {
|
|
89
|
+
id: string;
|
|
90
|
+
group_by?: BillableMetric.GroupBy;
|
|
91
|
+
}
|
|
92
|
+
namespace BillableMetric {
|
|
93
|
+
interface GroupBy {
|
|
94
|
+
/**
|
|
95
|
+
* The name of the group_by key to use
|
|
96
|
+
*/
|
|
97
|
+
key: string;
|
|
98
|
+
/**
|
|
99
|
+
* Values of the group_by key to return in the query. If this field is omitted, all
|
|
100
|
+
* available values will be returned, up to a maximum of 200.
|
|
101
|
+
*/
|
|
102
|
+
values?: Array<string>;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export type UsageIngestParams = Array<UsageIngestParams.Usage>;
|
|
107
|
+
export declare namespace UsageIngestParams {
|
|
108
|
+
interface Usage {
|
|
109
|
+
customer_id: string;
|
|
110
|
+
event_type: string;
|
|
111
|
+
/**
|
|
112
|
+
* RFC 3339 formatted
|
|
113
|
+
*/
|
|
114
|
+
timestamp: string;
|
|
115
|
+
transaction_id: string;
|
|
116
|
+
properties?: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export interface UsageListWithGroupsParams {
|
|
120
|
+
/**
|
|
121
|
+
* Body param:
|
|
122
|
+
*/
|
|
123
|
+
billable_metric_id: string;
|
|
124
|
+
/**
|
|
125
|
+
* Body param:
|
|
126
|
+
*/
|
|
127
|
+
customer_id: string;
|
|
128
|
+
/**
|
|
129
|
+
* Body param: A window_size of "day" or "hour" will return the usage for the
|
|
130
|
+
* specified period segmented into daily or hourly aggregates. A window_size of
|
|
131
|
+
* "none" will return a single usage aggregate for the entirety of the specified
|
|
132
|
+
* period.
|
|
133
|
+
*/
|
|
134
|
+
window_size: 'hour' | 'day' | 'none' | 'HOUR' | 'DAY' | 'NONE' | 'Hour' | 'Day' | 'None';
|
|
135
|
+
/**
|
|
136
|
+
* Query param: Max number of results that should be returned
|
|
137
|
+
*/
|
|
138
|
+
limit?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Query param: Cursor that indicates where the next page of results should start.
|
|
141
|
+
*/
|
|
142
|
+
next_page?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Body param: If true, will return the usage for the current billing period. Will
|
|
145
|
+
* return an error if the customer is currently uncontracted or starting_on and
|
|
146
|
+
* ending_before are specified when this is true.
|
|
147
|
+
*/
|
|
148
|
+
current_period?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Body param:
|
|
151
|
+
*/
|
|
152
|
+
ending_before?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Body param:
|
|
155
|
+
*/
|
|
156
|
+
group_by?: UsageListWithGroupsParams.GroupBy;
|
|
157
|
+
/**
|
|
158
|
+
* Body param:
|
|
159
|
+
*/
|
|
160
|
+
starting_on?: string;
|
|
161
|
+
}
|
|
162
|
+
export declare namespace UsageListWithGroupsParams {
|
|
163
|
+
interface GroupBy {
|
|
164
|
+
/**
|
|
165
|
+
* The name of the group_by key to use
|
|
166
|
+
*/
|
|
167
|
+
key: string;
|
|
168
|
+
/**
|
|
169
|
+
* Values of the group_by key to return in the query. Omit this if you'd like all
|
|
170
|
+
* values for the key returned.
|
|
171
|
+
*/
|
|
172
|
+
values?: Array<string>;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export declare namespace Usage {
|
|
176
|
+
export import UsageListResponse = UsageAPI.UsageListResponse;
|
|
177
|
+
export import UsageListWithGroupsResponse = UsageAPI.UsageListWithGroupsResponse;
|
|
178
|
+
export import UsageListParams = UsageAPI.UsageListParams;
|
|
179
|
+
export import UsageIngestParams = UsageAPI.UsageIngestParams;
|
|
180
|
+
export import UsageListWithGroupsParams = UsageAPI.UsageListWithGroupsParams;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/resources/usage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,qBAAa,KAAM,SAAQ,WAAW;IACpC;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAKhG;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,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,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC;IAE7C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yBAAiB,yBAAyB,CAAC;IACzC,UAAiB,OAAO;QACtB;;WAEG;QACH,GAAG,EAAE,MAAM,CAAC;QAEZ;;;WAGG;QACH,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACxB;CACF;AAED,yBAAiB,KAAK,CAAC;IACrB,MAAM,QAAQ,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IAC7D,MAAM,QAAQ,2BAA2B,GAAG,QAAQ,CAAC,2BAA2B,CAAC;IACjF,MAAM,QAAQ,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;IACzD,MAAM,QAAQ,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IAC7D,MAAM,QAAQ,yBAAyB,GAAG,QAAQ,CAAC,yBAAyB,CAAC;CAC9E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Usage = void 0;
|
|
5
|
+
const resource_1 = require("@metronome/sdk/resource");
|
|
6
|
+
class Usage extends resource_1.APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Fetch aggregated usage data for multiple customers and billable-metrics, broken
|
|
9
|
+
* into intervals of the specified length.
|
|
10
|
+
*/
|
|
11
|
+
list(params, options) {
|
|
12
|
+
const { next_page, ...body } = params;
|
|
13
|
+
return this._client.post('/usage', { query: { next_page }, body, ...options });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Send usage events to Metronome. The body of this request is expected to be a
|
|
17
|
+
* JSON array of between 1 and 100 usage events. Compressed request bodies are
|
|
18
|
+
* supported with a `Content-Encoding: gzip` header. See
|
|
19
|
+
* [Getting usage into Metronome](https://docs.metronome.com/getting-usage-data-into-metronome/overview)
|
|
20
|
+
* to learn more about usage events.
|
|
21
|
+
*/
|
|
22
|
+
ingest(body, options) {
|
|
23
|
+
return this._client.post('/ingest', {
|
|
24
|
+
body,
|
|
25
|
+
...options,
|
|
26
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Fetch aggregated usage data for the specified customer, billable-metric, and
|
|
31
|
+
* optional group, broken into intervals of the specified length.
|
|
32
|
+
*/
|
|
33
|
+
listWithGroups(params, options) {
|
|
34
|
+
const { limit, next_page, ...body } = params;
|
|
35
|
+
return this._client.post('/usage/groups', { query: { limit, next_page }, body, ...options });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Usage = Usage;
|
|
39
|
+
(function (Usage) {
|
|
40
|
+
})(Usage = exports.Usage || (exports.Usage = {}));
|
|
41
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/resources/usage.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAGtF,sDAAsD;AAGtD,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;OAGG;IACH,IAAI,CAAC,MAAuB,EAAE,OAA6B;QACzD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAuB,EAAE,OAA6B;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;YAClC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,cAAc,CACZ,MAAiC,EACjC,OAA6B;QAE7B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;CACF;AApCD,sBAoCC;AAoMD,WAAiB,KAAK;AAMtB,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAMrB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from '@metronome/sdk/resource';
|
|
3
|
+
export class Usage extends APIResource {
|
|
4
|
+
/**
|
|
5
|
+
* Fetch aggregated usage data for multiple customers and billable-metrics, broken
|
|
6
|
+
* into intervals of the specified length.
|
|
7
|
+
*/
|
|
8
|
+
list(params, options) {
|
|
9
|
+
const { next_page, ...body } = params;
|
|
10
|
+
return this._client.post('/usage', { query: { next_page }, body, ...options });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Send usage events to Metronome. The body of this request is expected to be a
|
|
14
|
+
* JSON array of between 1 and 100 usage events. Compressed request bodies are
|
|
15
|
+
* supported with a `Content-Encoding: gzip` header. See
|
|
16
|
+
* [Getting usage into Metronome](https://docs.metronome.com/getting-usage-data-into-metronome/overview)
|
|
17
|
+
* to learn more about usage events.
|
|
18
|
+
*/
|
|
19
|
+
ingest(body, options) {
|
|
20
|
+
return this._client.post('/ingest', {
|
|
21
|
+
body,
|
|
22
|
+
...options,
|
|
23
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Fetch aggregated usage data for the specified customer, billable-metric, and
|
|
28
|
+
* optional group, broken into intervals of the specified length.
|
|
29
|
+
*/
|
|
30
|
+
listWithGroups(params, options) {
|
|
31
|
+
const { limit, next_page, ...body } = params;
|
|
32
|
+
return this._client.post('/usage/groups', { query: { limit, next_page }, body, ...options });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
(function (Usage) {
|
|
36
|
+
})(Usage || (Usage = {}));
|
|
37
|
+
//# sourceMappingURL=usage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.mjs","sourceRoot":"","sources":["../src/resources/usage.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,WAAW,EAAE,MAAM,yBAAyB;AAGrD,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;OAGG;IACH,IAAI,CAAC,MAAuB,EAAE,OAA6B;QACzD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAuB,EAAE,OAA6B;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;YAClC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,cAAc,CACZ,MAAiC,EACjC,OAA6B;QAE7B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;CACF;AAoMD,WAAiB,KAAK;AAMtB,CAAC,EANgB,KAAK,KAAL,KAAK,QAMrB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { APIResource } from "../resource.js";
|
|
2
|
+
import { HeadersLike } from "../core.js";
|
|
3
|
+
export declare class Webhooks extends APIResource {
|
|
4
|
+
/**
|
|
5
|
+
* Validates that the given payload was sent by Metronome and parses the payload.
|
|
6
|
+
*/
|
|
7
|
+
unwrap(payload: string, headers: HeadersLike, secret?: string | undefined | null): Object;
|
|
8
|
+
private validateSecret;
|
|
9
|
+
private signPayload;
|
|
10
|
+
/** Make an assertion, if not `true`, then throw. */
|
|
11
|
+
private assert;
|
|
12
|
+
/** Compare to array buffers or data views in a way that timing based attacks
|
|
13
|
+
* cannot gain information about the platform. */
|
|
14
|
+
private timingSafeEqual;
|
|
15
|
+
/**
|
|
16
|
+
* Validates whether or not the webhook payload was sent by Metronome.
|
|
17
|
+
*
|
|
18
|
+
* An error will be raised if the webhook payload was not sent by Metronome.
|
|
19
|
+
*/
|
|
20
|
+
verifySignature(body: string, headers: HeadersLike, secret?: string | undefined | null): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/resources/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAqB,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,qBAAa,QAAS,SAAQ,WAAW;IACvC;;OAEG;IACH,MAAM,CACJ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW,EACpB,MAAM,GAAE,MAAM,GAAG,SAAS,GAAG,IAAiC,GAC7D,MAAM;IAKT,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,WAAW;IAUnB,oDAAoD;IACpD,OAAO,CAAC,MAAM;IAMd;qDACiD;IACjD,OAAO,CAAC,eAAe;IAwBvB;;;;OAIG;IACH,eAAe,CACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,MAAM,GAAE,MAAM,GAAG,SAAS,GAAG,IAAiC,GAC7D,IAAI;CAsCR"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Webhooks = void 0;
|
|
5
|
+
const resource_1 = require("../resource.js");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
const core_1 = require("../core.js");
|
|
8
|
+
class Webhooks extends resource_1.APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Validates that the given payload was sent by Metronome and parses the payload.
|
|
11
|
+
*/
|
|
12
|
+
unwrap(payload, headers, secret = this._client.webhookSecret) {
|
|
13
|
+
this.verifySignature(payload, headers, secret);
|
|
14
|
+
return JSON.parse(payload);
|
|
15
|
+
}
|
|
16
|
+
validateSecret(secret) {
|
|
17
|
+
if (typeof secret !== 'string') {
|
|
18
|
+
throw new Error("The webhook secret must either be set using the env var, METRONOME_WEBHOOK_SECRET, on the client class, Metronome({ webhook_secret: '123' }), or passed to this function");
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
signPayload(payload, { date, secret }) {
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const toSign = encoder.encode(`${date}\n${payload}`);
|
|
25
|
+
const hmac = (0, crypto_1.createHmac)('sha256', secret);
|
|
26
|
+
hmac.update(toSign);
|
|
27
|
+
return hmac.digest('hex');
|
|
28
|
+
}
|
|
29
|
+
/** Make an assertion, if not `true`, then throw. */
|
|
30
|
+
assert(expr, msg = '') {
|
|
31
|
+
if (!expr) {
|
|
32
|
+
throw new Error(msg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Compare to array buffers or data views in a way that timing based attacks
|
|
36
|
+
* cannot gain information about the platform. */
|
|
37
|
+
timingSafeEqual(a, b) {
|
|
38
|
+
if (a.byteLength !== b.byteLength) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (!(a instanceof DataView)) {
|
|
42
|
+
a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
|
|
43
|
+
}
|
|
44
|
+
if (!(b instanceof DataView)) {
|
|
45
|
+
b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
|
|
46
|
+
}
|
|
47
|
+
this.assert(a instanceof DataView);
|
|
48
|
+
this.assert(b instanceof DataView);
|
|
49
|
+
const length = a.byteLength;
|
|
50
|
+
let out = 0;
|
|
51
|
+
let i = -1;
|
|
52
|
+
while (++i < length) {
|
|
53
|
+
out |= a.getUint8(i) ^ b.getUint8(i);
|
|
54
|
+
}
|
|
55
|
+
return out === 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Validates whether or not the webhook payload was sent by Metronome.
|
|
59
|
+
*
|
|
60
|
+
* An error will be raised if the webhook payload was not sent by Metronome.
|
|
61
|
+
*/
|
|
62
|
+
verifySignature(body, headers, secret = this._client.webhookSecret) {
|
|
63
|
+
this.validateSecret(secret);
|
|
64
|
+
const msgDate = (0, core_1.getRequiredHeader)(headers, 'Date');
|
|
65
|
+
const msgSignature = (0, core_1.getRequiredHeader)(headers, 'Metronome-Webhook-Signature');
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
const timestampSeconds = Math.floor(new Date(msgDate).valueOf());
|
|
68
|
+
if (isNaN(timestampSeconds)) {
|
|
69
|
+
throw new Error(`Invalid timestamp header: ${msgDate}`);
|
|
70
|
+
}
|
|
71
|
+
if (typeof body !== 'string') {
|
|
72
|
+
throw new Error('Webhook body must be passed as the raw JSON string sent from the server (do not parse it first).');
|
|
73
|
+
}
|
|
74
|
+
const webhook_tolerance_in_seconds = 5 * 60; // 5 minutes
|
|
75
|
+
if (now - timestampSeconds > webhook_tolerance_in_seconds) {
|
|
76
|
+
throw new Error('Webhook timestamp is too old');
|
|
77
|
+
}
|
|
78
|
+
if (timestampSeconds > now + webhook_tolerance_in_seconds) {
|
|
79
|
+
throw new Error('Webhook timestamp is too new');
|
|
80
|
+
}
|
|
81
|
+
const expectedSignature = this.signPayload(body, { date: msgDate, secret });
|
|
82
|
+
const encoder = new globalThis.TextEncoder();
|
|
83
|
+
if (this.timingSafeEqual(encoder.encode(msgSignature), encoder.encode(expectedSignature))) {
|
|
84
|
+
// valid!
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
throw new Error('The given webhook signature does not match the expected signature');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Webhooks = Webhooks;
|
|
91
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/resources/webhooks.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAC1C,mCAAoC;AACpC,qCAAyD;AAEzD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;OAEG;IACH,MAAM,CACJ,OAAe,EACf,OAAoB,EACpB,SAAoC,IAAI,CAAC,OAAO,CAAC,aAAa;QAE9D,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAE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AAG,4BAA4B,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QAED,IAAI,gBAAgB,GAAG,GAAG,GAAG,4BAA4B,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAE7C,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE;YACzF,SAAS;YACT,OAAO;SACR;QAED,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;CACF;AAjHD,4BAiHC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../resource.mjs";
|
|
3
|
+
import { createHmac } from 'crypto';
|
|
4
|
+
import { getRequiredHeader } from "../core.mjs";
|
|
5
|
+
export class Webhooks extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* Validates that the given payload was sent by Metronome and parses the payload.
|
|
8
|
+
*/
|
|
9
|
+
unwrap(payload, headers, secret = this._client.webhookSecret) {
|
|
10
|
+
this.verifySignature(payload, headers, secret);
|
|
11
|
+
return JSON.parse(payload);
|
|
12
|
+
}
|
|
13
|
+
validateSecret(secret) {
|
|
14
|
+
if (typeof secret !== 'string') {
|
|
15
|
+
throw new Error("The webhook secret must either be set using the env var, METRONOME_WEBHOOK_SECRET, on the client class, Metronome({ webhook_secret: '123' }), or passed to this function");
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
signPayload(payload, { date, secret }) {
|
|
20
|
+
const encoder = new TextEncoder();
|
|
21
|
+
const toSign = encoder.encode(`${date}\n${payload}`);
|
|
22
|
+
const hmac = createHmac('sha256', secret);
|
|
23
|
+
hmac.update(toSign);
|
|
24
|
+
return hmac.digest('hex');
|
|
25
|
+
}
|
|
26
|
+
/** Make an assertion, if not `true`, then throw. */
|
|
27
|
+
assert(expr, msg = '') {
|
|
28
|
+
if (!expr) {
|
|
29
|
+
throw new Error(msg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Compare to array buffers or data views in a way that timing based attacks
|
|
33
|
+
* cannot gain information about the platform. */
|
|
34
|
+
timingSafeEqual(a, b) {
|
|
35
|
+
if (a.byteLength !== b.byteLength) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (!(a instanceof DataView)) {
|
|
39
|
+
a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
|
|
40
|
+
}
|
|
41
|
+
if (!(b instanceof DataView)) {
|
|
42
|
+
b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
|
|
43
|
+
}
|
|
44
|
+
this.assert(a instanceof DataView);
|
|
45
|
+
this.assert(b instanceof DataView);
|
|
46
|
+
const length = a.byteLength;
|
|
47
|
+
let out = 0;
|
|
48
|
+
let i = -1;
|
|
49
|
+
while (++i < length) {
|
|
50
|
+
out |= a.getUint8(i) ^ b.getUint8(i);
|
|
51
|
+
}
|
|
52
|
+
return out === 0;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates whether or not the webhook payload was sent by Metronome.
|
|
56
|
+
*
|
|
57
|
+
* An error will be raised if the webhook payload was not sent by Metronome.
|
|
58
|
+
*/
|
|
59
|
+
verifySignature(body, headers, secret = this._client.webhookSecret) {
|
|
60
|
+
this.validateSecret(secret);
|
|
61
|
+
const msgDate = getRequiredHeader(headers, 'Date');
|
|
62
|
+
const msgSignature = getRequiredHeader(headers, 'Metronome-Webhook-Signature');
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
const timestampSeconds = Math.floor(new Date(msgDate).valueOf());
|
|
65
|
+
if (isNaN(timestampSeconds)) {
|
|
66
|
+
throw new Error(`Invalid timestamp header: ${msgDate}`);
|
|
67
|
+
}
|
|
68
|
+
if (typeof body !== 'string') {
|
|
69
|
+
throw new Error('Webhook body must be passed as the raw JSON string sent from the server (do not parse it first).');
|
|
70
|
+
}
|
|
71
|
+
const webhook_tolerance_in_seconds = 5 * 60; // 5 minutes
|
|
72
|
+
if (now - timestampSeconds > webhook_tolerance_in_seconds) {
|
|
73
|
+
throw new Error('Webhook timestamp is too old');
|
|
74
|
+
}
|
|
75
|
+
if (timestampSeconds > now + webhook_tolerance_in_seconds) {
|
|
76
|
+
throw new Error('Webhook timestamp is too new');
|
|
77
|
+
}
|
|
78
|
+
const expectedSignature = this.signPayload(body, { date: msgDate, secret });
|
|
79
|
+
const encoder = new globalThis.TextEncoder();
|
|
80
|
+
if (this.timingSafeEqual(encoder.encode(msgSignature), encoder.encode(expectedSignature))) {
|
|
81
|
+
// valid!
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
throw new Error('The given webhook signature does not match the expected signature');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=webhooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.mjs","sourceRoot":"","sources":["../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE,MAAM,QAAQ;OAC5B,EAAE,iBAAiB,EAAe;AAEzC,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;OAEG;IACH,MAAM,CACJ,OAAe,EACf,OAAoB,EACpB,SAAoC,IAAI,CAAC,OAAO,CAAC,aAAa;QAE9D,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,C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AAG,GAAG,gBAAgB,GAAG,4BAA4B,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QAED,IAAI,gBAAgB,GAAG,GAAG,GAAG,4BAA4B,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAE7C,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE;YACzF,SAAS;YACT,OAAO;SACR;QAED,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;CACF"}
|
package/shims/node.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import * as types from "../_shims/node-types.js";
|
|
5
|
+
declare module '../_shims/manual-types' {
|
|
6
|
+
namespace manual {
|
|
7
|
+
type Agent = types.Agent;
|
|
8
|
+
export import fetch = types.fetch;
|
|
9
|
+
type Request = types.Request;
|
|
10
|
+
type RequestInfo = types.RequestInfo;
|
|
11
|
+
type RequestInit = types.RequestInit;
|
|
12
|
+
type Response = types.Response;
|
|
13
|
+
type ResponseInit = types.ResponseInit;
|
|
14
|
+
type ResponseType = types.ResponseType;
|
|
15
|
+
type BodyInit = types.BodyInit;
|
|
16
|
+
type Headers = types.Headers;
|
|
17
|
+
type HeadersInit = types.HeadersInit;
|
|
18
|
+
type BlobPropertyBag = types.BlobPropertyBag;
|
|
19
|
+
type FilePropertyBag = types.FilePropertyBag;
|
|
20
|
+
type FileFromPathOptions = types.FileFromPathOptions;
|
|
21
|
+
export import FormData = types.FormData;
|
|
22
|
+
export import File = types.File;
|
|
23
|
+
export import Blob = types.Blob;
|
|
24
|
+
type Readable = types.Readable;
|
|
25
|
+
type FsReadStream = types.FsReadStream;
|
|
26
|
+
export import ReadableStream = types.ReadableStream;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/shims/node.ts"],"names":[],"mappings":";;;AACA,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAK9C,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,MAAM,CAAC;QAEtB,KAAY,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAEhC,MAAM,QAAQ,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAElC,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAEpC,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAEpC,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAEpD,KAAY,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAEpD,KAAY,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC;QAE5D,MAAM,QAAQ,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAExC,MAAM,QAAQ,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAEhC,MAAM,QAAQ,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAEhC,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,MAAM,QAAQ,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;KACrD;CACF"}
|
package/shims/node.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
const types = __importStar(require("../_shims/node-types.js"));
|
|
28
|
+
const registry_1 = require("../_shims/registry.js");
|
|
29
|
+
const node_runtime_1 = require("../_shims/node-runtime.js");
|
|
30
|
+
(0, registry_1.setShims)((0, node_runtime_1.getRuntime)());
|
|
31
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/shims/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,+DAA8C;AAC9C,oDAA8C;AAC9C,4DAAoD;AACpD,IAAA,mBAAQ,EAAC,IAAA,yBAAU,GAAE,CAAC,CAAC"}
|
package/shims/node.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.mjs","sourceRoot":"","sources":["../src/shims/node.ts"],"names":[],"mappings":"OACO,KAAK,KAAK;OACV,EAAE,QAAQ,EAAE;OACZ,EAAE,UAAU,EAAE;AACrB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC"}
|
package/shims/web.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as types from "../_shims/web-types.js";
|
|
2
|
+
declare module '../_shims/manual-types' {
|
|
3
|
+
namespace manual {
|
|
4
|
+
type Agent = types.Agent;
|
|
5
|
+
export import fetch = types.fetch;
|
|
6
|
+
type Request = types.Request;
|
|
7
|
+
type RequestInfo = types.RequestInfo;
|
|
8
|
+
type RequestInit = types.RequestInit;
|
|
9
|
+
type Response = types.Response;
|
|
10
|
+
type ResponseInit = types.ResponseInit;
|
|
11
|
+
type ResponseType = types.ResponseType;
|
|
12
|
+
type BodyInit = types.BodyInit;
|
|
13
|
+
type Headers = types.Headers;
|
|
14
|
+
type HeadersInit = types.HeadersInit;
|
|
15
|
+
type BlobPropertyBag = types.BlobPropertyBag;
|
|
16
|
+
type FilePropertyBag = types.FilePropertyBag;
|
|
17
|
+
type FileFromPathOptions = types.FileFromPathOptions;
|
|
18
|
+
export import FormData = types.FormData;
|
|
19
|
+
export import File = types.File;
|
|
20
|
+
export import Blob = types.Blob;
|
|
21
|
+
type Readable = types.Readable;
|
|
22
|
+
type FsReadStream = types.FsReadStream;
|
|
23
|
+
export import ReadableStream = types.ReadableStream;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/shims/web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAK7C,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,MAAM,CAAC;QAEtB,KAAY,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAEhC,MAAM,QAAQ,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAElC,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAEpC,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAEpC,KAAY,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QAE5C,KAAY,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAEpD,KAAY,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAEpD,KAAY,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC;QAE5D,MAAM,QAAQ,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAExC,MAAM,QAAQ,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAEhC,MAAM,QAAQ,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAEhC,KAAY,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEtC,KAAY,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAE9C,MAAM,QAAQ,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;KACrD;CACF"}
|
package/shims/web.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
const types = __importStar(require("../_shims/web-types.js"));
|
|
28
|
+
const registry_1 = require("../_shims/registry.js");
|
|
29
|
+
const web_runtime_1 = require("../_shims/web-runtime.js");
|
|
30
|
+
(0, registry_1.setShims)((0, web_runtime_1.getRuntime)({ manuallyImported: true }));
|
|
31
|
+
//# sourceMappingURL=web.js.map
|
package/shims/web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/shims/web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,8DAA6C;AAC7C,oDAA8C;AAC9C,0DAAmD;AACnD,IAAA,mBAAQ,EAAC,IAAA,wBAAU,EAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC"}
|