@oatscenter/trellis 0.100.0-rc.12 → 0.100.0-rc.14

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.
Files changed (40) hide show
  1. package/auth/browser/oauth.js +3 -5
  2. package/auth/issuer_trust.d.ts +1 -1
  3. package/auth/issuer_trust.js +2 -2
  4. package/auth/protocol_wasm/client/trellis_protocol_wasm_bg.wasm +0 -0
  5. package/auth/protocol_wasm/provider/trellis_protocol_wasm_bg.wasm +0 -0
  6. package/device/activation.js +2 -0
  7. package/device.js +4 -0
  8. package/internal_sdk/generated/apis/auth/mod.d.ts +37 -25
  9. package/internal_sdk/generated/apis/auth/mod.js +47 -33
  10. package/internal_sdk/generated/apis/core/mod.js +4 -4
  11. package/internal_sdk/generated/apis/events/mod.js +4 -4
  12. package/internal_sdk/generated/apis/health/mod.js +4 -4
  13. package/internal_sdk/generated/apis/jobs/mod.js +4 -4
  14. package/internal_sdk/generated/apis/state/mod.js +4 -4
  15. package/internal_sdk/generated/apps/cli/mod.d.ts +15 -10
  16. package/internal_sdk/generated/apps/cli/mod.js +18 -12
  17. package/internal_sdk/generated/apps/console/mod.d.ts +15 -10
  18. package/internal_sdk/generated/apps/console/mod.js +18 -12
  19. package/internal_sdk/generated/package.json +2 -2
  20. package/internal_sdk/generated/participants/eventsRuntime/mod.d.ts +3 -2
  21. package/internal_sdk/generated/participants/eventsRuntime/mod.js +7 -6
  22. package/internal_sdk/generated/participants/healthRuntime/mod.js +4 -4
  23. package/internal_sdk/generated/participants/jobsRuntime/mod.d.ts +3 -2
  24. package/internal_sdk/generated/participants/jobsRuntime/mod.js +7 -6
  25. package/internal_sdk/generated/participants/platform/mod.d.ts +4 -3
  26. package/internal_sdk/generated/participants/platform/mod.js +9 -8
  27. package/internal_sdk/generated/types/_internal/p0.d.ts +63 -54
  28. package/internal_sdk/generated/types/_internal/p0.js +34 -28
  29. package/internal_sdk/generated/types/index.d.ts +12 -10
  30. package/internal_sdk/generated/types/index.js +6 -5
  31. package/native/certificate_acceptance.d.ts +45 -0
  32. package/native/certificate_acceptance.js +171 -0
  33. package/native/custody.js +3 -1
  34. package/native/discovery.js +7 -5
  35. package/native/oauth.js +1 -1
  36. package/native.d.ts +1 -0
  37. package/native.js +1 -0
  38. package/package.json +2 -2
  39. package/service/runtime/service.js +9 -1
  40. package/session.d.ts +1 -0
@@ -74,13 +74,12 @@ export class BrowserOAuthClient {
74
74
  issuer.password ||
75
75
  issuer.hash ||
76
76
  issuer.search ||
77
- issuer.pathname !== "/" ||
78
77
  (issuer.protocol !== "https:" &&
79
78
  !(options.loopbackDevelopment &&
80
79
  loopback &&
81
80
  issuer.protocol === "http:")))
82
81
  return err(new AuthError({ reason: "InvalidIssuer" }));
83
- const response = await fetch(new URL("/.well-known/oauth-authorization-server", issuer), {
82
+ const response = await fetch(`${issuer.href.replace(/\/+$/, "")}/.well-known/oauth-authorization-server`, {
84
83
  redirect: "error",
85
84
  credentials: "omit",
86
85
  signal: AbortSignal.timeout(30_000),
@@ -259,7 +258,7 @@ export class BrowserOAuthClient {
259
258
  }
260
259
  async #prepareTrust(metadata) {
261
260
  if (!metadata) {
262
- const response = await fetch(new URL("/.well-known/oauth-authorization-server", this.scope.issuer), {
261
+ const response = await fetch(`${this.scope.issuer.replace(/\/+$/, "")}/.well-known/oauth-authorization-server`, {
263
262
  redirect: "error",
264
263
  credentials: "omit",
265
264
  signal: AbortSignal.timeout(30000),
@@ -269,8 +268,7 @@ export class BrowserOAuthClient {
269
268
  metadata = metadataSchema.parse(await boundedJson(response));
270
269
  }
271
270
  const active = metadata.trellis.issuers.filter((key) => key.state === "active");
272
- if (new URL(metadata.issuer).origin !== this.scope.issuer ||
273
- active.length !== 1)
271
+ if (metadata.issuer !== this.scope.issuer || active.length !== 1)
274
272
  throw new AuthError({ reason: "OAuthTrustUnavailable" });
275
273
  const owner = await authenticateIssuerChain(this.scope.issuer, this.#owner?.trustSnapshot ?? this.store.trust, {
276
274
  instanceId: metadata.trellis.trellisInstanceId,
@@ -1,3 +1,3 @@
1
1
  import { SessionAuthorityOwner, type RuntimeAuthorizationTrust } from "./authority.ts";
2
2
  /** Authenticate a discovery hint from the credential's existing pin, without consuming OAuth credentials. */
3
- export declare function authenticateIssuerChain(origin: string, anchor: RuntimeAuthorizationTrust, target: RuntimeAuthorizationTrust, signal?: AbortSignal, existingOwner?: SessionAuthorityOwner): Promise<SessionAuthorityOwner>;
3
+ export declare function authenticateIssuerChain(issuer: string, anchor: RuntimeAuthorizationTrust, target: RuntimeAuthorizationTrust, signal?: AbortSignal, existingOwner?: SessionAuthorityOwner): Promise<SessionAuthorityOwner>;
@@ -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(origin, anchor, target, signal, existingOwner) {
5
+ export async function authenticateIssuerChain(issuer, anchor, target, signal, existingOwner) {
6
6
  const owner = existingOwner ??
7
7
  new SessionAuthorityOwner({
8
8
  instanceId: anchor.instanceId,
@@ -16,7 +16,7 @@ export async function authenticateIssuerChain(origin, anchor, target, signal, ex
16
16
  BigInt(target.rotationSequence) < BigInt(anchor.rotationSequence))
17
17
  throw new Error("issuer scope or sequence mismatch");
18
18
  if (anchor.issuer.keyId !== target.issuer.keyId) {
19
- const url = new URL("/.well-known/trellis/issuer-chain", origin);
19
+ const url = new URL(`${issuer.replace(/\/+$/, "")}/.well-known/trellis/issuer-chain`);
20
20
  url.search = new URLSearchParams({
21
21
  pinnedKeyId: anchor.issuer.keyId,
22
22
  targetKeyId: target.issuer.keyId,
@@ -1,4 +1,5 @@
1
1
  import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
2
+ import { acceptServerCertificateFor } from "../native/certificate_acceptance.js";
2
3
  import { dirname, join } from "node:path";
3
4
  import { env, platform } from "node:process";
4
5
  import { Type } from "typebox";
@@ -288,6 +289,7 @@ async function createActivationRequiredStatus(args) {
288
289
  * local completion alone never grants device access or creates a new review.
289
290
  */
290
291
  export async function checkDeviceActivation(args) {
292
+ await acceptServerCertificateFor(args.trellisUrl, args.participant.identity);
291
293
  const store = await openDeviceActivationStateStore({
292
294
  trellisUrl: args.trellisUrl,
293
295
  rootSecret: args.rootSecret,
package/device.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Request-serving participants load the provider protocol build.
2
+ import { acceptServerCertificateFor, trustAcceptedCertificatesFor, } from "./native/certificate_acceptance.js";
2
3
  import "./auth/protocol_wasm_provider.js";
3
4
  export { checkDeviceActivation } from "./device/activation.js";
4
5
  import { AsyncResult, Result, UnexpectedError } from "@oatscenter/result";
@@ -197,6 +198,7 @@ function createActivationSession(args) {
197
198
  * @internal Exported for focused tests and platform-specific wrappers.
198
199
  */
199
200
  export async function startDeviceActivationWithDeps(args, deps) {
201
+ await acceptServerCertificateFor(args.trellisUrl, args.participant.identity);
200
202
  const rootSecret = normalizeRootSecret(args.rootSecret);
201
203
  const identity = await deriveDeviceIdentity(rootSecret);
202
204
  const nonce = base64urlEncode(crypto.getRandomValues(new Uint8Array(32)));
@@ -264,6 +266,7 @@ export async function startDeviceActivationWithDeps(args, deps) {
264
266
  * @internal Exported for focused tests and platform-specific wrappers.
265
267
  */
266
268
  export async function resumeDeviceActivationWithDeps(args, deps) {
269
+ await acceptServerCertificateFor(args.trellisUrl, args.participant.identity);
267
270
  const rootSecret = normalizeRootSecret(args.rootSecret);
268
271
  const identity = await deriveDeviceIdentity(rootSecret);
269
272
  return await createActivationSession({
@@ -281,6 +284,7 @@ export async function resumeDeviceActivationWithDeps(args, deps) {
281
284
  * `TrellisDevice.connect`.
282
285
  */
283
286
  export async function connectDeviceWithDeps(args, deps) {
287
+ await trustAcceptedCertificatesFor(args.participant.identity);
284
288
  const connected = await connectProvisioned(args, "device", {}, await deps.loadTransport());
285
289
  let companion;
286
290
  try {
@@ -41,10 +41,6 @@ export declare class ValidationError extends TrellisError<ValidationErrorData> {
41
41
  static fromSerializable(data: unknown): ValidationError;
42
42
  override toSerializable(): ValidationErrorData;
43
43
  }
44
- export type AdministrationReviewsDecideInput = Types0.AuthAdministrationReviewDecideRequest;
45
- export type AdministrationReviewsDecideOutput = Types0.AuthAdministrationReviewResponse;
46
- export type AdministrationReviewsListInput = Types0.AuthPageRequest;
47
- export type AdministrationReviewsListOutput = Types0.AuthAdministrationReviewsListResponse;
48
44
  export type AdmissionRenewInput = Types0.AuthAdmissionRenewRequest;
49
45
  export type AdmissionRenewOutput = Types0.AuthAdmissionRenewResponse;
50
46
  export type ApisAcceptInput = Types0.AuthApiAcceptRequest;
@@ -179,6 +175,12 @@ export type RolesListInput = Types0.AuthPageRequest;
179
175
  export type RolesListOutput = Types0.AuthRolesListResponse;
180
176
  export type RolesPutInput = Types0.AuthRolePutRequest;
181
177
  export type RolesPutOutput = Types0.AuthRolePutResponse;
178
+ export type ServiceClaimsCreateInput = Types0.AuthServiceClaimCreateRequest;
179
+ export type ServiceClaimsCreateOutput = Types0.AuthServiceClaimResponse;
180
+ export type ServiceClaimsListInput = Types0.AuthPageRequest;
181
+ export type ServiceClaimsListOutput = Types0.AuthServiceClaimsListResponse;
182
+ export type ServiceClaimsRemoveInput = Types0.AuthServiceClaimRemoveRequest;
183
+ export type ServiceClaimsRemoveOutput = Types0.AuthServiceClaimResponse;
182
184
  export type ServiceInstancesDisableInput = Types0.AuthInstanceMutationRequest;
183
185
  export type ServiceInstancesDisableOutput = Types0.AuthInstanceMutationResponse;
184
186
  export type ServiceInstancesEnableInput = Types0.AuthInstanceMutationRequest;
@@ -242,26 +244,6 @@ export type IssuersRotatedEvent = Types0.AuthSecurityEvent;
242
244
  declare const __api: {
243
245
  readonly identity: "trellis.auth@v1";
244
246
  readonly actions: {
245
- readonly "rpc:Administration.Reviews.Decide": {
246
- readonly kind: "rpc";
247
- readonly descriptorName: "rpc:Administration.Reviews.Decide";
248
- readonly subject: "rpc.v1.auth.Administration.Reviews.Decide";
249
- readonly input: typeof Types0.AuthAdministrationReviewDecideRequestCodec;
250
- readonly output: typeof Types0.AuthAdministrationReviewResponseCodec;
251
- readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
252
- readonly download: false;
253
- readonly pagination: undefined;
254
- };
255
- readonly "rpc:Administration.Reviews.List": {
256
- readonly kind: "rpc";
257
- readonly descriptorName: "rpc:Administration.Reviews.List";
258
- readonly subject: "rpc.v1.auth.Administration.Reviews.List";
259
- readonly input: typeof Types0.AuthPageRequestCodec;
260
- readonly output: typeof Types0.AuthAdministrationReviewsListResponseCodec;
261
- readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
262
- readonly download: false;
263
- readonly pagination: "cursor";
264
- };
265
247
  readonly "rpc:Admission.Renew": {
266
248
  readonly kind: "rpc";
267
249
  readonly descriptorName: "rpc:Admission.Renew";
@@ -932,6 +914,36 @@ declare const __api: {
932
914
  readonly download: false;
933
915
  readonly pagination: undefined;
934
916
  };
917
+ readonly "rpc:ServiceClaims.Create": {
918
+ readonly kind: "rpc";
919
+ readonly descriptorName: "rpc:ServiceClaims.Create";
920
+ readonly subject: "rpc.v1.auth.ServiceClaims.Create";
921
+ readonly input: typeof Types0.AuthServiceClaimCreateRequestCodec;
922
+ readonly output: typeof Types0.AuthServiceClaimResponseCodec;
923
+ readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
924
+ readonly download: false;
925
+ readonly pagination: undefined;
926
+ };
927
+ readonly "rpc:ServiceClaims.List": {
928
+ readonly kind: "rpc";
929
+ readonly descriptorName: "rpc:ServiceClaims.List";
930
+ readonly subject: "rpc.v1.auth.ServiceClaims.List";
931
+ readonly input: typeof Types0.AuthPageRequestCodec;
932
+ readonly output: typeof Types0.AuthServiceClaimsListResponseCodec;
933
+ readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
934
+ readonly download: false;
935
+ readonly pagination: "cursor";
936
+ };
937
+ readonly "rpc:ServiceClaims.Remove": {
938
+ readonly kind: "rpc";
939
+ readonly descriptorName: "rpc:ServiceClaims.Remove";
940
+ readonly subject: "rpc.v1.auth.ServiceClaims.Remove";
941
+ readonly input: typeof Types0.AuthServiceClaimRemoveRequestCodec;
942
+ readonly output: typeof Types0.AuthServiceClaimResponseCodec;
943
+ readonly errors: readonly [typeof AuthError, typeof UnexpectedError, typeof ValidationError];
944
+ readonly download: false;
945
+ readonly pagination: undefined;
946
+ };
935
947
  readonly "rpc:ServiceInstances.Disable": {
936
948
  readonly kind: "rpc";
937
949
  readonly descriptorName: "rpc:ServiceInstances.Disable";
@@ -1248,5 +1260,5 @@ declare const __api: {
1248
1260
  readonly packageEvidence: unknown;
1249
1261
  };
1250
1262
  export declare const API: typeof __api;
1251
- export declare const API_DIGEST: "WIFkjJqL0kGo4gCb0d8BC3r4pY2Pehw7usNB3fP73bs";
1263
+ export declare const API_DIGEST: "LUcTB3jviCaJWBgxAKT7p1wmTgbKCTkfICbQTbNv5Xc";
1252
1264
  export {};