construct-hub 0.4.521 → 0.4.522
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/.jsii +2 -2
- package/.yarn/install-state.gz +0 -0
- package/lib/backend/ingestion/re-ingest.lambda.bundle/index.js.map +1 -1
- package/lib/backend/shared/time.lambda-shared.d.ts +1 -0
- package/lib/backend/shared/time.lambda-shared.js +5 -1
- package/lib/construct-hub.js +1 -1
- package/lib/package-sources/code-artifact.js +1 -1
- package/lib/package-sources/npmjs/stage-and-notify.lambda.bundle/index.js +77 -36
- package/lib/package-sources/npmjs/stage-and-notify.lambda.bundle/index.js.map +4 -4
- package/lib/package-sources/npmjs/stage-and-notify.lambda.js +47 -10
- package/lib/package-sources/npmjs.js +1 -1
- package/lib/package-tag/index.js +3 -3
- package/lib/package-tag-group/index.js +2 -2
- package/lib/preload-file/index.js +1 -1
- package/lib/s3/storage.js +1 -1
- package/lib/spdx-license.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.now = void 0;
|
|
4
|
+
exports.sleep = sleep;
|
|
4
5
|
exports.now = Date.now;
|
|
5
|
-
|
|
6
|
+
async function sleep(ms) {
|
|
7
|
+
return new Promise((ok) => setTimeout(ok, ms));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGltZS5sYW1iZGEtc2hhcmVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JhY2tlbmQvc2hhcmVkL3RpbWUubGFtYmRhLXNoYXJlZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxzQkFFQztBQUpZLFFBQUEsR0FBRyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUM7QUFFckIsS0FBSyxVQUFVLEtBQUssQ0FBQyxFQUFVO0lBQ3BDLE9BQU8sSUFBSSxPQUFPLENBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBRSxDQUFDLFVBQVUsQ0FBQyxFQUFFLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQztBQUNqRCxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IG5vdyA9IERhdGUubm93O1xuXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gc2xlZXAobXM6IG51bWJlcikge1xuICByZXR1cm4gbmV3IFByb21pc2UoKG9rKSA9PiBzZXRUaW1lb3V0KG9rLCBtcykpO1xufVxuIl19
|
package/lib/construct-hub.js
CHANGED
|
@@ -65,7 +65,7 @@ const webapp_1 = require("./webapp");
|
|
|
65
65
|
* Construct Hub.
|
|
66
66
|
*/
|
|
67
67
|
class ConstructHub extends constructs_1.Construct {
|
|
68
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "construct-hub.ConstructHub", version: "0.4.
|
|
68
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "construct-hub.ConstructHub", version: "0.4.522" };
|
|
69
69
|
/**
|
|
70
70
|
* The function operators can use to reprocess a specific package version
|
|
71
71
|
* through the backend data pipeline.
|
|
@@ -21,7 +21,7 @@ const storage_1 = require("../s3/storage");
|
|
|
21
21
|
*/
|
|
22
22
|
class CodeArtifact {
|
|
23
23
|
props;
|
|
24
|
-
static [JSII_RTTI_SYMBOL_1] = { fqn: "construct-hub.sources.CodeArtifact", version: "0.4.
|
|
24
|
+
static [JSII_RTTI_SYMBOL_1] = { fqn: "construct-hub.sources.CodeArtifact", version: "0.4.522" };
|
|
25
25
|
constructor(props) {
|
|
26
26
|
this.props = props;
|
|
27
27
|
}
|
|
@@ -14793,8 +14793,8 @@ var init_S3ExpressIdentityCache = __esm({
|
|
|
14793
14793
|
delete this.data[key];
|
|
14794
14794
|
}
|
|
14795
14795
|
async purgeExpired() {
|
|
14796
|
-
const
|
|
14797
|
-
if (this.lastPurgeTime + _S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS >
|
|
14796
|
+
const now2 = Date.now();
|
|
14797
|
+
if (this.lastPurgeTime + _S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS > now2) {
|
|
14798
14798
|
return;
|
|
14799
14799
|
}
|
|
14800
14800
|
for (const key in this.data) {
|
|
@@ -14802,7 +14802,7 @@ var init_S3ExpressIdentityCache = __esm({
|
|
|
14802
14802
|
if (!entry.isRefreshing) {
|
|
14803
14803
|
const credential = await entry.identity;
|
|
14804
14804
|
if (credential.expiration) {
|
|
14805
|
-
if (credential.expiration.getTime() <
|
|
14805
|
+
if (credential.expiration.getTime() < now2) {
|
|
14806
14806
|
delete this.data[key];
|
|
14807
14807
|
}
|
|
14808
14808
|
}
|
|
@@ -15220,8 +15220,8 @@ ${toHex2(hashedRequest)}`;
|
|
|
15220
15220
|
throw new Error("Resolved credential object is not valid");
|
|
15221
15221
|
}
|
|
15222
15222
|
}
|
|
15223
|
-
formatDate(
|
|
15224
|
-
const longDate = iso8601(
|
|
15223
|
+
formatDate(now2) {
|
|
15224
|
+
const longDate = iso8601(now2).replace(/[-:]/g, "");
|
|
15225
15225
|
return {
|
|
15226
15226
|
longDate,
|
|
15227
15227
|
shortDate: longDate.slice(0, 8)
|
|
@@ -27653,9 +27653,9 @@ var require_dist_cjs11 = __commonJS({
|
|
|
27653
27653
|
throw new CredentialsProviderError2(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`, { tryNextLink: false, logger: this.logger });
|
|
27654
27654
|
}
|
|
27655
27655
|
const accessToken = token.accessToken;
|
|
27656
|
-
const
|
|
27656
|
+
const now2 = Date.now();
|
|
27657
27657
|
const expiryTime = new Date(accessToken.expiresAt).getTime();
|
|
27658
|
-
const timeUntilExpiry = expiryTime -
|
|
27658
|
+
const timeUntilExpiry = expiryTime - now2;
|
|
27659
27659
|
if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
|
|
27660
27660
|
return this.refresh(token);
|
|
27661
27661
|
}
|
|
@@ -27678,10 +27678,10 @@ var require_dist_cjs11 = __commonJS({
|
|
|
27678
27678
|
}
|
|
27679
27679
|
async refresh(token) {
|
|
27680
27680
|
const diskToken = await this.loadToken().catch(() => token);
|
|
27681
|
-
const
|
|
27681
|
+
const now2 = Date.now();
|
|
27682
27682
|
const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
|
|
27683
27683
|
const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
|
|
27684
|
-
const freshToken = diskExpiry <=
|
|
27684
|
+
const freshToken = diskExpiry <= now2 && tokenExpiry > now2 ? token : diskToken;
|
|
27685
27685
|
const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
|
|
27686
27686
|
if (freshExpiry - Date.now() > _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
|
|
27687
27687
|
return this.toCredentials(freshToken.accessToken);
|
|
@@ -62058,10 +62058,10 @@ var require_local_reservoir = __commonJS({
|
|
|
62058
62058
|
}
|
|
62059
62059
|
};
|
|
62060
62060
|
LocalReservoir.prototype.isSampled = function isSampled() {
|
|
62061
|
-
var
|
|
62062
|
-
if (
|
|
62061
|
+
var now2 = Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
62062
|
+
if (now2 !== this.thisSecond) {
|
|
62063
62063
|
this.usedThisSecond = 0;
|
|
62064
|
-
this.thisSecond =
|
|
62064
|
+
this.thisSecond = now2;
|
|
62065
62065
|
}
|
|
62066
62066
|
if (this.usedThisSecond >= this.fixedTarget) {
|
|
62067
62067
|
return Math.random() < this.fallbackRate;
|
|
@@ -62235,9 +62235,9 @@ var require_reservoir = __commonJS({
|
|
|
62235
62235
|
this.reportInterval = 1;
|
|
62236
62236
|
this.reportElapsed = 0;
|
|
62237
62237
|
};
|
|
62238
|
-
Reservoir.prototype.borrowOrTake = function borrowOrTake(
|
|
62239
|
-
this.adjustThisSec(
|
|
62240
|
-
if (this.quota >= 0 && this.TTL >=
|
|
62238
|
+
Reservoir.prototype.borrowOrTake = function borrowOrTake(now2, canBorrow) {
|
|
62239
|
+
this.adjustThisSec(now2);
|
|
62240
|
+
if (this.quota >= 0 && this.TTL >= now2) {
|
|
62241
62241
|
if (this.takenThisSec >= this.quota) {
|
|
62242
62242
|
return false;
|
|
62243
62243
|
}
|
|
@@ -62252,11 +62252,11 @@ var require_reservoir = __commonJS({
|
|
|
62252
62252
|
return "borrow";
|
|
62253
62253
|
}
|
|
62254
62254
|
};
|
|
62255
|
-
Reservoir.prototype.adjustThisSec = function adjustThisSec(
|
|
62256
|
-
if (
|
|
62255
|
+
Reservoir.prototype.adjustThisSec = function adjustThisSec(now2) {
|
|
62256
|
+
if (now2 !== this.thisSec) {
|
|
62257
62257
|
this.takenThisSec = 0;
|
|
62258
62258
|
this.borrowedThisSec = 0;
|
|
62259
|
-
this.thisSec =
|
|
62259
|
+
this.thisSec = now2;
|
|
62260
62260
|
}
|
|
62261
62261
|
};
|
|
62262
62262
|
Reservoir.prototype.loadNewQuota = function loadNewQuota(quota, TTL, interval) {
|
|
@@ -62465,7 +62465,7 @@ var require_service_connector = __commonJS({
|
|
|
62465
62465
|
};
|
|
62466
62466
|
var constructStatisticsDocs = function constructStatisticsDocs2(rules) {
|
|
62467
62467
|
var documents = [];
|
|
62468
|
-
var
|
|
62468
|
+
var now2 = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
62469
62469
|
rules.forEach(function(rule) {
|
|
62470
62470
|
var statistics = rule.snapshotStatistics();
|
|
62471
62471
|
var doc = {
|
|
@@ -62474,7 +62474,7 @@ var require_service_connector = __commonJS({
|
|
|
62474
62474
|
"RequestCount": statistics.requestCount,
|
|
62475
62475
|
"BorrowCount": statistics.borrowCount,
|
|
62476
62476
|
"SampledCount": statistics.sampledCount,
|
|
62477
|
-
"Timestamp":
|
|
62477
|
+
"Timestamp": now2
|
|
62478
62478
|
};
|
|
62479
62479
|
documents.push(doc);
|
|
62480
62480
|
});
|
|
@@ -62545,8 +62545,8 @@ var require_rule_cache = __commonJS({
|
|
|
62545
62545
|
* @module RuleCache
|
|
62546
62546
|
* @function getMatchedRule
|
|
62547
62547
|
*/
|
|
62548
|
-
getMatchedRule: function getMatchedRule(sampleRequest,
|
|
62549
|
-
if (isExpired(
|
|
62548
|
+
getMatchedRule: function getMatchedRule(sampleRequest, now2) {
|
|
62549
|
+
if (isExpired(now2)) {
|
|
62550
62550
|
return null;
|
|
62551
62551
|
}
|
|
62552
62552
|
var matchedRule;
|
|
@@ -62608,18 +62608,18 @@ var require_rule_cache = __commonJS({
|
|
|
62608
62608
|
getRules: function getRules() {
|
|
62609
62609
|
return this.rules;
|
|
62610
62610
|
},
|
|
62611
|
-
timestamp: function timestamp(
|
|
62612
|
-
this.lastUpdated =
|
|
62611
|
+
timestamp: function timestamp(now2) {
|
|
62612
|
+
this.lastUpdated = now2;
|
|
62613
62613
|
},
|
|
62614
62614
|
getLastUpdated: function getLastUpdated() {
|
|
62615
62615
|
return this.lastUpdated;
|
|
62616
62616
|
}
|
|
62617
62617
|
};
|
|
62618
|
-
var isExpired = function isExpired2(
|
|
62618
|
+
var isExpired = function isExpired2(now2) {
|
|
62619
62619
|
if (!RuleCache.getLastUpdated()) {
|
|
62620
62620
|
return true;
|
|
62621
62621
|
}
|
|
62622
|
-
return
|
|
62622
|
+
return now2 > RuleCache.getLastUpdated() + TTL;
|
|
62623
62623
|
};
|
|
62624
62624
|
module2.exports = RuleCache;
|
|
62625
62625
|
}
|
|
@@ -62660,13 +62660,13 @@ var require_rule_poller = __commonJS({
|
|
|
62660
62660
|
}
|
|
62661
62661
|
};
|
|
62662
62662
|
var refreshCache = function refreshCache2() {
|
|
62663
|
-
var
|
|
62663
|
+
var now2 = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
62664
62664
|
ServiceConnector.fetchSamplingRules(function(err, newRules) {
|
|
62665
62665
|
if (err) {
|
|
62666
62666
|
logger2.getLogger().warn("Failed to retrieve sampling rules from X-Ray service:", err);
|
|
62667
62667
|
} else if (newRules.length !== 0) {
|
|
62668
62668
|
ruleCache.loadRules(newRules);
|
|
62669
|
-
ruleCache.timestamp(
|
|
62669
|
+
ruleCache.timestamp(now2);
|
|
62670
62670
|
logger2.getLogger().info("Successfully refreshed centralized sampling rule cache.");
|
|
62671
62671
|
}
|
|
62672
62672
|
});
|
|
@@ -62762,11 +62762,11 @@ var require_default_sampler = __commonJS({
|
|
|
62762
62762
|
if (!sampleRequest.serviceType) {
|
|
62763
62763
|
sampleRequest.serviceType = SegmentUtils.origin;
|
|
62764
62764
|
}
|
|
62765
|
-
var
|
|
62766
|
-
var matchedRule = this.ruleCache.getMatchedRule(sampleRequest,
|
|
62765
|
+
var now2 = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
62766
|
+
var matchedRule = this.ruleCache.getMatchedRule(sampleRequest, now2);
|
|
62767
62767
|
if (matchedRule) {
|
|
62768
62768
|
logger2.getLogger().debug(util.format("Rule %s is matched.", matchedRule.getName()));
|
|
62769
|
-
return processMatchedRule(matchedRule,
|
|
62769
|
+
return processMatchedRule(matchedRule, now2);
|
|
62770
62770
|
} else {
|
|
62771
62771
|
logger2.getLogger().info("No effective centralized sampling rule match. Fallback to local rules.");
|
|
62772
62772
|
return this.localSampler.shouldSample(sampleRequest);
|
|
@@ -62796,11 +62796,11 @@ var require_default_sampler = __commonJS({
|
|
|
62796
62796
|
}
|
|
62797
62797
|
}
|
|
62798
62798
|
};
|
|
62799
|
-
var processMatchedRule = function processMatchedRule2(rule,
|
|
62799
|
+
var processMatchedRule = function processMatchedRule2(rule, now2) {
|
|
62800
62800
|
rule.incrementRequestCount();
|
|
62801
62801
|
var reservoir = rule.getReservoir();
|
|
62802
62802
|
var sample = true;
|
|
62803
|
-
var decision = reservoir.borrowOrTake(
|
|
62803
|
+
var decision = reservoir.borrowOrTake(now2, rule.canBorrow());
|
|
62804
62804
|
if (decision === "borrow") {
|
|
62805
62805
|
rule.incrementBorrowCount();
|
|
62806
62806
|
} else if (decision === "take") {
|
|
@@ -67631,9 +67631,20 @@ function integrity(input, tarball, alg = input.integrity?.split("-")[0] ?? "sha3
|
|
|
67631
67631
|
};
|
|
67632
67632
|
}
|
|
67633
67633
|
|
|
67634
|
+
// src/backend/shared/time.lambda-shared.ts
|
|
67635
|
+
var now = Date.now;
|
|
67636
|
+
async function sleep2(ms) {
|
|
67637
|
+
return new Promise((ok) => setTimeout(ok, ms));
|
|
67638
|
+
}
|
|
67639
|
+
|
|
67634
67640
|
// src/package-sources/npmjs/stage-and-notify.lambda.ts
|
|
67635
67641
|
var HttpNotFoundError = class extends Error {
|
|
67636
67642
|
};
|
|
67643
|
+
var NOT_FOUND_RETRY = {
|
|
67644
|
+
baseDelayMs: 1e3,
|
|
67645
|
+
maxDelayMs: 8e3,
|
|
67646
|
+
deadlineMs: 6e4
|
|
67647
|
+
};
|
|
67637
67648
|
async function handler(event, context) {
|
|
67638
67649
|
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
|
|
67639
67650
|
if ("Records" in event) {
|
|
@@ -67648,12 +67659,14 @@ async function handler(event, context) {
|
|
|
67648
67659
|
console.log(`Package was deny-listed: ${denyRule.reason}`);
|
|
67649
67660
|
return;
|
|
67650
67661
|
}
|
|
67651
|
-
let tarball
|
|
67662
|
+
let tarball;
|
|
67652
67663
|
try {
|
|
67653
|
-
|
|
67654
|
-
tarball = await httpGet(event.tarballUrl);
|
|
67664
|
+
tarball = await downloadTarball(event);
|
|
67655
67665
|
} catch (e5) {
|
|
67656
67666
|
if (e5 instanceof HttpNotFoundError) {
|
|
67667
|
+
console.log(
|
|
67668
|
+
`Tarball not found for ${event.name}@${event.version} (modified ${event.modified}), ignoring this version: ${event.tarballUrl}`
|
|
67669
|
+
);
|
|
67657
67670
|
return;
|
|
67658
67671
|
} else {
|
|
67659
67672
|
throw e5;
|
|
@@ -67721,6 +67734,34 @@ async function handler(event, context) {
|
|
|
67721
67734
|
})
|
|
67722
67735
|
);
|
|
67723
67736
|
}
|
|
67737
|
+
async function downloadTarball(event) {
|
|
67738
|
+
const startTime = now();
|
|
67739
|
+
let attempt = 0;
|
|
67740
|
+
while (true) {
|
|
67741
|
+
try {
|
|
67742
|
+
console.log(`Downloading tarball from URL: ${event.tarballUrl}`);
|
|
67743
|
+
return await httpGet(event.tarballUrl);
|
|
67744
|
+
} catch (e5) {
|
|
67745
|
+
if (!(e5 instanceof HttpNotFoundError) || now() - startTime >= NOT_FOUND_RETRY.deadlineMs) {
|
|
67746
|
+
throw e5;
|
|
67747
|
+
}
|
|
67748
|
+
const delay = Math.max(
|
|
67749
|
+
NOT_FOUND_RETRY.baseDelayMs,
|
|
67750
|
+
Math.floor(
|
|
67751
|
+
Math.random() * Math.min(
|
|
67752
|
+
NOT_FOUND_RETRY.baseDelayMs * Math.pow(2, attempt),
|
|
67753
|
+
NOT_FOUND_RETRY.maxDelayMs
|
|
67754
|
+
)
|
|
67755
|
+
)
|
|
67756
|
+
);
|
|
67757
|
+
console.log(
|
|
67758
|
+
`Tarball not found (HTTP 404), retrying in ${delay} ms: ${event.tarballUrl}`
|
|
67759
|
+
);
|
|
67760
|
+
await sleep2(delay);
|
|
67761
|
+
attempt++;
|
|
67762
|
+
}
|
|
67763
|
+
}
|
|
67764
|
+
}
|
|
67724
67765
|
function httpGet(url) {
|
|
67725
67766
|
return new Promise((ok, ko) => {
|
|
67726
67767
|
https.get(url, (response) => {
|