@hot-updater/js 0.12.7 → 0.13.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.
@@ -0,0 +1,36 @@
1
+ export type SuccessResponse = {
2
+ status: 200;
3
+ responseHeaders?: Record<string, string>;
4
+ responseBody: any;
5
+ };
6
+ export type ErrorResponse = {
7
+ status: 400 | 403 | 404;
8
+ error: string;
9
+ };
10
+ export type VerifyJwtSignedUrlResponse = SuccessResponse | ErrorResponse;
11
+ /**
12
+ * Verifies JWT token only and returns the file key (path with leading slashes removed) if valid.
13
+ */
14
+ export declare const verifyJwtToken: ({ path, token, jwtSecret, }: {
15
+ path: string;
16
+ token: string | undefined;
17
+ jwtSecret: string;
18
+ }) => Promise<{
19
+ valid: boolean;
20
+ key?: string;
21
+ error?: string;
22
+ }>;
23
+ /**
24
+ * Integrated function for JWT verification and file handling.
25
+ * - Returns error response if token is missing or validation fails.
26
+ * - On success, retrieves file data through the handler and constructs a response object.
27
+ */
28
+ export declare const verifyJwtSignedUrl: ({ path, token, jwtSecret, handler, }: {
29
+ path: string;
30
+ token: string | undefined;
31
+ jwtSecret: string;
32
+ handler: (key: string) => Promise<{
33
+ body: any;
34
+ contentType?: string;
35
+ } | null>;
36
+ }) => Promise<VerifyJwtSignedUrlResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Creates a JWT-signed download URL based on the provided update information.
3
+ *
4
+ * @param {Object} options - Function options
5
+ * @param {T|null} options.data - Update information (null if none)
6
+ * @param {string} options.reqUrl - Request URL (base URL for token generation)
7
+ * @param {string} options.jwtSecret - Secret key for JWT signing
8
+ * @returns {Promise<T|null>} - Update response object with fileUrl or null
9
+ */
10
+ export declare const withJwtSignedUrl: <T extends {
11
+ id: string;
12
+ }>({ data, reqUrl, jwtSecret, }: {
13
+ data: T | null;
14
+ reqUrl: string;
15
+ jwtSecret: string;
16
+ }) => Promise<(T & {
17
+ fileUrl: string | null;
18
+ }) | null>;
19
+ export declare const signToken: (key: string, jwtSecret: string) => Promise<string>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/js",
3
- "version": "0.12.7",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -38,12 +38,13 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@hot-updater/core": "0.12.7"
41
+ "@hot-updater/core": "0.13.1"
42
42
  },
43
43
  "devDependencies": {
44
- "semver": "^7.6.3",
45
44
  "@types/node": "^20.9.4",
46
- "@types/semver": "^7.5.8"
45
+ "@types/semver": "^7.5.8",
46
+ "jose": "^6.0.10",
47
+ "semver": "^7.6.3"
47
48
  },
48
49
  "scripts": {
49
50
  "build": "rslib build",