@peektravel/app-utilities 0.7.0 → 0.7.1

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.cts CHANGED
@@ -1926,9 +1926,10 @@ declare class PeekAccessService {
1926
1926
  * decoded claims.
1927
1927
  *
1928
1928
  * Validates the HMAC signature (using this service's `jwtSecret`), the token
1929
- * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Throws
1930
- * from the `jsonwebtoken` library on any failure — callers should catch to
1931
- * distinguish error kinds:
1929
+ * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Pass the
1930
+ * raw `x-peek-auth` request header value — a leading `Bearer ` prefix, if
1931
+ * present, is stripped for you. Throws from the `jsonwebtoken` library on any
1932
+ * failure — callers should catch to distinguish error kinds:
1932
1933
  *
1933
1934
  * - `JsonWebTokenError` — signature invalid, wrong issuer/audience, or token
1934
1935
  * malformed
@@ -2542,7 +2543,9 @@ interface InstallWebhook {
2542
2543
  * }
2543
2544
  * ```
2544
2545
  *
2545
- * @param token the raw JWT delivered by the install webhook (no `Bearer` prefix)
2546
+ * @param token the JWT delivered by the install webhook. Pass the raw
2547
+ * `x-peek-auth` header value directly — a leading `Bearer ` prefix, if
2548
+ * present, is stripped for you.
2546
2549
  * @param body the delivered JSON body (raw object or a JSON string)
2547
2550
  * @param secret the app's HMAC signing secret (the `jwtSecret` you construct
2548
2551
  * `PeekAccessService` with)
@@ -2572,7 +2575,9 @@ declare function parseInstallWebhook(token: string, body: unknown, secret: strin
2572
2575
  * - `TokenExpiredError` — past `exp`
2573
2576
  * - `NotBeforeError` — before `nbf`
2574
2577
  *
2575
- * @param token the raw JWT delivered by the install webhook (no `Bearer` prefix)
2578
+ * @param token the JWT delivered by the install webhook. Pass the raw
2579
+ * `x-peek-auth` header value directly — a leading `Bearer ` prefix, if
2580
+ * present, is stripped for you.
2576
2581
  * @param secret the app's HMAC signing secret (the `jwtSecret` you construct
2577
2582
  * `PeekAccessService` with)
2578
2583
  * @throws {JsonWebTokenError} signature invalid or token malformed
package/dist/index.d.ts CHANGED
@@ -1926,9 +1926,10 @@ declare class PeekAccessService {
1926
1926
  * decoded claims.
1927
1927
  *
1928
1928
  * Validates the HMAC signature (using this service's `jwtSecret`), the token
1929
- * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Throws
1930
- * from the `jsonwebtoken` library on any failure — callers should catch to
1931
- * distinguish error kinds:
1929
+ * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Pass the
1930
+ * raw `x-peek-auth` request header value — a leading `Bearer ` prefix, if
1931
+ * present, is stripped for you. Throws from the `jsonwebtoken` library on any
1932
+ * failure — callers should catch to distinguish error kinds:
1932
1933
  *
1933
1934
  * - `JsonWebTokenError` — signature invalid, wrong issuer/audience, or token
1934
1935
  * malformed
@@ -2542,7 +2543,9 @@ interface InstallWebhook {
2542
2543
  * }
2543
2544
  * ```
2544
2545
  *
2545
- * @param token the raw JWT delivered by the install webhook (no `Bearer` prefix)
2546
+ * @param token the JWT delivered by the install webhook. Pass the raw
2547
+ * `x-peek-auth` header value directly — a leading `Bearer ` prefix, if
2548
+ * present, is stripped for you.
2546
2549
  * @param body the delivered JSON body (raw object or a JSON string)
2547
2550
  * @param secret the app's HMAC signing secret (the `jwtSecret` you construct
2548
2551
  * `PeekAccessService` with)
@@ -2572,7 +2575,9 @@ declare function parseInstallWebhook(token: string, body: unknown, secret: strin
2572
2575
  * - `TokenExpiredError` — past `exp`
2573
2576
  * - `NotBeforeError` — before `nbf`
2574
2577
  *
2575
- * @param token the raw JWT delivered by the install webhook (no `Bearer` prefix)
2578
+ * @param token the JWT delivered by the install webhook. Pass the raw
2579
+ * `x-peek-auth` header value directly — a leading `Bearer ` prefix, if
2580
+ * present, is stripped for you.
2576
2581
  * @param secret the app's HMAC signing secret (the `jwtSecret` you construct
2577
2582
  * `PeekAccessService` with)
2578
2583
  * @throws {JsonWebTokenError} signature invalid or token malformed
package/dist/index.js CHANGED
@@ -2039,8 +2039,13 @@ var GraphQLClient = class {
2039
2039
  };
2040
2040
  var PEEK_TOKEN_ISSUER = "app_registry_v2";
2041
2041
  var PEEK_TOKEN_AUDIENCE = "Joken";
2042
+ var BEARER_PREFIX = "bearer ";
2043
+ function stripBearer(token) {
2044
+ const trimmed = token.trim();
2045
+ return trimmed.toLowerCase().startsWith(BEARER_PREFIX) ? trimmed.slice(BEARER_PREFIX.length).trim() : trimmed;
2046
+ }
2042
2047
  function verifyPeekJwt(token, secret) {
2043
- return jwt.verify(token, secret, {
2048
+ return jwt.verify(stripBearer(token), secret, {
2044
2049
  issuer: PEEK_TOKEN_ISSUER,
2045
2050
  audience: PEEK_TOKEN_AUDIENCE
2046
2051
  });
@@ -3564,9 +3569,10 @@ var PeekAccessService = class {
3564
3569
  * decoded claims.
3565
3570
  *
3566
3571
  * Validates the HMAC signature (using this service's `jwtSecret`), the token
3567
- * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Throws
3568
- * from the `jsonwebtoken` library on any failure — callers should catch to
3569
- * distinguish error kinds:
3572
+ * expiry, the `"app_registry_v2"` issuer, and the `"Joken"` audience. Pass the
3573
+ * raw `x-peek-auth` request header value — a leading `Bearer ` prefix, if
3574
+ * present, is stripped for you. Throws from the `jsonwebtoken` library on any
3575
+ * failure — callers should catch to distinguish error kinds:
3570
3576
  *
3571
3577
  * - `JsonWebTokenError` — signature invalid, wrong issuer/audience, or token
3572
3578
  * malformed