@oatscenter/trellis 0.100.0-rc.6 → 0.100.0-rc.7

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/authority.js CHANGED
@@ -44,6 +44,27 @@ export class VerifiedAuthority {
44
44
  /** Verified logical caller identity usable by all SDK adapters. */
45
45
  get caller() {
46
46
  const authority = this.#entry.authority;
47
+ // Auth signs the user's own profile into a user principal's authority.
48
+ const profile = authority.principalKind === "user"
49
+ ? authority.extensions["trellis.user.v1"]
50
+ : undefined;
51
+ const text = (value) => typeof value === "string" ? value : undefined;
52
+ const user = profile !== null &&
53
+ typeof profile === "object" &&
54
+ !Array.isArray(profile) &&
55
+ typeof profile.displayName === "string"
56
+ ? {
57
+ displayName: profile.displayName,
58
+ ...(text(profile.givenName) && {
59
+ givenName: text(profile.givenName),
60
+ }),
61
+ ...(text(profile.familyName) && {
62
+ familyName: text(profile.familyName),
63
+ }),
64
+ ...(text(profile.email) && { email: text(profile.email) }),
65
+ emailVerified: profile.emailVerified === true,
66
+ }
67
+ : undefined;
47
68
  return {
48
69
  authorityDigest: this.digest,
49
70
  principalId: authority.principalId,
@@ -57,6 +78,7 @@ export class VerifiedAuthority {
57
78
  oauthGrantId: authority.oauthGrantId,
58
79
  capabilities: authority.capabilities,
59
80
  apis: authority.apis,
81
+ ...(user && { user }),
60
82
  };
61
83
  }
62
84
  /** Time and observed retirement are checked again immediately before authorized work. */
@@ -172,6 +172,21 @@ export type AuthenticatedCaller = {
172
172
  oauthGrantId?: string;
173
173
  capabilities: CapabilityAuthority[];
174
174
  apis: AuthorityApi[];
175
+ /** The user's own profile, for user principals. */
176
+ user?: CallerUser;
177
+ };
178
+ /**
179
+ * Auth's profile of a user caller, as of the authority's issuance.
180
+ *
181
+ * Identification only: the stable key is `principalId`, and names and email
182
+ * are neither unique nor authorization.
183
+ */
184
+ export type CallerUser = {
185
+ displayName: string;
186
+ givenName?: string;
187
+ familyName?: string;
188
+ email?: string;
189
+ emailVerified: boolean;
175
190
  };
176
191
  /** Cryptographically authenticated request binding, before dispatch authorization. */
177
192
  export type VerifySessionRequestResult = {
package/generated.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** Portable runtime support for generated Trellis packages. */
2
2
  export { TrellisError } from "./errors/TrellisError.ts";
3
- export { apiDescriptor, type AppRequestDescriptor, type Codec, codecs, type JsonValue, participantDescriptor, type SerializableErrorData, } from "./generated_support.ts";
3
+ export { apiDescriptor, type AppRequestDescriptor, type Codec, codecs, type DeclaredErrorOptions, type JsonValue, participantDescriptor, type SerializableErrorData, } from "./generated_support.ts";
4
4
  export type { ParticipantJobsFromResources, ParticipantKvFromResources, RuntimeApiFromGenerated, } from "./participant_runtime/participant.ts";
@@ -3,6 +3,14 @@ export type Codec<T> = Readonly<{
3
3
  decode(value: unknown): T;
4
4
  encode(value: T): unknown;
5
5
  }>;
6
+ /** Optional fields when constructing a generated declared error. */
7
+ export type DeclaredErrorOptions = ErrorOptions & {
8
+ /** Human-readable message; defaults to the declared error's name. */
9
+ message?: string;
10
+ context?: Record<string, unknown>;
11
+ id?: string;
12
+ traceId?: string;
13
+ };
6
14
  /** Serializable fields shared by generated declared errors. */
7
15
  export type SerializableErrorData = {
8
16
  id: string;
@@ -1,6 +1,6 @@
1
1
  // Generated by Trellis. Do not edit.
2
2
  import { TrellisError } from "@oatscenter/trellis/generated";
3
- import type { SerializableErrorData } from "@oatscenter/trellis/generated";
3
+ import type { DeclaredErrorOptions, SerializableErrorData } from "@oatscenter/trellis/generated";
4
4
  import * as Types0 from "../../types/_internal/p0.js";
5
5
  export type AuthErrorData = SerializableErrorData & {
6
6
  readonly type: "trellis.auth@v1::AuthError";
@@ -9,8 +9,9 @@ export declare class AuthError extends TrellisError<AuthErrorData> {
9
9
  static readonly type: "trellis.auth@v1::AuthError";
10
10
  static readonly payloadCodec: typeof Types0.AuthErrorDetailsCodec;
11
11
  override readonly name: "AuthError";
12
- readonly data: AuthErrorData;
13
- constructor(data: AuthErrorData);
12
+ readonly payload: Types0.AuthErrorDetails;
13
+ constructor(payload: Types0.AuthErrorDetails, options?: DeclaredErrorOptions);
14
+ get data(): AuthErrorData;
14
15
  static fromSerializable(data: unknown): AuthError;
15
16
  override toSerializable(): AuthErrorData;
16
17
  }
@@ -21,8 +22,9 @@ export declare class UnexpectedError extends TrellisError<UnexpectedErrorData> {
21
22
  static readonly type: "trellis.auth@v1::UnexpectedError";
22
23
  static readonly payloadCodec: typeof Types0.AuthErrorDetailsCodec;
23
24
  override readonly name: "UnexpectedError";
24
- readonly data: UnexpectedErrorData;
25
- constructor(data: UnexpectedErrorData);
25
+ readonly payload: Types0.AuthErrorDetails;
26
+ constructor(payload: Types0.AuthErrorDetails, options?: DeclaredErrorOptions);
27
+ get data(): UnexpectedErrorData;
26
28
  static fromSerializable(data: unknown): UnexpectedError;
27
29
  override toSerializable(): UnexpectedErrorData;
28
30
  }
@@ -33,8 +35,9 @@ export declare class ValidationError extends TrellisError<ValidationErrorData> {
33
35
  static readonly type: "trellis.auth@v1::ValidationError";
34
36
  static readonly payloadCodec: typeof Types0.AuthErrorDetailsCodec;
35
37
  override readonly name: "ValidationError";
36
- readonly data: ValidationErrorData;
37
- constructor(data: ValidationErrorData);
38
+ readonly payload: Types0.AuthErrorDetails;
39
+ constructor(payload: Types0.AuthErrorDetails, options?: DeclaredErrorOptions);
40
+ get data(): ValidationErrorData;
38
41
  static fromSerializable(data: unknown): ValidationError;
39
42
  override toSerializable(): ValidationErrorData;
40
43
  }