@@ -1512,6 +1512,118 @@ describe('the connector read withholds root keys the entry shape does not declar
15121512 } ) ;
15131513} ) ;
15141514
1515+ // ---------------------------------------------------------------------------
1516+ // The carry-forward keeps a withheld key whose own name carries a dot
1517+ // ---------------------------------------------------------------------------
1518+ //
1519+ // `redactedKeys` joins each path on dots, so a key spelled `v1.url` reads like
1520+ // a nested path `v1` → `url`. A save of the served form must still keep it at
1521+ // rest: the carry-forward tries the standard split first, then the whole
1522+ // string as a single key.
1523+
1524+ const DOTTED_ROOT_VALUE = 'TEST_PLACEHOLDER_DOTTED_ROOT_VALUE' ;
1525+ const DOTTED_PROVIDER_URL = 'https://svc:TEST_PLACEHOLDER_DOTTED_PROVIDER@api.vendor.example/v1' ;
1526+
1527+ function storedDottedConnectorBody ( ) {
1528+ return {
1529+ name : 'vendor_api' ,
1530+ label : 'Vendor API' ,
1531+ type : 'api' ,
1532+ provider : 'rest' ,
1533+ providerConfig : { baseUrl : 'https://api.vendor.example/v1' , 'v1.url' : DOTTED_PROVIDER_URL } ,
1534+ auth : { type : 'bearer' , credentialRef : 'VENDOR_API_TOKEN' } ,
1535+ 'x.y' : DOTTED_ROOT_VALUE ,
1536+ } ;
1537+ }
1538+
1539+ function seedDottedConnectorRow ( rows : Map < string , Row > ) {
1540+ const where = { type : 'connector' , name : 'vendor_api' , organization_id : null , package_id : null , state : 'active' } ;
1541+ const body = storedDottedConnectorBody ( ) ;
1542+ rows . set ( keyOf ( where ) , {
1543+ id : 'r_connector_dotted' , ...where , metadata : JSON . stringify ( body ) , checksum : hashSpec ( body ) , version : 1 ,
1544+ } as Row ) ;
1545+ }
1546+
1547+ describe ( 'the connector carry-forward keeps a withheld dot-spelled key at rest' , ( ) => {
1548+ const BUILTIN_CONNECTOR_REDACTOR = getMetadataTypeRedactor ( 'connector' ) ! ;
1549+ afterEach ( ( ) => registerMetadataTypeRedactor ( 'connector' , BUILTIN_CONNECTOR_REDACTOR ) ) ;
1550+
1551+ it ( 'the served read withholds the dot-spelled root key and the dot-spelled providerConfig URL' , async ( ) => {
1552+ const { engine, rows } = makeStubEngine ( ) ;
1553+ seedDottedConnectorRow ( rows ) ;
1554+ const protocol = new ObjectStackProtocolImplementation ( engine ) ;
1555+ const served : any = ( await protocol . getMetaItem ( { type : 'connector' , name : 'vendor_api' } ) ) . item ;
1556+ expect ( served [ 'x.y' ] ) . toBeUndefined ( ) ;
1557+ expect ( served . providerConfig [ 'v1.url' ] ) . toBeUndefined ( ) ;
1558+ expect ( served . providerConfig . baseUrl ) . toBe ( 'https://api.vendor.example/v1' ) ;
1559+ expect ( allStrings ( served ) ) . not . toContain ( DOTTED_ROOT_VALUE ) ;
1560+ } ) ;
1561+
1562+ it ( 'carryForwardRedactedValues restores both dot-spelled positions into a served body' , ( ) => {
1563+ const stored = storedDottedConnectorBody ( ) ;
1564+ const served : any = redactMetadataItem ( 'connector' , stored ) ;
1565+ const out : any = carryForwardRedactedValues ( 'connector' , served , stored ) ;
1566+ expect ( out [ 'x.y' ] ) . toBe ( DOTTED_ROOT_VALUE ) ;
1567+ expect ( out . providerConfig [ 'v1.url' ] ) . toBe ( DOTTED_PROVIDER_URL ) ;
1568+ // redactedPathsCarriedForward names the same positions it fills.
1569+ expect ( redactedPathsCarriedForward ( 'connector' , served , stored ) . sort ( ) )
1570+ . toEqual ( [ 'providerConfig.v1.url' , 'x.y' ] ) ;
1571+ } ) ;
1572+
1573+ it ( 'a save of the served form keeps both dot-spelled values at rest' , async ( ) => {
1574+ const { engine, rows } = makeStubEngine ( ) ;
1575+ seedDottedConnectorRow ( rows ) ;
1576+ const protocol = new ObjectStackProtocolImplementation ( engine ) ;
1577+ const served : any = ( await protocol . getMetaItem ( { type : 'connector' , name : 'vendor_api' } ) ) . item ;
1578+ await protocol . saveMetaItem ( { type : 'connector' , name : 'vendor_api' , item : { ...served , label : 'Vendor API (edited)' } } ) ;
1579+ const atRest = storedConnector ( rows ) ;
1580+ expect ( atRest . label ) . toBe ( 'Vendor API (edited)' ) ;
1581+ expect ( atRest [ 'x.y' ] ) . toBe ( DOTTED_ROOT_VALUE ) ;
1582+ expect ( atRest . providerConfig [ 'v1.url' ] ) . toBe ( DOTTED_PROVIDER_URL ) ;
1583+ } ) ;
1584+
1585+ it ( 'the author`s own value wins — a new dot-spelled providerConfig URL is not refused by the entry (it is not a top-level key) and replaces the stored one' , async ( ) => {
1586+ // A dot-spelled key UNDER providerConfig is a provider setting, not a
1587+ // top-level entry key, so the closed entry does not refuse it; the
1588+ // author editing it is the author's word.
1589+ const { engine, rows } = makeStubEngine ( ) ;
1590+ seedDottedConnectorRow ( rows ) ;
1591+ const protocol = new ObjectStackProtocolImplementation ( engine ) ;
1592+ const served : any = ( await protocol . getMetaItem ( { type : 'connector' , name : 'vendor_api' } ) ) . item ;
1593+ const edited = { ...served , providerConfig : { ...served . providerConfig , 'v1.url' : 'https://api.vendor.example/v2' } } ;
1594+ await protocol . saveMetaItem ( { type : 'connector' , name : 'vendor_api' , item : edited } ) ;
1595+ expect ( storedConnector ( rows ) . providerConfig [ 'v1.url' ] ) . toBe ( 'https://api.vendor.example/v2' ) ;
1596+ } ) ;
1597+
1598+ it ( 'the dotted-alias ambiguity is explicit: a nested position and a same-spelled dotted key collide, and neither is carried' , ( ) => {
1599+ // Two stored positions whose `redactedKeys` entry is the IDENTICAL
1600+ // string `providerConfig.v1.url`: the nested `{ v1: { url } }` (its URL
1601+ // rewritten in place) and the literal `'v1.url'` (withheld whole). The
1602+ // two cannot be told apart from one dotted string, so the carry-forward
1603+ // refuses to guess — its two-onto-one guard carries NEITHER rather than
1604+ // graft a stored credential onto the wrong position. The read stays
1605+ // fail-closed (both secrets absent from what is served); a save of the
1606+ // served form does not restore either, which is the honest outcome of a
1607+ // genuinely ambiguous spelling.
1608+ const nestedUrl = 'https://svc:TEST_PLACEHOLDER_NESTED@api.vendor.example/nested' ;
1609+ const literalUrl = 'https://svc:TEST_PLACEHOLDER_LITERAL@api.vendor.example/literal' ;
1610+ const stored = {
1611+ name : 'vendor_api' , label : 'Vendor API' , type : 'api' , provider : 'rest' ,
1612+ auth : { type : 'bearer' , credentialRef : 'VENDOR_API_TOKEN' } ,
1613+ providerConfig : { v1 : { url : nestedUrl } , 'v1.url' : literalUrl } ,
1614+ } ;
1615+ const served : any = redactMetadataItem ( 'connector' , stored ) ;
1616+ expect ( allStrings ( served ) ) . not . toContain ( 'TEST_PLACEHOLDER_NESTED' ) ;
1617+ expect ( allStrings ( served ) ) . not . toContain ( 'TEST_PLACEHOLDER_LITERAL' ) ;
1618+ // The same string names both withheld positions.
1619+ const redactedForStored = ( getMetadataTypeRedactor ( 'connector' ) ! ) ( stored as any ) . redactedKeys ;
1620+ expect ( redactedForStored . filter ( ( p ) => p === 'providerConfig.v1.url' ) ) . toHaveLength ( 2 ) ;
1621+ // The collision trips the two-onto-one guard: nothing is carried.
1622+ expect ( redactedPathsCarriedForward ( 'connector' , served , stored ) ) . toEqual ( [ ] ) ;
1623+ expect ( carryForwardRedactedValues ( 'connector' , served , stored ) ) . toBe ( served ) ;
1624+ } ) ;
1625+ } ) ;
1626+
15151627describe ( 'the read exits withhold the declared ssl secret member of a datasource' , ( ) => {
15161628 /** The stored client key, which no read exit may serve; the public members it sits beside. */
15171629 const SSL_KEY = 'TEST_PLACEHOLDER_SSL_KEY' ;
0 commit comments