@le-space/core 0.6.3 → 0.6.4
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/index.d.ts +8 -0
- package/index.js +12 -2
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -219,6 +219,9 @@ declare function broadcastAlephMessage(message: AlephBroadcastMessage, options:
|
|
|
219
219
|
apiHost?: string;
|
|
220
220
|
sync?: boolean;
|
|
221
221
|
fetch: JsonFetchLike$1;
|
|
222
|
+
attempts?: number;
|
|
223
|
+
retryDelayMs?: number;
|
|
224
|
+
sleep?: (ms: number) => Promise<void>;
|
|
222
225
|
}): Promise<{
|
|
223
226
|
response: AlephBroadcastResponse;
|
|
224
227
|
httpStatus: number;
|
|
@@ -522,6 +525,9 @@ declare function deployInstance(args: {
|
|
|
522
525
|
channel?: string;
|
|
523
526
|
sync?: boolean;
|
|
524
527
|
now?: number;
|
|
528
|
+
broadcastAttempts?: number;
|
|
529
|
+
broadcastRetryDelayMs?: number;
|
|
530
|
+
broadcastSleep?: (ms: number) => Promise<void>;
|
|
525
531
|
onProgress?: DeploymentProgressListener;
|
|
526
532
|
}): Promise<DeploymentResult>;
|
|
527
533
|
|
|
@@ -665,6 +671,8 @@ declare function configureUcanStore(args: {
|
|
|
665
671
|
setupPort: number;
|
|
666
672
|
publicIpv6?: string | null;
|
|
667
673
|
proxyUrl?: string | null;
|
|
674
|
+
serviceDid?: string | null;
|
|
675
|
+
serviceOrigin?: string | null;
|
|
668
676
|
webauthnOrigin?: string | null;
|
|
669
677
|
webauthnOriginFallbacks?: string | null;
|
|
670
678
|
adminDid?: string | null;
|
package/index.js
CHANGED
|
@@ -764,7 +764,9 @@ async function postBroadcastPayload(body, options) {
|
|
|
764
764
|
}
|
|
765
765
|
async function broadcastAlephMessage(message, options) {
|
|
766
766
|
const requestBody = { sync: options.sync ?? false, message };
|
|
767
|
-
const maxAttempts = 3;
|
|
767
|
+
const maxAttempts = Math.max(1, Number(options.attempts ?? 3));
|
|
768
|
+
const retryDelayMs = Math.max(0, Number(options.retryDelayMs ?? 0));
|
|
769
|
+
const sleep2 = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
768
770
|
for (let index = 0; index < maxAttempts; index += 1) {
|
|
769
771
|
const result = await postBroadcastPayload(requestBody, {
|
|
770
772
|
apiHost: options.apiHost,
|
|
@@ -777,6 +779,9 @@ async function broadcastAlephMessage(message, options) {
|
|
|
777
779
|
if (!canRetry) {
|
|
778
780
|
throw new Error(`Broadcast failed: ${result.httpStatus} ${JSON.stringify(result.response ?? {})}`);
|
|
779
781
|
}
|
|
782
|
+
if (retryDelayMs > 0) {
|
|
783
|
+
await sleep2(retryDelayMs);
|
|
784
|
+
}
|
|
780
785
|
}
|
|
781
786
|
throw new Error("Broadcast failed: retry budget exhausted");
|
|
782
787
|
}
|
|
@@ -1984,7 +1989,10 @@ async function deployInstance(args) {
|
|
|
1984
1989
|
const { response, httpStatus } = await broadcastAlephMessage(message, {
|
|
1985
1990
|
apiHost: args.apiHost,
|
|
1986
1991
|
sync: args.sync,
|
|
1987
|
-
fetch: args.fetch
|
|
1992
|
+
fetch: args.fetch,
|
|
1993
|
+
attempts: args.broadcastAttempts,
|
|
1994
|
+
retryDelayMs: args.broadcastRetryDelayMs,
|
|
1995
|
+
sleep: args.broadcastSleep
|
|
1988
1996
|
});
|
|
1989
1997
|
const status = httpStatus === 202 ? "pending" : typeof response.message_status === "string" ? response.message_status : "unknown";
|
|
1990
1998
|
args.onProgress?.({
|
|
@@ -2241,6 +2249,8 @@ async function configureUcanStore(args) {
|
|
|
2241
2249
|
public_ipv4: args.hostIpv4,
|
|
2242
2250
|
public_ipv6: args.publicIpv6 ?? void 0,
|
|
2243
2251
|
proxy_url: args.proxyUrl ?? void 0,
|
|
2252
|
+
service_did: args.serviceDid ?? void 0,
|
|
2253
|
+
service_origin: args.serviceOrigin ?? void 0,
|
|
2244
2254
|
webauthn_origin: args.webauthnOrigin ?? void 0,
|
|
2245
2255
|
webauthn_origin_fallbacks: args.webauthnOriginFallbacks ?? void 0,
|
|
2246
2256
|
admin_did: args.adminDid ?? void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/NiKrause/relay-button/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@le-space/aleph-bootstrap": "0.6.
|
|
28
|
-
"@le-space/shared-types": "0.6.
|
|
27
|
+
"@le-space/aleph-bootstrap": "0.6.4",
|
|
28
|
+
"@le-space/shared-types": "0.6.4"
|
|
29
29
|
}
|
|
30
30
|
}
|