@amerged/ohmyhost-mcp 0.1.48 → 0.1.50

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.
@@ -56,6 +56,7 @@ export interface WorkosConnectUserClaims {
56
56
  readonly issuedAt: number;
57
57
  readonly notBefore?: number;
58
58
  readonly scopes: readonly string[];
59
+ readonly authorizationRestriction?: Readonly<Record<string, readonly string[]>>;
59
60
  }
60
61
 
61
62
  export interface WorkosRsaJwk {
@@ -186,6 +187,26 @@ export function parseWorkosTokenClaims(
186
187
  throw new WorkosContractError("invalid_consent", "Connect consent identifier is invalid");
187
188
  }
188
189
  const tokenId = expectString(input["jti"], "jti", { optional: true });
190
+ const restriction = input["ohmyhost_authorization"];
191
+ let authorizationRestriction: Record<string, readonly string[]> | undefined;
192
+ if (restriction !== undefined) {
193
+ const raw = expectRecord(restriction, "invalid_claim");
194
+ const keys = ["actions", "organizationIds", "projectIds", "mailDomainIds"];
195
+ authorizationRestriction = {};
196
+ for (const [key, value] of Object.entries(raw)) {
197
+ if (
198
+ !keys.includes(key) ||
199
+ !Array.isArray(value) ||
200
+ value.length > 1000 ||
201
+ !value.every((item) => typeof item === "string" && item.length > 0 && item.length <= 128)
202
+ )
203
+ throw new WorkosContractError(
204
+ "invalid_claim",
205
+ "Token authorization restriction is invalid",
206
+ );
207
+ authorizationRestriction[key] = [...new Set(value as string[])].sort();
208
+ }
209
+ }
189
210
  return {
190
211
  kind,
191
212
  ...common,
@@ -196,6 +217,7 @@ export function parseWorkosTokenClaims(
196
217
  ...(tokenId === undefined ? {} : { tokenId }),
197
218
  ...(notBefore === undefined ? {} : { notBefore }),
198
219
  scopes: parseScopes(input["scope"]),
220
+ ...(authorizationRestriction === undefined ? {} : { authorizationRestriction }),
199
221
  };
200
222
  }
201
223
  if (kind === "m2m") {