@brazosd/node 0.1.9 → 0.1.10

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/README.md CHANGED
@@ -146,7 +146,9 @@ and PKCE. Service credentials remain on the app server. Store the verified
146
146
  identity or user credentials in your own server session and send an opaque
147
147
  session cookie to the browser. Identity JWTs contain `account_id`, `org_id`,
148
148
  `user_id` and `sub=String(account_id)`; `(iss, sub)` is the recommended identity
149
- key. They cannot call Brazosd APIs or refresh API credentials.
149
+ key. The boolean `identity.is_org_owner` reports whether the user owned the
150
+ selected organization when the JWT was issued. Older tokens omit this field.
151
+ Identity JWTs cannot call Brazosd APIs or refresh API credentials.
150
152
 
151
153
  `sso.userClient({getTokens, saveTokens})` refreshes org-user credentials and
152
154
  keeps each user's identity isolated. Shared session stores must compare-and-swap
package/browser.d.ts CHANGED
@@ -3538,7 +3538,7 @@ type SSOTokens = {
3538
3538
  expiresAt: string;
3539
3539
  grantId?: string;
3540
3540
  /**
3541
- * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, iss, aud=app ID, iat, exp and token_use=sso_identity. Never accepted as a brazosd API credential.
3541
+ * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, is_org_owner, iss, aud=app ID, iat, exp and token_use=sso_identity. The boolean is_org_owner records whether the user owned the selected organization at issuance. Never accepted as a brazosd API credential.
3542
3542
  */
3543
3543
  identityToken?: string;
3544
3544
  mode: SSOMode;
package/index.d.ts CHANGED
@@ -3540,7 +3540,7 @@ export type SSOTokens = {
3540
3540
  expiresAt: string;
3541
3541
  grantId?: string;
3542
3542
  /**
3543
- * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, iss, aud=app ID, iat, exp and token_use=sso_identity. Never accepted as a brazosd API credential.
3543
+ * Only present in identity mode. JWT with sub=string(account_id), account_id, org_id, user_id, is_org_owner, iss, aud=app ID, iat, exp and token_use=sso_identity. The boolean is_org_owner records whether the user owned the selected organization at issuance. Never accepted as a brazosd API credential.
3544
3544
  */
3545
3545
  identityToken?: string;
3546
3546
  mode: SSOMode;
@@ -8855,6 +8855,8 @@ export interface SSOIdentity {
8855
8855
  account_id: number;
8856
8856
  org_id: number;
8857
8857
  user_id: number;
8858
+ /** Ownership of the selected organization at issuance. Older tokens omit this claim. */
8859
+ is_org_owner?: boolean;
8858
8860
  iat: number;
8859
8861
  exp: number;
8860
8862
  token_use: "sso_identity";
package/index.js CHANGED
@@ -13635,6 +13635,7 @@ var SSOIdentityVerifier = class {
13635
13635
  if (claims.iss !== this.options.issuer || claims.aud !== this.options.audience || claims.token_use !== "sso_identity") throw new Error("SSO JWT issuer, audience or purpose mismatch");
13636
13636
  const now = Math.floor(Date.now() / 1e3);
13637
13637
  if (![claims.account_id, claims.org_id, claims.user_id].every((id) => typeof id === "number" && Number.isSafeInteger(id) && id > 0) || claims.sub !== String(claims.account_id)) throw new Error("Invalid SSO identity");
13638
+ if (claims.is_org_owner !== void 0 && typeof claims.is_org_owner !== "boolean") throw new Error("Invalid SSO is_org_owner claim");
13638
13639
  if (typeof claims.exp !== "number" || typeof claims.iat !== "number" || !Number.isSafeInteger(claims.exp) || !Number.isSafeInteger(claims.iat) || claims.exp <= now || claims.iat > now + 30 || claims.exp <= claims.iat || claims.exp - claims.iat > 300 || claims.nbf !== void 0 && (typeof claims.nbf !== "number" || !Number.isSafeInteger(claims.nbf) || claims.nbf > now + 30)) throw new Error("SSO JWT expired or has invalid timestamps");
13639
13640
  let set = await this.keys();
13640
13641
  let key = set.keys.find((item) => item.kid === header.kid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brazosd/node",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Brazosd Node.js SDK with automatic cloud function identity",
5
5
  "repository": {
6
6
  "type": "git",