mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
chore: Add something
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import { Origin } from "./Origin";
|
import { Origin } from "./Origin";
|
||||||
|
|
||||||
export class LocalBinding {
|
export class LocalBinding {
|
||||||
constructor(readonly localAddress: string, readonly ipAddress: string) {}
|
constructor(readonly localHost: string, readonly ipHost: string) {}
|
||||||
createOrigins(protocol: string) {
|
createOrigins(protocol: string) {
|
||||||
return {
|
return {
|
||||||
local: new Origin(protocol, this.localAddress),
|
local: new Origin(protocol, this.localHost),
|
||||||
ip: new Origin(protocol, this.ipAddress),
|
ip: new Origin(protocol, this.ipHost),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,8 @@ export class NetworkInterfaceBuilder {
|
|||||||
|
|
||||||
async exportAddresses(addresses: Iterable<Origin>) {
|
async exportAddresses(addresses: Iterable<Origin>) {
|
||||||
const { name, description, id, ui, path, search } = this.options;
|
const { name, description, id, ui, path, search } = this.options;
|
||||||
// prettier-ignore
|
|
||||||
const urlAuth = !!(this.options?.basic) ? `${this.options.basic.username}:${this.options.basic.password}@` :
|
|
||||||
'';
|
|
||||||
for (const origin of addresses) {
|
for (const origin of addresses) {
|
||||||
const address = `${origin.protocol}://${urlAuth}${origin.address}`;
|
const address = origin.withAuth(this.options.basic);
|
||||||
await this.options.effects.exportAddress({
|
await this.options.effects.exportAddress({
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
export class Origin {
|
export class Origin {
|
||||||
constructor(readonly protocol: string, readonly address: string) {}
|
constructor(readonly protocol: string, readonly host: string) {}
|
||||||
|
|
||||||
|
withAuth(
|
||||||
|
origin?:
|
||||||
|
| {
|
||||||
|
password: string;
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
| null
|
||||||
|
| undefined
|
||||||
|
) {
|
||||||
|
// prettier-ignore
|
||||||
|
const urlAuth = !!(origin) ? `${origin.username}:${origin.password}@` :
|
||||||
|
'';
|
||||||
|
return `${this.protocol}://${urlAuth}${this.host}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Origin } from "./Origin";
|
import { Origin } from "./Origin";
|
||||||
|
|
||||||
export class TorBinding {
|
export class TorBinding {
|
||||||
constructor(readonly address: string) {}
|
constructor(readonly host: string) {}
|
||||||
createOrigin(protocol: string) {
|
createOrigin(protocol: string) {
|
||||||
return new Origin(protocol, this.address);
|
return new Origin(protocol, this.host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ export type UnionToIntersection<T> = ((x: T) => any) extends (x: infer R) => any
|
|||||||
export function setupPropertiesExport(
|
export function setupPropertiesExport(
|
||||||
fn: (
|
fn: (
|
||||||
...args: Parameters<ExpectedExports.properties>
|
...args: Parameters<ExpectedExports.properties>
|
||||||
) => Promise<Properties<PackagePropertiesV2>>
|
) => Promise<void> | void | Promise<Properties<PackagePropertiesV2>>
|
||||||
): ExpectedExports.properties {
|
): ExpectedExports.properties {
|
||||||
return (...args: Parameters<ExpectedExports.properties>) =>
|
return async (...args: Parameters<ExpectedExports.properties>) => {
|
||||||
fn(...args).then((x) => x.build());
|
const value = await fn(...args);
|
||||||
|
if (value) return value.build();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie15",
|
"version": "0.4.0-lib0.charlie17",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie15",
|
"version": "0.4.0-lib0.charlie17",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie15",
|
"version": "0.4.0-lib0.charlie17",
|
||||||
"description": "For making the patterns that are wanted in making services for the startOS.",
|
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user