@centia-io/sdk 0.1.3 → 0.2.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/centia-io-sdk-node.cjs +174 -0
- package/dist/centia-io-sdk-node.d.cts +50 -0
- package/dist/centia-io-sdk-node.d.cts.map +1 -0
- package/dist/centia-io-sdk-node.d.ts +50 -0
- package/dist/centia-io-sdk-node.d.ts.map +1 -0
- package/dist/centia-io-sdk-node.js +174 -0
- package/dist/centia-io-sdk-node.js.map +1 -0
- package/dist/centia-io-sdk.cjs +0 -107
- package/dist/centia-io-sdk.d.cts +1 -34
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +1 -34
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +1 -107
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +0 -107
- package/node.d.ts +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
3
|
+
function _typeof(o) {
|
|
4
|
+
"@babel/helpers - typeof";
|
|
5
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
6
|
+
return typeof o$1;
|
|
7
|
+
} : function(o$1) {
|
|
8
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
9
|
+
}, _typeof(o);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
14
|
+
function toPrimitive(t, r) {
|
|
15
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
16
|
+
var e = t[Symbol.toPrimitive];
|
|
17
|
+
if (void 0 !== e) {
|
|
18
|
+
var i = e.call(t, r || "default");
|
|
19
|
+
if ("object" != _typeof(i)) return i;
|
|
20
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
21
|
+
}
|
|
22
|
+
return ("string" === r ? String : Number)(t);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
27
|
+
function toPropertyKey(t) {
|
|
28
|
+
var i = toPrimitive(t, "string");
|
|
29
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
34
|
+
function _defineProperty(e, r, t) {
|
|
35
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
36
|
+
value: t,
|
|
37
|
+
enumerable: !0,
|
|
38
|
+
configurable: !0,
|
|
39
|
+
writable: !0
|
|
40
|
+
}) : e[r] = t, e;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
45
|
+
function ownKeys(e, r) {
|
|
46
|
+
var t = Object.keys(e);
|
|
47
|
+
if (Object.getOwnPropertySymbols) {
|
|
48
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
49
|
+
r && (o = o.filter(function(r$1) {
|
|
50
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
51
|
+
})), t.push.apply(t, o);
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
function _objectSpread2(e) {
|
|
56
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
57
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
58
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
59
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
60
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
61
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return e;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/auth/configstoreTokenStore.ts
|
|
69
|
+
const LOCK_RETRIES = 5;
|
|
70
|
+
const LOCK_RETRY_MIN_MS = 100;
|
|
71
|
+
const LOCK_RETRY_MAX_MS = 500;
|
|
72
|
+
const LOCK_STALE_MS = 1e4;
|
|
73
|
+
/**
|
|
74
|
+
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
75
|
+
* credentials at `~/.config/configstore/<name>.json` (or
|
|
76
|
+
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
77
|
+
* and cross-process write safety.
|
|
78
|
+
*
|
|
79
|
+
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
80
|
+
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
81
|
+
* same on-disk credentials and therefore the same login session. The default
|
|
82
|
+
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
83
|
+
* `gc2 login` is observable to every process that calls
|
|
84
|
+
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
85
|
+
* to isolate.
|
|
86
|
+
*
|
|
87
|
+
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
88
|
+
* concurrent same-process calls do not race on the shared configstore cache.
|
|
89
|
+
*
|
|
90
|
+
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
91
|
+
* read-merge-write critical section across processes so two simultaneous
|
|
92
|
+
* `set()` calls from different processes cannot corrupt the file.
|
|
93
|
+
*
|
|
94
|
+
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
95
|
+
* out of browser bundles even when this module is imported through the SDK
|
|
96
|
+
* barrel. Calling this function in a browser environment will fail at
|
|
97
|
+
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
98
|
+
*
|
|
99
|
+
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
100
|
+
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
101
|
+
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
102
|
+
*/
|
|
103
|
+
function createConfigstoreTokenStore(name = "gc2-env") {
|
|
104
|
+
let configstoreInstance = null;
|
|
105
|
+
let setChain = Promise.resolve();
|
|
106
|
+
async function getConfigstore() {
|
|
107
|
+
var _default;
|
|
108
|
+
if (configstoreInstance) return configstoreInstance;
|
|
109
|
+
const mod = await import("configstore");
|
|
110
|
+
const Configstore = (_default = mod.default) !== null && _default !== void 0 ? _default : mod;
|
|
111
|
+
const { homedir } = await import("node:os");
|
|
112
|
+
const { join } = await import("node:path");
|
|
113
|
+
configstoreInstance = new Configstore(name, void 0, { configPath: join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "configstore", `${name}.json`) });
|
|
114
|
+
return configstoreInstance;
|
|
115
|
+
}
|
|
116
|
+
async function getLockfile() {
|
|
117
|
+
var _default2;
|
|
118
|
+
const mod = await import("proper-lockfile");
|
|
119
|
+
return (_default2 = mod.default) !== null && _default2 !== void 0 ? _default2 : mod;
|
|
120
|
+
}
|
|
121
|
+
function readAll(cs) {
|
|
122
|
+
const result = {};
|
|
123
|
+
const token = cs.get("token");
|
|
124
|
+
const refresh_token = cs.get("refresh_token");
|
|
125
|
+
const host = cs.get("host");
|
|
126
|
+
if (token !== void 0) result.token = token;
|
|
127
|
+
if (refresh_token !== void 0) result.refresh_token = refresh_token;
|
|
128
|
+
if (host !== void 0) result.host = host;
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
async function doLockedSet(patch) {
|
|
132
|
+
const cs = await getConfigstore();
|
|
133
|
+
const lockfile = await getLockfile();
|
|
134
|
+
const filePath = cs.path;
|
|
135
|
+
const { mkdirSync, writeFileSync } = await import("node:fs");
|
|
136
|
+
const { dirname } = await import("node:path");
|
|
137
|
+
try {
|
|
138
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
139
|
+
writeFileSync(filePath, "{}", { flag: "wx" });
|
|
140
|
+
} catch (e) {
|
|
141
|
+
if ((e === null || e === void 0 ? void 0 : e.code) !== "EEXIST") throw e;
|
|
142
|
+
}
|
|
143
|
+
const release = await lockfile.lock(filePath, {
|
|
144
|
+
retries: {
|
|
145
|
+
retries: LOCK_RETRIES,
|
|
146
|
+
minTimeout: LOCK_RETRY_MIN_MS,
|
|
147
|
+
maxTimeout: LOCK_RETRY_MAX_MS,
|
|
148
|
+
factor: 2
|
|
149
|
+
},
|
|
150
|
+
stale: LOCK_STALE_MS,
|
|
151
|
+
realpath: false
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
configstoreInstance = null;
|
|
155
|
+
const fresh = await getConfigstore();
|
|
156
|
+
fresh.all = _objectSpread2(_objectSpread2({}, readAll(fresh)), patch);
|
|
157
|
+
} finally {
|
|
158
|
+
await release();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
async get() {
|
|
163
|
+
return readAll(await getConfigstore());
|
|
164
|
+
},
|
|
165
|
+
async set(patch) {
|
|
166
|
+
const next = setChain.then(() => doLockedSet(patch));
|
|
167
|
+
setChain = next.catch(() => {});
|
|
168
|
+
return next;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
exports.createConfigstoreTokenStore = createConfigstoreTokenStore;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/auth/types.d.ts
|
|
2
|
+
|
|
3
|
+
interface StoredCredentials {
|
|
4
|
+
token?: string;
|
|
5
|
+
refresh_token?: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
database?: string;
|
|
9
|
+
superUser?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface TokenStore {
|
|
12
|
+
get(): Promise<StoredCredentials>;
|
|
13
|
+
set(patch: Partial<StoredCredentials>): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/auth/configstoreTokenStore.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
19
|
+
* credentials at `~/.config/configstore/<name>.json` (or
|
|
20
|
+
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
21
|
+
* and cross-process write safety.
|
|
22
|
+
*
|
|
23
|
+
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
24
|
+
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
25
|
+
* same on-disk credentials and therefore the same login session. The default
|
|
26
|
+
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
27
|
+
* `gc2 login` is observable to every process that calls
|
|
28
|
+
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
29
|
+
* to isolate.
|
|
30
|
+
*
|
|
31
|
+
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
32
|
+
* concurrent same-process calls do not race on the shared configstore cache.
|
|
33
|
+
*
|
|
34
|
+
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
35
|
+
* read-merge-write critical section across processes so two simultaneous
|
|
36
|
+
* `set()` calls from different processes cannot corrupt the file.
|
|
37
|
+
*
|
|
38
|
+
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
39
|
+
* out of browser bundles even when this module is imported through the SDK
|
|
40
|
+
* barrel. Calling this function in a browser environment will fail at
|
|
41
|
+
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
42
|
+
*
|
|
43
|
+
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
44
|
+
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
45
|
+
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
46
|
+
*/
|
|
47
|
+
declare function createConfigstoreTokenStore(name?: string): TokenStore;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createConfigstoreTokenStore };
|
|
50
|
+
//# sourceMappingURL=centia-io-sdk-node.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centia-io-sdk-node.d.cts","names":[],"sources":["../src/auth/types.ts","../src/auth/configstoreTokenStore.ts"],"sourcesContent":[],"mappings":";;AAoB4C,UAX3B,iBAAA,CAW2B;EAAO,KAAA,CAAA,EAAA,MAAA;;;;;;;UAFlC,UAAA;SACN,QAAQ;aACJ,QAAQ,qBAAqB;ACwB5C;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;iBAAgB,2BAAA,iBAA+C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/auth/types.d.ts
|
|
2
|
+
|
|
3
|
+
interface StoredCredentials {
|
|
4
|
+
token?: string;
|
|
5
|
+
refresh_token?: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
user?: string;
|
|
8
|
+
database?: string;
|
|
9
|
+
superUser?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface TokenStore {
|
|
12
|
+
get(): Promise<StoredCredentials>;
|
|
13
|
+
set(patch: Partial<StoredCredentials>): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/auth/configstoreTokenStore.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
19
|
+
* credentials at `~/.config/configstore/<name>.json` (or
|
|
20
|
+
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
21
|
+
* and cross-process write safety.
|
|
22
|
+
*
|
|
23
|
+
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
24
|
+
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
25
|
+
* same on-disk credentials and therefore the same login session. The default
|
|
26
|
+
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
27
|
+
* `gc2 login` is observable to every process that calls
|
|
28
|
+
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
29
|
+
* to isolate.
|
|
30
|
+
*
|
|
31
|
+
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
32
|
+
* concurrent same-process calls do not race on the shared configstore cache.
|
|
33
|
+
*
|
|
34
|
+
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
35
|
+
* read-merge-write critical section across processes so two simultaneous
|
|
36
|
+
* `set()` calls from different processes cannot corrupt the file.
|
|
37
|
+
*
|
|
38
|
+
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
39
|
+
* out of browser bundles even when this module is imported through the SDK
|
|
40
|
+
* barrel. Calling this function in a browser environment will fail at
|
|
41
|
+
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
42
|
+
*
|
|
43
|
+
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
44
|
+
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
45
|
+
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
46
|
+
*/
|
|
47
|
+
declare function createConfigstoreTokenStore(name?: string): TokenStore;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createConfigstoreTokenStore };
|
|
50
|
+
//# sourceMappingURL=centia-io-sdk-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centia-io-sdk-node.d.ts","names":[],"sources":["../src/auth/types.ts","../src/auth/configstoreTokenStore.ts"],"sourcesContent":[],"mappings":";;AAoB4C,UAX3B,iBAAA,CAW2B;EAAO,KAAA,CAAA,EAAA,MAAA;;;;;;;UAFlC,UAAA;SACN,QAAQ;aACJ,QAAQ,qBAAqB;ACwB5C;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;iBAAgB,2BAAA,iBAA+C"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
5
|
+
return typeof o$1;
|
|
6
|
+
} : function(o$1) {
|
|
7
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
13
|
+
function toPrimitive(t, r) {
|
|
14
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
15
|
+
var e = t[Symbol.toPrimitive];
|
|
16
|
+
if (void 0 !== e) {
|
|
17
|
+
var i = e.call(t, r || "default");
|
|
18
|
+
if ("object" != _typeof(i)) return i;
|
|
19
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
20
|
+
}
|
|
21
|
+
return ("string" === r ? String : Number)(t);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
26
|
+
function toPropertyKey(t) {
|
|
27
|
+
var i = toPrimitive(t, "string");
|
|
28
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
33
|
+
function _defineProperty(e, r, t) {
|
|
34
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
35
|
+
value: t,
|
|
36
|
+
enumerable: !0,
|
|
37
|
+
configurable: !0,
|
|
38
|
+
writable: !0
|
|
39
|
+
}) : e[r] = t, e;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
44
|
+
function ownKeys(e, r) {
|
|
45
|
+
var t = Object.keys(e);
|
|
46
|
+
if (Object.getOwnPropertySymbols) {
|
|
47
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
48
|
+
r && (o = o.filter(function(r$1) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
50
|
+
})), t.push.apply(t, o);
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
function _objectSpread2(e) {
|
|
55
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
56
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
57
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
58
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
59
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
60
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/auth/configstoreTokenStore.ts
|
|
68
|
+
const LOCK_RETRIES = 5;
|
|
69
|
+
const LOCK_RETRY_MIN_MS = 100;
|
|
70
|
+
const LOCK_RETRY_MAX_MS = 500;
|
|
71
|
+
const LOCK_STALE_MS = 1e4;
|
|
72
|
+
/**
|
|
73
|
+
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
74
|
+
* credentials at `~/.config/configstore/<name>.json` (or
|
|
75
|
+
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
76
|
+
* and cross-process write safety.
|
|
77
|
+
*
|
|
78
|
+
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
79
|
+
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
80
|
+
* same on-disk credentials and therefore the same login session. The default
|
|
81
|
+
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
82
|
+
* `gc2 login` is observable to every process that calls
|
|
83
|
+
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
84
|
+
* to isolate.
|
|
85
|
+
*
|
|
86
|
+
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
87
|
+
* concurrent same-process calls do not race on the shared configstore cache.
|
|
88
|
+
*
|
|
89
|
+
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
90
|
+
* read-merge-write critical section across processes so two simultaneous
|
|
91
|
+
* `set()` calls from different processes cannot corrupt the file.
|
|
92
|
+
*
|
|
93
|
+
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
94
|
+
* out of browser bundles even when this module is imported through the SDK
|
|
95
|
+
* barrel. Calling this function in a browser environment will fail at
|
|
96
|
+
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
97
|
+
*
|
|
98
|
+
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
99
|
+
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
100
|
+
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
101
|
+
*/
|
|
102
|
+
function createConfigstoreTokenStore(name = "gc2-env") {
|
|
103
|
+
let configstoreInstance = null;
|
|
104
|
+
let setChain = Promise.resolve();
|
|
105
|
+
async function getConfigstore() {
|
|
106
|
+
var _default;
|
|
107
|
+
if (configstoreInstance) return configstoreInstance;
|
|
108
|
+
const mod = await import("configstore");
|
|
109
|
+
const Configstore = (_default = mod.default) !== null && _default !== void 0 ? _default : mod;
|
|
110
|
+
const { homedir } = await import("node:os");
|
|
111
|
+
const { join } = await import("node:path");
|
|
112
|
+
configstoreInstance = new Configstore(name, void 0, { configPath: join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "configstore", `${name}.json`) });
|
|
113
|
+
return configstoreInstance;
|
|
114
|
+
}
|
|
115
|
+
async function getLockfile() {
|
|
116
|
+
var _default2;
|
|
117
|
+
const mod = await import("proper-lockfile");
|
|
118
|
+
return (_default2 = mod.default) !== null && _default2 !== void 0 ? _default2 : mod;
|
|
119
|
+
}
|
|
120
|
+
function readAll(cs) {
|
|
121
|
+
const result = {};
|
|
122
|
+
const token = cs.get("token");
|
|
123
|
+
const refresh_token = cs.get("refresh_token");
|
|
124
|
+
const host = cs.get("host");
|
|
125
|
+
if (token !== void 0) result.token = token;
|
|
126
|
+
if (refresh_token !== void 0) result.refresh_token = refresh_token;
|
|
127
|
+
if (host !== void 0) result.host = host;
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
async function doLockedSet(patch) {
|
|
131
|
+
const cs = await getConfigstore();
|
|
132
|
+
const lockfile = await getLockfile();
|
|
133
|
+
const filePath = cs.path;
|
|
134
|
+
const { mkdirSync, writeFileSync } = await import("node:fs");
|
|
135
|
+
const { dirname } = await import("node:path");
|
|
136
|
+
try {
|
|
137
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
138
|
+
writeFileSync(filePath, "{}", { flag: "wx" });
|
|
139
|
+
} catch (e) {
|
|
140
|
+
if ((e === null || e === void 0 ? void 0 : e.code) !== "EEXIST") throw e;
|
|
141
|
+
}
|
|
142
|
+
const release = await lockfile.lock(filePath, {
|
|
143
|
+
retries: {
|
|
144
|
+
retries: LOCK_RETRIES,
|
|
145
|
+
minTimeout: LOCK_RETRY_MIN_MS,
|
|
146
|
+
maxTimeout: LOCK_RETRY_MAX_MS,
|
|
147
|
+
factor: 2
|
|
148
|
+
},
|
|
149
|
+
stale: LOCK_STALE_MS,
|
|
150
|
+
realpath: false
|
|
151
|
+
});
|
|
152
|
+
try {
|
|
153
|
+
configstoreInstance = null;
|
|
154
|
+
const fresh = await getConfigstore();
|
|
155
|
+
fresh.all = _objectSpread2(_objectSpread2({}, readAll(fresh)), patch);
|
|
156
|
+
} finally {
|
|
157
|
+
await release();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
async get() {
|
|
162
|
+
return readAll(await getConfigstore());
|
|
163
|
+
},
|
|
164
|
+
async set(patch) {
|
|
165
|
+
const next = setChain.then(() => doLockedSet(patch));
|
|
166
|
+
setChain = next.catch(() => {});
|
|
167
|
+
return next;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { createConfigstoreTokenStore };
|
|
174
|
+
//# sourceMappingURL=centia-io-sdk-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centia-io-sdk-node.js","names":["configstoreInstance: any | null","setChain: Promise<void>","Configstore: any","result: StoredCredentials","filePath: string","e: any"],"sources":["../src/auth/configstoreTokenStore.ts"],"sourcesContent":["/**\n * @author Martin Høgh <mh@mapcentia.com>\n * @copyright 2013-2026 MapCentia ApS\n * @license https://opensource.org/license/mit The MIT License\n *\n */\n\nimport type { StoredCredentials, TokenStore } from './types'\n\nconst LOCK_RETRIES = 5\nconst LOCK_RETRY_MIN_MS = 100\nconst LOCK_RETRY_MAX_MS = 500\nconst LOCK_STALE_MS = 10_000\n\n/**\n * Build a Node-only file-backed {@link TokenStore} that persists OAuth\n * credentials at `~/.config/configstore/<name>.json` (or\n * `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process\n * and cross-process write safety.\n *\n * **Shared-state intent.** The `name` is the file name on disk. Two processes\n * (e.g. `gc2-cli` and a local MCP server) that pass the same name share the\n * same on-disk credentials and therefore the same login session. The default\n * `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time\n * `gc2 login` is observable to every process that calls\n * `createConfigstoreTokenStore()` with no argument. Pass a different name\n * to isolate.\n *\n * **In-process correctness.** A serial promise chain on `set()` ensures\n * concurrent same-process calls do not race on the shared configstore cache.\n *\n * **Cross-process correctness.** `proper-lockfile` serializes the\n * read-merge-write critical section across processes so two simultaneous\n * `set()` calls from different processes cannot corrupt the file.\n *\n * **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`\n * out of browser bundles even when this module is imported through the SDK\n * barrel. Calling this function in a browser environment will fail at\n * runtime when the deferred `await import('configstore')` cannot resolve.\n *\n * @param name - configstore file name (without `.json`). Default `'gc2-env'`\n * matches `gc2-cli`'s configstore so credentials are shared.\n * @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.\n */\nexport function createConfigstoreTokenStore(name = 'gc2-env'): TokenStore {\n let configstoreInstance: any | null = null\n let setChain: Promise<void> = Promise.resolve()\n\n async function getConfigstore(): Promise<any> {\n if (configstoreInstance) return configstoreInstance\n const mod = await import('configstore')\n const Configstore: any = (mod as any).default ?? mod\n const { homedir } = await import('node:os')\n const { join } = await import('node:path')\n // Resolve XDG_CONFIG_HOME at call time (not at module-load time):\n // configstore@7's transitive xdg-basedir snapshots the env var when\n // first imported, which would ignore per-test mutations and (more\n // importantly) couple our path to xdg-basedir's caching across\n // process lifetimes. Computing configPath ourselves keeps the\n // SDK's storage location stable regardless of dep version churn.\n const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), '.config')\n const configPath = join(xdgConfig, 'configstore', `${name}.json`)\n configstoreInstance = new Configstore(name, undefined, { configPath })\n return configstoreInstance\n }\n\n async function getLockfile(): Promise<typeof import('proper-lockfile')> {\n const mod = await import('proper-lockfile')\n return ((mod as any).default ?? mod) as typeof import('proper-lockfile')\n }\n\n function readAll(cs: any): StoredCredentials {\n const result: StoredCredentials = {}\n const token = cs.get('token')\n const refresh_token = cs.get('refresh_token')\n const host = cs.get('host')\n if (token !== undefined) result.token = token\n if (refresh_token !== undefined) result.refresh_token = refresh_token\n if (host !== undefined) result.host = host\n return result\n }\n\n async function doLockedSet(patch: Partial<StoredCredentials>): Promise<void> {\n const cs = await getConfigstore()\n const lockfile = await getLockfile()\n const filePath: string = cs.path\n\n // Ensure the file (and its directory) exist so proper-lockfile has\n // something to anchor on. `wx` is atomic create-if-not-exists, so this\n // is safe even if another process is racing to create the same file.\n const { mkdirSync, writeFileSync } = await import('node:fs')\n const { dirname } = await import('node:path')\n try {\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, '{}', { flag: 'wx' })\n } catch (e: any) {\n if (e?.code !== 'EEXIST') throw e\n }\n\n // realpath:false skips symlink resolution. configstore returns an\n // already-absolute path, and resolving symlinks would force an extra\n // stat (and breaks on macOS test tmpdirs which are symlinks).\n const release = await lockfile.lock(filePath, {\n retries: {\n retries: LOCK_RETRIES,\n minTimeout: LOCK_RETRY_MIN_MS,\n maxTimeout: LOCK_RETRY_MAX_MS,\n factor: 2,\n },\n stale: LOCK_STALE_MS,\n realpath: false,\n })\n\n try {\n // Force configstore to re-read the on-disk state so we merge\n // against the latest cross-process value, not a stale cache.\n configstoreInstance = null\n const fresh = await getConfigstore()\n const merged: StoredCredentials = { ...readAll(fresh), ...patch }\n ;(fresh as any).all = merged\n } finally {\n await release()\n }\n }\n\n return {\n async get(): Promise<StoredCredentials> {\n const cs = await getConfigstore()\n return readAll(cs)\n },\n\n async set(patch: Partial<StoredCredentials>): Promise<void> {\n const next = setChain.then(() => doLockedSet(patch))\n // Don't poison the chain on a rejection; the original error still\n // propagates via `next` to the caller.\n setChain = next.catch(() => {})\n return next\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCtB,SAAgB,4BAA4B,OAAO,WAAuB;CACtE,IAAIA,sBAAkC;CACtC,IAAIC,WAA0B,QAAQ,SAAS;CAE/C,eAAe,iBAA+B;;AAC1C,MAAI,oBAAqB,QAAO;EAChC,MAAM,MAAM,MAAM,OAAO;EACzB,MAAMC,0BAAoB,IAAY,sDAAW;EACjD,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,MAAM,EAAE,SAAS,MAAM,OAAO;AAS9B,wBAAsB,IAAI,YAAY,MAAM,QAAW,EAAE,YADtC,KADD,QAAQ,IAAI,mBAAmB,KAAK,SAAS,EAAE,UAAU,EACxC,eAAe,GAAG,KAAK,OAAO,EACI,CAAC;AACtE,SAAO;;CAGX,eAAe,cAAyD;;EACpE,MAAM,MAAM,MAAM,OAAO;AACzB,sBAAS,IAAY,wDAAW;;CAGpC,SAAS,QAAQ,IAA4B;EACzC,MAAMC,SAA4B,EAAE;EACpC,MAAM,QAAQ,GAAG,IAAI,QAAQ;EAC7B,MAAM,gBAAgB,GAAG,IAAI,gBAAgB;EAC7C,MAAM,OAAO,GAAG,IAAI,OAAO;AAC3B,MAAI,UAAU,OAAW,QAAO,QAAQ;AACxC,MAAI,kBAAkB,OAAW,QAAO,gBAAgB;AACxD,MAAI,SAAS,OAAW,QAAO,OAAO;AACtC,SAAO;;CAGX,eAAe,YAAY,OAAkD;EACzE,MAAM,KAAK,MAAM,gBAAgB;EACjC,MAAM,WAAW,MAAM,aAAa;EACpC,MAAMC,WAAmB,GAAG;EAK5B,MAAM,EAAE,WAAW,kBAAkB,MAAM,OAAO;EAClD,MAAM,EAAE,YAAY,MAAM,OAAO;AACjC,MAAI;AACA,aAAU,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACjD,iBAAc,UAAU,MAAM,EAAE,MAAM,MAAM,CAAC;WACxCC,GAAQ;AACb,8CAAI,EAAG,UAAS,SAAU,OAAM;;EAMpC,MAAM,UAAU,MAAM,SAAS,KAAK,UAAU;GAC1C,SAAS;IACL,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,QAAQ;IACX;GACD,OAAO;GACP,UAAU;GACb,CAAC;AAEF,MAAI;AAGA,yBAAsB;GACtB,MAAM,QAAQ,MAAM,gBAAgB;AAEnC,GAAC,MAAc,wCADuB,QAAQ,MAAM,GAAK;YAEpD;AACN,SAAM,SAAS;;;AAIvB,QAAO;EACH,MAAM,MAAkC;AAEpC,UAAO,QADI,MAAM,gBAAgB,CACf;;EAGtB,MAAM,IAAI,OAAkD;GACxD,MAAM,OAAO,SAAS,WAAW,YAAY,MAAM,CAAC;AAGpD,cAAW,KAAK,YAAY,GAAG;AAC/B,UAAO;;EAEd"}
|
package/dist/centia-io-sdk.cjs
CHANGED
|
@@ -2681,112 +2681,6 @@ function isExpired(jwt, skewSeconds) {
|
|
|
2681
2681
|
return Math.floor(Date.now() / 1e3) + skewSeconds >= exp;
|
|
2682
2682
|
}
|
|
2683
2683
|
|
|
2684
|
-
//#endregion
|
|
2685
|
-
//#region src/auth/configstoreTokenStore.ts
|
|
2686
|
-
const LOCK_RETRIES = 5;
|
|
2687
|
-
const LOCK_RETRY_MIN_MS = 100;
|
|
2688
|
-
const LOCK_RETRY_MAX_MS = 500;
|
|
2689
|
-
const LOCK_STALE_MS = 1e4;
|
|
2690
|
-
/**
|
|
2691
|
-
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
2692
|
-
* credentials at `~/.config/configstore/<name>.json` (or
|
|
2693
|
-
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
2694
|
-
* and cross-process write safety.
|
|
2695
|
-
*
|
|
2696
|
-
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
2697
|
-
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
2698
|
-
* same on-disk credentials and therefore the same login session. The default
|
|
2699
|
-
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
2700
|
-
* `gc2 login` is observable to every process that calls
|
|
2701
|
-
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
2702
|
-
* to isolate.
|
|
2703
|
-
*
|
|
2704
|
-
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
2705
|
-
* concurrent same-process calls do not race on the shared configstore cache.
|
|
2706
|
-
*
|
|
2707
|
-
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
2708
|
-
* read-merge-write critical section across processes so two simultaneous
|
|
2709
|
-
* `set()` calls from different processes cannot corrupt the file.
|
|
2710
|
-
*
|
|
2711
|
-
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
2712
|
-
* out of browser bundles even when this module is imported through the SDK
|
|
2713
|
-
* barrel. Calling this function in a browser environment will fail at
|
|
2714
|
-
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
2715
|
-
*
|
|
2716
|
-
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
2717
|
-
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
2718
|
-
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
2719
|
-
*/
|
|
2720
|
-
function createConfigstoreTokenStore(name = "gc2-env") {
|
|
2721
|
-
let configstoreInstance = null;
|
|
2722
|
-
let setChain = Promise.resolve();
|
|
2723
|
-
async function getConfigstore() {
|
|
2724
|
-
var _default;
|
|
2725
|
-
if (configstoreInstance) return configstoreInstance;
|
|
2726
|
-
const mod = await import("configstore");
|
|
2727
|
-
const Configstore = (_default = mod.default) !== null && _default !== void 0 ? _default : mod;
|
|
2728
|
-
const { homedir } = await import("node:os");
|
|
2729
|
-
const { join } = await import("node:path");
|
|
2730
|
-
configstoreInstance = new Configstore(name, void 0, { configPath: join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "configstore", `${name}.json`) });
|
|
2731
|
-
return configstoreInstance;
|
|
2732
|
-
}
|
|
2733
|
-
async function getLockfile() {
|
|
2734
|
-
var _default2;
|
|
2735
|
-
const mod = await import("proper-lockfile");
|
|
2736
|
-
return (_default2 = mod.default) !== null && _default2 !== void 0 ? _default2 : mod;
|
|
2737
|
-
}
|
|
2738
|
-
function readAll(cs) {
|
|
2739
|
-
const result = {};
|
|
2740
|
-
const token = cs.get("token");
|
|
2741
|
-
const refresh_token = cs.get("refresh_token");
|
|
2742
|
-
const host = cs.get("host");
|
|
2743
|
-
if (token !== void 0) result.token = token;
|
|
2744
|
-
if (refresh_token !== void 0) result.refresh_token = refresh_token;
|
|
2745
|
-
if (host !== void 0) result.host = host;
|
|
2746
|
-
return result;
|
|
2747
|
-
}
|
|
2748
|
-
async function doLockedSet(patch) {
|
|
2749
|
-
const cs = await getConfigstore();
|
|
2750
|
-
const lockfile = await getLockfile();
|
|
2751
|
-
const filePath = cs.path;
|
|
2752
|
-
const { mkdirSync, writeFileSync } = await import("node:fs");
|
|
2753
|
-
const { dirname } = await import("node:path");
|
|
2754
|
-
try {
|
|
2755
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
2756
|
-
writeFileSync(filePath, "{}", { flag: "wx" });
|
|
2757
|
-
} catch (e) {
|
|
2758
|
-
if ((e === null || e === void 0 ? void 0 : e.code) !== "EEXIST") throw e;
|
|
2759
|
-
}
|
|
2760
|
-
const release = await lockfile.lock(filePath, {
|
|
2761
|
-
retries: {
|
|
2762
|
-
retries: LOCK_RETRIES,
|
|
2763
|
-
minTimeout: LOCK_RETRY_MIN_MS,
|
|
2764
|
-
maxTimeout: LOCK_RETRY_MAX_MS,
|
|
2765
|
-
factor: 2
|
|
2766
|
-
},
|
|
2767
|
-
stale: LOCK_STALE_MS,
|
|
2768
|
-
realpath: false
|
|
2769
|
-
});
|
|
2770
|
-
try {
|
|
2771
|
-
configstoreInstance = null;
|
|
2772
|
-
const fresh = await getConfigstore();
|
|
2773
|
-
fresh.all = _objectSpread2(_objectSpread2({}, readAll(fresh)), patch);
|
|
2774
|
-
} finally {
|
|
2775
|
-
await release();
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
return {
|
|
2779
|
-
async get() {
|
|
2780
|
-
return readAll(await getConfigstore());
|
|
2781
|
-
},
|
|
2782
|
-
async set(patch) {
|
|
2783
|
-
const next = setChain.then(() => doLockedSet(patch));
|
|
2784
|
-
setChain = next.catch(() => {});
|
|
2785
|
-
return next;
|
|
2786
|
-
}
|
|
2787
|
-
};
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
2684
|
//#endregion
|
|
2791
2685
|
//#region src/index.ts
|
|
2792
2686
|
/**
|
|
@@ -2817,7 +2711,6 @@ exports.Ws = Ws;
|
|
|
2817
2711
|
exports.createApi = createApi;
|
|
2818
2712
|
exports.createCentiaAdminClient = createCentiaAdminClient;
|
|
2819
2713
|
exports.createCentiaClient = createCentiaClient;
|
|
2820
|
-
exports.createConfigstoreTokenStore = createConfigstoreTokenStore;
|
|
2821
2714
|
exports.createSqlBuilder = createSqlBuilder;
|
|
2822
2715
|
exports.createTokenProvider = createTokenProvider;
|
|
2823
2716
|
exports.isCentiaApiError = isCentiaApiError;
|
package/dist/centia-io-sdk.d.cts
CHANGED
|
@@ -1288,39 +1288,6 @@ interface CreateTokenProviderOptions {
|
|
|
1288
1288
|
*/
|
|
1289
1289
|
declare function createTokenProvider(opts: CreateTokenProviderOptions): TokenProvider;
|
|
1290
1290
|
//#endregion
|
|
1291
|
-
//#region src/auth/configstoreTokenStore.d.ts
|
|
1292
|
-
/**
|
|
1293
|
-
* Build a Node-only file-backed {@link TokenStore} that persists OAuth
|
|
1294
|
-
* credentials at `~/.config/configstore/<name>.json` (or
|
|
1295
|
-
* `$XDG_CONFIG_HOME/configstore/<name>.json` if set), with both in-process
|
|
1296
|
-
* and cross-process write safety.
|
|
1297
|
-
*
|
|
1298
|
-
* **Shared-state intent.** The `name` is the file name on disk. Two processes
|
|
1299
|
-
* (e.g. `gc2-cli` and a local MCP server) that pass the same name share the
|
|
1300
|
-
* same on-disk credentials and therefore the same login session. The default
|
|
1301
|
-
* `'gc2-env'` matches the name `gc2-cli` already uses, so a one-time
|
|
1302
|
-
* `gc2 login` is observable to every process that calls
|
|
1303
|
-
* `createConfigstoreTokenStore()` with no argument. Pass a different name
|
|
1304
|
-
* to isolate.
|
|
1305
|
-
*
|
|
1306
|
-
* **In-process correctness.** A serial promise chain on `set()` ensures
|
|
1307
|
-
* concurrent same-process calls do not race on the shared configstore cache.
|
|
1308
|
-
*
|
|
1309
|
-
* **Cross-process correctness.** `proper-lockfile` serializes the
|
|
1310
|
-
* read-merge-write critical section across processes so two simultaneous
|
|
1311
|
-
* `set()` calls from different processes cannot corrupt the file.
|
|
1312
|
-
*
|
|
1313
|
-
* **Node-only.** The dynamic imports keep `configstore` and `proper-lockfile`
|
|
1314
|
-
* out of browser bundles even when this module is imported through the SDK
|
|
1315
|
-
* barrel. Calling this function in a browser environment will fail at
|
|
1316
|
-
* runtime when the deferred `await import('configstore')` cannot resolve.
|
|
1317
|
-
*
|
|
1318
|
-
* @param name - configstore file name (without `.json`). Default `'gc2-env'`
|
|
1319
|
-
* matches `gc2-cli`'s configstore so credentials are shared.
|
|
1320
|
-
* @returns A {@link TokenStore} suitable for passing to {@link createTokenProvider}.
|
|
1321
|
-
*/
|
|
1322
|
-
declare function createConfigstoreTokenStore(name?: string): TokenStore;
|
|
1323
|
-
//#endregion
|
|
1324
1291
|
//#region src/auth/errors.d.ts
|
|
1325
1292
|
/**
|
|
1326
1293
|
* @author Martin Høgh <mh@mapcentia.com>
|
|
@@ -1357,5 +1324,5 @@ declare class SessionExpiredError extends Error {
|
|
|
1357
1324
|
*/
|
|
1358
1325
|
|
|
1359
1326
|
//#endregion
|
|
1360
|
-
export { type AuthService, type BatchMessage, type CentiaAdminClient, CentiaApiError, type CentiaApiErrorOptions, type CentiaAuth, type CentiaClientConfig, type CentiaHttpClient, Claims, type ClientInfo, CodeFlow, type CodeFlowOptions, type ColumnDef, type ColumnInfo, type CommitRequest, type CommitResult, type ConstraintInfo, type CreateClientRequest, type CreateClientResponse, type CreateColumnRequest, type CreateConstraintRequest, type CreateIndexRequest, type CreateRpcMethodRequest, type CreateRuleRequest, type CreateSchemaRequest, type CreateSequenceRequest, type CreateTokenProviderOptions, type CreateUserRequest, type DBSchema, type FileProcessRequest, type FileProcessResponse, type FileUploadOptions, type FullResponse, type GetSchemaOptions, Gql, type GqlRequest, type GqlResponse, type IndexInfo, type LocationResponse, Meta, type MetadataFieldInfo, type MetadataRelationInfo, NotLoggedInError, type Options, type ParamsOfApiMethod, PasswordFlow, type PasswordFlowOptions, type PatchClientRequest, type PatchColumnRequest, type PatchMetadataRequest, type PatchPrivilegeRequest, type PatchRpcMethodRequest, type PatchRuleRequest, type PatchSequenceRequest, type PatchUserRequest, type pgTypes_d_exports as PgTypes, type PickRow, type PrivilegeInfo, type PrivilegeLevel, type RenameSchemaRequest, type RequestOptions, type RowForTable, type RowOfApiCall, type RowOfApiMethod, type RowOfRequest, type RowOfSelect, type RowsOfApiCall, type RowsOfApiMethod, type RowsOfRequest, type RowsOfSelect, Rpc, type RpcMethodInfo, type RpcRequest, type RpcResponse, type RuleAccess, type RuleInfo, type RuleRequest, type RuleService, type SchemaInfo, type SequenceInfo, SessionExpiredError, SignUp, Sql, SqlNoToken, type SqlNoTokenRequest, type SqlRequest, type SqlResponse, Stats, Status, type StoredCredentials, type SubscriptionAckMessage, type SubscriptionRequest, type TableBatch, type TableDef, type TableInfo, Tables, type TokenProvider, type TokenStore, type UserInfo, Users, Ws, type WsErrorMessage, type WsMessage, type WsOptions, createApi, createCentiaAdminClient, createCentiaClient,
|
|
1327
|
+
export { type AuthService, type BatchMessage, type CentiaAdminClient, CentiaApiError, type CentiaApiErrorOptions, type CentiaAuth, type CentiaClientConfig, type CentiaHttpClient, Claims, type ClientInfo, CodeFlow, type CodeFlowOptions, type ColumnDef, type ColumnInfo, type CommitRequest, type CommitResult, type ConstraintInfo, type CreateClientRequest, type CreateClientResponse, type CreateColumnRequest, type CreateConstraintRequest, type CreateIndexRequest, type CreateRpcMethodRequest, type CreateRuleRequest, type CreateSchemaRequest, type CreateSequenceRequest, type CreateTokenProviderOptions, type CreateUserRequest, type DBSchema, type FileProcessRequest, type FileProcessResponse, type FileUploadOptions, type FullResponse, type GetSchemaOptions, Gql, type GqlRequest, type GqlResponse, type IndexInfo, type LocationResponse, Meta, type MetadataFieldInfo, type MetadataRelationInfo, NotLoggedInError, type Options, type ParamsOfApiMethod, PasswordFlow, type PasswordFlowOptions, type PatchClientRequest, type PatchColumnRequest, type PatchMetadataRequest, type PatchPrivilegeRequest, type PatchRpcMethodRequest, type PatchRuleRequest, type PatchSequenceRequest, type PatchUserRequest, type pgTypes_d_exports as PgTypes, type PickRow, type PrivilegeInfo, type PrivilegeLevel, type RenameSchemaRequest, type RequestOptions, type RowForTable, type RowOfApiCall, type RowOfApiMethod, type RowOfRequest, type RowOfSelect, type RowsOfApiCall, type RowsOfApiMethod, type RowsOfRequest, type RowsOfSelect, Rpc, type RpcMethodInfo, type RpcRequest, type RpcResponse, type RuleAccess, type RuleInfo, type RuleRequest, type RuleService, type SchemaInfo, type SequenceInfo, SessionExpiredError, SignUp, Sql, SqlNoToken, type SqlNoTokenRequest, type SqlRequest, type SqlResponse, Stats, Status, type StoredCredentials, type SubscriptionAckMessage, type SubscriptionRequest, type TableBatch, type TableDef, type TableInfo, Tables, type TokenProvider, type TokenStore, type UserInfo, Users, Ws, type WsErrorMessage, type WsMessage, type WsOptions, createApi, createCentiaAdminClient, createCentiaClient, createSqlBuilder, createTokenProvider, isCentiaApiError };
|
|
1361
1328
|
//# sourceMappingURL=centia-io-sdk.d.cts.map
|