@versori/run 0.4.3 → 0.4.5
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/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +35 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.js +113 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +4 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +13 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +9 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +2 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +40 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.js +82 -0
- package/esm/src/connection/CredentialsProvider.d.ts +17 -0
- package/esm/src/connection/CredentialsProvider.d.ts.map +1 -0
- package/esm/src/connection/CredentialsProvider.js +63 -0
- package/esm/src/connection/DirectConnectionFactory.d.ts +5 -3
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +7 -2
- package/esm/src/credentials/CredentialsProvider.d.ts +49 -0
- package/esm/src/credentials/CredentialsProvider.d.ts.map +1 -0
- package/esm/src/credentials/CredentialsProvider.js +102 -0
- package/esm/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/durable/DurableInterpreter.js +4 -17
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +4 -9
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +2 -2
- package/esm/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/sdk/SDKKeyValueProvider.js +3 -3
- package/package.json +1 -1
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +35 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.js +119 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +4 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +16 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +9 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +3 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +40 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.js +86 -0
- package/script/src/connection/CredentialsProvider.d.ts +17 -0
- package/script/src/connection/CredentialsProvider.d.ts.map +1 -0
- package/script/src/connection/CredentialsProvider.js +67 -0
- package/script/src/connection/DirectConnectionFactory.d.ts +5 -3
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +7 -2
- package/script/src/credentials/CredentialsProvider.d.ts +49 -0
- package/script/src/credentials/CredentialsProvider.d.ts.map +1 -0
- package/script/src/credentials/CredentialsProvider.js +106 -0
- package/script/src/interpreter/durable/DurableInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/durable/DurableInterpreter.js +4 -17
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +4 -9
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +2 -2
- package/script/src/kv/sdk/SDKKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/sdk/SDKKeyValueProvider.js +3 -3
- package/esm/src/dsl/http/default.d.ts +0 -26
- package/esm/src/dsl/http/default.d.ts.map +0 -1
- package/esm/src/dsl/http/default.js +0 -56
- package/esm/src/dsl/http/versori/cli.d.ts +0 -2
- package/esm/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/cli.js +0 -32
- package/esm/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/internalauth.js +0 -102
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/esm/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/esm/src/dsl/http/versori/proxyroundtripper.js +0 -208
- package/script/src/dsl/http/default.d.ts +0 -26
- package/script/src/dsl/http/default.d.ts.map +0 -1
- package/script/src/dsl/http/default.js +0 -60
- package/script/src/dsl/http/versori/cli.d.ts +0 -2
- package/script/src/dsl/http/versori/cli.d.ts.map +0 -1
- package/script/src/dsl/http/versori/cli.js +0 -35
- package/script/src/dsl/http/versori/internalauth.d.ts +0 -15
- package/script/src/dsl/http/versori/internalauth.d.ts.map +0 -1
- package/script/src/dsl/http/versori/internalauth.js +0 -106
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts +0 -23
- package/script/src/dsl/http/versori/proxyroundtripper.d.ts.map +0 -1
- package/script/src/dsl/http/versori/proxyroundtripper.js +0 -212
|
@@ -18,11 +18,9 @@ import express from 'express';
|
|
|
18
18
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
19
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
20
20
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
21
|
-
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
22
21
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
22
|
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
23
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
|
-
import { ProxyRoundTripper } from '../../dsl/http/versori/proxyroundtripper.js';
|
|
26
24
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
27
25
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
28
26
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
@@ -37,14 +35,6 @@ function getKVProvider(runLocal) {
|
|
|
37
35
|
}
|
|
38
36
|
return SDKKeyValueProvider.fromEnv();
|
|
39
37
|
}
|
|
40
|
-
function getRoundTripperFactory(log, _tracer, opts) {
|
|
41
|
-
if (opts && opts.runLocal) {
|
|
42
|
-
log.info('Running in local mode, using ProxyRoundTripperFactory');
|
|
43
|
-
return ProxyRoundTripper.fromEnv(log);
|
|
44
|
-
}
|
|
45
|
-
log.info('Running with default round tripper factory');
|
|
46
|
-
return new DefaultRoundTripperFactory();
|
|
47
|
-
}
|
|
48
38
|
/**
|
|
49
39
|
* DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
50
40
|
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
@@ -228,23 +218,20 @@ export class DurableInterpreter {
|
|
|
228
218
|
otelSDK.start();
|
|
229
219
|
}
|
|
230
220
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
231
|
-
const roundTripperFactory = getRoundTripperFactory(log, tracer, {
|
|
232
|
-
skipVersoriCredentials: options.skipVersoriCredentials,
|
|
233
|
-
runLocal: runLocal,
|
|
234
|
-
});
|
|
235
221
|
const queueProvider = await QueueImpl.fromEnv(log);
|
|
222
|
+
const connectionFactory = DirectConnectionFactory.fromEnv(log);
|
|
236
223
|
const issuesProvider = new IssueImpl(log);
|
|
237
224
|
if (options.contextProvider) {
|
|
238
225
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
239
226
|
// initialised.
|
|
240
|
-
return new DurableInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(),
|
|
227
|
+
return new DurableInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
241
228
|
}
|
|
242
229
|
const kvp = await getKVProvider(runLocal);
|
|
243
230
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
244
231
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
245
232
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
246
|
-
const ctxProvider = new ContextProviderImpl(log, kvp,
|
|
247
|
-
return new DurableInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(),
|
|
233
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, connectionFactory.getCredentialsProvider(), platformApi, organisationId, environmentId, issuesProvider);
|
|
234
|
+
return new DurableInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
248
235
|
}
|
|
249
236
|
register(workflow, options) {
|
|
250
237
|
const localAbortController = new AbortController();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"AAaA,OAAsB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAgB,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAA+B,UAAU,EAAM,YAAY,EAAO,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/memory/MemoryInterpreter.ts"],"names":[],"mappings":"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"}
|
|
@@ -18,11 +18,10 @@ import express from 'express';
|
|
|
18
18
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
19
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
20
20
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
21
|
-
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
22
21
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
|
-
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
22
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
23
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
24
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion } from '../../internal/constants.js';
|
|
26
25
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
27
26
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
28
27
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
@@ -35,10 +34,6 @@ function getKVProvider(runLocal) {
|
|
|
35
34
|
}
|
|
36
35
|
return NatsKeyValueProvider.fromEnv();
|
|
37
36
|
}
|
|
38
|
-
function getRoundTripperFactory(log) {
|
|
39
|
-
log.info('Running with default round tripper factory');
|
|
40
|
-
return new DefaultRoundTripperFactory();
|
|
41
|
-
}
|
|
42
37
|
/**
|
|
43
38
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
44
39
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -205,7 +200,7 @@ export class MemoryInterpreter {
|
|
|
205
200
|
otelSDK.start();
|
|
206
201
|
}
|
|
207
202
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
208
|
-
const
|
|
203
|
+
const connectionFactory = DirectConnectionFactory.fromEnv(log);
|
|
209
204
|
const issuesProvider = new IssueImpl(log);
|
|
210
205
|
if (options.contextProvider) {
|
|
211
206
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
@@ -216,8 +211,8 @@ export class MemoryInterpreter {
|
|
|
216
211
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
217
212
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
218
213
|
const environmentId = Deno.env.get(envVarEnvId) || 'development';
|
|
219
|
-
const ctxProvider = new ContextProviderImpl(log, kvp,
|
|
220
|
-
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(),
|
|
214
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, connectionFactory.getCredentialsProvider(), platformApi, organisationId, environmentId, issuesProvider);
|
|
215
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
221
216
|
}
|
|
222
217
|
register(workflow, options) {
|
|
223
218
|
const localAbortController = new AbortController();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AAExH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA4CvF,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa,oBAAqB,YAAW,gBAAgB,EAAE,eAAe;IAEtE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALzB,OAAO;WAQM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,OAAO,CAAC,oBAAoB,CAAC;IA0BhC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI/C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
import { JetStreamApiCodes, JetStreamApiError } from '../../../deps/jsr.io/@nats-io/jetstream/3.2.0/src/mod.js';
|
|
14
14
|
import { Kvm } from '../../../deps/jsr.io/@nats-io/kv/3.2.0/src/mod.js';
|
|
15
15
|
import { connect, credsAuthenticator } from '../../../deps/jsr.io/@nats-io/transport-deno/3.2.0/src/mod.js';
|
|
16
|
-
import { NatsKeyValue } from './NatsKeyValue.js';
|
|
17
16
|
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
17
|
+
import { NatsKeyValue } from './NatsKeyValue.js';
|
|
18
18
|
function getOptionsFromEnv() {
|
|
19
19
|
const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
20
20
|
return {
|
|
@@ -172,7 +172,7 @@ export class NatsKeyValueProvider {
|
|
|
172
172
|
const activationSuffix = options.activationId ? `.${options.activationId}` : '';
|
|
173
173
|
switch (options.scope) {
|
|
174
174
|
case ':organization:':
|
|
175
|
-
return `${this.opts.organizationId}
|
|
175
|
+
return `${this.opts.organizationId}`;
|
|
176
176
|
case ':project:':
|
|
177
177
|
return `${this.opts.organizationId}.${this.opts.projectId}.${this.opts.environment}${activationSuffix}`;
|
|
178
178
|
case ':execution:':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SDKKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/sdk/SDKKeyValueProvider.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkCvF,MAAM,MAAM,0BAA0B,GAAG;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF,qBAAa,mBAAoB,YAAW,gBAAgB,EAAE,eAAe;IAErE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJzB,OAAO;WAOM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAC/C,OAAO,CAAC,mBAAmB,CAAC;IAY/B,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI9C,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;IAI1C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* As of the Change Date, in accordance with the Business Source License,
|
|
11
11
|
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
12
|
*/
|
|
13
|
-
import { StoresService } from '../../dsl/http/versori/kvapi/services/StoresService.js';
|
|
14
13
|
import { KvOperationsService } from '../../dsl/http/versori/kvapi/services/KvOperationsService.js';
|
|
15
|
-
import {
|
|
14
|
+
import { StoresService } from '../../dsl/http/versori/kvapi/services/StoresService.js';
|
|
16
15
|
import { isKVOptionsExecution } from '../isKVOptionsExecution.js';
|
|
16
|
+
import { SDKKeyValue } from './SDKKeyValue.js';
|
|
17
17
|
function getOptionsFromEnv() {
|
|
18
18
|
return {
|
|
19
19
|
organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
|
|
@@ -145,7 +145,7 @@ export class SDKKeyValueProvider {
|
|
|
145
145
|
const activationSuffix = options.activationId ? `/${options.activationId}` : '';
|
|
146
146
|
switch (options.scope) {
|
|
147
147
|
case ':organization:':
|
|
148
|
-
return `${this.opts.organizationId}
|
|
148
|
+
return `${this.opts.organizationId}`;
|
|
149
149
|
case ':project:':
|
|
150
150
|
return `${this.opts.organizationId}/${this.opts.projectId}/${this.opts.environment}${activationSuffix}`;
|
|
151
151
|
case ':execution:':
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
+
export type { Uint8Array_ };
|
|
3
|
+
export declare const padding: number;
|
|
4
|
+
export declare const alphabet: Record<Base64Alphabet, Uint8Array>;
|
|
5
|
+
export declare const rAlphabet: Record<Base64Alphabet, Uint8Array>;
|
|
6
|
+
/**
|
|
7
|
+
* Options for encoding and decoding base64 strings.
|
|
8
|
+
*/
|
|
9
|
+
export interface Base64Options {
|
|
10
|
+
/** The base64 alphabet. Defaults to "base64" */
|
|
11
|
+
alphabet?: Base64Alphabet;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The base64 alphabets.
|
|
15
|
+
*/
|
|
16
|
+
export type Base64Alphabet = "base64" | "base64url";
|
|
17
|
+
/**
|
|
18
|
+
* Calculate the output size needed to encode a given input size for
|
|
19
|
+
* {@linkcode encodeIntoBase64}.
|
|
20
|
+
*
|
|
21
|
+
* @param originalSize The size of the input buffer.
|
|
22
|
+
* @returns The size of the output buffer.
|
|
23
|
+
*
|
|
24
|
+
* @example Basic Usage
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { assertEquals } from "@std/assert";
|
|
27
|
+
* import { calcSizeBase64 } from "@std/encoding/unstable-base64";
|
|
28
|
+
*
|
|
29
|
+
* assertEquals(calcSizeBase64(1), 4);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function calcSizeBase64(originalSize: number): number;
|
|
33
|
+
export declare function encode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
|
34
|
+
export declare function decode(buffer: Uint8Array_, i: number, o: number, alphabet: Uint8Array, padding: number): number;
|
|
35
|
+
//# sourceMappingURL=_common64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_common64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common64.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,eAAO,MAAM,OAAO,QAAoB,CAAC;AACzC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAKvD,CAAC;AACF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAGxD,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CA4BR;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAmDR"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.rAlphabet = exports.alphabet = exports.padding = void 0;
|
|
5
|
+
exports.calcSizeBase64 = calcSizeBase64;
|
|
6
|
+
exports.encode = encode;
|
|
7
|
+
exports.decode = decode;
|
|
8
|
+
exports.padding = "=".charCodeAt(0);
|
|
9
|
+
exports.alphabet = {
|
|
10
|
+
base64: new TextEncoder()
|
|
11
|
+
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),
|
|
12
|
+
base64url: new TextEncoder()
|
|
13
|
+
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),
|
|
14
|
+
};
|
|
15
|
+
exports.rAlphabet = {
|
|
16
|
+
base64: new Uint8Array(128).fill(64), // alphabet.base64.length
|
|
17
|
+
base64url: new Uint8Array(128).fill(64),
|
|
18
|
+
};
|
|
19
|
+
exports.alphabet.base64
|
|
20
|
+
.forEach((byte, i) => exports.rAlphabet.base64[byte] = i);
|
|
21
|
+
exports.alphabet.base64url
|
|
22
|
+
.forEach((byte, i) => exports.rAlphabet.base64url[byte] = i);
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the output size needed to encode a given input size for
|
|
25
|
+
* {@linkcode encodeIntoBase64}.
|
|
26
|
+
*
|
|
27
|
+
* @param originalSize The size of the input buffer.
|
|
28
|
+
* @returns The size of the output buffer.
|
|
29
|
+
*
|
|
30
|
+
* @example Basic Usage
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { assertEquals } from "@std/assert";
|
|
33
|
+
* import { calcSizeBase64 } from "@std/encoding/unstable-base64";
|
|
34
|
+
*
|
|
35
|
+
* assertEquals(calcSizeBase64(1), 4);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function calcSizeBase64(originalSize) {
|
|
39
|
+
return ((originalSize + 2) / 3 | 0) * 4;
|
|
40
|
+
}
|
|
41
|
+
function encode(buffer, i, o, alphabet, padding) {
|
|
42
|
+
i += 2;
|
|
43
|
+
for (; i < buffer.length; i += 3) {
|
|
44
|
+
const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8) | buffer[i];
|
|
45
|
+
buffer[o++] = alphabet[x >> 18];
|
|
46
|
+
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
|
47
|
+
buffer[o++] = alphabet[x >> 6 & 0x3F];
|
|
48
|
+
buffer[o++] = alphabet[x & 0x3F];
|
|
49
|
+
}
|
|
50
|
+
switch (i) {
|
|
51
|
+
case buffer.length + 1: {
|
|
52
|
+
const x = buffer[i - 2] << 16;
|
|
53
|
+
buffer[o++] = alphabet[x >> 18];
|
|
54
|
+
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
|
55
|
+
buffer[o++] = padding;
|
|
56
|
+
buffer[o++] = padding;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case buffer.length: {
|
|
60
|
+
const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8);
|
|
61
|
+
buffer[o++] = alphabet[x >> 18];
|
|
62
|
+
buffer[o++] = alphabet[x >> 12 & 0x3F];
|
|
63
|
+
buffer[o++] = alphabet[x >> 6 & 0x3F];
|
|
64
|
+
buffer[o++] = padding;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return o;
|
|
69
|
+
}
|
|
70
|
+
function decode(buffer, i, o, alphabet, padding) {
|
|
71
|
+
for (let x = buffer.length - 2; x < buffer.length; ++x) {
|
|
72
|
+
if (buffer[x] === padding) {
|
|
73
|
+
for (let y = x + 1; y < buffer.length; ++y) {
|
|
74
|
+
if (buffer[y] !== padding) {
|
|
75
|
+
throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(buffer[y])})`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
buffer = buffer.subarray(0, x);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if ((buffer.length - o) % 4 === 1) {
|
|
83
|
+
throw new RangeError(`Cannot decode input as base64: Length (${buffer.length - o}), excluding padding, must not have a remainder of 1 when divided by 4`);
|
|
84
|
+
}
|
|
85
|
+
i += 3;
|
|
86
|
+
for (; i < buffer.length; i += 4) {
|
|
87
|
+
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
|
88
|
+
(getByte(buffer[i - 2], alphabet) << 12) |
|
|
89
|
+
(getByte(buffer[i - 1], alphabet) << 6) |
|
|
90
|
+
getByte(buffer[i], alphabet);
|
|
91
|
+
buffer[o++] = x >> 16;
|
|
92
|
+
buffer[o++] = x >> 8 & 0xFF;
|
|
93
|
+
buffer[o++] = x & 0xFF;
|
|
94
|
+
}
|
|
95
|
+
switch (i) {
|
|
96
|
+
case buffer.length + 1: {
|
|
97
|
+
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
|
98
|
+
(getByte(buffer[i - 2], alphabet) << 12);
|
|
99
|
+
buffer[o++] = x >> 16;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case buffer.length: {
|
|
103
|
+
const x = (getByte(buffer[i - 3], alphabet) << 18) |
|
|
104
|
+
(getByte(buffer[i - 2], alphabet) << 12) |
|
|
105
|
+
(getByte(buffer[i - 1], alphabet) << 6);
|
|
106
|
+
buffer[o++] = x >> 16;
|
|
107
|
+
buffer[o++] = x >> 8 & 0xFF;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return o;
|
|
112
|
+
}
|
|
113
|
+
function getByte(char, alphabet) {
|
|
114
|
+
const byte = alphabet[char] ?? 64;
|
|
115
|
+
if (byte === 64) { // alphabet.Base64.length
|
|
116
|
+
throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(char)})`);
|
|
117
|
+
}
|
|
118
|
+
return byte;
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.detach = detach;
|
|
5
|
+
function detach(buffer, maxSize) {
|
|
6
|
+
const originalSize = buffer.length;
|
|
7
|
+
if (buffer.byteOffset) {
|
|
8
|
+
const b = new Uint8Array(buffer.buffer);
|
|
9
|
+
b.set(buffer);
|
|
10
|
+
buffer = b.subarray(0, originalSize);
|
|
11
|
+
}
|
|
12
|
+
// deno-lint-ignore no-explicit-any
|
|
13
|
+
buffer = new Uint8Array(buffer.buffer.transfer(maxSize));
|
|
14
|
+
buffer.set(buffer.subarray(0, originalSize), maxSize - originalSize);
|
|
15
|
+
return [buffer, maxSize - originalSize];
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
|
|
3
|
+
*
|
|
4
|
+
* This type is internal utility type and should not be used directly.
|
|
5
|
+
*
|
|
6
|
+
* @internal @private
|
|
7
|
+
*/
|
|
8
|
+
export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
|
|
9
|
+
//# sourceMappingURL=_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
+
export type { Uint8Array_ };
|
|
3
|
+
/**
|
|
4
|
+
* Converts data into a base64-encoded string.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
7
|
+
*
|
|
8
|
+
* @param data The data to encode.
|
|
9
|
+
* @returns The base64-encoded string.
|
|
10
|
+
*
|
|
11
|
+
* @example Usage
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { encodeBase64 } from "@std/encoding/base64";
|
|
14
|
+
* import { assertEquals } from "@std/assert";
|
|
15
|
+
*
|
|
16
|
+
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Decodes a base64-encoded string.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
24
|
+
*
|
|
25
|
+
* @param b64 The base64-encoded string to decode.
|
|
26
|
+
* @returns The decoded data.
|
|
27
|
+
*
|
|
28
|
+
* @example Usage
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { decodeBase64 } from "@std/encoding/base64";
|
|
31
|
+
* import { assertEquals } from "@std/assert";
|
|
32
|
+
*
|
|
33
|
+
* assertEquals(
|
|
34
|
+
* decodeBase64("Zm9vYmFy"),
|
|
35
|
+
* new TextEncoder().encode("foobar")
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function decodeBase64(b64: string): Uint8Array_;
|
|
40
|
+
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/base64.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAQ5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAW5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKrD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.encodeBase64 = encodeBase64;
|
|
6
|
+
exports.decodeBase64 = decodeBase64;
|
|
7
|
+
/**
|
|
8
|
+
* Utilities for
|
|
9
|
+
* {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4 | base64}
|
|
10
|
+
* encoding and decoding.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import {
|
|
14
|
+
* encodeBase64,
|
|
15
|
+
* decodeBase64,
|
|
16
|
+
* } from "@std/encoding/base64";
|
|
17
|
+
* import { assertEquals } from "@std/assert";
|
|
18
|
+
*
|
|
19
|
+
* const foobar = new TextEncoder().encode("foobar");
|
|
20
|
+
*
|
|
21
|
+
* assertEquals(encodeBase64(foobar), "Zm9vYmFy");
|
|
22
|
+
* assertEquals(decodeBase64("Zm9vYmFy"), foobar);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
const _common64_js_1 = require("./_common64.js");
|
|
28
|
+
const _common_detach_js_1 = require("./_common_detach.js");
|
|
29
|
+
const padding = "=".charCodeAt(0);
|
|
30
|
+
const alphabet = new TextEncoder()
|
|
31
|
+
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
|
32
|
+
const rAlphabet = new Uint8Array(128).fill(64); // alphabet.length
|
|
33
|
+
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
34
|
+
/**
|
|
35
|
+
* Converts data into a base64-encoded string.
|
|
36
|
+
*
|
|
37
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
38
|
+
*
|
|
39
|
+
* @param data The data to encode.
|
|
40
|
+
* @returns The base64-encoded string.
|
|
41
|
+
*
|
|
42
|
+
* @example Usage
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { encodeBase64 } from "@std/encoding/base64";
|
|
45
|
+
* import { assertEquals } from "@std/assert";
|
|
46
|
+
*
|
|
47
|
+
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function encodeBase64(data) {
|
|
51
|
+
if (typeof data === "string") {
|
|
52
|
+
data = new TextEncoder().encode(data);
|
|
53
|
+
}
|
|
54
|
+
else if (data instanceof ArrayBuffer)
|
|
55
|
+
data = new Uint8Array(data).slice();
|
|
56
|
+
else
|
|
57
|
+
data = data.slice();
|
|
58
|
+
const [output, i] = (0, _common_detach_js_1.detach)(data, (0, _common64_js_1.calcSizeBase64)(data.length));
|
|
59
|
+
(0, _common64_js_1.encode)(output, i, 0, alphabet, padding);
|
|
60
|
+
return new TextDecoder().decode(output);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Decodes a base64-encoded string.
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
66
|
+
*
|
|
67
|
+
* @param b64 The base64-encoded string to decode.
|
|
68
|
+
* @returns The decoded data.
|
|
69
|
+
*
|
|
70
|
+
* @example Usage
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { decodeBase64 } from "@std/encoding/base64";
|
|
73
|
+
* import { assertEquals } from "@std/assert";
|
|
74
|
+
*
|
|
75
|
+
* assertEquals(
|
|
76
|
+
* decodeBase64("Zm9vYmFy"),
|
|
77
|
+
* new TextEncoder().encode("foobar")
|
|
78
|
+
* );
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function decodeBase64(b64) {
|
|
82
|
+
const output = new TextEncoder().encode(b64);
|
|
83
|
+
// deno-lint-ignore no-explicit-any
|
|
84
|
+
return new Uint8Array(output.buffer
|
|
85
|
+
.transfer((0, _common64_js_1.decode)(output, 0, 0, rAlphabet, padding)));
|
|
86
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Client } from '@connectrpc/connect';
|
|
2
|
+
import { CredentialsProvider } from '../credentials/CredentialsProvider.js';
|
|
3
|
+
import { credentialv1alpha1, oauth1v1, tokensv1 } from '../services/credentials/mod.js';
|
|
4
|
+
export declare class CredentialsProviderImpl implements CredentialsProvider {
|
|
5
|
+
private readonly credentials;
|
|
6
|
+
private readonly tokens;
|
|
7
|
+
private readonly oauth1;
|
|
8
|
+
constructor(credentials: Client<typeof credentialv1alpha1.CredentialService>, tokens: Client<typeof tokensv1.TokenService>, oauth1: Client<typeof oauth1v1.AuthorizationService>);
|
|
9
|
+
getRaw(name: string, _activationId?: string): Promise<Uint8Array>;
|
|
10
|
+
getAccessToken(name: string, forceRefresh?: boolean, _activationId?: string): Promise<{
|
|
11
|
+
accessToken: string;
|
|
12
|
+
tokenType: string;
|
|
13
|
+
expiry: Date | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
getOAuth1Metadata(name: string, _activationId?: string): Promise<oauth1v1.GetAuthorizationMetadataResponse>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=CredentialsProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialsProvider.d.ts","sourceRoot":"","sources":["../../../src/src/connection/CredentialsProvider.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAExF,qBAAa,uBAAwB,YAAW,mBAAmB;IAE3D,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,WAAW,EAAE,MAAM,CAAC,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,EAChE,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,YAAY,CAAC,EAC5C,MAAM,EAAE,MAAM,CAAC,OAAO,QAAQ,CAAC,oBAAoB,CAAC;IAInE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IASjE,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM;;;;;IAY3E,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM;CAO/D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
4
|
+
*
|
|
5
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
6
|
+
* included in the LICENSE file at the root of this repository.
|
|
7
|
+
*
|
|
8
|
+
* Change Date: 2029-01-01
|
|
9
|
+
* Change License: Apache License, Version 2.0
|
|
10
|
+
*
|
|
11
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
12
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CredentialsProviderImpl = void 0;
|
|
16
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
17
|
+
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
18
|
+
const mod_js_1 = require("../services/credentials/mod.js");
|
|
19
|
+
class CredentialsProviderImpl {
|
|
20
|
+
constructor(credentials, tokens, oauth1) {
|
|
21
|
+
Object.defineProperty(this, "credentials", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: credentials
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "tokens", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: tokens
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "oauth1", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: oauth1
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async getRaw(name, _activationId) {
|
|
41
|
+
const response = await this.credentials.get({ id: name, organisationId: '' });
|
|
42
|
+
if (!response.credential) {
|
|
43
|
+
throw new Error(`Failed to get credential: ${name}`);
|
|
44
|
+
}
|
|
45
|
+
const rawData = (0, protobuf_1.create)(mod_js_1.credentialv1alpha1.CredentialDataRawSchema, response.credential.data);
|
|
46
|
+
return rawData.raw;
|
|
47
|
+
}
|
|
48
|
+
async getAccessToken(name, forceRefresh, _activationId) {
|
|
49
|
+
const response = await this.tokens.getToken({ credentialId: name, forceRefresh: forceRefresh || false });
|
|
50
|
+
if (!response.token) {
|
|
51
|
+
throw new Error(`Failed to get token for credential: ${name}`);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
accessToken: response.token.accessToken,
|
|
55
|
+
tokenType: response.token.tokenType,
|
|
56
|
+
expiry: response.token.expiry ? new Date((0, wkt_1.timestampMs)(response.token.expiry)) : undefined,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async getOAuth1Metadata(name, _activationId) {
|
|
60
|
+
const response = await this.oauth1.getAuthorizationMetadata({ credentialId: name });
|
|
61
|
+
if (!response) {
|
|
62
|
+
throw new Error(`Failed to get OAuth1 metadata for credential: ${name}`);
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.CredentialsProviderImpl = CredentialsProviderImpl;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Client } from '@connectrpc/connect';
|
|
2
2
|
import { RequestHandler } from 'express';
|
|
3
|
+
import { CredentialsProvider } from '../credentials/CredentialsProvider.js';
|
|
3
4
|
import { Logger } from '../observability/mod.js';
|
|
4
5
|
import { credentialv1alpha1, oauth1v1, tokensv1 } from '../services/credentials/mod.js';
|
|
5
6
|
import { Connection } from '../services/platform/mod.js';
|
|
@@ -15,15 +16,16 @@ import { ConnectionFactory, FetchLike } from './types.js';
|
|
|
15
16
|
*/
|
|
16
17
|
export declare class DirectConnectionFactory implements ConnectionFactory {
|
|
17
18
|
private readonly httpClientFactory;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
readonly credentials: Client<typeof credentialv1alpha1.CredentialService>;
|
|
20
|
+
readonly tokens: Client<typeof tokensv1.TokenService>;
|
|
21
|
+
readonly oauth1: Client<typeof oauth1v1.AuthorizationService>;
|
|
21
22
|
private readonly logger;
|
|
22
23
|
private readonly outboundConnectionFactory;
|
|
23
24
|
private readonly expressInboundConnectionFactory;
|
|
24
25
|
constructor(httpClientFactory: HttpClientFactory, credentials: Client<typeof credentialv1alpha1.CredentialService>, tokens: Client<typeof tokensv1.TokenService>, oauth1: Client<typeof oauth1v1.AuthorizationService>, logger: Logger);
|
|
25
26
|
fetcher(cnx: Connection): Promise<FetchLike>;
|
|
26
27
|
handler(cnx: Connection): Promise<RequestHandler>;
|
|
28
|
+
getCredentialsProvider(): CredentialsProvider;
|
|
27
29
|
static fromEnv(logger: Logger): DirectConnectionFactory;
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=DirectConnectionFactory.d.ts.map
|