@zuplo/cli 7.15.32 → 7.15.33

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.
Files changed (26) hide show
  1. package/node_modules/@hono/node-server/dist/index.cjs +5 -2
  2. package/node_modules/@hono/node-server/dist/index.mjs +5 -2
  3. package/node_modules/@hono/node-server/package.json +1 -1
  4. package/node_modules/@zuplo/core/package.json +1 -1
  5. package/node_modules/@zuplo/graphql/package.json +1 -1
  6. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  7. package/node_modules/@zuplo/otel/package.json +1 -1
  8. package/node_modules/@zuplo/runtime/out/esm/{chunk-C4ZTXG6P.js → chunk-552QIZSP.js} +86 -86
  9. package/node_modules/@zuplo/runtime/out/esm/chunk-552QIZSP.js.map +1 -0
  10. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  11. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  12. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  13. package/node_modules/@zuplo/runtime/out/types/index.d.ts +15 -3
  14. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +13 -1
  15. package/node_modules/@zuplo/runtime/package.json +1 -1
  16. package/node_modules/fast-copy/README.md +34 -34
  17. package/node_modules/fast-copy/dist/cjs/index.cjs +72 -24
  18. package/node_modules/fast-copy/dist/cjs/index.cjs.map +1 -1
  19. package/node_modules/fast-copy/dist/es/index.mjs +72 -24
  20. package/node_modules/fast-copy/dist/es/index.mjs.map +1 -1
  21. package/node_modules/fast-copy/dist/umd/index.js +72 -24
  22. package/node_modules/fast-copy/dist/umd/index.js.map +1 -1
  23. package/node_modules/fast-copy/package.json +13 -13
  24. package/package.json +11 -11
  25. package/node_modules/@zuplo/runtime/out/esm/chunk-C4ZTXG6P.js.map +0 -1
  26. /package/node_modules/@zuplo/runtime/out/esm/{chunk-C4ZTXG6P.js.LEGAL.txt → chunk-552QIZSP.js.LEGAL.txt} +0 -0
@@ -9,5 +9,5 @@
9
9
  * See https://zuplo.com/legal/eula for more information.
10
10
  */
11
11
 
12
- import{P as p,V as c,Z as u}from"../chunk-C4ZTXG6P.js";import"../chunk-KZBZ5KM5.js";import{a as d}from"../chunk-JAY7SQGG.js";import"../chunk-R6UNMRUU.js";import"../chunk-A7HRIAHJ.js";import"../chunk-5JGLAPFA.js";import{Y as i}from"../chunk-3ITT2MYM.js";import{a as o}from"../chunk-VXPFMOL5.js";function w(l={request:new Request("https://api.example.com")}){let e=[];function t(s){e.push(Promise.resolve(s))}return o(t,"waitUntil"),{context:new a({event:{waitUntil:t},route:l.route,originalRequest:l.request}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(w,"createMockContext");var g={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},a=class extends EventTarget{static{o(this,"MockZuploContext")}#e;#t;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=g,parentContext:n,originalRequest:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:i.console.info,log:i.console.log,debug:i.console.debug,warn:i.console.warn,error:i.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={ip:"203.0.113.7",asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=n,this.#e=e,this.#t=r,this.analyticsContext=new c(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,n){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addPreRequestHandler(e,t){let n;try{n=u.getContextExtensions(this)}catch{n=u.initialize(this,new d(this.#t??new Request("https://api.example.com")))}n.preRequestPhase??="active",p(this,n,e,t)}get preRequestHandlers(){let e;try{e=u.getContextExtensions(this)}catch{return[]}return(e.preRequestState?.entries??[]).map(t=>({policyName:t.policyName,name:t.name}))}addEventListener(e,t,n){let r=o(s=>{try{typeof t=="function"?t(s):t.handleEvent(s)}catch(m){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),m}},"wrapped");super.addEventListener(e,r,n)}};export{a as MockZuploContext,w as createMockContext};
12
+ import{P as p,V as c,Z as u}from"../chunk-552QIZSP.js";import"../chunk-KZBZ5KM5.js";import{a as d}from"../chunk-JAY7SQGG.js";import"../chunk-R6UNMRUU.js";import"../chunk-A7HRIAHJ.js";import"../chunk-5JGLAPFA.js";import{Y as i}from"../chunk-3ITT2MYM.js";import{a as o}from"../chunk-VXPFMOL5.js";function w(l={request:new Request("https://api.example.com")}){let e=[];function t(s){e.push(Promise.resolve(s))}return o(t,"waitUntil"),{context:new a({event:{waitUntil:t},route:l.route,originalRequest:l.request}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(w,"createMockContext");var g={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},a=class extends EventTarget{static{o(this,"MockZuploContext")}#e;#t;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=g,parentContext:n,originalRequest:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:i.console.info,log:i.console.log,debug:i.console.debug,warn:i.console.warn,error:i.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={ip:"203.0.113.7",asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=n,this.#e=e,this.#t=r,this.analyticsContext=new c(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,n){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addPreRequestHandler(e,t){let n;try{n=u.getContextExtensions(this)}catch{n=u.initialize(this,new d(this.#t??new Request("https://api.example.com")))}n.preRequestPhase??="active",p(this,n,e,t)}get preRequestHandlers(){let e;try{e=u.getContextExtensions(this)}catch{return[]}return(e.preRequestState?.entries??[]).map(t=>({policyName:t.policyName,name:t.name}))}addEventListener(e,t,n){let r=o(s=>{try{typeof t=="function"?t(s):t.handleEvent(s)}catch(m){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),m}},"wrapped");super.addEventListener(e,r,n)}};export{a as MockZuploContext,w as createMockContext};
13
13
  //# sourceMappingURL=index.js.map
@@ -1971,8 +1971,8 @@ export declare class ApiKeyConsumerClient {
1971
1971
  export declare interface ApiKeyConsumerClientOptions {
1972
1972
  /**
1973
1973
  * The bucket ID for the API key service. Must start with `bckt_`
1974
- * (e.g. `bckt_2HaK3odRyJle6NJSu8mzNKBC30BYxllxL`) — a bucket name is not
1975
- * accepted. Defaults to the bucket configured for the current environment.
1974
+ * (e.g. `bckt_...`) — a bucket name is not accepted. Defaults to the
1975
+ * bucket configured for the current environment.
1976
1976
  */
1977
1977
  bucketId?: string;
1978
1978
  /**
@@ -9839,6 +9839,14 @@ export declare interface McpEntraOAuthInboundPolicyOptions {
9839
9839
  * The Microsoft Entra tenant UUID. Multi-tenant aliases like common and organizations are not supported by this policy yet.
9840
9840
  */
9841
9841
  tenantId: string;
9842
+ /**
9843
+ * The Microsoft Entra cloud or tenant type. Use us-government for Microsoft Entra ID for US Government (login.microsoftonline.us), china for Microsoft Entra ID operated by 21Vianet (login.chinacloudapi.cn), and external-id for a Microsoft Entra External ID tenant ({tenantId}.ciamlogin.com).
9844
+ */
9845
+ cloud?: "global" | "us-government" | "china" | "external-id";
9846
+ /**
9847
+ * The External ID custom URL domain users sign in on. Only valid with cloud set to external-id. Moves the browser login endpoints to this host; the token issuer stays on {tenantId}.ciamlogin.com.
9848
+ */
9849
+ customDomain?: string;
9842
9850
  /**
9843
9851
  * The Microsoft Entra application (client) ID UUID registered for the gateway's browser login flow.
9844
9852
  */
@@ -10596,7 +10604,7 @@ export declare class McpOktaOAuthInboundPolicy extends InboundPolicy<McpOktaOAut
10596
10604
  */
10597
10605
  export declare interface McpOktaOAuthInboundPolicyOptions {
10598
10606
  /**
10599
- * The Okta org domain, without https://, a trailing slash, or a path.
10607
+ * The Okta org domain or Okta custom domain, without https://, a port, a trailing slash, or a path.
10600
10608
  */
10601
10609
  oktaDomain: string;
10602
10610
  /**
@@ -11063,6 +11071,10 @@ export declare interface McpWorkosOAuthInboundPolicyOptions {
11063
11071
  * The WorkOS client_id registered for the gateway's browser login flow. The OIDC issuer and JWKS URL are derived from this client ID.
11064
11072
  */
11065
11073
  clientId: string;
11074
+ /**
11075
+ * The WorkOS API hostname. Set this to your WorkOS custom authentication API domain when you use one; the OIDC issuer, JWKS URL, and browser login endpoints are derived from it. Omit it to use api.workos.com.
11076
+ */
11077
+ apiHostname?: string;
11066
11078
  /**
11067
11079
  * The WorkOS client_secret. Use $env(...) to source from a secret environment variable.
11068
11080
  */
@@ -1664,6 +1664,14 @@ export declare interface McpEntraOAuthInboundPolicyOptions {
1664
1664
  * The Microsoft Entra tenant UUID. Multi-tenant aliases like common and organizations are not supported by this policy yet.
1665
1665
  */
1666
1666
  tenantId: string;
1667
+ /**
1668
+ * The Microsoft Entra cloud or tenant type. Use us-government for Microsoft Entra ID for US Government (login.microsoftonline.us), china for Microsoft Entra ID operated by 21Vianet (login.chinacloudapi.cn), and external-id for a Microsoft Entra External ID tenant ({tenantId}.ciamlogin.com).
1669
+ */
1670
+ cloud?: "global" | "us-government" | "china" | "external-id";
1671
+ /**
1672
+ * The External ID custom URL domain users sign in on. Only valid with cloud set to external-id. Moves the browser login endpoints to this host; the token issuer stays on {tenantId}.ciamlogin.com.
1673
+ */
1674
+ customDomain?: string;
1667
1675
  /**
1668
1676
  * The Microsoft Entra application (client) ID UUID registered for the gateway's browser login flow.
1669
1677
  */
@@ -2513,7 +2521,7 @@ export declare class McpOktaOAuthInboundPolicy extends InboundPolicy<McpOktaOAut
2513
2521
  */
2514
2522
  export declare interface McpOktaOAuthInboundPolicyOptions {
2515
2523
  /**
2516
- * The Okta org domain, without https://, a trailing slash, or a path.
2524
+ * The Okta org domain or Okta custom domain, without https://, a port, a trailing slash, or a path.
2517
2525
  */
2518
2526
  oktaDomain: string;
2519
2527
  /**
@@ -3134,6 +3142,10 @@ export declare interface McpWorkosOAuthInboundPolicyOptions {
3134
3142
  * The WorkOS client_id registered for the gateway's browser login flow. The OIDC issuer and JWKS URL are derived from this client ID.
3135
3143
  */
3136
3144
  clientId: string;
3145
+ /**
3146
+ * The WorkOS API hostname. Set this to your WorkOS custom authentication API domain when you use one; the OIDC issuer, JWKS URL, and browser login endpoints are derived from it. Omit it to use api.workos.com.
3147
+ */
3148
+ apiHostname?: string;
3137
3149
  /**
3138
3150
  * The WorkOS client_secret. Use $env(...) to source from a secret environment variable.
3139
3151
  */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "7.15.32",
4
+ "version": "7.15.33",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -413,19 +413,19 @@ _Small number of properties, all values are primitives_
413
413
  ┌────────────────────┬────────────────┐
414
414
  │ Name │ Ops / sec │
415
415
  ├────────────────────┼────────────────┤
416
- │ fast-copy │ 4703763.632489 │
416
+ │ fast-copy │ 4691100.447041 │
417
417
  ├────────────────────┼────────────────┤
418
- │ lodash.cloneDeep │ 2900386.981967 │
418
+ │ fast-copy (strict) │ 3199219.762228 │
419
419
  ├────────────────────┼────────────────┤
420
- │ clone │ 2463600.840365 │
420
+ │ lodash.cloneDeep │ 2696862.235376 │
421
421
  ├────────────────────┼────────────────┤
422
- │ ramda │ 2028306.417736 │
422
+ │ clone │ 2426749.851828 │
423
423
  ├────────────────────┼────────────────┤
424
- │ fast-clone │ 1664860.767121 │
424
+ │ ramda │ 2278397.482431 │
425
425
  ├────────────────────┼────────────────┤
426
- │ deepclone │ 1250640.565482 │
426
+ │ fast-clone │ 2190029.860151 │
427
427
  ├────────────────────┼────────────────┤
428
- │ fast-copy (strict) │ 1183583.933015 │
428
+ │ deepclone │ 1241416.283236 │
429
429
  └────────────────────┴────────────────┘
430
430
  Fastest was "fast-copy".
431
431
  ```
@@ -438,19 +438,19 @@ _Large number of properties, values are a combination of primitives and complex
438
438
  ┌────────────────────┬───────────────┐
439
439
  │ Name │ Ops / sec │
440
440
  ├────────────────────┼───────────────┤
441
- │ fast-copy │ 177138.851917 │
441
+ │ fast-copy │ 149439.30263 │
442
442
  ├────────────────────┼───────────────┤
443
- │ deepclone │ 130207.533019 │
443
+ │ deepclone │ 131501.309808 │
444
444
  ├────────────────────┼───────────────┤
445
- │ ramda │ 110970.833493 │
445
+ │ ramda │ 105161.747843 │
446
446
  ├────────────────────┼───────────────┤
447
- │ fast-clone │ 101175.588811 │
447
+ │ fast-clone │ 101472.360116 │
448
448
  ├────────────────────┼───────────────┤
449
- │ clone │ 85344.001401 │
449
+ │ clone │ 79821.005135 │
450
450
  ├────────────────────┼───────────────┤
451
- │ lodash.cloneDeep │ 61029.915045 │
451
+ │ fast-copy (strict) │ 75651.44961 │
452
452
  ├────────────────────┼───────────────┤
453
- │ fast-copy (strict) │ 54327.779721 │
453
+ │ lodash.cloneDeep │ 56264.638648 │
454
454
  └────────────────────┴───────────────┘
455
455
  Fastest was "fast-copy".
456
456
  ```
@@ -463,19 +463,19 @@ _Very large number of properties with high amount of nesting, mainly objects and
463
463
  ┌────────────────────┬────────────┐
464
464
  │ Name │ Ops / sec │
465
465
  ├────────────────────┼────────────┤
466
- │ fast-copy │ 604.504457 │
466
+ │ fast-copy │ 633.468489 │
467
467
  ├────────────────────┼────────────┤
468
- │ fast-clone │ 282.651482 │
468
+ │ fast-clone │ 380.501032 │
469
469
  ├────────────────────┼────────────┤
470
- │ lodash.cloneDeep │ 176.367952 │
470
+ │ fast-copy (strict) │ 380.24112 │
471
471
  ├────────────────────┼────────────┤
472
- │ deepclone │ 169.510853 │
472
+ │ lodash.cloneDeep │ 181.789573 │
473
473
  ├────────────────────┼────────────┤
474
- │ fast-copy (strict) │ 149.42194 │
474
+ │ deepclone │ 170.46305 │
475
475
  ├────────────────────┼────────────┤
476
- │ clone │ 129.962388 │
476
+ │ clone │ 128.175008 │
477
477
  ├────────────────────┼────────────┤
478
- │ ramda │ 45.381864 │
478
+ │ ramda │ 42.339667 │
479
479
  └────────────────────┴────────────┘
480
480
  Fastest was "fast-copy".
481
481
  ```
@@ -488,17 +488,17 @@ _Simple object with a deeply nested reference to itself_
488
488
  ┌────────────────────┬────────────────┐
489
489
  │ Name │ Ops / sec │
490
490
  ├────────────────────┼────────────────┤
491
- │ fast-copy │ 2505272.461365 │
491
+ │ fast-copy │ 2472199.156721 │
492
492
  ├────────────────────┼────────────────┤
493
- │ deepclone │ 1234807.813458 │
493
+ │ fast-copy (strict) │ 2004785.964814 │
494
494
  ├────────────────────┼────────────────┤
495
- │ lodash.cloneDeep │ 1083042.324925 │
495
+ │ deepclone │ 1335221.473344 │
496
496
  ├────────────────────┼────────────────┤
497
- │ fast-copy (strict) │ 1061135.134507 │
497
+ │ lodash.cloneDeep │ 1090438.875229 │
498
498
  ├────────────────────┼────────────────┤
499
- │ clone │ 1047767.775975 │
499
+ │ clone │ 1001390.386735 │
500
500
  ├────────────────────┼────────────────┤
501
- │ ramda │ 643152.529276 │
501
+ │ ramda │ 668390.385915 │
502
502
  ├────────────────────┼────────────────┤
503
503
  │ fast-clone │ 0 │
504
504
  └────────────────────┴────────────────┘
@@ -513,19 +513,19 @@ _Custom constructors, React components, etc_
513
513
  ┌────────────────────┬───────────────┐
514
514
  │ Name │ Ops / sec │
515
515
  ├────────────────────┼───────────────┤
516
- │ fast-copy │ 152207.403222 │
516
+ │ fast-copy │ 154217.104021 │
517
517
  ├────────────────────┼───────────────┤
518
- │ clone │ 80839.604199 │
518
+ │ clone │ 82453.300428 │
519
519
  ├────────────────────┼───────────────┤
520
- │ lodash.cloneDeep │ 71106.679803 │
520
+ │ lodash.cloneDeep │ 71769.121067 │
521
521
  ├────────────────────┼───────────────┤
522
- │ fast-clone │ 60054.451033 │
522
+ │ fast-clone │ 62723.157482 │
523
523
  ├────────────────────┼───────────────┤
524
- │ ramda │ 34209.696554 │
524
+ │ ramda │ 36083.76561 │
525
525
  ├────────────────────┼───────────────┤
526
- │ deepclone │ 27853.483761 │
526
+ │ deepclone │ 27979.589941 │
527
527
  ├────────────────────┼───────────────┤
528
- │ fast-copy (strict) │ 22485.213946 │
528
+ │ fast-copy (strict) │ 26575.965642 │
529
529
  └────────────────────┴───────────────┘
530
530
  Fastest was "fast-copy".
531
531
  ```
@@ -61,30 +61,72 @@ function getTag(value) {
61
61
  * returns a view over the same memory, so copying through it would alias the original.
62
62
  */
63
63
  const sliceTypedArray = Object.getPrototypeOf(Int8Array.prototype).slice;
64
+ /**
65
+ * Whether the prototype chain of a standard array, `Array.prototype` -> `Object.prototype` -> `null`,
66
+ * was unmodified when this module loaded.
67
+ *
68
+ * @note
69
+ * The `[[Prototype]]` of `Object.prototype` cannot be changed, but that of `Array.prototype` can,
70
+ * such as to a `Proxy` whose `set` trap would intercept the assignment of a property on an array
71
+ * clone. This is checked once rather than for every copy, so it does not detect a change made after
72
+ * this module loaded.
73
+ */
74
+ const IS_ARRAY_PROTOTYPE_STANDARD = Object.getPrototypeOf(Array.prototype) === Object.prototype;
64
75
  /**
65
76
  * Copy the descriptor from the original value to the clone.
77
+ *
78
+ * @note
79
+ * When `assignable`, the clone's prototype is a standard one, so a standard (configurable,
80
+ * enumerable, writable) value whose property is not found on the clone is assigned, which is
81
+ * faster than `Object.defineProperty` and produces the same own property.
82
+ *
83
+ * This is only done for data descriptors, whose `configurable`, `enumerable`, and `writable` fields
84
+ * are always own properties. An accessor descriptor has no own `writable` or `value`, so reading them
85
+ * would resolve to any inherited from a polluted `Object.prototype`, which would replace the accessor
86
+ * with a data property.
66
87
  */
67
- function copyOwnDescriptor(original, clone, property, state) {
88
+ function copyOwnDescriptor(original, clone, property, state, assignable) {
68
89
  const ownDescriptor = Object.getOwnPropertyDescriptor(original, property) || {
69
90
  configurable: true,
70
91
  enumerable: true,
71
92
  value: original[property],
72
93
  writable: true,
73
94
  };
74
- const descriptor = ownDescriptor.get || ownDescriptor.set
75
- ? ownDescriptor
76
- : {
77
- configurable: ownDescriptor.configurable,
78
- enumerable: ownDescriptor.enumerable,
79
- value: state.copier(ownDescriptor.value, state),
80
- writable: ownDescriptor.writable,
81
- };
95
+ let descriptor;
96
+ if (ownDescriptor.get || ownDescriptor.set) {
97
+ descriptor = ownDescriptor;
98
+ }
99
+ else {
100
+ const { configurable, enumerable, writable } = ownDescriptor;
101
+ const value = state.copier(ownDescriptor.value, state);
102
+ if (assignable) {
103
+ if (configurable && enumerable && writable && !(property in clone)) {
104
+ clone[property] = value;
105
+ return;
106
+ }
107
+ // A standard array clone already has a writable `length`, which matches the original's once
108
+ // its indices are copied unless the original ends with holes, so redefining it can be skipped.
109
+ if (property === 'length' && writable && Array.isArray(clone) && clone.length === value) {
110
+ return;
111
+ }
112
+ }
113
+ descriptor = { configurable, enumerable, value, writable };
114
+ }
82
115
  try {
83
116
  Object.defineProperty(clone, property, descriptor);
84
117
  }
85
118
  catch (_a) {
86
- // The above can fail on node in extreme edge cases, so fall back to the loose assignment.
87
- clone[property] = descriptor.get ? descriptor.get() : descriptor.value;
119
+ try {
120
+ // `Object.defineProperty` also reads inherited fields of the descriptor, so one polluted on
121
+ // `Object.prototype`, such as `writable` for an accessor, mixes accessor and data fields and
122
+ // throws. Without a prototype, only its own fields are read. This is retried only on failure,
123
+ // to avoid the cost of a `null` prototype descriptor for every property.
124
+ Object.defineProperty(clone, property, Object.setPrototypeOf(descriptor, null));
125
+ }
126
+ catch (_b) {
127
+ // The above can fail on node in extreme edge cases, so fall back to the loose assignment.
128
+ clone[property] = descriptor.get ? descriptor.get() : descriptor.value;
129
+ }
88
130
  }
89
131
  }
90
132
  /**
@@ -104,13 +146,17 @@ function defineOwnValue(clone, property, value) {
104
146
  * @note
105
147
  * `Object.getOwnPropertyNames` lists integer keys first in ascending order, so array-like values
106
148
  * whose indices are already copied can pass their count as `start` to skip them.
149
+ *
150
+ * Pass `assignable` only when the prototype of the clone is `Object.prototype`, `null`, or
151
+ * `Array.prototype` when {@link IS_ARRAY_PROTOTYPE_STANDARD}, since only these are trusted to have no
152
+ * side effects when checking for and assigning a property.
107
153
  */
108
- function copyOwnPropertiesStrict(value, clone, state, names, start) {
154
+ function copyOwnPropertiesStrict(value, clone, state, names, start, assignable) {
109
155
  for (let index = start; index < names.length; ++index) {
110
- copyOwnDescriptor(value, clone, names[index], state);
156
+ copyOwnDescriptor(value, clone, names[index], state, assignable);
111
157
  }
112
158
  for (const symbol of Object.getOwnPropertySymbols(value)) {
113
- copyOwnDescriptor(value, clone, symbol, state);
159
+ copyOwnDescriptor(value, clone, symbol, state, assignable);
114
160
  }
115
161
  return clone;
116
162
  }
@@ -135,7 +181,7 @@ function copyArrayStrict(array, state) {
135
181
  state.cache.set(array, clone);
136
182
  // Indices are copied by descriptor rather than by assignment, unlike typed arrays and strings,
137
183
  // because array indices can be holes, accessors, or non-writable / non-enumerable values.
138
- return copyOwnPropertiesStrict(array, clone, state, Object.getOwnPropertyNames(array), 0);
184
+ return copyOwnPropertiesStrict(array, clone, state, Object.getOwnPropertyNames(array), 0, IS_ARRAY_PROTOTYPE_STANDARD && state.Constructor === Array);
139
185
  }
140
186
  /**
141
187
  * Copy the contents of the ArrayBuffer, or of the typed array viewing one.
@@ -174,7 +220,7 @@ function copyArrayBufferStrict(arrayBuffer, state) {
174
220
  // Typed arrays list their indices first, but unlike arrays have no own `length` to skip. The
175
221
  // fresh clone is read, since the original may have an own `length` that shadows the real one.
176
222
  const start = ArrayBuffer.isView(clone) ? clone.length || 0 : 0;
177
- return copyOwnPropertiesStrict(arrayBuffer, clone, state, Object.getOwnPropertyNames(arrayBuffer), start);
223
+ return copyOwnPropertiesStrict(arrayBuffer, clone, state, Object.getOwnPropertyNames(arrayBuffer), start, false);
178
224
  }
179
225
  /**
180
226
  * Create a new Blob with the contents of the original.
@@ -212,7 +258,7 @@ function copyDataViewStrict(dataView, state) {
212
258
  const clone = new Constructor(bufferClone, dataView.byteOffset, dataView.byteLength);
213
259
  // set in the cache immediately to be able to reuse the object recursively.
214
260
  state.cache.set(dataView, clone);
215
- return copyOwnPropertiesStrict(dataView, clone, state, Object.getOwnPropertyNames(dataView), 0);
261
+ return copyOwnPropertiesStrict(dataView, clone, state, Object.getOwnPropertyNames(dataView), 0, false);
216
262
  }
217
263
  /**
218
264
  * Create a new Date based on the time of the original.
@@ -232,7 +278,7 @@ function copyMap(map, state) {
232
278
  // set in the cache immediately to be able to reuse the object recursively
233
279
  state.cache.set(map, clone);
234
280
  for (const [key, value] of map) {
235
- clone.set(key, state.copier(value, state));
281
+ clone.set(key != null && typeof key === 'object' ? state.copier(key, state) : key, state.copier(value, state));
236
282
  }
237
283
  return clone;
238
284
  }
@@ -240,7 +286,7 @@ function copyMap(map, state) {
240
286
  * Deeply copy the keys and values of the original, as well as any custom properties.
241
287
  */
242
288
  function copyMapStrict(map, state) {
243
- return copyOwnPropertiesStrict(map, copyMap(map, state), state, Object.getOwnPropertyNames(map), 0);
289
+ return copyOwnPropertiesStrict(map, copyMap(map, state), state, Object.getOwnPropertyNames(map), 0, false);
244
290
  }
245
291
  /**
246
292
  * Deeply copy the properties (keys and symbols) and values of the original.
@@ -292,10 +338,12 @@ function copyObject(object, state) {
292
338
  * as any hidden or non-enumerable properties.
293
339
  */
294
340
  function copyObjectStrict(object, state) {
295
- const clone = getCleanClone(state.prototype);
341
+ // captured before copying nested values, which change `state.prototype`
342
+ const { prototype } = state;
343
+ const clone = getCleanClone(prototype);
296
344
  // set in the cache immediately to be able to reuse the object recursively
297
345
  state.cache.set(object, clone);
298
- return copyOwnPropertiesStrict(object, clone, state, Object.getOwnPropertyNames(object), 0);
346
+ return copyOwnPropertiesStrict(object, clone, state, Object.getOwnPropertyNames(object), 0, prototype === Object.prototype || prototype === null);
299
347
  }
300
348
  /**
301
349
  * Create a new primitive wrapper from the value of the original.
@@ -346,7 +394,7 @@ function copySet(set, state) {
346
394
  * Deeply copy the values of the original, as well as any custom properties.
347
395
  */
348
396
  function copySetStrict(set, state) {
349
- return copyOwnPropertiesStrict(set, copySet(set, state), state, Object.getOwnPropertyNames(set), 0);
397
+ return copyOwnPropertiesStrict(set, copySet(set, state), state, Object.getOwnPropertyNames(set), 0, false);
350
398
  }
351
399
  /**
352
400
  * Copy the original value based on the handler passed, and also copy custom properties.
@@ -361,7 +409,7 @@ function createStrictHandler(handler) {
361
409
  const clone = handler(value, state);
362
410
  // set in the cache immediately to be able to reuse the object recursively
363
411
  state.cache.set(value, clone);
364
- return copyOwnPropertiesStrict(value, clone, state, Object.getOwnPropertyNames(value), 0);
412
+ return copyOwnPropertiesStrict(value, clone, state, Object.getOwnPropertyNames(value), 0, false);
365
413
  };
366
414
  }
367
415
  /**
@@ -378,7 +426,7 @@ function copyStringStrict(string, state) {
378
426
  // Custom integer keys beyond the string's length are listed before `length`, so only skip
379
427
  // `length` when it directly follows the characters.
380
428
  const start = names[length] === 'length' ? length + 1 : length;
381
- return copyOwnPropertiesStrict(string, clone, state, names, start);
429
+ return copyOwnPropertiesStrict(string, clone, state, names, start, false);
382
430
  }
383
431
 
384
432
  /**