@oatscenter/trellis 0.100.0-rc.19 → 0.100.0-rc.21
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/auth/device_activation.d.ts +3 -0
- package/auth/device_activation.js +1 -1
- package/auth/issuer_trust.d.ts +2 -1
- package/auth/issuer_trust.js +2 -2
- package/auth/oauth_core.d.ts +13 -0
- package/auth/oauth_core.js +1 -1
- package/device/activation.js +2 -1
- package/device.js +4 -2
- package/internal_sdk/generated/apis/auth/mod.d.ts +1 -1
- package/internal_sdk/generated/apis/auth/mod.js +5 -5
- package/internal_sdk/generated/apis/core/mod.js +4 -4
- package/internal_sdk/generated/apis/events/mod.js +4 -4
- package/internal_sdk/generated/apis/health/mod.js +4 -4
- package/internal_sdk/generated/apis/jobs/mod.js +4 -4
- package/internal_sdk/generated/apis/state/mod.js +4 -4
- package/internal_sdk/generated/package.json +2 -2
- package/internal_sdk/generated/participants/eventsRuntime/mod.js +4 -4
- package/internal_sdk/generated/participants/healthRuntime/mod.js +4 -4
- package/internal_sdk/generated/participants/jobsRuntime/mod.js +4 -4
- package/internal_sdk/generated/participants/platform/mod.d.ts +1 -1
- package/internal_sdk/generated/participants/platform/mod.js +6 -6
- package/internal_sdk/generated/types/_internal/p0.d.ts +1 -1
- package/internal_sdk/generated/types/_internal/p0.js +1 -1
- package/native/certificate_acceptance.d.ts +39 -13
- package/native/certificate_acceptance.js +138 -33
- package/native/discovery.js +5 -1
- package/native/oauth.js +3 -1
- package/package.json +3 -2
- package/runtime_transport.js +11 -2
- package/service/runtime/core.js +17 -4
- package/service/runtime/service.js +37 -33
|
@@ -2,6 +2,7 @@ import type { StaticDecode } from "typebox";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { GeneratedParticipant } from "../participant_runtime/participant.ts";
|
|
4
4
|
import { createAuth } from "./session_auth.ts";
|
|
5
|
+
import type { HttpFetch } from "./oauth_core.ts";
|
|
5
6
|
export declare const DeviceActivationPayloadSchema: Type.TObject<{
|
|
6
7
|
v: Type.TLiteral<1>;
|
|
7
8
|
publicIdentityKey: Type.TString;
|
|
@@ -51,6 +52,8 @@ export declare function verifyDeviceConfirmationCode(input: {
|
|
|
51
52
|
/** Submit one proof-bound device enrollment request. */
|
|
52
53
|
export declare function requestDeviceEnrollment(args: {
|
|
53
54
|
trellisUrl: string;
|
|
55
|
+
/** Defaults to `fetch`. */
|
|
56
|
+
fetch?: HttpFetch;
|
|
54
57
|
publicIdentityKey: string;
|
|
55
58
|
identitySeed: Uint8Array | string;
|
|
56
59
|
sessionIdentity: Awaited<ReturnType<typeof createAuth>>;
|
|
@@ -198,7 +198,7 @@ export async function requestDeviceEnrollment(args) {
|
|
|
198
198
|
provisioningSecret: args.provisioningSecret,
|
|
199
199
|
}),
|
|
200
200
|
};
|
|
201
|
-
const response = await fetch(new URL("/auth/device/enroll", args.trellisUrl), {
|
|
201
|
+
const response = await (args.fetch ?? fetch)(new URL("/auth/device/enroll", args.trellisUrl), {
|
|
202
202
|
method: "POST",
|
|
203
203
|
signal: args.signal,
|
|
204
204
|
headers: { "Content-Type": "application/json" },
|
package/auth/issuer_trust.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HttpFetch } from "./oauth_core.ts";
|
|
1
2
|
import { SessionAuthorityOwner, type RuntimeAuthorizationTrust } from "./authority.ts";
|
|
2
3
|
/** Authenticate a discovery hint from the credential's existing pin, without consuming OAuth credentials. */
|
|
3
|
-
export declare function authenticateIssuerChain(issuer: string, anchor: RuntimeAuthorizationTrust, target: RuntimeAuthorizationTrust, signal?: AbortSignal, existingOwner?: SessionAuthorityOwner): Promise<SessionAuthorityOwner>;
|
|
4
|
+
export declare function authenticateIssuerChain(issuer: string, anchor: RuntimeAuthorizationTrust, target: RuntimeAuthorizationTrust, signal?: AbortSignal, existingOwner?: SessionAuthorityOwner, request?: HttpFetch): Promise<SessionAuthorityOwner>;
|
package/auth/issuer_trust.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AuthError } from "../errors/AuthError.js";
|
|
|
2
2
|
import { issuerChainSchema, signedBytes } from "./protocol_wasm.js";
|
|
3
3
|
import { SessionAuthorityOwner, } from "./authority.js";
|
|
4
4
|
/** Authenticate a discovery hint from the credential's existing pin, without consuming OAuth credentials. */
|
|
5
|
-
export async function authenticateIssuerChain(issuer, anchor, target, signal, existingOwner) {
|
|
5
|
+
export async function authenticateIssuerChain(issuer, anchor, target, signal, existingOwner, request = fetch) {
|
|
6
6
|
const owner = existingOwner ??
|
|
7
7
|
new SessionAuthorityOwner({
|
|
8
8
|
instanceId: anchor.instanceId,
|
|
@@ -21,7 +21,7 @@ export async function authenticateIssuerChain(issuer, anchor, target, signal, ex
|
|
|
21
21
|
pinnedKeyId: anchor.issuer.keyId,
|
|
22
22
|
targetKeyId: target.issuer.keyId,
|
|
23
23
|
}).toString();
|
|
24
|
-
const response = await
|
|
24
|
+
const response = await request(url, {
|
|
25
25
|
credentials: "omit",
|
|
26
26
|
redirect: "error",
|
|
27
27
|
signal: AbortSignal.any([
|
package/auth/oauth_core.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export type TokenResponse = Readonly<{
|
|
|
26
26
|
}>;
|
|
27
27
|
/** One bounded `DPoP-Nonce` value, or undefined. @internal */
|
|
28
28
|
export declare function usableNonce(value: string | null): string | undefined;
|
|
29
|
+
/** The request options Trellis's own HTTPS requests use. @internal */
|
|
30
|
+
export type HttpRequest = {
|
|
31
|
+
method?: string;
|
|
32
|
+
headers?: Record<string, string>;
|
|
33
|
+
body?: string | URLSearchParams;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
redirect?: RequestRedirect;
|
|
36
|
+
credentials?: RequestCredentials;
|
|
37
|
+
};
|
|
38
|
+
/** The part of `fetch` Trellis's own HTTPS requests use. @internal */
|
|
39
|
+
export type HttpFetch = (input: string | URL, init?: HttpRequest) => Promise<Response>;
|
|
29
40
|
/**
|
|
30
41
|
* POST a DPoP-bound form, answering a `use_dpop_nonce` challenge. Each attempt
|
|
31
42
|
* signs a fresh proof; a challenge precedes any artifact consumption, so the
|
|
@@ -39,6 +50,8 @@ export declare function postWithDpop(options: {
|
|
|
39
50
|
sessionPublicKey: string;
|
|
40
51
|
nonce?: string;
|
|
41
52
|
signal: AbortSignal;
|
|
53
|
+
/** Defaults to `fetch`. */
|
|
54
|
+
fetch?: HttpFetch;
|
|
42
55
|
}): Promise<TokenResponse>;
|
|
43
56
|
/**
|
|
44
57
|
* Verify a signed OAuth admission against current trust. If it does not
|
package/auth/oauth_core.js
CHANGED
|
@@ -75,7 +75,7 @@ export async function postWithDpop(options) {
|
|
|
75
75
|
let nonce = options.nonce;
|
|
76
76
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
77
77
|
const proof = await createDpopProof(options.key, options.endpoint, options.runtimeId, options.sessionPublicKey, nonce);
|
|
78
|
-
const response = await fetch(options.endpoint, {
|
|
78
|
+
const response = await (options.fetch ?? fetch)(options.endpoint, {
|
|
79
79
|
method: "POST",
|
|
80
80
|
body: options.form,
|
|
81
81
|
headers: { DPoP: proof },
|
package/device/activation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
2
|
-
import { acceptServerCertificateFor } from "../native/certificate_acceptance.js";
|
|
2
|
+
import { acceptServerCertificateFor, installationFetch, } from "../native/certificate_acceptance.js";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { env, platform } from "node:process";
|
|
5
5
|
import { Type } from "typebox";
|
|
@@ -301,6 +301,7 @@ export async function checkDeviceActivation(args) {
|
|
|
301
301
|
if (localState?.status === "activated") {
|
|
302
302
|
const identity = await deriveDeviceIdentity(normalizeRootSecret(args.rootSecret));
|
|
303
303
|
const enrollment = await requestDeviceEnrollment({
|
|
304
|
+
fetch: installationFetch,
|
|
304
305
|
trellisUrl: args.trellisUrl,
|
|
305
306
|
publicIdentityKey: identity.publicIdentityKey,
|
|
306
307
|
identitySeed: identity.identitySeed,
|
package/device.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Request-serving participants load the provider protocol build.
|
|
2
|
-
import { acceptServerCertificateFor, trustAcceptedCertificatesFor, } from "./native/certificate_acceptance.js";
|
|
2
|
+
import { acceptServerCertificateFor, installationFetch, trustAcceptedCertificatesFor, } from "./native/certificate_acceptance.js";
|
|
3
3
|
import "./auth/protocol_wasm_provider.js";
|
|
4
4
|
export { checkDeviceActivation } from "./device/activation.js";
|
|
5
5
|
import { AsyncResult, Result, UnexpectedError } from "@oatscenter/result";
|
|
@@ -169,6 +169,7 @@ function createActivationSession(args) {
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
const enrollment = await requestDeviceEnrollment({
|
|
172
|
+
fetch: installationFetch,
|
|
172
173
|
trellisUrl: args.trellisUrl,
|
|
173
174
|
publicIdentityKey: args.identity.publicIdentityKey,
|
|
174
175
|
identitySeed: args.identity.identitySeed,
|
|
@@ -207,6 +208,7 @@ export async function startDeviceActivationWithDeps(args, deps) {
|
|
|
207
208
|
});
|
|
208
209
|
const connectionId = ulid();
|
|
209
210
|
const activation = await requestDeviceEnrollment({
|
|
211
|
+
fetch: installationFetch,
|
|
210
212
|
trellisUrl: args.trellisUrl,
|
|
211
213
|
publicIdentityKey: identity.publicIdentityKey,
|
|
212
214
|
identitySeed: identity.identitySeed,
|
|
@@ -284,7 +286,7 @@ export async function resumeDeviceActivationWithDeps(args, deps) {
|
|
|
284
286
|
* `TrellisDevice.connect`.
|
|
285
287
|
*/
|
|
286
288
|
export async function connectDeviceWithDeps(args, deps) {
|
|
287
|
-
await trustAcceptedCertificatesFor(args.participant.identity);
|
|
289
|
+
await trustAcceptedCertificatesFor(args.participant.identity, [args.servers].flat());
|
|
288
290
|
const connected = await connectProvisioned(args, "device", {}, await deps.loadTransport());
|
|
289
291
|
let companion;
|
|
290
292
|
try {
|
|
@@ -1272,5 +1272,5 @@ declare const __api: {
|
|
|
1272
1272
|
readonly packageEvidence: unknown;
|
|
1273
1273
|
};
|
|
1274
1274
|
export declare const API: typeof __api;
|
|
1275
|
-
export declare const API_DIGEST: "
|
|
1275
|
+
export declare const API_DIGEST: "q4mGqO6Iv7Gh1OQpvhRVYEXqsNecVXpHIIiTzlmCWok";
|
|
1276
1276
|
export {};
|