@qlever-llc/trellis 0.10.18 → 0.10.20

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 (87) hide show
  1. package/esm/auth/browser/login.d.ts +8 -7
  2. package/esm/auth/browser/login.d.ts.map +1 -1
  3. package/esm/auth/browser/logout.d.ts +23 -0
  4. package/esm/auth/browser/logout.d.ts.map +1 -0
  5. package/esm/auth/browser/logout.js +80 -0
  6. package/esm/auth/browser/session.d.ts +2 -0
  7. package/esm/auth/browser/session.d.ts.map +1 -1
  8. package/esm/auth/browser/session.js +6 -0
  9. package/esm/auth/browser.d.ts +3 -2
  10. package/esm/auth/browser.d.ts.map +1 -1
  11. package/esm/auth/browser.js +3 -2
  12. package/esm/auth/mod.d.ts +2 -2
  13. package/esm/auth/mod.d.ts.map +1 -1
  14. package/esm/auth/mod.js +2 -2
  15. package/esm/auth/schemas.d.ts +26 -0
  16. package/esm/auth/schemas.d.ts.map +1 -1
  17. package/esm/auth/schemas.js +35 -0
  18. package/esm/browser.d.ts +1 -1
  19. package/esm/browser.d.ts.map +1 -1
  20. package/esm/contract_support/mod.d.ts +1 -1
  21. package/esm/contract_support/mod.d.ts.map +1 -1
  22. package/esm/contract_support/protocol.d.ts +7 -7
  23. package/esm/contract_support/protocol.d.ts.map +1 -1
  24. package/esm/generated-sdk/auth/contract.d.ts +1 -1
  25. package/esm/generated-sdk/auth/contract.d.ts.map +1 -1
  26. package/esm/generated-sdk/auth/contract.js +7 -2
  27. package/esm/generated-sdk/auth/schemas.d.ts +2 -0
  28. package/esm/generated-sdk/auth/schemas.d.ts.map +1 -1
  29. package/esm/generated-sdk/auth/schemas.js +2 -0
  30. package/esm/generated-sdk/auth/types.d.ts +4 -2
  31. package/esm/generated-sdk/auth/types.d.ts.map +1 -1
  32. package/esm/generated-sdk/auth/types.js +1 -1
  33. package/esm/index.d.ts +1 -1
  34. package/esm/index.d.ts.map +1 -1
  35. package/esm/models/auth/rpc/Logout.d.ts.map +1 -1
  36. package/esm/models/auth/rpc/Logout.js +2 -2
  37. package/package.json +2 -2
  38. package/script/auth/browser/login.d.ts +8 -7
  39. package/script/auth/browser/login.d.ts.map +1 -1
  40. package/script/auth/browser/logout.d.ts +23 -0
  41. package/script/auth/browser/logout.d.ts.map +1 -0
  42. package/script/auth/browser/logout.js +84 -0
  43. package/script/auth/browser/session.d.ts +2 -0
  44. package/script/auth/browser/session.d.ts.map +1 -1
  45. package/script/auth/browser/session.js +7 -0
  46. package/script/auth/browser.d.ts +3 -2
  47. package/script/auth/browser.d.ts.map +1 -1
  48. package/script/auth/browser.js +9 -1
  49. package/script/auth/mod.d.ts +2 -2
  50. package/script/auth/mod.d.ts.map +1 -1
  51. package/script/auth/mod.js +12 -5
  52. package/script/auth/schemas.d.ts +26 -0
  53. package/script/auth/schemas.d.ts.map +1 -1
  54. package/script/auth/schemas.js +37 -1
  55. package/script/browser.d.ts +1 -1
  56. package/script/browser.d.ts.map +1 -1
  57. package/script/contract_support/mod.d.ts +1 -1
  58. package/script/contract_support/mod.d.ts.map +1 -1
  59. package/script/contract_support/protocol.d.ts +7 -7
  60. package/script/contract_support/protocol.d.ts.map +1 -1
  61. package/script/generated-sdk/auth/contract.d.ts +1 -1
  62. package/script/generated-sdk/auth/contract.d.ts.map +1 -1
  63. package/script/generated-sdk/auth/contract.js +7 -2
  64. package/script/generated-sdk/auth/schemas.d.ts +2 -0
  65. package/script/generated-sdk/auth/schemas.d.ts.map +1 -1
  66. package/script/generated-sdk/auth/schemas.js +2 -0
  67. package/script/generated-sdk/auth/types.d.ts +4 -2
  68. package/script/generated-sdk/auth/types.d.ts.map +1 -1
  69. package/script/generated-sdk/auth/types.js +1 -1
  70. package/script/index.d.ts +1 -1
  71. package/script/index.d.ts.map +1 -1
  72. package/script/models/auth/rpc/Logout.d.ts.map +1 -1
  73. package/script/models/auth/rpc/Logout.js +2 -2
  74. package/src/auth/browser/login.ts +12 -8
  75. package/src/auth/browser/logout.ts +114 -0
  76. package/src/auth/browser/session.ts +15 -0
  77. package/src/auth/browser.ts +14 -0
  78. package/src/auth/mod.ts +12 -0
  79. package/src/auth/schemas.ts +58 -0
  80. package/src/browser.ts +1 -0
  81. package/src/contract_support/mod.ts +1 -0
  82. package/src/contract_support/protocol.ts +15 -2
  83. package/src/index.ts +1 -0
  84. package/src/models/auth/rpc/Logout.ts +2 -0
  85. package/src/sdk/_generated/auth/contract.ts +7 -2
  86. package/src/sdk/_generated/auth/schemas.ts +2 -0
  87. package/src/sdk/_generated/auth/types.ts +2 -2
@@ -19,6 +19,11 @@ export {
19
19
  type SentinelCreds,
20
20
  startAuthRequest,
21
21
  } from "./browser/login.js";
22
+ export {
23
+ completeSessionLogout,
24
+ type CompleteSessionLogoutArgs,
25
+ logoutSession,
26
+ } from "./browser/logout.js";
22
27
  export {
23
28
  type ApprovalDecision,
24
29
  fetchPortalFlowState,
@@ -38,6 +43,7 @@ export {
38
43
  getPublicSessionKey,
39
44
  hasSessionKey,
40
45
  loadSessionKey,
46
+ logoutSessionSig,
41
47
  natsConnectSigForIat,
42
48
  type SessionKeyHandle,
43
49
  type SessionKeyOptions,
@@ -57,6 +63,12 @@ export {
57
63
  approvalCapabilityKeys,
58
64
  type ApprovalDecision as ApprovalDecisionData,
59
65
  ApprovalDecisionSchema,
66
+ type AuthLogoutRequest as AuthLogoutRequestData,
67
+ AuthLogoutRequestSchema,
68
+ type AuthLogoutResponse as AuthLogoutResponseData,
69
+ type AuthLogoutResponseMode as AuthLogoutResponseModeData,
70
+ AuthLogoutResponseModeSchema,
71
+ AuthLogoutResponseSchema,
60
72
  type AuthStartFlowResponse as AuthStartFlowResponseData,
61
73
  AuthStartFlowResponseSchema,
62
74
  type AuthStartRequest as AuthStartRequestData,
@@ -67,6 +79,7 @@ export {
67
79
  BindResponseSchema,
68
80
  type BindSuccessResponse as BindSuccessResponseData,
69
81
  BindSuccessResponseSchema,
82
+ buildLogoutSignaturePayload,
70
83
  type ClientTransportEndpoints as ClientTransportEndpointsData,
71
84
  ClientTransportEndpointsSchema,
72
85
  type ClientTransports as ClientTransportsData,
@@ -74,6 +87,7 @@ export {
74
87
  type ContractApproval as ContractApprovalData,
75
88
  type ContractApprovalCapability as ContractApprovalCapabilityData,
76
89
  ContractApprovalSchema,
90
+ type LogoutSignaturePayloadInput as LogoutSignaturePayloadInputData,
77
91
  type NatsAuthTokenV1 as NatsAuthTokenV1Data,
78
92
  NatsAuthTokenV1Schema,
79
93
  type SentinelCreds as SentinelCredsData,
package/src/auth/mod.ts CHANGED
@@ -48,6 +48,8 @@ export {
48
48
  buildLoginUrl,
49
49
  classifyBrowserAuthError,
50
50
  clearSessionKey,
51
+ completeSessionLogout,
52
+ type CompleteSessionLogoutArgs,
51
53
  createRpcProof,
52
54
  fetchPortalFlowState,
53
55
  generateSessionKey,
@@ -57,6 +59,8 @@ export {
57
59
  isBindSuccessResponse,
58
60
  isRecoverableBrowserAuthError,
59
61
  loadSessionKey,
62
+ logoutSession,
63
+ logoutSessionSig,
60
64
  natsConnectSigForIat,
61
65
  portalFlowIdFromUrl,
62
66
  portalProviderLoginUrl,
@@ -321,6 +325,12 @@ export {
321
325
  approvalCapabilityKeys,
322
326
  type ApprovalDecision,
323
327
  ApprovalDecisionSchema,
328
+ type AuthLogoutRequest,
329
+ AuthLogoutRequestSchema,
330
+ type AuthLogoutResponse,
331
+ type AuthLogoutResponseMode,
332
+ AuthLogoutResponseModeSchema,
333
+ AuthLogoutResponseSchema,
324
334
  type AuthStartFlowResponse,
325
335
  AuthStartFlowResponseSchema,
326
336
  type AuthStartRequest,
@@ -331,6 +341,7 @@ export {
331
341
  BindResponseSchema,
332
342
  type BindSuccessResponse,
333
343
  BindSuccessResponseSchema,
344
+ buildLogoutSignaturePayload,
334
345
  type ClientTransportEndpoints,
335
346
  ClientTransportEndpointsSchema,
336
347
  type ClientTransports,
@@ -338,6 +349,7 @@ export {
338
349
  type ContractApproval,
339
350
  type ContractApprovalCapability,
340
351
  ContractApprovalSchema,
352
+ type LogoutSignaturePayloadInput,
341
353
  type NatsAuthTokenV1,
342
354
  NatsAuthTokenV1Schema,
343
355
  type SentinelCreds,
@@ -1,5 +1,6 @@
1
1
  import type { StaticDecode } from "typebox";
2
2
  import { Type } from "typebox";
3
+ import { canonicalizeJsonValue } from "./utils.js";
3
4
 
4
5
  const SessionKeySchema = Type.String({
5
6
  pattern: "^[A-Za-z0-9_-]{43}$",
@@ -9,6 +10,43 @@ const SignatureSchema = Type.String({
9
10
  pattern: "^[A-Za-z0-9_-]{86}$",
10
11
  });
11
12
 
13
+ export const AuthLogoutResponseModeSchema = Type.Union([
14
+ Type.Literal("json"),
15
+ Type.Literal("redirect"),
16
+ ]);
17
+
18
+ export type AuthLogoutResponseMode = StaticDecode<
19
+ typeof AuthLogoutResponseModeSchema
20
+ >;
21
+
22
+ export type LogoutSignaturePayloadInput = {
23
+ iat: number;
24
+ providerLogout?: boolean;
25
+ federatedProviderLogout?: boolean;
26
+ returnTo?: string;
27
+ responseMode?: AuthLogoutResponseMode;
28
+ };
29
+
30
+ /** Builds the canonical value signed for POST-based HTTP logout requests. */
31
+ export function buildLogoutSignaturePayload(
32
+ input: LogoutSignaturePayloadInput,
33
+ ): string {
34
+ const payload: Record<string, boolean | number | string> = { iat: input.iat };
35
+ if (input.providerLogout !== undefined) {
36
+ payload.providerLogout = input.providerLogout;
37
+ }
38
+ if (input.federatedProviderLogout !== undefined) {
39
+ payload.federatedProviderLogout = input.federatedProviderLogout;
40
+ }
41
+ if (input.returnTo !== undefined) {
42
+ payload.returnTo = input.returnTo;
43
+ }
44
+ if (input.responseMode !== undefined) {
45
+ payload.responseMode = input.responseMode;
46
+ }
47
+ return canonicalizeJsonValue(payload);
48
+ }
49
+
12
50
  export const ContractDigestSchema = Type.String({
13
51
  pattern: "^[A-Za-z0-9_-]+$",
14
52
  });
@@ -117,6 +155,26 @@ export const AuthStartRequestSchema = Type.Object({
117
155
  context: Type.Optional(OpenObjectSchema),
118
156
  });
119
157
 
158
+ export const AuthLogoutRequestSchema = Type.Object({
159
+ sessionKey: SessionKeySchema,
160
+ iat: Type.Integer(),
161
+ sig: SignatureSchema,
162
+ providerLogout: Type.Optional(Type.Boolean()),
163
+ federatedProviderLogout: Type.Optional(Type.Boolean()),
164
+ returnTo: Type.Optional(Type.String({ minLength: 1 })),
165
+ responseMode: Type.Optional(AuthLogoutResponseModeSchema),
166
+ }, { additionalProperties: true });
167
+
168
+ export const AuthLogoutResponseSchema = Type.Object({
169
+ success: Type.Literal(true),
170
+ redirectTo: Type.Optional(
171
+ Type.String({ format: "uri", pattern: "^https?://", minLength: 1 }),
172
+ ),
173
+ }, { additionalProperties: false });
174
+
175
+ export type AuthLogoutRequest = StaticDecode<typeof AuthLogoutRequestSchema>;
176
+ export type AuthLogoutResponse = StaticDecode<typeof AuthLogoutResponseSchema>;
177
+
120
178
  export const AuthStartFlowResponseSchema = Type.Object({
121
179
  status: Type.Literal("flow_started"),
122
180
  flowId: Type.String({ minLength: 1 }),
package/src/browser.ts CHANGED
@@ -54,6 +54,7 @@ export {
54
54
  export type {
55
55
  CursorPage,
56
56
  CursorPageInfo,
57
+ CursorPageResponseSchema,
57
58
  CursorQuery,
58
59
  CursorQueryOptions,
59
60
  ErrorClass,
@@ -89,6 +89,7 @@ export {
89
89
  type CursorPage,
90
90
  type CursorPageInfo,
91
91
  CursorPageInfoSchema,
92
+ type CursorPageResponseSchema,
92
93
  CursorPageSchema,
93
94
  type CursorQuery,
94
95
  type CursorQueryOptions,
@@ -1,4 +1,9 @@
1
- import Type, { type Static, type TSchema } from "typebox";
1
+ import Type, {
2
+ type Static,
3
+ type TArray,
4
+ type TObject,
5
+ type TSchema,
6
+ } from "typebox";
2
7
 
3
8
  function parseIsoDate(value: string): Date {
4
9
  const parsed = new Date(value);
@@ -356,8 +361,16 @@ export const CursorPageInfoSchema = Type.Object({
356
361
  /** Cursor pagination response metadata. */
357
362
  export type CursorPageInfo = Static<typeof CursorPageInfoSchema>;
358
363
 
364
+ /** TypeBox schema for a cursor page response with typed items. */
365
+ export type CursorPageResponseSchema<TItem extends TSchema> = TObject<{
366
+ items: TArray<TItem>;
367
+ page: typeof CursorPageInfoSchema;
368
+ }>;
369
+
359
370
  /** Create a schema for a cursor page response with typed items. */
360
- export function CursorPageSchema<TItem extends TSchema>(item: TItem) {
371
+ export function CursorPageSchema<TItem extends TSchema>(
372
+ item: TItem,
373
+ ): CursorPageResponseSchema<TItem> {
361
374
  return Type.Object({
362
375
  items: Type.Array(item, { default: [] }),
363
376
  page: CursorPageInfoSchema,
package/src/index.ts CHANGED
@@ -70,6 +70,7 @@ export {
70
70
  export type {
71
71
  CursorPage,
72
72
  CursorPageInfo,
73
+ CursorPageResponseSchema,
73
74
  CursorQuery,
74
75
  CursorQueryOptions,
75
76
  ErrorClass,
@@ -2,6 +2,7 @@ import Type, { type Static } from "typebox";
2
2
 
3
3
  export const AuthSessionsLogoutSchema = Type.Object(
4
4
  {},
5
+ { additionalProperties: true },
5
6
  );
6
7
  export type AuthSessionsLogoutInput = Static<typeof AuthSessionsLogoutSchema>;
7
8
 
@@ -9,6 +10,7 @@ export const AuthSessionsLogoutResponseSchema = Type.Object(
9
10
  {
10
11
  success: Type.Boolean(),
11
12
  },
13
+ { additionalProperties: false },
12
14
  );
13
15
  export type AuthSessionsLogoutResponse = Static<
14
16
  typeof AuthSessionsLogoutResponseSchema
@@ -13,7 +13,7 @@ const CONTRACT_MODULE_METADATA = Symbol.for(
13
13
 
14
14
  export const CONTRACT_ID = "trellis.auth@v1" as const;
15
15
  export const CONTRACT_DIGEST =
16
- "U-Y6P1smzJB4MeG6NdhDuZ0CTT2BWOud9iL1zIQktMM" as const;
16
+ "x-9_MjfSThvbn1yc9jAWbaraniKLZ74oUeUqqtZijXQ" as const;
17
17
  export const CONTRACT = {
18
18
  "capabilities": {
19
19
  "trellis.auth::device.review": {
@@ -7322,8 +7322,13 @@ export const CONTRACT = {
7322
7322
  "required": ["entries", "count", "offset", "limit"],
7323
7323
  "type": "object",
7324
7324
  },
7325
- "AuthSessionsLogoutRequest": { "properties": {}, "type": "object" },
7325
+ "AuthSessionsLogoutRequest": {
7326
+ "additionalProperties": true,
7327
+ "properties": {},
7328
+ "type": "object",
7329
+ },
7326
7330
  "AuthSessionsLogoutResponse": {
7331
+ "additionalProperties": false,
7327
7332
  "properties": { "success": { "type": "boolean" } },
7328
7333
  "required": ["success"],
7329
7334
  "type": "object",
@@ -6138,11 +6138,13 @@ export const AuthSessionsListResponseSchema = {
6138
6138
  } as const;
6139
6139
 
6140
6140
  export const AuthSessionsLogoutRequestSchema = {
6141
+ "additionalProperties": true,
6141
6142
  "properties": {},
6142
6143
  "type": "object",
6143
6144
  } as const;
6144
6145
 
6145
6146
  export const AuthSessionsLogoutResponseSchema = {
6147
+ "additionalProperties": false,
6146
6148
  "properties": { "success": { "type": "boolean" } },
6147
6149
  "required": ["success"],
6148
6150
  "type": "object",
@@ -4,7 +4,7 @@ import type { API } from "./api.js";
4
4
 
5
5
  export const CONTRACT_ID = "trellis.auth@v1" as const;
6
6
  export const CONTRACT_DIGEST =
7
- "U-Y6P1smzJB4MeG6NdhDuZ0CTT2BWOud9iL1zIQktMM" as const;
7
+ "x-9_MjfSThvbn1yc9jAWbaraniKLZ74oUeUqqtZijXQ" as const;
8
8
 
9
9
  export type AuthCapabilitiesListInput = { limit: number; offset?: number };
10
10
  export type AuthCapabilitiesListOutput = {
@@ -2083,7 +2083,7 @@ export type AuthSessionsListOutput = {
2083
2083
  offset: number;
2084
2084
  };
2085
2085
 
2086
- export type AuthSessionsLogoutInput = {};
2086
+ export type AuthSessionsLogoutInput = { [k: string]: unknown };
2087
2087
  export type AuthSessionsLogoutOutput = { success: boolean };
2088
2088
 
2089
2089
  export type AuthSessionsMeInput = {};