diff --git a/lib/index.ts b/lib/index.ts index 5d2e994..a8bd188 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,16 +1,19 @@ -import { webResourceHandler } from '@balena/pinejs'; import memoize from 'memoizee'; import { getSignedUrl } from '@aws-sdk/cloudfront-signer'; +import { S3Handler, type S3HandlerProps } from '@balena/pinejs-webresource-s3'; import type { WebResourceType as WebResource } from '@balena/sbvr-types'; -export interface CloudFrontHandlerProps - extends webResourceHandler.S3HandlerProps { +export interface CloudFrontHandlerProps extends S3HandlerProps { cfPublicKeyId: string; cfSecretKey: string; cfDistributionDomain: string; } -export class CloudFrontHandler extends webResourceHandler.S3Handler { +const normalizeHref = (href: string) => { + return href.split('?', 1)[0]; +}; + +export class CloudFrontHandler extends S3Handler { private readonly cfSecretKey: string; private readonly cfPublicKeyId: string; private readonly cfDistributionDomain: string; @@ -59,7 +62,7 @@ export class CloudFrontHandler extends webResourceHandler.S3Handler { } private cfGetKeyFromHref(href: string): string { - const hrefWithoutParams = webResourceHandler.normalizeHref(href); + const hrefWithoutParams = normalizeHref(href); return hrefWithoutParams .split('/') .slice(3) diff --git a/package.json b/package.json index 009557d..fd7ab82 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,10 @@ "typescript": "^5.7.2" }, "dependencies": { + "@balena/pinejs-webresource-s3": "^1.0.0", "@aws-sdk/cloudfront-signer": "^3.709.0", "memoizee": "^0.4.17" }, - "peerDependencies": { - "@balena/pinejs": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" - }, "versionist": { "publishedAt": "2025-01-02T12:37:27.492Z" }