@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/README.md +6 -3
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/docs/webhooks.md +9 -5
- package/llms.txt +5 -3
- package/package.json +1 -1
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.
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
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
|
|
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
|
|
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.
|
|
1930
|
-
*
|
|
1931
|
-
*
|
|
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
|
|
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
|
|
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.
|
|
3568
|
-
*
|
|
3569
|
-
*
|
|
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
|