Skip to content

Commit

Permalink
Use standalone S3 Handler instead of pinejs core one
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
otaviojacobi committed Jan 2, 2025
1 parent 545357a commit 65a3ca1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 8 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { webResourceHandler } from '@balena/pinejs';
import memoize from 'memoizee';

Check failure on line 1 in lib/index.ts

View workflow job for this annotation

GitHub Actions / Flowzone / Test npm (20.x)

Could not find a declaration file for module 'memoizee'. '/home/runner/work/pinejs-webresource-cloudfront/pinejs-webresource-cloudfront/node_modules/memoizee/index.js' implicitly has an 'any' type.
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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 65a3ca1

Please sign in to comment.