@versori/run 0.4.4 → 0.4.6
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 +23 -0
- package/esm/src/connection/CredentialsProvider.d.ts.map +1 -0
- package/esm/src/connection/CredentialsProvider.js +130 -0
- package/esm/src/connection/DirectConnectionFactory.d.ts +3 -3
- package/esm/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/esm/src/connection/DirectConnectionFactory.js +2 -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 +5 -17
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +5 -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 +23 -0
- package/script/src/connection/CredentialsProvider.d.ts.map +1 -0
- package/script/src/connection/CredentialsProvider.js +134 -0
- package/script/src/connection/DirectConnectionFactory.d.ts +3 -3
- package/script/src/connection/DirectConnectionFactory.d.ts.map +1 -1
- package/script/src/connection/DirectConnectionFactory.js +2 -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 +5 -17
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +5 -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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Versori Group Inc
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License 1.1
|
|
5
|
+
* included in the LICENSE file at the root of this repository.
|
|
6
|
+
*
|
|
7
|
+
* Change Date: 2029-01-01
|
|
8
|
+
* Change License: Apache License, Version 2.0
|
|
9
|
+
*
|
|
10
|
+
* As of the Change Date, in accordance with the Business Source License,
|
|
11
|
+
* use of this software will be governed by the Apache License, Version 2.0.
|
|
12
|
+
*/
|
|
13
|
+
import { create } from '@bufbuild/protobuf';
|
|
14
|
+
import { encodeBase64 } from '../../deps/jsr.io/@std/encoding/1.0.10/base64.js';
|
|
15
|
+
import { credentialv1alpha1 } from '../services/credentials/mod.js';
|
|
16
|
+
/**
|
|
17
|
+
* CredentialsProviderV2 is the latest version of the CredentialsProvider interface and provides more capabilities for
|
|
18
|
+
* interacting with the credentials service.
|
|
19
|
+
*
|
|
20
|
+
* THIS IS A WORK IN PROGRESS - WE SHOULD STILL USE THE V1 INTERFACE FOR NOW.
|
|
21
|
+
*
|
|
22
|
+
* No idea if this approach is a good idea, happy to change it if there's a better way.
|
|
23
|
+
*/
|
|
24
|
+
export class CredentialsProviderImpl {
|
|
25
|
+
constructor(client, organisationId) {
|
|
26
|
+
Object.defineProperty(this, "client", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: client
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "organisationId", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: organisationId
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async get(id) {
|
|
40
|
+
const response = await this.client.get({ id, organisationId: this.organisationId });
|
|
41
|
+
if (!response.credential) {
|
|
42
|
+
throw new Error('Failed to get credential, response was undefined');
|
|
43
|
+
}
|
|
44
|
+
return response.credential;
|
|
45
|
+
}
|
|
46
|
+
async updateApiKey(id, key) {
|
|
47
|
+
const rawMsg = create(credentialv1alpha1.CredentialDataRawSchema, {
|
|
48
|
+
raw: new TextEncoder().encode(encodeBase64(key)),
|
|
49
|
+
});
|
|
50
|
+
const response = await this.client.update({
|
|
51
|
+
id,
|
|
52
|
+
organisationId: this.organisationId,
|
|
53
|
+
data: {
|
|
54
|
+
raw: rawMsg.raw,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
if (!response.credential) {
|
|
58
|
+
throw new Error('Failed to update API key credential, response was undefined');
|
|
59
|
+
}
|
|
60
|
+
return response.credential;
|
|
61
|
+
}
|
|
62
|
+
async updateBasicAuth(id, username, password) {
|
|
63
|
+
const basicAuthMsg = create(credentialv1alpha1.CredentialDataBasicAuthSchema, {
|
|
64
|
+
username,
|
|
65
|
+
password,
|
|
66
|
+
});
|
|
67
|
+
const data = {
|
|
68
|
+
username: new TextEncoder().encode(encodeBase64(basicAuthMsg.username)),
|
|
69
|
+
password: new TextEncoder().encode(encodeBase64(basicAuthMsg.password)),
|
|
70
|
+
};
|
|
71
|
+
const response = await this.client.update({
|
|
72
|
+
id,
|
|
73
|
+
organisationId: this.organisationId,
|
|
74
|
+
data,
|
|
75
|
+
});
|
|
76
|
+
if (!response.credential) {
|
|
77
|
+
throw new Error('Failed to update basic auth credential, response was undefined');
|
|
78
|
+
}
|
|
79
|
+
return response.credential;
|
|
80
|
+
}
|
|
81
|
+
async updateCertificate(id, payload) {
|
|
82
|
+
const certificateMsg = create(credentialv1alpha1.CredentialDataCertificateSchema, {
|
|
83
|
+
certificate: payload.certificate,
|
|
84
|
+
key: payload.key,
|
|
85
|
+
ca: payload.ca,
|
|
86
|
+
});
|
|
87
|
+
const data = {
|
|
88
|
+
certificate: new TextEncoder().encode(encodeBase64(certificateMsg.certificate)),
|
|
89
|
+
key: new TextEncoder().encode(encodeBase64(certificateMsg.key)),
|
|
90
|
+
ca: new TextEncoder().encode(encodeBase64(certificateMsg.ca)),
|
|
91
|
+
};
|
|
92
|
+
const response = await this.client.update({
|
|
93
|
+
id,
|
|
94
|
+
organisationId: this.organisationId,
|
|
95
|
+
data,
|
|
96
|
+
});
|
|
97
|
+
if (!response.credential) {
|
|
98
|
+
throw new Error('Failed to update certificate credential, response was undefined');
|
|
99
|
+
}
|
|
100
|
+
return response.credential;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.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;
|
|
1
|
+
{"version":3,"file":"DurableInterpreter.d.ts","sourceRoot":"","sources":["../../../../src/src/interpreter/durable/DurableInterpreter.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;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAcrE,OAAO,EAAE,QAAQ,EAAgB,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,wBAAwB,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAmB,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OA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CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IApB7B,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAa;IACpC,OAAO,CAAC,cAAc,CAAS;gBAGV,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,kBAAkB,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,uBAAuB,EACxC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuG9F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAoDtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4MtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -16,13 +16,12 @@ import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
|
16
16
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
17
17
|
import express from 'express';
|
|
18
18
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
|
+
import { CredentialsProviderImpl } from '../../connection/CredentialsProvider.js';
|
|
19
20
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
20
21
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
21
|
-
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
22
22
|
import { VersoriConfigReader } from '../../dsl/http/versori/configloader.js';
|
|
23
23
|
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarSDKApiBaseURL, envVarVersion, } from '../../dsl/http/versori/constants.js';
|
|
24
24
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
|
-
import { ProxyRoundTripper } from '../../dsl/http/versori/proxyroundtripper.js';
|
|
26
25
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
27
26
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
28
27
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
@@ -37,14 +36,6 @@ function getKVProvider(runLocal) {
|
|
|
37
36
|
}
|
|
38
37
|
return SDKKeyValueProvider.fromEnv();
|
|
39
38
|
}
|
|
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
39
|
/**
|
|
49
40
|
* DurableInterpreter is an interpreter for executing Versori workflows with support for durable, queue-based workflow
|
|
50
41
|
* execution. It supports all trigger types including the {@link workflow} trigger which allows workflows to be started
|
|
@@ -228,23 +219,20 @@ export class DurableInterpreter {
|
|
|
228
219
|
otelSDK.start();
|
|
229
220
|
}
|
|
230
221
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
231
|
-
const roundTripperFactory = getRoundTripperFactory(log, tracer, {
|
|
232
|
-
skipVersoriCredentials: options.skipVersoriCredentials,
|
|
233
|
-
runLocal: runLocal,
|
|
234
|
-
});
|
|
235
222
|
const queueProvider = await QueueImpl.fromEnv(log);
|
|
223
|
+
const connectionFactory = DirectConnectionFactory.fromEnv(log);
|
|
236
224
|
const issuesProvider = new IssueImpl(log);
|
|
237
225
|
if (options.contextProvider) {
|
|
238
226
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
239
227
|
// initialised.
|
|
240
|
-
return new DurableInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(),
|
|
228
|
+
return new DurableInterpreter(log, compiler, options.contextProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
241
229
|
}
|
|
242
230
|
const kvp = await getKVProvider(runLocal);
|
|
243
231
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
244
232
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
245
233
|
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(),
|
|
234
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
|
|
235
|
+
return new DurableInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), PlatformApiImpl.fromEnv(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, queueProvider, otelSDK);
|
|
248
236
|
}
|
|
249
237
|
register(workflow, options) {
|
|
250
238
|
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,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AE,MAAM,CAAC,EACxB,UAAU,EAAE,uBAAuB,EACnC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,QAAQ,EACxB,SAAS,EAAE,YAAY,EACvB,OAAO,CAAC,EAAE,OAAO,YAAA;WAWzB,WAAW,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqG5F,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAmDrE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+LtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CASxB"}
|
|
@@ -16,13 +16,13 @@ import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
|
16
16
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
17
17
|
import express from 'express';
|
|
18
18
|
import { catchError, EMPTY, mergeMap, of, tap } from 'rxjs';
|
|
19
|
+
import { CredentialsProviderImpl } from '../../connection/CredentialsProvider.js';
|
|
19
20
|
import { DirectConnectionFactory } from '../../connection/DirectConnectionFactory.js';
|
|
20
21
|
import { ContextProviderImpl } from '../../context/ContextProvider.js';
|
|
21
|
-
import { DefaultRoundTripperFactory } from '../../dsl/http/default.js';
|
|
22
22
|
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
23
|
import { CronAPIClient } from '../../dsl/http/versori/cronapi.js';
|
|
25
24
|
import { WorkflowImpl } from '../../dsl/Workflow.js';
|
|
25
|
+
import { envVarEnvId, envVarEnvironmentName, envVarLocalRun, envVarOrgId, envVarOrgSlug, envVarOtelTracesURL, envVarProjectId, envVarVersion } from '../../internal/constants.js';
|
|
26
26
|
import { IssueImpl } from '../../issues/Issues.js';
|
|
27
27
|
import { MemoryKeyValueProvider } from '../../kv/memory/MemoryKeyValueProvider.js';
|
|
28
28
|
import { NatsKeyValueProvider } from '../../kv/nats/NatsKeyValueProvider.js';
|
|
@@ -35,10 +35,6 @@ function getKVProvider(runLocal) {
|
|
|
35
35
|
}
|
|
36
36
|
return NatsKeyValueProvider.fromEnv();
|
|
37
37
|
}
|
|
38
|
-
function getRoundTripperFactory(log) {
|
|
39
|
-
log.info('Running with default round tripper factory');
|
|
40
|
-
return new DefaultRoundTripperFactory();
|
|
41
|
-
}
|
|
42
38
|
/**
|
|
43
39
|
* MemoryInterpreter is the default interpreter for executing Versori workflows. It handles registration and execution
|
|
44
40
|
* of workflows triggered by schedules and webhooks.
|
|
@@ -205,7 +201,7 @@ export class MemoryInterpreter {
|
|
|
205
201
|
otelSDK.start();
|
|
206
202
|
}
|
|
207
203
|
const tracer = opentelemetry.trace.getTracer(serviceName, version);
|
|
208
|
-
const
|
|
204
|
+
const connectionFactory = DirectConnectionFactory.fromEnv(log);
|
|
209
205
|
const issuesProvider = new IssueImpl(log);
|
|
210
206
|
if (options.contextProvider) {
|
|
211
207
|
// no need to set up a key-value provider if options.contextProvider is already
|
|
@@ -216,8 +212,8 @@ export class MemoryInterpreter {
|
|
|
216
212
|
const platformApi = PlatformApiImpl.fromEnv();
|
|
217
213
|
const organisationId = Deno.env.get(envVarOrgId) || 'development';
|
|
218
214
|
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(),
|
|
215
|
+
const ctxProvider = new ContextProviderImpl(log, kvp, new CredentialsProviderImpl(connectionFactory.credentials, connectionFactory.tokens, connectionFactory.oauth1, configReader, platformApi), platformApi, organisationId, environmentId, issuesProvider);
|
|
216
|
+
return new MemoryInterpreter(log, compiler, ctxProvider, express.Router(), express.Router(), new Map(), connectionFactory, CronAPIClient.fromEnv(), tracer, issuesProvider, configReader, otelSDK);
|
|
221
217
|
}
|
|
222
218
|
register(workflow, options) {
|
|
223
219
|
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
|
+
}
|