@contractspec/integration.providers-impls 1.57.0 → 1.58.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/analytics.d.ts +1 -8
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +3 -3
- package/dist/calendar.d.ts +1 -8
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +3 -3
- package/dist/database.d.ts +1 -8
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +3 -3
- package/dist/email.d.ts +1 -8
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3 -3
- package/dist/embedding.d.ts +1 -8
- package/dist/embedding.d.ts.map +1 -1
- package/dist/embedding.js +3 -3
- package/dist/impls/elevenlabs-voice.d.ts +14 -18
- package/dist/impls/elevenlabs-voice.d.ts.map +1 -1
- package/dist/impls/elevenlabs-voice.js +98 -88
- package/dist/impls/fal-voice.d.ts +22 -26
- package/dist/impls/fal-voice.d.ts.map +1 -1
- package/dist/impls/fal-voice.js +103 -78
- package/dist/impls/fathom-meeting-recorder.d.ts +35 -39
- package/dist/impls/fathom-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.js +285 -142
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts +4 -8
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js +102 -38
- package/dist/impls/fathom-meeting-recorder.types.d.ts +16 -20
- package/dist/impls/fathom-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.types.js +1 -0
- package/dist/impls/fathom-meeting-recorder.utils.d.ts +10 -14
- package/dist/impls/fathom-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.utils.js +58 -41
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts +3 -7
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js +25 -20
- package/dist/impls/fireflies-meeting-recorder.d.ts +21 -25
- package/dist/impls/fireflies-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.js +272 -149
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts +3 -6
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js +10 -8
- package/dist/impls/fireflies-meeting-recorder.types.d.ts +26 -29
- package/dist/impls/fireflies-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.types.js +1 -0
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts +4 -7
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js +34 -27
- package/dist/impls/gcs-storage.d.ts +18 -22
- package/dist/impls/gcs-storage.d.ts.map +1 -1
- package/dist/impls/gcs-storage.js +92 -84
- package/dist/impls/gmail-inbound.d.ts +20 -24
- package/dist/impls/gmail-inbound.d.ts.map +1 -1
- package/dist/impls/gmail-inbound.js +212 -185
- package/dist/impls/gmail-outbound.d.ts +12 -16
- package/dist/impls/gmail-outbound.d.ts.map +1 -1
- package/dist/impls/gmail-outbound.js +126 -92
- package/dist/impls/google-calendar.d.ts +17 -21
- package/dist/impls/google-calendar.d.ts.map +1 -1
- package/dist/impls/google-calendar.js +182 -145
- package/dist/impls/gradium-voice.d.ts +20 -22
- package/dist/impls/gradium-voice.d.ts.map +1 -1
- package/dist/impls/gradium-voice.js +85 -74
- package/dist/impls/granola-meeting-recorder.d.ts +31 -24
- package/dist/impls/granola-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.js +511 -143
- package/dist/impls/granola-meeting-recorder.mcp.d.ts +25 -0
- package/dist/impls/granola-meeting-recorder.mcp.d.ts.map +1 -0
- package/dist/impls/granola-meeting-recorder.mcp.js +279 -0
- package/dist/impls/granola-meeting-recorder.types.d.ts +60 -49
- package/dist/impls/granola-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.types.js +1 -0
- package/dist/impls/index.d.ts +28 -28
- package/dist/impls/index.d.ts.map +1 -0
- package/dist/impls/index.js +4659 -29
- package/dist/impls/jira.d.ts +18 -22
- package/dist/impls/jira.d.ts.map +1 -1
- package/dist/impls/jira.js +112 -101
- package/dist/impls/linear.d.ts +17 -21
- package/dist/impls/linear.d.ts.map +1 -1
- package/dist/impls/linear.js +78 -69
- package/dist/impls/mistral-embedding.d.ts +17 -21
- package/dist/impls/mistral-embedding.d.ts.map +1 -1
- package/dist/impls/mistral-embedding.js +41 -39
- package/dist/impls/mistral-llm.d.ts +25 -29
- package/dist/impls/mistral-llm.d.ts.map +1 -1
- package/dist/impls/mistral-llm.js +266 -244
- package/dist/impls/notion.d.ts +20 -24
- package/dist/impls/notion.d.ts.map +1 -1
- package/dist/impls/notion.js +145 -110
- package/dist/impls/posthog-reader.d.ts +18 -22
- package/dist/impls/posthog-reader.d.ts.map +1 -1
- package/dist/impls/posthog-reader.js +148 -129
- package/dist/impls/posthog-utils.d.ts +4 -7
- package/dist/impls/posthog-utils.d.ts.map +1 -1
- package/dist/impls/posthog-utils.js +31 -22
- package/dist/impls/posthog.d.ts +33 -37
- package/dist/impls/posthog.d.ts.map +1 -1
- package/dist/impls/posthog.js +320 -119
- package/dist/impls/postmark-email.d.ts +13 -17
- package/dist/impls/postmark-email.d.ts.map +1 -1
- package/dist/impls/postmark-email.js +55 -50
- package/dist/impls/powens-client.d.ts +111 -114
- package/dist/impls/powens-client.d.ts.map +1 -1
- package/dist/impls/powens-client.js +194 -170
- package/dist/impls/powens-openbanking.d.ts +22 -26
- package/dist/impls/powens-openbanking.d.ts.map +1 -1
- package/dist/impls/powens-openbanking.js +425 -217
- package/dist/impls/provider-factory.d.ts +29 -33
- package/dist/impls/provider-factory.d.ts.map +1 -1
- package/dist/impls/provider-factory.js +4072 -275
- package/dist/impls/qdrant-vector.d.ts +18 -22
- package/dist/impls/qdrant-vector.d.ts.map +1 -1
- package/dist/impls/qdrant-vector.js +76 -69
- package/dist/impls/stripe-payments.d.ts +22 -26
- package/dist/impls/stripe-payments.d.ts.map +1 -1
- package/dist/impls/stripe-payments.js +219 -193
- package/dist/impls/supabase-psql.d.ts +21 -25
- package/dist/impls/supabase-psql.d.ts.map +1 -1
- package/dist/impls/supabase-psql.js +138 -98
- package/dist/impls/supabase-vector.d.ts +29 -33
- package/dist/impls/supabase-vector.d.ts.map +1 -1
- package/dist/impls/supabase-vector.js +278 -103
- package/dist/impls/tldv-meeting-recorder.d.ts +18 -22
- package/dist/impls/tldv-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/tldv-meeting-recorder.js +142 -127
- package/dist/impls/twilio-sms.d.ts +14 -17
- package/dist/impls/twilio-sms.d.ts.map +1 -1
- package/dist/impls/twilio-sms.js +62 -55
- package/dist/index.d.ts +15 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4700 -107
- package/dist/llm.d.ts +1 -8
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +3 -3
- package/dist/meeting-recorder.d.ts +1 -8
- package/dist/meeting-recorder.d.ts.map +1 -1
- package/dist/meeting-recorder.js +3 -3
- package/dist/node/analytics.js +2 -0
- package/dist/node/calendar.js +2 -0
- package/dist/node/database.js +2 -0
- package/dist/node/email.js +2 -0
- package/dist/node/embedding.js +2 -0
- package/dist/node/impls/elevenlabs-voice.js +102 -0
- package/dist/node/impls/fal-voice.js +112 -0
- package/dist/node/impls/fathom-meeting-recorder.js +287 -0
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +105 -0
- package/dist/node/impls/fathom-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fathom-meeting-recorder.utils.js +72 -0
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +29 -0
- package/dist/node/impls/fireflies-meeting-recorder.js +274 -0
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +85 -0
- package/dist/node/impls/fireflies-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +42 -0
- package/dist/node/impls/gcs-storage.js +97 -0
- package/dist/node/impls/gmail-inbound.js +227 -0
- package/dist/node/impls/gmail-outbound.js +139 -0
- package/dist/node/impls/google-calendar.js +191 -0
- package/dist/node/impls/gradium-voice.js +90 -0
- package/dist/node/impls/granola-meeting-recorder.js +512 -0
- package/dist/node/impls/granola-meeting-recorder.mcp.js +278 -0
- package/dist/node/impls/granola-meeting-recorder.types.js +0 -0
- package/dist/node/impls/index.js +4658 -0
- package/dist/node/impls/jira.js +124 -0
- package/dist/node/impls/linear.js +83 -0
- package/dist/node/impls/mistral-embedding.js +43 -0
- package/dist/node/impls/mistral-llm.js +269 -0
- package/dist/node/impls/notion.js +160 -0
- package/dist/node/impls/posthog-reader.js +159 -0
- package/dist/node/impls/posthog-utils.js +38 -0
- package/dist/node/impls/posthog.js +322 -0
- package/dist/node/impls/postmark-email.js +60 -0
- package/dist/node/impls/powens-client.js +195 -0
- package/dist/node/impls/powens-openbanking.js +426 -0
- package/dist/node/impls/provider-factory.js +4080 -0
- package/dist/node/impls/qdrant-vector.js +78 -0
- package/dist/node/impls/stripe-payments.js +228 -0
- package/dist/node/impls/supabase-psql.js +150 -0
- package/dist/node/impls/supabase-vector.js +323 -0
- package/dist/node/impls/tldv-meeting-recorder.js +145 -0
- package/dist/node/impls/twilio-sms.js +65 -0
- package/dist/node/index.js +4699 -0
- package/dist/node/llm.js +2 -0
- package/dist/node/meeting-recorder.js +2 -0
- package/dist/node/openbanking.js +2 -0
- package/dist/node/payments.js +2 -0
- package/dist/node/project-management.js +2 -0
- package/dist/node/runtime.js +0 -0
- package/dist/node/secrets/provider.js +11 -0
- package/dist/node/sms.js +2 -0
- package/dist/node/storage.js +2 -0
- package/dist/node/vector-store.js +2 -0
- package/dist/node/voice.js +2 -0
- package/dist/openbanking.d.ts +1 -8
- package/dist/openbanking.d.ts.map +1 -1
- package/dist/openbanking.js +3 -3
- package/dist/payments.d.ts +1 -8
- package/dist/payments.d.ts.map +1 -1
- package/dist/payments.js +3 -3
- package/dist/project-management.d.ts +1 -8
- package/dist/project-management.d.ts.map +1 -1
- package/dist/project-management.js +3 -3
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/secrets/provider.d.ts +3 -2
- package/dist/secrets/provider.d.ts.map +1 -0
- package/dist/secrets/provider.js +12 -3
- package/dist/sms.d.ts +1 -8
- package/dist/sms.d.ts.map +1 -1
- package/dist/sms.js +3 -3
- package/dist/storage.d.ts +1 -8
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -3
- package/dist/vector-store.d.ts +1 -8
- package/dist/vector-store.d.ts.map +1 -1
- package/dist/vector-store.js +3 -3
- package/dist/voice.d.ts +1 -8
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +3 -3
- package/package.json +405 -114
- package/dist/_virtual/_rolldown/runtime.js +0 -36
- package/dist/impls/elevenlabs-voice.js.map +0 -1
- package/dist/impls/fal-voice.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/gcs-storage.js.map +0 -1
- package/dist/impls/gmail-inbound.js.map +0 -1
- package/dist/impls/gmail-outbound.js.map +0 -1
- package/dist/impls/google-calendar.js.map +0 -1
- package/dist/impls/gradium-voice.js.map +0 -1
- package/dist/impls/granola-meeting-recorder.js.map +0 -1
- package/dist/impls/jira.js.map +0 -1
- package/dist/impls/linear.js.map +0 -1
- package/dist/impls/mistral-embedding.js.map +0 -1
- package/dist/impls/mistral-llm.js.map +0 -1
- package/dist/impls/notion.js.map +0 -1
- package/dist/impls/posthog-reader.js.map +0 -1
- package/dist/impls/posthog-utils.js.map +0 -1
- package/dist/impls/posthog.js.map +0 -1
- package/dist/impls/postmark-email.js.map +0 -1
- package/dist/impls/powens-client.js.map +0 -1
- package/dist/impls/powens-openbanking.js.map +0 -1
- package/dist/impls/provider-factory.js.map +0 -1
- package/dist/impls/qdrant-vector.js.map +0 -1
- package/dist/impls/stripe-payments.js.map +0 -1
- package/dist/impls/supabase-psql.js.map +0 -1
- package/dist/impls/supabase-vector.js.map +0 -1
- package/dist/impls/tldv-meeting-recorder.js.map +0 -1
- package/dist/impls/twilio-sms.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,172 +1,196 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
var PowensClientError = class extends Error {
|
|
9
|
-
status;
|
|
10
|
-
code;
|
|
11
|
-
requestId;
|
|
12
|
-
response;
|
|
13
|
-
constructor(message, status, code, requestId, response) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = "PowensClientError";
|
|
16
|
-
this.status = status;
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.requestId = requestId;
|
|
19
|
-
this.response = response;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
var PowensClient = class {
|
|
23
|
-
clientId;
|
|
24
|
-
clientSecret;
|
|
25
|
-
apiKey;
|
|
26
|
-
fetchImpl;
|
|
27
|
-
logger;
|
|
28
|
-
defaultTimeoutMs;
|
|
29
|
-
token;
|
|
30
|
-
baseUrl;
|
|
31
|
-
constructor(options) {
|
|
32
|
-
this.clientId = options.clientId;
|
|
33
|
-
this.clientSecret = options.clientSecret;
|
|
34
|
-
this.apiKey = options.apiKey;
|
|
35
|
-
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
36
|
-
this.logger = options.logger;
|
|
37
|
-
this.defaultTimeoutMs = options.defaultTimeoutMs ?? 15e3;
|
|
38
|
-
this.baseUrl = options.baseUrl ?? POWENS_BASE_URL[options.environment] ?? POWENS_BASE_URL.production;
|
|
39
|
-
}
|
|
40
|
-
async listAccounts(params) {
|
|
41
|
-
const searchParams = {
|
|
42
|
-
cursor: params.cursor,
|
|
43
|
-
limit: params.limit,
|
|
44
|
-
include_balances: params.includeBalances,
|
|
45
|
-
institution_uuid: params.institutionUuid
|
|
46
|
-
};
|
|
47
|
-
return await this.request({
|
|
48
|
-
method: "GET",
|
|
49
|
-
path: `/users/${encodeURIComponent(params.userUuid)}/accounts`,
|
|
50
|
-
searchParams
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async getAccount(accountUuid) {
|
|
54
|
-
return this.request({
|
|
55
|
-
method: "GET",
|
|
56
|
-
path: `/accounts/${encodeURIComponent(accountUuid)}`
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async listTransactions(params) {
|
|
60
|
-
const searchParams = {
|
|
61
|
-
cursor: params.cursor,
|
|
62
|
-
limit: params.limit,
|
|
63
|
-
from: params.from,
|
|
64
|
-
to: params.to,
|
|
65
|
-
include_pending: params.includePending
|
|
66
|
-
};
|
|
67
|
-
return this.request({
|
|
68
|
-
method: "GET",
|
|
69
|
-
path: `/accounts/${encodeURIComponent(params.accountUuid)}/transactions`,
|
|
70
|
-
searchParams
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async getBalances(accountUuid) {
|
|
74
|
-
return this.request({
|
|
75
|
-
method: "GET",
|
|
76
|
-
path: `/accounts/${encodeURIComponent(accountUuid)}/balances`
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
async getConnectionStatus(connectionUuid) {
|
|
80
|
-
return this.request({
|
|
81
|
-
method: "GET",
|
|
82
|
-
path: `/connections/${encodeURIComponent(connectionUuid)}`
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async request(options) {
|
|
86
|
-
const url = new URL(options.path, this.baseUrl);
|
|
87
|
-
if (options.searchParams) for (const [key, value] of Object.entries(options.searchParams)) {
|
|
88
|
-
if (value === void 0 || value === null) continue;
|
|
89
|
-
url.searchParams.set(key, String(value));
|
|
90
|
-
}
|
|
91
|
-
const headers = {
|
|
92
|
-
Accept: "application/json",
|
|
93
|
-
"Content-Type": "application/json",
|
|
94
|
-
...options.headers
|
|
95
|
-
};
|
|
96
|
-
if (this.apiKey) headers["x-api-key"] = this.apiKey;
|
|
97
|
-
if (!options.skipAuth) headers.Authorization = `Bearer ${await this.ensureAccessToken()}`;
|
|
98
|
-
const controller = new AbortController();
|
|
99
|
-
const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.defaultTimeoutMs);
|
|
100
|
-
try {
|
|
101
|
-
const response = await this.fetchImpl(url, {
|
|
102
|
-
method: options.method,
|
|
103
|
-
headers,
|
|
104
|
-
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
105
|
-
signal: controller.signal
|
|
106
|
-
});
|
|
107
|
-
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
108
|
-
if (!response.ok) {
|
|
109
|
-
let errorBody;
|
|
110
|
-
try {
|
|
111
|
-
errorBody = await response.json();
|
|
112
|
-
} catch {}
|
|
113
|
-
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
|
|
114
|
-
const message = typeof errorObject?.message === "string" ? errorObject.message : `Powens API request failed with status ${response.status}`;
|
|
115
|
-
const code = typeof errorObject?.code === "string" ? errorObject.code : void 0;
|
|
116
|
-
throw new PowensClientError(message, response.status, code, requestId, errorBody);
|
|
117
|
-
}
|
|
118
|
-
if (response.status === 204) return;
|
|
119
|
-
try {
|
|
120
|
-
return await response.json();
|
|
121
|
-
} catch (error) {
|
|
122
|
-
this.logger?.error?.("[PowensClient] Failed to parse JSON response", error);
|
|
123
|
-
throw new PowensClientError("Failed to parse Powens response payload as JSON", response.status, void 0, requestId);
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (error instanceof PowensClientError) throw error;
|
|
127
|
-
if (error.name === "AbortError") throw new PowensClientError(`Powens API request timed out after ${options.timeoutMs ?? this.defaultTimeoutMs}ms`, 408);
|
|
128
|
-
this.logger?.error?.("[PowensClient] Request failed", error);
|
|
129
|
-
throw new PowensClientError(error.message ?? "Powens API request failed", 500);
|
|
130
|
-
} finally {
|
|
131
|
-
clearTimeout(timeout);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async ensureAccessToken() {
|
|
135
|
-
if (this.token && Date.now() < this.token.expiresAt - 5e3) return this.token.accessToken;
|
|
136
|
-
this.token = await this.fetchAccessToken();
|
|
137
|
-
return this.token.accessToken;
|
|
138
|
-
}
|
|
139
|
-
async fetchAccessToken() {
|
|
140
|
-
const url = new URL("/oauth/token", this.baseUrl);
|
|
141
|
-
const basicAuth = Buffer.from(`${this.clientId}:${this.clientSecret}`, "utf-8").toString("base64");
|
|
142
|
-
const response = await this.fetchImpl(url, {
|
|
143
|
-
method: "POST",
|
|
144
|
-
headers: {
|
|
145
|
-
Authorization: `Basic ${basicAuth}`,
|
|
146
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
147
|
-
Accept: "application/json"
|
|
148
|
-
},
|
|
149
|
-
body: new URLSearchParams({ grant_type: "client_credentials" }).toString()
|
|
150
|
-
});
|
|
151
|
-
if (!response.ok) {
|
|
152
|
-
let errorBody;
|
|
153
|
-
try {
|
|
154
|
-
errorBody = await response.json();
|
|
155
|
-
} catch {}
|
|
156
|
-
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : void 0;
|
|
157
|
-
throw new PowensClientError(typeof errorObject?.error_description === "string" ? errorObject.error_description : "Failed to obtain Powens access token", response.status, void 0, void 0, errorBody);
|
|
158
|
-
}
|
|
159
|
-
const payload = await response.json();
|
|
160
|
-
const expiresAt = Date.now() + payload.expires_in * 1e3;
|
|
161
|
-
this.logger?.debug?.("[PowensClient] Received access token", { expiresIn: payload.expires_in });
|
|
162
|
-
return {
|
|
163
|
-
accessToken: payload.access_token,
|
|
164
|
-
expiresAt,
|
|
165
|
-
scope: payload.scope
|
|
166
|
-
};
|
|
167
|
-
}
|
|
1
|
+
// @bun
|
|
2
|
+
// src/impls/powens-client.ts
|
|
3
|
+
import { URL } from "url";
|
|
4
|
+
var POWENS_BASE_URL = {
|
|
5
|
+
sandbox: "https://api-sandbox.powens.com/v2",
|
|
6
|
+
production: "https://api.powens.com/v2"
|
|
168
7
|
};
|
|
169
8
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
9
|
+
class PowensClientError extends Error {
|
|
10
|
+
status;
|
|
11
|
+
code;
|
|
12
|
+
requestId;
|
|
13
|
+
response;
|
|
14
|
+
constructor(message, status, code, requestId, response) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "PowensClientError";
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.requestId = requestId;
|
|
20
|
+
this.response = response;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class PowensClient {
|
|
25
|
+
clientId;
|
|
26
|
+
clientSecret;
|
|
27
|
+
apiKey;
|
|
28
|
+
fetchImpl;
|
|
29
|
+
logger;
|
|
30
|
+
defaultTimeoutMs;
|
|
31
|
+
token;
|
|
32
|
+
baseUrl;
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.clientId = options.clientId;
|
|
35
|
+
this.clientSecret = options.clientSecret;
|
|
36
|
+
this.apiKey = options.apiKey;
|
|
37
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
38
|
+
this.logger = options.logger;
|
|
39
|
+
this.defaultTimeoutMs = options.defaultTimeoutMs ?? 15000;
|
|
40
|
+
this.baseUrl = options.baseUrl ?? POWENS_BASE_URL[options.environment] ?? POWENS_BASE_URL.production;
|
|
41
|
+
}
|
|
42
|
+
async listAccounts(params) {
|
|
43
|
+
const searchParams = {
|
|
44
|
+
cursor: params.cursor,
|
|
45
|
+
limit: params.limit,
|
|
46
|
+
include_balances: params.includeBalances,
|
|
47
|
+
institution_uuid: params.institutionUuid
|
|
48
|
+
};
|
|
49
|
+
const response = await this.request({
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: `/users/${encodeURIComponent(params.userUuid)}/accounts`,
|
|
52
|
+
searchParams
|
|
53
|
+
});
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
async getAccount(accountUuid) {
|
|
57
|
+
return this.request({
|
|
58
|
+
method: "GET",
|
|
59
|
+
path: `/accounts/${encodeURIComponent(accountUuid)}`
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async listTransactions(params) {
|
|
63
|
+
const searchParams = {
|
|
64
|
+
cursor: params.cursor,
|
|
65
|
+
limit: params.limit,
|
|
66
|
+
from: params.from,
|
|
67
|
+
to: params.to,
|
|
68
|
+
include_pending: params.includePending
|
|
69
|
+
};
|
|
70
|
+
return this.request({
|
|
71
|
+
method: "GET",
|
|
72
|
+
path: `/accounts/${encodeURIComponent(params.accountUuid)}/transactions`,
|
|
73
|
+
searchParams
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async getBalances(accountUuid) {
|
|
77
|
+
return this.request({
|
|
78
|
+
method: "GET",
|
|
79
|
+
path: `/accounts/${encodeURIComponent(accountUuid)}/balances`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async getConnectionStatus(connectionUuid) {
|
|
83
|
+
return this.request({
|
|
84
|
+
method: "GET",
|
|
85
|
+
path: `/connections/${encodeURIComponent(connectionUuid)}`
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async request(options) {
|
|
89
|
+
const url = new URL(options.path, this.baseUrl);
|
|
90
|
+
if (options.searchParams) {
|
|
91
|
+
for (const [key, value] of Object.entries(options.searchParams)) {
|
|
92
|
+
if (value === undefined || value === null)
|
|
93
|
+
continue;
|
|
94
|
+
url.searchParams.set(key, String(value));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const headers = {
|
|
98
|
+
Accept: "application/json",
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
...options.headers
|
|
101
|
+
};
|
|
102
|
+
if (this.apiKey) {
|
|
103
|
+
headers["x-api-key"] = this.apiKey;
|
|
104
|
+
}
|
|
105
|
+
if (!options.skipAuth) {
|
|
106
|
+
const token = await this.ensureAccessToken();
|
|
107
|
+
headers.Authorization = `Bearer ${token}`;
|
|
108
|
+
}
|
|
109
|
+
const controller = new AbortController;
|
|
110
|
+
const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.defaultTimeoutMs);
|
|
111
|
+
try {
|
|
112
|
+
const response = await this.fetchImpl(url, {
|
|
113
|
+
method: options.method,
|
|
114
|
+
headers,
|
|
115
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
116
|
+
signal: controller.signal
|
|
117
|
+
});
|
|
118
|
+
const requestId = response.headers.get("x-request-id") ?? undefined;
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
let errorBody;
|
|
121
|
+
try {
|
|
122
|
+
errorBody = await response.json();
|
|
123
|
+
} catch {}
|
|
124
|
+
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : undefined;
|
|
125
|
+
const message = typeof errorObject?.message === "string" ? errorObject.message : `Powens API request failed with status ${response.status}`;
|
|
126
|
+
const code = typeof errorObject?.code === "string" ? errorObject.code : undefined;
|
|
127
|
+
throw new PowensClientError(message, response.status, code, requestId, errorBody);
|
|
128
|
+
}
|
|
129
|
+
if (response.status === 204) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
return await response.json();
|
|
134
|
+
} catch (error) {
|
|
135
|
+
this.logger?.error?.("[PowensClient] Failed to parse JSON response", error);
|
|
136
|
+
throw new PowensClientError("Failed to parse Powens response payload as JSON", response.status, undefined, requestId);
|
|
137
|
+
}
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if (error instanceof PowensClientError) {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
if (error.name === "AbortError") {
|
|
143
|
+
throw new PowensClientError(`Powens API request timed out after ${options.timeoutMs ?? this.defaultTimeoutMs}ms`, 408);
|
|
144
|
+
}
|
|
145
|
+
this.logger?.error?.("[PowensClient] Request failed", error);
|
|
146
|
+
throw new PowensClientError(error.message ?? "Powens API request failed", 500);
|
|
147
|
+
} finally {
|
|
148
|
+
clearTimeout(timeout);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async ensureAccessToken() {
|
|
152
|
+
if (this.token && Date.now() < this.token.expiresAt - 5000) {
|
|
153
|
+
return this.token.accessToken;
|
|
154
|
+
}
|
|
155
|
+
this.token = await this.fetchAccessToken();
|
|
156
|
+
return this.token.accessToken;
|
|
157
|
+
}
|
|
158
|
+
async fetchAccessToken() {
|
|
159
|
+
const url = new URL("/oauth/token", this.baseUrl);
|
|
160
|
+
const basicAuth = Buffer.from(`${this.clientId}:${this.clientSecret}`, "utf-8").toString("base64");
|
|
161
|
+
const response = await this.fetchImpl(url, {
|
|
162
|
+
method: "POST",
|
|
163
|
+
headers: {
|
|
164
|
+
Authorization: `Basic ${basicAuth}`,
|
|
165
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
166
|
+
Accept: "application/json"
|
|
167
|
+
},
|
|
168
|
+
body: new URLSearchParams({
|
|
169
|
+
grant_type: "client_credentials"
|
|
170
|
+
}).toString()
|
|
171
|
+
});
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
let errorBody;
|
|
174
|
+
try {
|
|
175
|
+
errorBody = await response.json();
|
|
176
|
+
} catch {}
|
|
177
|
+
const errorObject = typeof errorBody === "object" && errorBody !== null ? errorBody : undefined;
|
|
178
|
+
const message = typeof errorObject?.error_description === "string" ? errorObject.error_description : "Failed to obtain Powens access token";
|
|
179
|
+
throw new PowensClientError(message, response.status, undefined, undefined, errorBody);
|
|
180
|
+
}
|
|
181
|
+
const payload = await response.json();
|
|
182
|
+
const expiresAt = Date.now() + payload.expires_in * 1000;
|
|
183
|
+
this.logger?.debug?.("[PowensClient] Received access token", {
|
|
184
|
+
expiresIn: payload.expires_in
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
accessToken: payload.access_token,
|
|
188
|
+
expiresAt,
|
|
189
|
+
scope: payload.scope
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
PowensClientError,
|
|
195
|
+
PowensClient
|
|
196
|
+
};
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private mapConnectionStatus;
|
|
24
|
-
private handleError;
|
|
1
|
+
import type { OpenBankingAccountBalance, OpenBankingAccountDetails, OpenBankingConnectionStatus, OpenBankingGetAccountDetailsParams, OpenBankingGetBalancesParams, OpenBankingGetConnectionStatusParams, OpenBankingListAccountsParams, OpenBankingListAccountsResult, OpenBankingListTransactionsParams, OpenBankingListTransactionsResult, OpenBankingProvider } from '../openbanking';
|
|
2
|
+
import { type PowensClientOptions } from './powens-client';
|
|
3
|
+
export type PowensOpenBankingProviderOptions = PowensClientOptions;
|
|
4
|
+
export declare class PowensOpenBankingProvider implements OpenBankingProvider {
|
|
5
|
+
private readonly client;
|
|
6
|
+
private readonly logger?;
|
|
7
|
+
constructor(options: PowensOpenBankingProviderOptions);
|
|
8
|
+
listAccounts(params: OpenBankingListAccountsParams): Promise<OpenBankingListAccountsResult>;
|
|
9
|
+
getAccountDetails(params: OpenBankingGetAccountDetailsParams): Promise<OpenBankingAccountDetails>;
|
|
10
|
+
listTransactions(params: OpenBankingListTransactionsParams): Promise<OpenBankingListTransactionsResult>;
|
|
11
|
+
getBalances(params: OpenBankingGetBalancesParams): Promise<OpenBankingAccountBalance[]>;
|
|
12
|
+
getConnectionStatus(params: OpenBankingGetConnectionStatusParams): Promise<OpenBankingConnectionStatus>;
|
|
13
|
+
private mapAccount;
|
|
14
|
+
private mapAccountDetails;
|
|
15
|
+
private mapTransaction;
|
|
16
|
+
private mapBalance;
|
|
17
|
+
private toContext;
|
|
18
|
+
private mapOwnership;
|
|
19
|
+
private mapAccountStatus;
|
|
20
|
+
private mapTransactionStatus;
|
|
21
|
+
private mapConnectionStatus;
|
|
22
|
+
private handleError;
|
|
25
23
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { PowensOpenBankingProvider, PowensOpenBankingProviderOptions };
|
|
28
24
|
//# sourceMappingURL=powens-openbanking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powens-openbanking.d.ts","
|
|
1
|
+
{"version":3,"file":"powens-openbanking.d.ts","sourceRoot":"","sources":["../../src/impls/powens-openbanking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EAEzB,2BAA2B,EAC3B,kCAAkC,EAClC,4BAA4B,EAC5B,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,iCAAiC,EACjC,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,KAAK,mBAAmB,EAKzB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;AAOnE,qBAAa,yBAA0B,YAAW,mBAAmB;IACnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAgC;gBAE5C,OAAO,EAAE,gCAAgC;IAK/C,YAAY,CAChB,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,6BAA6B,CAAC;IA4BnC,iBAAiB,CACrB,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,yBAAyB,CAAC;IAU/B,gBAAgB,CACpB,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAuBvC,WAAW,CACf,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAgBjC,mBAAmB,CACvB,MAAM,EAAE,oCAAoC,GAC3C,OAAO,CAAC,2BAA2B,CAAC;IAiBvC,OAAO,CAAC,UAAU;IA8BlB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,UAAU;IAgBlB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,WAAW;CAkBpB"}
|