@datadog/openfeature-node-server 0.1.0-preview.8 → 0.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/LICENSE +201 -0
- package/README.md +4 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/initialization-controller.d.ts +30 -0
- package/cjs/initialization-controller.d.ts.map +1 -0
- package/cjs/initialization-controller.js +74 -0
- package/cjs/initialization-controller.js.map +1 -0
- package/cjs/provider.d.ts +9 -3
- package/cjs/provider.d.ts.map +1 -1
- package/cjs/provider.js +47 -19
- package/cjs/provider.js.map +1 -1
- package/cjs/shards/sharders.js +2 -2
- package/cjs/shards/sharders.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/initialization-controller.d.ts +30 -0
- package/esm/initialization-controller.d.ts.map +1 -0
- package/esm/initialization-controller.js +70 -0
- package/esm/initialization-controller.js.map +1 -0
- package/esm/provider.d.ts +9 -3
- package/esm/provider.d.ts.map +1 -1
- package/esm/provider.js +48 -20
- package/esm/provider.js.map +1 -1
- package/esm/shards/sharders.js +1 -1
- package/esm/shards/sharders.js.map +1 -1
- package/package.json +4 -6
- package/cjs/shards/obfuscation.d.ts +0 -9
- package/cjs/shards/obfuscation.d.ts.map +0 -1
- package/cjs/shards/obfuscation.js +0 -23
- package/cjs/shards/obfuscation.js.map +0 -1
- package/esm/shards/obfuscation.d.ts +0 -9
- package/esm/shards/obfuscation.d.ts.map +0 -1
- package/esm/shards/obfuscation.js +0 -16
- package/esm/shards/obfuscation.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Datadog, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
# Datadog OpenFeature Node.js Server Client
|
|
2
2
|
|
|
3
3
|
This package provides OpenFeature integration for Node.js server environments and is designed exclusively for internal Datadog use. Support is not provided for external organizations or third-party usage.
|
|
4
|
+
|
|
5
|
+
## End-user license agreement
|
|
6
|
+
|
|
7
|
+
https://www.datadoghq.com/legal/eula
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAC1E,cAAc,YAAY,CAAA"}
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA0B;AAE1B,4CAA4C;AAC5C,MAAM,YAAY,GAAG,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages deferred initialization with timeout support.
|
|
3
|
+
* Encapsulates the pattern of waiting for external resolution/rejection
|
|
4
|
+
* with automatic timeout handling and cleanup.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InitializationController {
|
|
7
|
+
private resolve?;
|
|
8
|
+
private reject?;
|
|
9
|
+
private timeoutId?;
|
|
10
|
+
private readonly promise;
|
|
11
|
+
constructor(timeoutMs: number, onTimeout: () => void);
|
|
12
|
+
/**
|
|
13
|
+
* Wait for initialization to complete (or timeout)
|
|
14
|
+
*/
|
|
15
|
+
wait(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Complete initialization successfully
|
|
18
|
+
*/
|
|
19
|
+
complete(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Fail initialization with an error
|
|
22
|
+
*/
|
|
23
|
+
fail(error: unknown): void;
|
|
24
|
+
/**
|
|
25
|
+
* Check if initialization is still in progress
|
|
26
|
+
*/
|
|
27
|
+
isInitializing(): boolean;
|
|
28
|
+
private cleanup;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=initialization-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialization-controller.d.ts","sourceRoot":"","sources":["../src/initialization-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAC,CAAwB;IACxC,OAAO,CAAC,MAAM,CAAC,CAA4B;IAC3C,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI;IAsBpD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAMhB;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM1B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,OAAO,CAAC,OAAO;CAQhB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitializationController = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manages deferred initialization with timeout support.
|
|
6
|
+
* Encapsulates the pattern of waiting for external resolution/rejection
|
|
7
|
+
* with automatic timeout handling and cleanup.
|
|
8
|
+
*/
|
|
9
|
+
class InitializationController {
|
|
10
|
+
constructor(timeoutMs, onTimeout) {
|
|
11
|
+
this.promise = Promise.race([
|
|
12
|
+
// Deferred promise - resolved/rejected externally
|
|
13
|
+
new Promise((resolve, reject) => {
|
|
14
|
+
this.resolve = () => {
|
|
15
|
+
this.cleanup();
|
|
16
|
+
resolve();
|
|
17
|
+
};
|
|
18
|
+
this.reject = (reason) => {
|
|
19
|
+
this.cleanup();
|
|
20
|
+
reject(reason);
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
// Timeout promise
|
|
24
|
+
new Promise(() => {
|
|
25
|
+
this.timeoutId = setTimeout(() => {
|
|
26
|
+
onTimeout();
|
|
27
|
+
}, timeoutMs);
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wait for initialization to complete (or timeout)
|
|
33
|
+
*/
|
|
34
|
+
async wait() {
|
|
35
|
+
try {
|
|
36
|
+
await this.promise;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
this.cleanup();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Complete initialization successfully
|
|
44
|
+
*/
|
|
45
|
+
complete() {
|
|
46
|
+
if (this.resolve) {
|
|
47
|
+
this.resolve();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fail initialization with an error
|
|
52
|
+
*/
|
|
53
|
+
fail(error) {
|
|
54
|
+
if (this.reject) {
|
|
55
|
+
this.reject(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if initialization is still in progress
|
|
60
|
+
*/
|
|
61
|
+
isInitializing() {
|
|
62
|
+
return this.resolve !== undefined;
|
|
63
|
+
}
|
|
64
|
+
cleanup() {
|
|
65
|
+
if (this.timeoutId) {
|
|
66
|
+
clearTimeout(this.timeoutId);
|
|
67
|
+
this.timeoutId = undefined;
|
|
68
|
+
}
|
|
69
|
+
this.resolve = undefined;
|
|
70
|
+
this.reject = undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.InitializationController = InitializationController;
|
|
74
|
+
//# sourceMappingURL=initialization-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialization-controller.js","sourceRoot":"","sources":["../src/initialization-controller.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,wBAAwB;IAMnC,YAAY,SAAiB,EAAE,SAAqB;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YAC1B,kDAAkD;YAClD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACpC,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;oBAClB,IAAI,CAAC,OAAO,EAAE,CAAA;oBACd,OAAO,EAAE,CAAA;gBACX,CAAC,CAAA;gBACD,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE;oBACvB,IAAI,CAAC,OAAO,EAAE,CAAA;oBACd,MAAM,CAAC,MAAM,CAAC,CAAA;gBAChB,CAAC,CAAA;YACH,CAAC,CAAC;YACF,kBAAkB;YAClB,IAAI,OAAO,CAAO,GAAG,EAAE;gBACrB,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC/B,SAAS,EAAE,CAAA;gBACb,CAAC,EAAE,SAAS,CAAC,CAAA;YACf,CAAC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAA;QACpB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,CAAA;QAChB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAA;QAChB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,KAAc;QACjB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAA;IACnC,CAAC;IAEO,OAAO;QACb,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;IACzB,CAAC;CACF;AAxED,4DAwEC"}
|
package/cjs/provider.d.ts
CHANGED
|
@@ -9,15 +9,21 @@ export interface DatadogNodeServerProviderOptions {
|
|
|
9
9
|
* Log experiment exposures
|
|
10
10
|
*/
|
|
11
11
|
exposureChannel: Channel<ExposureEvent>;
|
|
12
|
+
/**
|
|
13
|
+
* Timeout in milliseconds for provider initialization.
|
|
14
|
+
* If the configuration is not set within this time, initialization will fail.
|
|
15
|
+
* @default DEFAULT_INITIALIZATION_TIMEOUT_MS (30000ms / 30 seconds)
|
|
16
|
+
*/
|
|
17
|
+
initializationTimeoutMs?: number;
|
|
12
18
|
}
|
|
13
19
|
export declare class DatadogNodeServerProvider implements Provider {
|
|
14
20
|
private readonly options;
|
|
15
21
|
readonly metadata: ProviderMetadata;
|
|
16
22
|
readonly runsOn: Paradigm;
|
|
17
23
|
readonly hooks?: Hook[];
|
|
18
|
-
private
|
|
19
|
-
private rejectInitialization?;
|
|
24
|
+
private initController?;
|
|
20
25
|
readonly events: ProviderEventEmitter<ProviderEvents>;
|
|
26
|
+
private readonly exposureCache;
|
|
21
27
|
private configuration?;
|
|
22
28
|
constructor(options: DatadogNodeServerProviderOptions);
|
|
23
29
|
/**
|
|
@@ -38,7 +44,7 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
38
44
|
* Status of 'PROVIDER_ERROR' is emitted with a rejected promise.
|
|
39
45
|
*
|
|
40
46
|
* Since we aren't loading the configuration in this Provider, we will simulate
|
|
41
|
-
* loading functionality via
|
|
47
|
+
* loading functionality via InitializationController.
|
|
42
48
|
* See setConfiguration and setError for more details.
|
|
43
49
|
*/
|
|
44
50
|
initialize(): Promise<void>;
|
package/cjs/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAGV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAA2B,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAQ1E,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IACvC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;C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,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAmBhC,OAAO,CAAC,cAAc;CAwBvB"}
|
package/cjs/provider.js
CHANGED
|
@@ -4,6 +4,11 @@ exports.DatadogNodeServerProvider = void 0;
|
|
|
4
4
|
const flagging_core_1 = require("@datadog/flagging-core");
|
|
5
5
|
const server_sdk_1 = require("@openfeature/server-sdk");
|
|
6
6
|
const evaluation_1 = require("./configuration/evaluation");
|
|
7
|
+
const initialization_controller_1 = require("./initialization-controller");
|
|
8
|
+
/**
|
|
9
|
+
* Default timeout in milliseconds for provider initialization.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_INITIALIZATION_TIMEOUT_MS = 30000;
|
|
7
12
|
class DatadogNodeServerProvider {
|
|
8
13
|
constructor(options) {
|
|
9
14
|
this.options = options;
|
|
@@ -13,6 +18,7 @@ class DatadogNodeServerProvider {
|
|
|
13
18
|
this.runsOn = 'server';
|
|
14
19
|
this.hooks = [];
|
|
15
20
|
this.events = new server_sdk_1.OpenFeatureEventEmitter();
|
|
21
|
+
this.exposureCache = new flagging_core_1.LRUInMemoryAssignmentCache(50000);
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* Used by dd-source-js
|
|
@@ -24,25 +30,37 @@ class DatadogNodeServerProvider {
|
|
|
24
30
|
* Used by dd-source-js
|
|
25
31
|
*/
|
|
26
32
|
setConfiguration(configuration) {
|
|
27
|
-
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const prevCreatedAt = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.createdAt;
|
|
35
|
+
const hadConfiguration = !!this.configuration;
|
|
36
|
+
if (hadConfiguration && this.configuration !== configuration) {
|
|
28
37
|
this.events.emit(server_sdk_1.ProviderEvents.ConfigurationChanged);
|
|
38
|
+
const newCreatedAt = configuration === null || configuration === void 0 ? void 0 : configuration.createdAt;
|
|
39
|
+
if (prevCreatedAt !== newCreatedAt) {
|
|
40
|
+
(_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.clear();
|
|
41
|
+
}
|
|
42
|
+
this.configuration = configuration;
|
|
29
43
|
return;
|
|
30
44
|
}
|
|
31
45
|
this.configuration = configuration;
|
|
32
|
-
if (this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
46
|
+
if ((_c = this.initController) === null || _c === void 0 ? void 0 : _c.isInitializing()) {
|
|
47
|
+
// First configuration during initialization - resolve the initialization promise
|
|
48
|
+
// This will cause OpenFeature SDK to emit PROVIDER_READY
|
|
49
|
+
this.initController.complete();
|
|
50
|
+
}
|
|
51
|
+
else if (!hadConfiguration) {
|
|
52
|
+
// Configuration is being set after initialization completed/failed (e.g., after timeout)
|
|
53
|
+
// Emit PROVIDER_READY to signal recovery from error state
|
|
54
|
+
this.events.emit(server_sdk_1.ProviderEvents.Ready);
|
|
36
55
|
}
|
|
37
56
|
}
|
|
38
57
|
/**
|
|
39
58
|
* Used by dd-source-js
|
|
40
59
|
*/
|
|
41
60
|
setError(error) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
this.rejectInitialization = undefined;
|
|
61
|
+
var _a;
|
|
62
|
+
if ((_a = this.initController) === null || _a === void 0 ? void 0 : _a.isInitializing()) {
|
|
63
|
+
this.initController.fail(error);
|
|
46
64
|
}
|
|
47
65
|
else {
|
|
48
66
|
this.events.emit(server_sdk_1.ProviderEvents.Error, { error });
|
|
@@ -54,17 +72,18 @@ class DatadogNodeServerProvider {
|
|
|
54
72
|
* Status of 'PROVIDER_ERROR' is emitted with a rejected promise.
|
|
55
73
|
*
|
|
56
74
|
* Since we aren't loading the configuration in this Provider, we will simulate
|
|
57
|
-
* loading functionality via
|
|
75
|
+
* loading functionality via InitializationController.
|
|
58
76
|
* See setConfiguration and setError for more details.
|
|
59
77
|
*/
|
|
60
|
-
initialize() {
|
|
78
|
+
async initialize() {
|
|
79
|
+
var _a, _b;
|
|
61
80
|
if (this.configuration) {
|
|
62
|
-
return
|
|
81
|
+
return;
|
|
63
82
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
const timeoutMs = (_a = this.options.initializationTimeoutMs) !== null && _a !== void 0 ? _a : DEFAULT_INITIALIZATION_TIMEOUT_MS;
|
|
84
|
+
this.initController = new initialization_controller_1.InitializationController(timeoutMs, () => this.setError(new Error(`Initialization timeout after ${timeoutMs}ms`)));
|
|
85
|
+
await this.initController.wait();
|
|
86
|
+
await ((_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.init());
|
|
68
87
|
}
|
|
69
88
|
async resolveBooleanEvaluation(flagKey, defaultValue, context, _logger) {
|
|
70
89
|
const resolutionDetails = (0, evaluation_1.evaluate)(this.configuration, 'boolean', flagKey, defaultValue, context, _logger);
|
|
@@ -93,15 +112,24 @@ class DatadogNodeServerProvider {
|
|
|
93
112
|
return resolutionDetails;
|
|
94
113
|
}
|
|
95
114
|
handleExposure(flagKey, context, resolutionDetails) {
|
|
96
|
-
var _a;
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
const timestamp = Date.now();
|
|
97
117
|
const evalutationDetails = {
|
|
98
118
|
...resolutionDetails,
|
|
99
119
|
flagKey: flagKey,
|
|
100
120
|
flagMetadata: (_a = resolutionDetails.flagMetadata) !== null && _a !== void 0 ? _a : {},
|
|
101
121
|
};
|
|
102
122
|
const exposureEvent = (0, flagging_core_1.createExposureEvent)(context, evalutationDetails);
|
|
103
|
-
if (exposureEvent
|
|
104
|
-
|
|
123
|
+
if (!exposureEvent) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const hasLoggedAssignment = (_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.has(exposureEvent);
|
|
127
|
+
if (hasLoggedAssignment) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (this.options.exposureChannel.hasSubscribers) {
|
|
131
|
+
this.options.exposureChannel.publish({ ...exposureEvent, timestamp });
|
|
132
|
+
(_c = this.exposureCache) === null || _c === void 0 ? void 0 : _c.set(exposureEvent);
|
|
105
133
|
}
|
|
106
134
|
}
|
|
107
135
|
}
|
package/cjs/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";;;AACA,0DAK+B;AAc/B,wDAAiF;AACjF,2DAAqD;AAErD,2EAAsE;AAEtE;;GAEG;AACH,MAAM,iCAAiC,GAAG,KAAM,CAAA;AAehD,MAAa,yBAAyB;IAapC,YAA6B,OAAyC;QAAzC,YAAO,GAAP,OAAO,CAAkC;QAZ7D,aAAQ,GAAqB;YACpC,IAAI,EAAE,qBAAqB;SAC5B,CAAA;QACQ,WAAM,GAAa,QAAQ,CAAA;QAUlC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,oCAAuB,EAAE,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,0CAA0B,CAAC,KAAM,CAAC,CAAA;IAC7D,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,aAA2C;;QAC1D,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,aAAa,0CAAE,SAAS,CAAA;QACnD,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAA;QAE7C,IAAI,gBAAgB,IAAI,IAAI,CAAC,aAAa,KAAK,aAAa,EAAE,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAAc,CAAC,oBAAoB,CAAC,CAAA;YACrD,MAAM,YAAY,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAA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terministicSharder = exports.MD5Sharder = exports.Sharder = void 0;
|
|
4
|
-
const
|
|
4
|
+
const flagging_core_1 = require("@datadog/flagging-core");
|
|
5
5
|
class Sharder {
|
|
6
6
|
}
|
|
7
7
|
exports.Sharder = Sharder;
|
|
8
8
|
class MD5Sharder extends Sharder {
|
|
9
9
|
getShard(input, totalShards) {
|
|
10
|
-
const hashOutput = (0,
|
|
10
|
+
const hashOutput = (0, flagging_core_1.getMD5Hash)(input);
|
|
11
11
|
// get the first 4 bytes of the md5 hex string and parse it using base 16
|
|
12
12
|
// (8 hex characters represent 4 bytes, e.g. 0xffffffff represents the max 4-byte integer)
|
|
13
13
|
const intFromHash = parseInt(hashOutput.slice(0, 8), 16);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharders.js","sourceRoot":"","sources":["../../src/shards/sharders.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"sharders.js","sourceRoot":"","sources":["../../src/shards/sharders.ts"],"names":[],"mappings":";;;AAAA,0DAAmD;AAEnD,MAAsB,OAAO;CAE5B;AAFD,0BAEC;AAED,MAAa,UAAW,SAAQ,OAAO;IACrC,QAAQ,CAAC,KAAa,EAAE,WAAmB;QACzC,MAAM,UAAU,GAAG,IAAA,0BAAU,EAAC,KAAK,CAAC,CAAA;QACpC,yEAAyE;QACzE,0FAA0F;QAC1F,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO,WAAW,GAAG,WAAW,CAAA;IAClC,CAAC;CACF;AARD,gCAQC;AAED,MAAa,oBAAqB,SAAQ,OAAO;IAO/C,YAAY,MAA8B;QACxC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,6DAA6D;IAC7D,QAAQ,CAAC,KAAa,EAAE,YAAoB;;QAC1C,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAI,CAAC,CAAA;IAChC,CAAC;CACF;AAhBD,oDAgBC"}
|
package/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAC1E,cAAc,YAAY,CAAA"}
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAE1B,4CAA4C;AAC5C,MAAM,YAAY,GAAG,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages deferred initialization with timeout support.
|
|
3
|
+
* Encapsulates the pattern of waiting for external resolution/rejection
|
|
4
|
+
* with automatic timeout handling and cleanup.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InitializationController {
|
|
7
|
+
private resolve?;
|
|
8
|
+
private reject?;
|
|
9
|
+
private timeoutId?;
|
|
10
|
+
private readonly promise;
|
|
11
|
+
constructor(timeoutMs: number, onTimeout: () => void);
|
|
12
|
+
/**
|
|
13
|
+
* Wait for initialization to complete (or timeout)
|
|
14
|
+
*/
|
|
15
|
+
wait(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Complete initialization successfully
|
|
18
|
+
*/
|
|
19
|
+
complete(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Fail initialization with an error
|
|
22
|
+
*/
|
|
23
|
+
fail(error: unknown): void;
|
|
24
|
+
/**
|
|
25
|
+
* Check if initialization is still in progress
|
|
26
|
+
*/
|
|
27
|
+
isInitializing(): boolean;
|
|
28
|
+
private cleanup;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=initialization-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialization-controller.d.ts","sourceRoot":"","sources":["../src/initialization-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,OAAO,CAAC,CAAwB;IACxC,OAAO,CAAC,MAAM,CAAC,CAA4B;IAC3C,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI;IAsBpD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAMhB;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM1B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,OAAO,CAAC,OAAO;CAQhB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages deferred initialization with timeout support.
|
|
3
|
+
* Encapsulates the pattern of waiting for external resolution/rejection
|
|
4
|
+
* with automatic timeout handling and cleanup.
|
|
5
|
+
*/
|
|
6
|
+
export class InitializationController {
|
|
7
|
+
constructor(timeoutMs, onTimeout) {
|
|
8
|
+
this.promise = Promise.race([
|
|
9
|
+
// Deferred promise - resolved/rejected externally
|
|
10
|
+
new Promise((resolve, reject) => {
|
|
11
|
+
this.resolve = () => {
|
|
12
|
+
this.cleanup();
|
|
13
|
+
resolve();
|
|
14
|
+
};
|
|
15
|
+
this.reject = (reason) => {
|
|
16
|
+
this.cleanup();
|
|
17
|
+
reject(reason);
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
// Timeout promise
|
|
21
|
+
new Promise(() => {
|
|
22
|
+
this.timeoutId = setTimeout(() => {
|
|
23
|
+
onTimeout();
|
|
24
|
+
}, timeoutMs);
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wait for initialization to complete (or timeout)
|
|
30
|
+
*/
|
|
31
|
+
async wait() {
|
|
32
|
+
try {
|
|
33
|
+
await this.promise;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
this.cleanup();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Complete initialization successfully
|
|
41
|
+
*/
|
|
42
|
+
complete() {
|
|
43
|
+
if (this.resolve) {
|
|
44
|
+
this.resolve();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Fail initialization with an error
|
|
49
|
+
*/
|
|
50
|
+
fail(error) {
|
|
51
|
+
if (this.reject) {
|
|
52
|
+
this.reject(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if initialization is still in progress
|
|
57
|
+
*/
|
|
58
|
+
isInitializing() {
|
|
59
|
+
return this.resolve !== undefined;
|
|
60
|
+
}
|
|
61
|
+
cleanup() {
|
|
62
|
+
if (this.timeoutId) {
|
|
63
|
+
clearTimeout(this.timeoutId);
|
|
64
|
+
this.timeoutId = undefined;
|
|
65
|
+
}
|
|
66
|
+
this.resolve = undefined;
|
|
67
|
+
this.reject = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=initialization-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialization-controller.js","sourceRoot":"","sources":["../src/initialization-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IAMnC,YAAY,SAAiB,EAAE,SAAqB;QAClD,IAAI,CAAC,O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AA;YAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;IACzB,CAAC;CACF"}
|
package/esm/provider.d.ts
CHANGED
|
@@ -9,15 +9,21 @@ export interface DatadogNodeServerProviderOptions {
|
|
|
9
9
|
* Log experiment exposures
|
|
10
10
|
*/
|
|
11
11
|
exposureChannel: Channel<ExposureEvent>;
|
|
12
|
+
/**
|
|
13
|
+
* Timeout in milliseconds for provider initialization.
|
|
14
|
+
* If the configuration is not set within this time, initialization will fail.
|
|
15
|
+
* @default DEFAULT_INITIALIZATION_TIMEOUT_MS (30000ms / 30 seconds)
|
|
16
|
+
*/
|
|
17
|
+
initializationTimeoutMs?: number;
|
|
12
18
|
}
|
|
13
19
|
export declare class DatadogNodeServerProvider implements Provider {
|
|
14
20
|
private readonly options;
|
|
15
21
|
readonly metadata: ProviderMetadata;
|
|
16
22
|
readonly runsOn: Paradigm;
|
|
17
23
|
readonly hooks?: Hook[];
|
|
18
|
-
private
|
|
19
|
-
private rejectInitialization?;
|
|
24
|
+
private initController?;
|
|
20
25
|
readonly events: ProviderEventEmitter<ProviderEvents>;
|
|
26
|
+
private readonly exposureCache;
|
|
21
27
|
private configuration?;
|
|
22
28
|
constructor(options: DatadogNodeServerProviderOptions);
|
|
23
29
|
/**
|
|
@@ -38,7 +44,7 @@ export declare class DatadogNodeServerProvider implements Provider {
|
|
|
38
44
|
* Status of 'PROVIDER_ERROR' is emitted with a rejected promise.
|
|
39
45
|
*
|
|
40
46
|
* Since we aren't loading the configuration in this Provider, we will simulate
|
|
41
|
-
* loading functionality via
|
|
47
|
+
* loading functionality via InitializationController.
|
|
42
48
|
* See setConfiguration and setError for more details.
|
|
43
49
|
*/
|
|
44
50
|
initialize(): Promise<void>;
|
package/esm/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAGV,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAA2B,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEjF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAQ1E,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IACvC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC;AAED,qBAAa,yBAA0B,YAAW,QAAQ;IAa5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAElC;IACD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAW;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IAEvB,OAAO,CAAC,cAAc,CAAC,CAA0B;IACjD,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAA;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAE3D,OAAO,CAAC,aAAa,CAAC,CAA0C;gBAEnC,OAAO,EAAE,gCAAgC;IAMtE;;OAEG;IACH,gBAAgB;IAIhB;;OAEG;IACH,gBAAgB,CAAC,aAAa,EAAE,4BAA4B;IA2B5D;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO;IAQvB;;;;;;;;OAQG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3B,wBAAwB,CAC5B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAMhC,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAM/B,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAM/B,uBAAuB,CAAC,CAAC,SAAS,SAAS,EAC/C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAmBhC,OAAO,CAAC,cAAc;CAwBvB"}
|
package/esm/provider.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { createExposureEvent } from '@datadog/flagging-core';
|
|
1
|
+
import { createExposureEvent, LRUInMemoryAssignmentCache, } from '@datadog/flagging-core';
|
|
2
2
|
import { OpenFeatureEventEmitter, ProviderEvents } from '@openfeature/server-sdk';
|
|
3
3
|
import { evaluate } from './configuration/evaluation';
|
|
4
|
+
import { InitializationController } from './initialization-controller';
|
|
5
|
+
/**
|
|
6
|
+
* Default timeout in milliseconds for provider initialization.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_INITIALIZATION_TIMEOUT_MS = 30000;
|
|
4
9
|
export class DatadogNodeServerProvider {
|
|
5
10
|
constructor(options) {
|
|
6
11
|
this.options = options;
|
|
@@ -10,6 +15,7 @@ export class DatadogNodeServerProvider {
|
|
|
10
15
|
this.runsOn = 'server';
|
|
11
16
|
this.hooks = [];
|
|
12
17
|
this.events = new OpenFeatureEventEmitter();
|
|
18
|
+
this.exposureCache = new LRUInMemoryAssignmentCache(50000);
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* Used by dd-source-js
|
|
@@ -21,25 +27,37 @@ export class DatadogNodeServerProvider {
|
|
|
21
27
|
* Used by dd-source-js
|
|
22
28
|
*/
|
|
23
29
|
setConfiguration(configuration) {
|
|
24
|
-
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
const prevCreatedAt = (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.createdAt;
|
|
32
|
+
const hadConfiguration = !!this.configuration;
|
|
33
|
+
if (hadConfiguration && this.configuration !== configuration) {
|
|
25
34
|
this.events.emit(ProviderEvents.ConfigurationChanged);
|
|
35
|
+
const newCreatedAt = configuration === null || configuration === void 0 ? void 0 : configuration.createdAt;
|
|
36
|
+
if (prevCreatedAt !== newCreatedAt) {
|
|
37
|
+
(_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.clear();
|
|
38
|
+
}
|
|
39
|
+
this.configuration = configuration;
|
|
26
40
|
return;
|
|
27
41
|
}
|
|
28
42
|
this.configuration = configuration;
|
|
29
|
-
if (this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
43
|
+
if ((_c = this.initController) === null || _c === void 0 ? void 0 : _c.isInitializing()) {
|
|
44
|
+
// First configuration during initialization - resolve the initialization promise
|
|
45
|
+
// This will cause OpenFeature SDK to emit PROVIDER_READY
|
|
46
|
+
this.initController.complete();
|
|
47
|
+
}
|
|
48
|
+
else if (!hadConfiguration) {
|
|
49
|
+
// Configuration is being set after initialization completed/failed (e.g., after timeout)
|
|
50
|
+
// Emit PROVIDER_READY to signal recovery from error state
|
|
51
|
+
this.events.emit(ProviderEvents.Ready);
|
|
33
52
|
}
|
|
34
53
|
}
|
|
35
54
|
/**
|
|
36
55
|
* Used by dd-source-js
|
|
37
56
|
*/
|
|
38
57
|
setError(error) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
this.rejectInitialization = undefined;
|
|
58
|
+
var _a;
|
|
59
|
+
if ((_a = this.initController) === null || _a === void 0 ? void 0 : _a.isInitializing()) {
|
|
60
|
+
this.initController.fail(error);
|
|
43
61
|
}
|
|
44
62
|
else {
|
|
45
63
|
this.events.emit(ProviderEvents.Error, { error });
|
|
@@ -51,17 +69,18 @@ export class DatadogNodeServerProvider {
|
|
|
51
69
|
* Status of 'PROVIDER_ERROR' is emitted with a rejected promise.
|
|
52
70
|
*
|
|
53
71
|
* Since we aren't loading the configuration in this Provider, we will simulate
|
|
54
|
-
* loading functionality via
|
|
72
|
+
* loading functionality via InitializationController.
|
|
55
73
|
* See setConfiguration and setError for more details.
|
|
56
74
|
*/
|
|
57
|
-
initialize() {
|
|
75
|
+
async initialize() {
|
|
76
|
+
var _a, _b;
|
|
58
77
|
if (this.configuration) {
|
|
59
|
-
return
|
|
78
|
+
return;
|
|
60
79
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
const timeoutMs = (_a = this.options.initializationTimeoutMs) !== null && _a !== void 0 ? _a : DEFAULT_INITIALIZATION_TIMEOUT_MS;
|
|
81
|
+
this.initController = new InitializationController(timeoutMs, () => this.setError(new Error(`Initialization timeout after ${timeoutMs}ms`)));
|
|
82
|
+
await this.initController.wait();
|
|
83
|
+
await ((_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.init());
|
|
65
84
|
}
|
|
66
85
|
async resolveBooleanEvaluation(flagKey, defaultValue, context, _logger) {
|
|
67
86
|
const resolutionDetails = evaluate(this.configuration, 'boolean', flagKey, defaultValue, context, _logger);
|
|
@@ -90,15 +109,24 @@ export class DatadogNodeServerProvider {
|
|
|
90
109
|
return resolutionDetails;
|
|
91
110
|
}
|
|
92
111
|
handleExposure(flagKey, context, resolutionDetails) {
|
|
93
|
-
var _a;
|
|
112
|
+
var _a, _b, _c;
|
|
113
|
+
const timestamp = Date.now();
|
|
94
114
|
const evalutationDetails = {
|
|
95
115
|
...resolutionDetails,
|
|
96
116
|
flagKey: flagKey,
|
|
97
117
|
flagMetadata: (_a = resolutionDetails.flagMetadata) !== null && _a !== void 0 ? _a : {},
|
|
98
118
|
};
|
|
99
119
|
const exposureEvent = createExposureEvent(context, evalutationDetails);
|
|
100
|
-
if (exposureEvent
|
|
101
|
-
|
|
120
|
+
if (!exposureEvent) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const hasLoggedAssignment = (_b = this.exposureCache) === null || _b === void 0 ? void 0 : _b.has(exposureEvent);
|
|
124
|
+
if (hasLoggedAssignment) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (this.options.exposureChannel.hasSubscribers) {
|
|
128
|
+
this.options.exposureChannel.publish({ ...exposureEvent, timestamp });
|
|
129
|
+
(_c = this.exposureCache) === null || _c === void 0 ? void 0 : _c.set(exposureEvent);
|
|
102
130
|
}
|
|
103
131
|
}
|
|
104
132
|
}
|
package/esm/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EAEnB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAA;AAc/B,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,C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AAuC;;QAEvC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC5B,MAAM,kBAAkB,GAAyB;YAC/C,GAAG,iBAAiB;YACpB,OAAO,EAAE,OAAO;YAChB,YAAY,EAAE,MAAA,iBAAiB,CAAC,YAAY,mCAAI,EAAE;SACnD,CAAA;QACD,MAAM,aAAa,GAAG,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;QACtE,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAM;QACR,CAAC;QACD,MAAM,mBAAmB,GAAG,MAAA,IAAI,CAAC,aAAa,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAA;QAClE,IAAI,mBAAmB,EAAE,CAAC;YACxB,OAAM;QACR,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC;YAChD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,EAAE,SAAS,EAAE,CAAC,CAAA;YACrE,MAAA,IAAI,CAAC,aAAa,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;CACF"}
|
package/esm/shards/sharders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharders.js","sourceRoot":"","sources":["../../src/shards/sharders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sharders.js","sourceRoot":"","sources":["../../src/shards/sharders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,MAAM,OAAgB,OAAO;CAE5B;AAED,MAAM,OAAO,UAAW,SAAQ,OAAO;IACrC,QAAQ,CAAC,KAAa,EAAE,WAAmB;QACzC,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;QACpC,yEAAyE;QACzE,0FAA0F;QAC1F,MAAM,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO,WAAW,GAAG,WAAW,CAAA;IAClC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IAO/C,YAAY,MAA8B;QACxC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,6DAA6D;IAC7D,QAAQ,CAAC,KAAa,EAAE,YAAoB;;QAC1C,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/openfeature-node-server",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "React Native bindings for OpenFeature (wraps @datadog/flagging-core)",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/DataDog/openfeature-js-client#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
"typecheck": "tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@datadog/flagging-core": "0.1.0
|
|
40
|
-
"@openfeature/server-sdk": "~1.18.0"
|
|
41
|
-
"spark-md5": "^3.0.2"
|
|
39
|
+
"@datadog/flagging-core": "0.1.0",
|
|
40
|
+
"@openfeature/server-sdk": "~1.18.0"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"@openfeature/server-sdk": "~1.18.0"
|
|
@@ -47,7 +46,6 @@
|
|
|
47
46
|
"@openfeature/core": "^1.9.0",
|
|
48
47
|
"@types/jest": "^30.0.0",
|
|
49
48
|
"@types/node": "^18.0.0",
|
|
50
|
-
"@types/spark-md5": "^3",
|
|
51
49
|
"jest": "^30.0.4",
|
|
52
50
|
"npm-run-all": "^4.1.5",
|
|
53
51
|
"ts-jest": "^29.4.0",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function getMD5Hash(input: string, salt?: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Builds a storage key suffix from an API key.
|
|
4
|
-
* @param apiKey - The API key to build the suffix from
|
|
5
|
-
* @returns A string suffix for storage keys
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare function buildStorageKeySuffix(apiKey: string): string;
|
|
9
|
-
//# sourceMappingURL=obfuscation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obfuscation.d.ts","sourceRoot":"","sources":["../../src/shards/obfuscation.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getMD5Hash = getMD5Hash;
|
|
7
|
-
exports.buildStorageKeySuffix = buildStorageKeySuffix;
|
|
8
|
-
const spark_md5_1 = __importDefault(require("spark-md5"));
|
|
9
|
-
function getMD5Hash(input, salt = '') {
|
|
10
|
-
return new spark_md5_1.default().append(salt).append(input).end();
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Builds a storage key suffix from an API key.
|
|
14
|
-
* @param apiKey - The API key to build the suffix from
|
|
15
|
-
* @returns A string suffix for storage keys
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
function buildStorageKeySuffix(apiKey) {
|
|
19
|
-
// Note that we hash the API key and use the first 16 characters of the digest.
|
|
20
|
-
const hashed = getMD5Hash(apiKey);
|
|
21
|
-
return hashed.slice(0, 16);
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=obfuscation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../../src/shards/obfuscation.ts"],"names":[],"mappings":";;;;;AAEA,gCAEC;AAQD,sDAIC;AAhBD,0DAAgC;AAEhC,SAAgB,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,mBAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAc;IAClD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function getMD5Hash(input: string, salt?: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Builds a storage key suffix from an API key.
|
|
4
|
-
* @param apiKey - The API key to build the suffix from
|
|
5
|
-
* @returns A string suffix for storage keys
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare function buildStorageKeySuffix(apiKey: string): string;
|
|
9
|
-
//# sourceMappingURL=obfuscation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obfuscation.d.ts","sourceRoot":"","sources":["../../src/shards/obfuscation.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import SparkMD5 from 'spark-md5';
|
|
2
|
-
export function getMD5Hash(input, salt = '') {
|
|
3
|
-
return new SparkMD5().append(salt).append(input).end();
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Builds a storage key suffix from an API key.
|
|
7
|
-
* @param apiKey - The API key to build the suffix from
|
|
8
|
-
* @returns A string suffix for storage keys
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export function buildStorageKeySuffix(apiKey) {
|
|
12
|
-
// Note that we hash the API key and use the first 16 characters of the digest.
|
|
13
|
-
const hashed = getMD5Hash(apiKey);
|
|
14
|
-
return hashed.slice(0, 16);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=obfuscation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../../src/shards/obfuscation.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC"}
|