📄 src/api-keys.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 *
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 *
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15export interface ApiKeyDictionary {
16 set(apiId: string, value: string): void;
17 get(apiId: string): string | undefined;
18 require(apiId: string): string;
19}
20
21const _keys = new Map<string, string>();
22
23export const apiKeyDictionary: ApiKeyDictionary = {
24 set(apiId: string, value: string): void {
25 if (!value) throw new Error(`[apiKeyDictionary] Empty value passed for apiId "${apiId}".`);
26 _keys.set(apiId, value);
27 },
28
29 get(apiId: string): string | undefined {
30 return _keys.get(apiId);
31 },
32
33 require(apiId: string): string {
34 const key = _keys.get(apiId);
35 if (!key) throw new Error(
36 `[${apiId}] API key is not configured. ` +
37 `Call apiKeyDictionary.set("${apiId}", "<your-key>") before using this adapter.`
38 );
39 return key;
40 },
41};
42