@sonisoft/now-sdk-ext-core 5.0.1 → 5.1.0
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/dist/PublicApi.d.ts
CHANGED
|
@@ -41,3 +41,11 @@ export { MessageClientBuilder } from './sn/amb/MessageClientBuilder.js';
|
|
|
41
41
|
export type { SubscriptionCollection, Context } from './sn/amb/MessageClientBuilder.js';
|
|
42
42
|
export { Channel } from './sn/amb/Channel.js';
|
|
43
43
|
export { ChannelListener } from './sn/amb/ChannelListener.js';
|
|
44
|
+
/**
|
|
45
|
+
* Not in the generated barrel, on purpose. ctix exports whatever a directory's
|
|
46
|
+
* index.ts re-exports, and a credentials/index.ts would make importing this
|
|
47
|
+
* library enough to monkeypatch the SDK's credential storage. Installing the
|
|
48
|
+
* shim has to stay an explicit call.
|
|
49
|
+
*/
|
|
50
|
+
export { initCredentialStore } from './credentials/ensureShim.js';
|
|
51
|
+
export type { InitCredentialStoreResult } from './credentials/ensureShim.js';
|
package/dist/PublicApi.js
CHANGED
|
@@ -43,4 +43,11 @@ export { AMBClient } from './sn/amb/AMBClient.js';
|
|
|
43
43
|
export { MessageClientBuilder } from './sn/amb/MessageClientBuilder.js';
|
|
44
44
|
export { Channel } from './sn/amb/Channel.js';
|
|
45
45
|
export { ChannelListener } from './sn/amb/ChannelListener.js';
|
|
46
|
+
/**
|
|
47
|
+
* Not in the generated barrel, on purpose. ctix exports whatever a directory's
|
|
48
|
+
* index.ts re-exports, and a credentials/index.ts would make importing this
|
|
49
|
+
* library enough to monkeypatch the SDK's credential storage. Installing the
|
|
50
|
+
* shim has to stay an explicit call.
|
|
51
|
+
*/
|
|
52
|
+
export { initCredentialStore } from './credentials/ensureShim.js';
|
|
46
53
|
//# sourceMappingURL=PublicApi.js.map
|
package/dist/PublicApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicApi.js","sourceRoot":"","sources":["../src/PublicApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,+EAA+E;AAC/E,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"PublicApi.js","sourceRoot":"","sources":["../src/PublicApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,+EAA+E;AAC/E,0EAA0E;AAC1E,qCAAqC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in headless credential storage for library consumers.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately NOT a module side effect and NOT in the ctix-generated barrel:
|
|
5
|
+
* `import { anything } from '@sonisoft/now-sdk-ext-core'` must never monkeypatch
|
|
6
|
+
* the ServiceNow SDK's credential storage as a consequence. A consumer that
|
|
7
|
+
* wants the shim asks for it by calling this.
|
|
8
|
+
*
|
|
9
|
+
* Applications that own their entry point (nex, the MCP server) import
|
|
10
|
+
* '@sonisoft/sn-credstore/register' there instead — earlier, and unconditional.
|
|
11
|
+
* This exists for embedders that do not control process startup.
|
|
12
|
+
*/
|
|
13
|
+
export interface InitCredentialStoreResult {
|
|
14
|
+
/** True once the SDK's KeyChain is reading the headless-safe store. */
|
|
15
|
+
active: boolean;
|
|
16
|
+
/** Why it is not active, when it is not. */
|
|
17
|
+
reason?: 'not-installed' | 'disabled';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Point the ServiceNow SDK's credential storage at a headless-safe store.
|
|
21
|
+
*
|
|
22
|
+
* Non-interactive sessions cannot unlock the OS keyring even as the same user,
|
|
23
|
+
* and `KeyChain.getPassword()` swallows that failure and returns null — so the
|
|
24
|
+
* SDK reports "Default Credential has not been set" rather than a keyring error.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent, and safe to call when @sonisoft/sn-credstore is not installed: it
|
|
27
|
+
* reports `active: false` and leaves the SDK on its default keyring path. Callers
|
|
28
|
+
* that require the store should check the result rather than assume success.
|
|
29
|
+
*
|
|
30
|
+
* Throws only when the shim IS installed and fails to apply — continuing then
|
|
31
|
+
* would silently fall back to the keyring, and the SDK's next credential write
|
|
32
|
+
* reseeds from a failed read, wiping every other alias.
|
|
33
|
+
*/
|
|
34
|
+
export declare function initCredentialStore(): Promise<InitCredentialStoreResult>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in headless credential storage for library consumers.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately NOT a module side effect and NOT in the ctix-generated barrel:
|
|
5
|
+
* `import { anything } from '@sonisoft/now-sdk-ext-core'` must never monkeypatch
|
|
6
|
+
* the ServiceNow SDK's credential storage as a consequence. A consumer that
|
|
7
|
+
* wants the shim asks for it by calling this.
|
|
8
|
+
*
|
|
9
|
+
* Applications that own their entry point (nex, the MCP server) import
|
|
10
|
+
* '@sonisoft/sn-credstore/register' there instead — earlier, and unconditional.
|
|
11
|
+
* This exists for embedders that do not control process startup.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Absence is legitimate. A shim that loads and then fails is not.
|
|
15
|
+
*
|
|
16
|
+
* sn-credstore is an OPTIONAL dependency of this package, because core is a
|
|
17
|
+
* library: making it required would force a credential shim onto every consumer,
|
|
18
|
+
* including ones that never call initCredentialStore(). So it can genuinely be
|
|
19
|
+
* missing — `npm install --no-optional`, a pruned install, a bundler that dropped
|
|
20
|
+
* it — and that must degrade rather than throw.
|
|
21
|
+
*/
|
|
22
|
+
function isNotInstalled(error) {
|
|
23
|
+
const err = error;
|
|
24
|
+
return (err?.code === 'ERR_MODULE_NOT_FOUND' &&
|
|
25
|
+
// Only OUR specifier missing means "not installed". The same code from a
|
|
26
|
+
// broken import *inside* sn-credstore means it is installed and broken,
|
|
27
|
+
// which must not be mistaken for absence.
|
|
28
|
+
/@sonisoft[/\\]sn-credstore/.test(String(err.message)));
|
|
29
|
+
}
|
|
30
|
+
let cached;
|
|
31
|
+
/**
|
|
32
|
+
* Point the ServiceNow SDK's credential storage at a headless-safe store.
|
|
33
|
+
*
|
|
34
|
+
* Non-interactive sessions cannot unlock the OS keyring even as the same user,
|
|
35
|
+
* and `KeyChain.getPassword()` swallows that failure and returns null — so the
|
|
36
|
+
* SDK reports "Default Credential has not been set" rather than a keyring error.
|
|
37
|
+
*
|
|
38
|
+
* Idempotent, and safe to call when @sonisoft/sn-credstore is not installed: it
|
|
39
|
+
* reports `active: false` and leaves the SDK on its default keyring path. Callers
|
|
40
|
+
* that require the store should check the result rather than assume success.
|
|
41
|
+
*
|
|
42
|
+
* Throws only when the shim IS installed and fails to apply — continuing then
|
|
43
|
+
* would silently fall back to the keyring, and the SDK's next credential write
|
|
44
|
+
* reseeds from a failed read, wiping every other alias.
|
|
45
|
+
*/
|
|
46
|
+
export async function initCredentialStore() {
|
|
47
|
+
if (cached)
|
|
48
|
+
return cached;
|
|
49
|
+
if (process.env.SN_CRED_STORE_DISABLE) {
|
|
50
|
+
cached = { active: false, reason: 'disabled' };
|
|
51
|
+
return cached;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
// Held in a variable so TypeScript does not try to resolve it. This
|
|
55
|
+
// package still compiles with moduleResolution "node", which predates and
|
|
56
|
+
// ignores `exports` maps, so a literal specifier for the ./register
|
|
57
|
+
// subpath fails to type-check even though Node resolves it correctly at
|
|
58
|
+
// runtime. Switching core to Node16 resolution would fix it properly, but
|
|
59
|
+
// that is a change with a much wider blast radius than this file.
|
|
60
|
+
const specifier = '@sonisoft/sn-credstore/register';
|
|
61
|
+
await import(specifier);
|
|
62
|
+
cached = { active: true };
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (!isNotInstalled(error))
|
|
66
|
+
throw error;
|
|
67
|
+
cached = { active: false, reason: 'not-installed' };
|
|
68
|
+
}
|
|
69
|
+
return cached;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=ensureShim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureShim.js","sourceRoot":"","sources":["../../src/credentials/ensureShim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,KAAc;IAClC,MAAM,GAAG,GAAG,KAA0C,CAAC;IACvD,OAAO,CACH,GAAG,EAAE,IAAI,KAAK,sBAAsB;QACpC,yEAAyE;QACzE,wEAAwE;QACxE,0CAA0C;QAC1C,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CACzD,CAAC;AACN,CAAC;AASD,IAAI,MAA6C,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACrC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;QACpC,MAAM,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;QAC/C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACD,oEAAoE;QACpE,0EAA0E;QAC1E,oEAAoE;QACpE,wEAAwE;QACxE,0EAA0E;QAC1E,kEAAkE;QAClE,MAAM,SAAS,GAAG,iCAAiC,CAAC;QACpD,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;QACxB,MAAM,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QACxC,MAAM,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonisoft/now-sdk-ext-core",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Comprehensive TypeScript library extending ServiceNow SDK with application management, ATF testing, real-time log monitoring, AMB event subscriptions, and automation tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"servicenow",
|
|
@@ -144,5 +144,8 @@
|
|
|
144
144
|
},
|
|
145
145
|
"engines": {
|
|
146
146
|
"node": ">=26.0.0"
|
|
147
|
+
},
|
|
148
|
+
"optionalDependencies": {
|
|
149
|
+
"@sonisoft/sn-credstore": "^1.0.0"
|
|
147
150
|
}
|
|
148
151
|
}
|