Skip to content

Commit fd0b9d2

Browse files
committed
Merge branch 'master' into chore/eslint-v9-bump
2 parents ebc82a0 + e61ad49 commit fd0b9d2

File tree

89 files changed

+56775
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+56775
-211
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [3.4.0](https://github.com/apify/apify-sdk-js/compare/[email protected]@3.4.0) (2025-04-01)
7+
8+
9+
### Features
10+
11+
* sign record's public url ([#358](https://github.com/apify/apify-sdk-js/issues/358)) ([6274cc0](https://github.com/apify/apify-sdk-js/commit/6274cc018ab3b02787c234eacbb025d4d973a95d))
12+
13+
14+
15+
16+
617
## [3.3.2](https://github.com/apify/apify-sdk-js/compare/[email protected]@3.3.2) (2025-02-20)
718

819
### Bug Fixes

package-lock.json

+433-184
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@types/tough-cookie": "^4.0.5",
6868
"@types/ws": "^8.5.12",
6969
"commitlint": "^19.3.0",
70-
"crawlee": "^3.11.5",
70+
"crawlee": "^3.13.0",
7171
"eslint": "^9.23.0",
7272
"eslint-config-prettier": "^10.1.1",
7373
"fs-extra": "^11.2.0",
@@ -80,7 +80,7 @@
8080
"puppeteer": "^24.0.0",
8181
"rimraf": "^6.0.1",
8282
"tsx": "^4.16.5",
83-
"turbo": "2.4.4",
83+
"turbo": "2.5.0",
8484
"typescript": "~5.8.0",
8585
"typescript-eslint": "^8.28.0",
8686
"vite-tsconfig-paths": "^4.3.2",

packages/actor-scraper/puppeteer-scraper/src/internals/crawler_setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class CrawlerSetup implements CrawlerSetupOptions {
255255
launchContext: {
256256
useChrome: this.input.useChrome,
257257
launchOptions: {
258-
ignoreHTTPSErrors: this.input.ignoreSslErrors,
258+
acceptInsecureCerts: this.input.ignoreSslErrors,
259259
defaultViewport: DEFAULT_VIEWPORT,
260260
devtools: this.devtools,
261261
args,

packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class CrawlerSetup implements CrawlerSetupOptions {
300300
launchContext: {
301301
useChrome: this.input.useChrome,
302302
launchOptions: {
303-
ignoreHTTPSErrors: this.input.ignoreSslErrors,
303+
acceptInsecureCerts: this.input.ignoreSslErrors,
304304
defaultViewport: DEFAULT_VIEWPORT,
305305
args,
306306
headless: this.input.headless,

packages/apify/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apify",
3-
"version": "3.3.2",
3+
"version": "3.4.0",
44
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
55
"engines": {
66
"node": ">=16.0.0"
@@ -58,11 +58,11 @@
5858
"@apify/input_secrets": "^1.1.40",
5959
"@apify/log": "^2.4.3",
6060
"@apify/timeout": "^0.3.0",
61-
"@apify/utilities": "^2.9.3",
62-
"@crawlee/core": "^3.9.0",
63-
"@crawlee/types": "^3.9.0",
64-
"@crawlee/utils": "^3.9.0",
65-
"apify-client": "^2.12.0",
61+
"@apify/utilities": "^2.13.0",
62+
"@crawlee/core": "^3.13.0",
63+
"@crawlee/types": "^3.13.0",
64+
"@crawlee/utils": "^3.13.0",
65+
"apify-client": "^2.12.1",
6666
"fs-extra": "^11.2.0",
6767
"ow": "^0.28.2",
6868
"semver": "^7.5.4",

packages/apify/src/configuration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export interface ConfigurationOptions extends CoreConfigurationOptions {
1717
actorRunId?: string;
1818
actorTaskId?: string;
1919
apiBaseUrl?: string;
20+
// apiBaseUrl is the internal API URL, accessible only within the platform(private network),
21+
// while apiPublicBaseUrl is the public API URL, available externally(through internet).
22+
apiPublicBaseUrl?: string;
2023
containerPort?: number;
2124
containerUrl?: string;
2225
proxyHostname?: string;
@@ -141,6 +144,7 @@ export class Configuration extends CoreConfiguration {
141144
APIFY_ACTOR_EVENTS_WS_URL: 'actorEventsWsUrl',
142145
APIFY_ACTOR_ID: 'actorId',
143146
APIFY_API_BASE_URL: 'apiBaseUrl',
147+
APIFY_API_PUBLIC_BASE_URL: 'apiPublicBaseUrl',
144148
APIFY_IS_AT_HOME: 'isAtHome',
145149
APIFY_ACTOR_RUN_ID: 'actorRunId',
146150
APIFY_ACTOR_TASK_ID: 'actorTaskId',
@@ -200,6 +204,7 @@ export class Configuration extends CoreConfiguration {
200204
LOCAL_ACTOR_ENV_VARS[ACTOR_ENV_VARS.DEFAULT_REQUEST_QUEUE_ID],
201205
inputKey: 'INPUT',
202206
apiBaseUrl: 'https://api.apify.com',
207+
apiPublicBaseUrl: 'https://api.apify.com',
203208
proxyStatusUrl: 'http://proxy.apify.com',
204209
proxyHostname: LOCAL_APIFY_ENV_VARS[APIFY_ENV_VARS.PROXY_HOSTNAME],
205210
proxyPort: +LOCAL_APIFY_ENV_VARS[APIFY_ENV_VARS.PROXY_PORT],

packages/apify/src/key_value_store.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createHmacSignature } from '@apify/utilities';
12
import type { StorageManagerOptions } from '@crawlee/core';
23
import { KeyValueStore as CoreKeyValueStore } from '@crawlee/core';
34

@@ -15,11 +16,18 @@ export class KeyValueStore extends CoreKeyValueStore {
1516
* access the value in the remote key-value store.
1617
*/
1718
override getPublicUrl(key: string): string {
18-
if (!(this.config as Configuration).get('isAtHome') && getPublicUrl) {
19+
const config = this.config as Configuration;
20+
if (!config.get('isAtHome') && getPublicUrl) {
1921
return getPublicUrl.call(this, key);
2022
}
2123

22-
return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
24+
const publicUrl = new URL(`${config.get('apiPublicBaseUrl')}/v2/key-value-stores/${this.id}/records/${key}`);
25+
26+
if (this.storageObject?.urlSigningSecretKey) {
27+
publicUrl.searchParams.append('signature', createHmacSignature(this.storageObject.urlSigningSecretKey as string, key));
28+
}
29+
30+
return publicUrl.toString();
2331
}
2432

2533
/**

packages/apify/src/proxy_configuration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export class ProxyConfiguration extends CoreProxyConfiguration {
356356
return this._handleTieredUrl(
357357
sessionId ?? cryptoRandomObjectId(6),
358358
options,
359-
).proxyUrl;
359+
).proxyUrl ?? undefined;
360360
}
361361

362362
return this.composeDefaultUrl(sessionId);

test/apify/events.test.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
99
describe('events', () => {
1010
let wss: WebSocketServer = null;
1111
const config = Configuration.getGlobalConfig();
12-
const events = new PlatformEventManager(config);
13-
config.useEventManager(events);
12+
let events: PlatformEventManager | null = null;
1413

1514
beforeEach(() => {
1615
wss = new WebSocketServer({ port: 9099 });
16+
events = new PlatformEventManager(config);
17+
config.useEventManager(events);
18+
1719
vitest.useFakeTimers();
1820
process.env[ACTOR_ENV_VARS.EVENTS_WEBSOCKET_URL] =
1921
'ws://localhost:9099/someRunId';
@@ -128,11 +130,13 @@ describe('events', () => {
128130

129131
test('should send persist state events in regular interval', async () => {
130132
const eventsReceived = [];
133+
const interval = config.get('persistStateIntervalMillis');
134+
131135
events.on(EventType.PERSIST_STATE, (data) => eventsReceived.push(data));
132136
await events.init();
133-
vitest.advanceTimersByTime(60001);
134-
vitest.advanceTimersByTime(60001);
135-
vitest.advanceTimersByTime(60001);
137+
await vitest.advanceTimersByTimeAsync(1.1 * interval);
138+
await vitest.advanceTimersByTimeAsync(1.1 * interval);
139+
await vitest.advanceTimersByTimeAsync(1.1 * interval);
136140
await events.close();
137141
expect(eventsReceived.length).toBe(5);
138142
});

test/e2e/sdk/publicUrl/src/main.mjs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Actor, log } from 'apify';
2+
3+
await Actor.init();
4+
5+
const { data } = await Actor.getInput();
6+
7+
await Actor.setValue('public-record-key', JSON.stringify(data), { contentType: `application/json` });
8+
9+
const defaultKeyValueStore = await Actor.openKeyValueStore();
10+
const publicUrl = defaultKeyValueStore.getPublicUrl('public-record-key');
11+
12+
// Here we store the url itself
13+
await Actor.setValue('urlToPublicData', publicUrl);
14+
15+
log.info('Generated public url', { publicUrl });
16+
17+
await Actor.pushData({ publicUrl });
18+
19+
await Actor.exit();

test/e2e/sdk/publicUrl/test.mjs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import assert from 'node:assert/strict';
2+
3+
import { ApifyClient } from 'apify';
4+
5+
const PUBLIC_DATA = { exposedData: 'test' };
6+
7+
const client = new ApifyClient({
8+
token: process.env.APIFY_TOKEN,
9+
});
10+
11+
const actor = client.actor(process.argv[2]);
12+
13+
const run = await actor.call({ data: PUBLIC_DATA }, { waitSecs: 15 });
14+
assert.equal(run.exitCode, 0);
15+
16+
const publicUrl = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('urlToPublicData');
17+
const data = await fetch(publicUrl.value).then((res) => res.json());
18+
19+
assert.deepEqual(data, PUBLIC_DATA);

website/package-lock.json

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"dependencies": {
3030
"@apify/docs-theme": "^1.0.131",
31-
"@apify/docusaurus-plugin-typedoc-api": "^4.3.12",
31+
"@apify/docusaurus-plugin-typedoc-api": "^4.4.3",
3232
"@docusaurus/core": "^3.5.2",
3333
"@docusaurus/plugin-client-redirects": "^3.5.2",
3434
"@docusaurus/preset-classic": "^3.5.2",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"entryPoints":{"index":{"label":"Index","path":"src/index.ts"}},"packageRoot":"../packages/apify","packagePath":"packages/apify","packageSlug":"apify","packageName":"apify","packageVersion":"3.4.0"}]

0 commit comments

Comments
 (0)