@sparkvault/sdk-js 9.0.1 → 9.1.0

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/dist/index.d.ts CHANGED
@@ -497,14 +497,16 @@ declare class IdentityModule {
497
497
  * Decode an identity token's claims WITHOUT verifying its signature.
498
498
  *
499
499
  * This is an UNVERIFIED, client-side decode: it parses the JWT payload and
500
- * sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (rejecting
501
- * `none` and any non-EdDSA algorithm so an unsigned or algorithm-confused token
502
- * cannot masquerade as valid). It does NOT verify the Ed25519 signature, so its
503
- * result MUST NOT be trusted for any authorization decision.
500
+ * sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (accepting
501
+ * only the algorithms the Identity server signs with, so an unsigned or
502
+ * algorithm-confused token cannot masquerade as valid). It does NOT verify the
503
+ * signature, so its result MUST NOT be trusted for any authorization decision.
504
504
  *
505
505
  * To trust a token (e.g. before keying records by `claims.svid`), verify the
506
- * Ed25519 signature server-side against the Identity JWKS endpoint
507
- * (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`). See docs/SDK.md.
506
+ * signature server-side against the Identity JWKS endpoint
507
+ * (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`), which
508
+ * publishes the EdDSA and RS256 keys and selects the verifying key by `kid`.
509
+ * See docs/SDK.md.
508
510
  */
509
511
  decodeToken(token: string): TokenClaims;
510
512
  /**
package/dist/index.mjs CHANGED
@@ -8569,6 +8569,11 @@ function attachClickHandler(selector, onClick) {
8569
8569
  * sv.products.identity.attach('.login-btn');
8570
8570
  */
8571
8571
  const PORTAL_SECTIONS = ['home', 'identity', 'security', 'sessions', 'sites'];
8572
+ // The exact algorithms the Identity server signs identity tokens with: EdDSA by
8573
+ // default, RS256 when a client opts in via `id_token_signed_response_alg`. The
8574
+ // unverified client-side decode gates on this set so an unsigned (`none`) or
8575
+ // algorithm-confused token cannot masquerade as valid.
8576
+ const ACCEPTED_TOKEN_ALGS = ['EdDSA', 'RS256'];
8572
8577
  // A sign-in is "pending" from popup open until its result arrives; a marker
8573
8578
  // that outlives a lost result (a mobile opener-tab discard clears the message
8574
8579
  // listener but not sessionStorage) is what lets the next load self-heal.
@@ -8969,14 +8974,16 @@ class IdentityModule {
8969
8974
  * Decode an identity token's claims WITHOUT verifying its signature.
8970
8975
  *
8971
8976
  * This is an UNVERIFIED, client-side decode: it parses the JWT payload and
8972
- * sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (rejecting
8973
- * `none` and any non-EdDSA algorithm so an unsigned or algorithm-confused token
8974
- * cannot masquerade as valid). It does NOT verify the Ed25519 signature, so its
8975
- * result MUST NOT be trusted for any authorization decision.
8977
+ * sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (accepting
8978
+ * only the algorithms the Identity server signs with, so an unsigned or
8979
+ * algorithm-confused token cannot masquerade as valid). It does NOT verify the
8980
+ * signature, so its result MUST NOT be trusted for any authorization decision.
8976
8981
  *
8977
8982
  * To trust a token (e.g. before keying records by `claims.svid`), verify the
8978
- * Ed25519 signature server-side against the Identity JWKS endpoint
8979
- * (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`). See docs/SDK.md.
8983
+ * signature server-side against the Identity JWKS endpoint
8984
+ * (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`), which
8985
+ * publishes the EdDSA and RS256 keys and selects the verifying key by `kid`.
8986
+ * See docs/SDK.md.
8980
8987
  */
8981
8988
  decodeToken(token) {
8982
8989
  if (!token || typeof token !== 'string') {
@@ -8991,10 +8998,12 @@ class IdentityModule {
8991
8998
  if (typeof header !== 'object' || header === null) {
8992
8999
  throw new ValidationError('Invalid token header');
8993
9000
  }
8994
- // Reject alg:none (unsigned) and any algorithm other than EdDSA. Identity
8995
- // tokens are Ed25519-signed; anything else is an unsigned or algorithm-
8996
- // confused token that could never pass server-side JWKS verification.
8997
- if (header.alg !== 'EdDSA') {
9001
+ // Accept exactly the algorithms the Identity server signs with; reject
9002
+ // everything else — `none` (unsigned), a symmetric or algorithm-confused
9003
+ // token, or an absent alg — none of which could pass the server-side JWKS
9004
+ // verification the host performs before trusting the token.
9005
+ const alg = header.alg;
9006
+ if (typeof alg !== 'string' || !ACCEPTED_TOKEN_ALGS.includes(alg)) {
8998
9007
  throw new ValidationError('Unsupported token algorithm');
8999
9008
  }
9000
9009
  const payload = JSON.parse(base64urlToString(payloadB64));
@@ -14752,7 +14761,7 @@ class SparkVault {
14752
14761
  }
14753
14762
  /** Get the SDK version */
14754
14763
  static get version() {
14755
- return '9.0.1';
14764
+ return '9.1.0';
14756
14765
  }
14757
14766
  }
14758
14767
  if (typeof window !== 'undefined') {