@casual-simulation/aux-records 4.1.4 → 4.1.5
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/CachingConfigStore.d.ts +2 -1
- package/CachingConfigStore.js +45 -35
- package/CachingConfigStore.js.map +1 -1
- package/ConfigurationStore.d.ts +47 -1
- package/ConfigurationStore.js +25 -0
- package/ConfigurationStore.js.map +1 -1
- package/MemoryStore.d.ts +1 -0
- package/MemoryStore.js +11 -0
- package/MemoryStore.js.map +1 -1
- package/RecordsController.d.ts +2 -2
- package/RecordsController.js +26 -4
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +7 -3
- package/RecordsStore.d.ts +4 -0
- package/ServerConfig.d.ts +6 -4
- package/ServerConfig.js +3 -16
- package/ServerConfig.js.map +1 -1
- package/dns/DNSDomainNameValidator.d.ts +2 -2
- package/dns/DNSDomainNameValidator.js +24 -4
- package/dns/DNSDomainNameValidator.js.map +1 -1
- package/dns/DomainNameValidator.d.ts +8 -6
- package/package.json +1 -1
package/CachingConfigStore.d.ts
CHANGED
|
@@ -22,9 +22,10 @@ export declare class CachingConfigStore implements ConfigurationStore {
|
|
|
22
22
|
constructor(store: ConfigurationStore, cache: Cache, cacheSeconds: number);
|
|
23
23
|
setConfiguration<TKey extends ConfigurationKey>(key: TKey, value: ConfigurationInput<TKey>): Promise<void>;
|
|
24
24
|
getConfiguration<TKey extends ConfigurationKey>(key: TKey, defaultValue?: ConfigurationInput<TKey>): Promise<ConfigurationOutput<TKey> | null>;
|
|
25
|
+
private _getConfiguration;
|
|
25
26
|
getWebConfig(): Promise<WebConfig | null>;
|
|
26
27
|
getPlayerWebManifest(): Promise<WebManifest | null>;
|
|
27
|
-
getSubscriptionConfiguration(): Promise<SubscriptionConfiguration>;
|
|
28
|
+
getSubscriptionConfiguration(): Promise<SubscriptionConfiguration | null>;
|
|
28
29
|
getPrivoConfiguration(): Promise<PrivoConfiguration>;
|
|
29
30
|
getModerationConfig(): Promise<ModerationConfiguration>;
|
|
30
31
|
}
|
package/CachingConfigStore.js
CHANGED
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { PLAYER_WEB_MANIFEST_KEY, WEB_CONFIG_KEY, } from './ConfigurationStore';
|
|
7
|
+
import { CONFIGURATION_SCHEMAS_MAP, MODERATION_CONFIG_KEY, PLAYER_WEB_MANIFEST_KEY, PRIVO_CONFIG_KEY, SUBSCRIPTIONS_CONFIG_KEY, WEB_CONFIG_KEY, } from './ConfigurationStore';
|
|
8
8
|
import { traced } from './tracing/TracingDecorators';
|
|
9
9
|
const TRACE_NAME = 'CachingConfigStore';
|
|
10
10
|
/**
|
|
@@ -29,56 +29,63 @@ export class CachingConfigStore {
|
|
|
29
29
|
async getConfiguration(key, defaultValue) {
|
|
30
30
|
const cached = await this._cache.retrieve(key);
|
|
31
31
|
if (typeof cached !== 'undefined') {
|
|
32
|
-
|
|
32
|
+
if (cached) {
|
|
33
|
+
const schema = CONFIGURATION_SCHEMAS_MAP[key];
|
|
34
|
+
const parsed = schema.safeParse(cached);
|
|
35
|
+
if (!parsed.success) {
|
|
36
|
+
console.warn(`Cached configuration for key "${key}" is invalid:`, parsed.error);
|
|
37
|
+
await this._cache.remove(key);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return parsed.data;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// If null is cached, return that instead of hitting the store again.
|
|
45
|
+
return cached;
|
|
46
|
+
}
|
|
33
47
|
}
|
|
34
48
|
const result = await this._store.getConfiguration(key, defaultValue);
|
|
35
49
|
await this._cache.store(key, result, this._cacheSeconds);
|
|
36
50
|
return result;
|
|
37
51
|
}
|
|
38
|
-
async
|
|
39
|
-
const cached = await this._cache.retrieve(
|
|
52
|
+
async _getConfiguration(key, retrieve) {
|
|
53
|
+
const cached = await this._cache.retrieve(key);
|
|
40
54
|
if (typeof cached !== 'undefined') {
|
|
41
|
-
|
|
55
|
+
if (cached) {
|
|
56
|
+
const schema = CONFIGURATION_SCHEMAS_MAP[key];
|
|
57
|
+
const parsed = schema.safeParse(cached);
|
|
58
|
+
if (!parsed.success) {
|
|
59
|
+
console.warn(`Cached configuration for key "${key}" is invalid:`, parsed.error);
|
|
60
|
+
await this._cache.remove(key);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return parsed.data;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// If null is cached, return that instead of hitting the store again.
|
|
68
|
+
return cached;
|
|
69
|
+
}
|
|
42
70
|
}
|
|
43
|
-
const result = await
|
|
44
|
-
await this._cache.store(
|
|
71
|
+
const result = await retrieve();
|
|
72
|
+
await this._cache.store(key, result, this._cacheSeconds);
|
|
45
73
|
return result;
|
|
46
74
|
}
|
|
75
|
+
async getWebConfig() {
|
|
76
|
+
return (await this._getConfiguration(WEB_CONFIG_KEY, async () => (await this._store.getWebConfig())));
|
|
77
|
+
}
|
|
47
78
|
async getPlayerWebManifest() {
|
|
48
|
-
|
|
49
|
-
if (typeof cached !== 'undefined') {
|
|
50
|
-
return cached;
|
|
51
|
-
}
|
|
52
|
-
const result = await this._store.getPlayerWebManifest();
|
|
53
|
-
await this._cache.store(PLAYER_WEB_MANIFEST_KEY, result, this._cacheSeconds);
|
|
54
|
-
return result;
|
|
79
|
+
return (await this._getConfiguration(PLAYER_WEB_MANIFEST_KEY, async () => (await this._store.getPlayerWebManifest())));
|
|
55
80
|
}
|
|
56
81
|
async getSubscriptionConfiguration() {
|
|
57
|
-
|
|
58
|
-
if (typeof cached !== 'undefined') {
|
|
59
|
-
return cached;
|
|
60
|
-
}
|
|
61
|
-
const result = await this._store.getSubscriptionConfiguration();
|
|
62
|
-
await this._cache.store('subscriptions', result, this._cacheSeconds);
|
|
63
|
-
return result;
|
|
82
|
+
return (await this._getConfiguration(SUBSCRIPTIONS_CONFIG_KEY, async () => (await this._store.getSubscriptionConfiguration())));
|
|
64
83
|
}
|
|
65
84
|
async getPrivoConfiguration() {
|
|
66
|
-
|
|
67
|
-
if (typeof cached !== 'undefined') {
|
|
68
|
-
return cached;
|
|
69
|
-
}
|
|
70
|
-
const result = await this._store.getPrivoConfiguration();
|
|
71
|
-
await this._cache.store('privo', result, this._cacheSeconds);
|
|
72
|
-
return result;
|
|
85
|
+
return (await this._getConfiguration(PRIVO_CONFIG_KEY, async () => (await this._store.getPrivoConfiguration())));
|
|
73
86
|
}
|
|
74
87
|
async getModerationConfig() {
|
|
75
|
-
|
|
76
|
-
if (typeof cached !== 'undefined') {
|
|
77
|
-
return cached;
|
|
78
|
-
}
|
|
79
|
-
const result = await this._store.getModerationConfig();
|
|
80
|
-
await this._cache.store('moderation', result, this._cacheSeconds);
|
|
81
|
-
return result;
|
|
88
|
+
return (await this._getConfiguration(MODERATION_CONFIG_KEY, async () => (await this._store.getModerationConfig())));
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
__decorate([
|
|
@@ -87,6 +94,9 @@ __decorate([
|
|
|
87
94
|
__decorate([
|
|
88
95
|
traced(TRACE_NAME)
|
|
89
96
|
], CachingConfigStore.prototype, "getConfiguration", null);
|
|
97
|
+
__decorate([
|
|
98
|
+
traced(TRACE_NAME)
|
|
99
|
+
], CachingConfigStore.prototype, "_getConfiguration", null);
|
|
90
100
|
__decorate([
|
|
91
101
|
traced(TRACE_NAME)
|
|
92
102
|
], CachingConfigStore.prototype, "getWebConfig", null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CachingConfigStore.js","sourceRoot":"","sources":["CachingConfigStore.ts"],"names":[],"mappings":";;;;;;AAwBA,OAAO,EACH,uBAAuB,EACvB,cA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AAE,CACP,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAEjC,CACf,CAAuB,CAAC;IAC7B,CAAC;IAGK,AAAN,KAAK,CAAC,4BAA4B;QAC9B,OAAO,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAChC,wBAAwB,EACxB,KAAK,IAAI,EAAE,CACP,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAEzC,CACf,CAAqC,CAAC;IAC3C,CAAC;IAGK,AAAN,KAAK,CAAC,qBAAqB;QACvB,OAAO,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAChC,gBAAgB,EAChB,KAAK,IAAI,EAAE,CACP,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAElC,CACf,CAAuB,CAAC;IAC7B,CAAC;IAGK,AAAN,KAAK,CAAC,mBAAmB;QACrB,OAAO,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAChC,qBAAqB,EACrB,KAAK,IAAI,EAAE,CACP,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAEhC,CACf,CAA4B,CAAC;IAClC,CAAC;CACJ;AApIS;IADL,MAAM,CAAC,UAAU,CAAC;0DAOlB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;0DAiClB;AAGa;IADb,MAAM,CAAC,UAAU,CAAC;2DAiClB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;sDASlB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;8DASlB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;sEASlB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;+DASlB;AAGK;IADL,MAAM,CAAC,UAAU,CAAC;6DASlB"}
|
package/ConfigurationStore.d.ts
CHANGED
|
@@ -3,13 +3,35 @@ import { type PrivoConfiguration } from './PrivoConfiguration';
|
|
|
3
3
|
import { type ModerationConfiguration } from './ModerationConfiguration';
|
|
4
4
|
import { type WebConfig } from '@casual-simulation/aux-common';
|
|
5
5
|
import { type WebManifest } from '@casual-simulation/aux-common/common/WebManifest';
|
|
6
|
-
import
|
|
6
|
+
import z from 'zod';
|
|
7
7
|
export declare const SUBSCRIPTIONS_CONFIG_KEY = "subscriptions";
|
|
8
8
|
export declare const PRIVO_CONFIG_KEY = "privo";
|
|
9
9
|
export declare const MODERATION_CONFIG_KEY = "moderation";
|
|
10
10
|
export declare const WEB_CONFIG_KEY = "web";
|
|
11
11
|
export declare const PLAYER_WEB_MANIFEST_KEY = "playerWebManifest";
|
|
12
12
|
export declare const AB1_BOOTSTRAP_KEY = "ab1Bootstrap";
|
|
13
|
+
export declare const METADATA_KEY = "metadata";
|
|
14
|
+
export declare const serverMetadataSchema: (() => z.ZodObject<{
|
|
15
|
+
frontendOrigin: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
16
|
+
apiOrigin: z.ZodString;
|
|
17
|
+
websocketOrigin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
websocketProtocol: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
"apiary-aws": "apiary-aws";
|
|
20
|
+
websocket: "websocket";
|
|
21
|
+
}>>>;
|
|
22
|
+
}, z.core.$strip>) & {
|
|
23
|
+
cache: import("es-toolkit").MemoizeCache<any, z.ZodObject<{
|
|
24
|
+
frontendOrigin: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
25
|
+
apiOrigin: z.ZodString;
|
|
26
|
+
websocketOrigin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
27
|
+
websocketProtocol: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
"apiary-aws": "apiary-aws";
|
|
29
|
+
websocket: "websocket";
|
|
30
|
+
}>>>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
};
|
|
33
|
+
export type ServerMetadataSchema = ReturnType<typeof serverMetadataSchema>;
|
|
34
|
+
export type ServerMetadata = z.infer<ServerMetadataSchema>;
|
|
13
35
|
/**
|
|
14
36
|
* The default configuration values used when no configuration is found in the store.
|
|
15
37
|
*/
|
|
@@ -34,6 +56,10 @@ export interface DefaultConfiguration {
|
|
|
34
56
|
* The default player web manifest.
|
|
35
57
|
*/
|
|
36
58
|
playerWebManifest: WebManifest | null;
|
|
59
|
+
/**
|
|
60
|
+
* The metadata about the server deployment.
|
|
61
|
+
*/
|
|
62
|
+
meta: ServerMetadata | null;
|
|
37
63
|
}
|
|
38
64
|
export declare const CONFIGURATION_SCHEMAS: ({
|
|
39
65
|
readonly key: "subscriptions";
|
|
@@ -724,6 +750,17 @@ export declare const CONFIGURATION_SCHEMAS: ({
|
|
|
724
750
|
timestamp: z.ZodNumber;
|
|
725
751
|
}, z.core.$strip>>;
|
|
726
752
|
}, z.core.$strip>], "version">;
|
|
753
|
+
} | {
|
|
754
|
+
readonly key: "metadata";
|
|
755
|
+
readonly schema: z.ZodObject<{
|
|
756
|
+
frontendOrigin: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
757
|
+
apiOrigin: z.ZodString;
|
|
758
|
+
websocketOrigin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
759
|
+
websocketProtocol: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
760
|
+
"apiary-aws": "apiary-aws";
|
|
761
|
+
websocket: "websocket";
|
|
762
|
+
}>>>;
|
|
763
|
+
}, z.core.$strip>;
|
|
727
764
|
})[];
|
|
728
765
|
/**
|
|
729
766
|
* The schemas for the different configuration values.
|
|
@@ -1406,6 +1443,15 @@ export declare const CONFIGURATION_SCHEMAS_MAP: {
|
|
|
1406
1443
|
timestamp: z.ZodNumber;
|
|
1407
1444
|
}, z.core.$strip>>;
|
|
1408
1445
|
}, z.core.$strip>], "version">;
|
|
1446
|
+
metadata: z.ZodObject<{
|
|
1447
|
+
frontendOrigin: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
1448
|
+
apiOrigin: z.ZodString;
|
|
1449
|
+
websocketOrigin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
1450
|
+
websocketProtocol: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
1451
|
+
"apiary-aws": "apiary-aws";
|
|
1452
|
+
websocket: "websocket";
|
|
1453
|
+
}>>>;
|
|
1454
|
+
}, z.core.$strip>;
|
|
1409
1455
|
};
|
|
1410
1456
|
export declare const CONFIGURATION_KEYS: ConfigurationKey[];
|
|
1411
1457
|
export type ConfigurationKey = (typeof CONFIGURATION_SCHEMAS)[number]['key'];
|
package/ConfigurationStore.js
CHANGED
|
@@ -20,13 +20,36 @@ import { privoSchema } from './PrivoConfiguration';
|
|
|
20
20
|
import { moderationSchema, } from './ModerationConfiguration';
|
|
21
21
|
import { WEB_CONFIG_SCHEMA, } from '@casual-simulation/aux-common';
|
|
22
22
|
import { WEB_MANIFEST_SCHEMA, } from '@casual-simulation/aux-common/common/WebManifest';
|
|
23
|
+
import z from 'zod';
|
|
23
24
|
import { STORED_AUX_SCHEMA } from './webhooks';
|
|
25
|
+
import { memoize } from 'es-toolkit';
|
|
24
26
|
export const SUBSCRIPTIONS_CONFIG_KEY = 'subscriptions';
|
|
25
27
|
export const PRIVO_CONFIG_KEY = 'privo';
|
|
26
28
|
export const MODERATION_CONFIG_KEY = 'moderation';
|
|
27
29
|
export const WEB_CONFIG_KEY = 'web';
|
|
28
30
|
export const PLAYER_WEB_MANIFEST_KEY = 'playerWebManifest';
|
|
29
31
|
export const AB1_BOOTSTRAP_KEY = 'ab1Bootstrap';
|
|
32
|
+
export const METADATA_KEY = 'metadata';
|
|
33
|
+
export const serverMetadataSchema = memoize(() => z.object({
|
|
34
|
+
frontendOrigin: z
|
|
35
|
+
.url()
|
|
36
|
+
.optional()
|
|
37
|
+
.nullable()
|
|
38
|
+
.describe('The HTTP origin that the CasualOS frontend (player) is available at.'),
|
|
39
|
+
apiOrigin: z
|
|
40
|
+
.string()
|
|
41
|
+
.describe('The HTTP origin that the API is available at.'),
|
|
42
|
+
websocketOrigin: z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.nullable()
|
|
46
|
+
.describe('The HTTP origin that the Websocket API is available at.'),
|
|
47
|
+
websocketProtocol: z
|
|
48
|
+
.enum(['websocket', 'apiary-aws'])
|
|
49
|
+
.optional()
|
|
50
|
+
.nullable()
|
|
51
|
+
.describe('The protocol that should be used to connect to the websocket origin.'),
|
|
52
|
+
}));
|
|
30
53
|
export const CONFIGURATION_SCHEMAS = [
|
|
31
54
|
{
|
|
32
55
|
key: SUBSCRIPTIONS_CONFIG_KEY,
|
|
@@ -37,6 +60,7 @@ export const CONFIGURATION_SCHEMAS = [
|
|
|
37
60
|
{ key: WEB_CONFIG_KEY, schema: WEB_CONFIG_SCHEMA },
|
|
38
61
|
{ key: PLAYER_WEB_MANIFEST_KEY, schema: WEB_MANIFEST_SCHEMA },
|
|
39
62
|
{ key: AB1_BOOTSTRAP_KEY, schema: STORED_AUX_SCHEMA },
|
|
63
|
+
{ key: METADATA_KEY, schema: serverMetadataSchema() },
|
|
40
64
|
];
|
|
41
65
|
/**
|
|
42
66
|
* The schemas for the different configuration values.
|
|
@@ -48,6 +72,7 @@ export const CONFIGURATION_SCHEMAS_MAP = {
|
|
|
48
72
|
[WEB_CONFIG_KEY]: WEB_CONFIG_SCHEMA,
|
|
49
73
|
[PLAYER_WEB_MANIFEST_KEY]: WEB_MANIFEST_SCHEMA,
|
|
50
74
|
[AB1_BOOTSTRAP_KEY]: STORED_AUX_SCHEMA,
|
|
75
|
+
[METADATA_KEY]: serverMetadataSchema(),
|
|
51
76
|
};
|
|
52
77
|
export const CONFIGURATION_KEYS = CONFIGURATION_SCHEMAS.map((c) => c.key);
|
|
53
78
|
//# sourceMappingURL=ConfigurationStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationStore.js","sourceRoot":"","sources":["ConfigurationStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,O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C,iBAAiB,CAAC,EAAE,iBAAiB;IACtC,CAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE;CACzC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAuB,qBAAqB,CAAC,GAAG,CAC3E,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CACf,CAAC"}
|
package/MemoryStore.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare class MemoryStore implements AuthStore, RecordsStore, DataRecords
|
|
|
67
67
|
private _loadedPackages;
|
|
68
68
|
private _financialAccounts;
|
|
69
69
|
private _customDomains;
|
|
70
|
+
private _serverMetadata;
|
|
70
71
|
get aiOpenAIRealtimeMetrics(): AIOpenAIRealtimeMetrics[];
|
|
71
72
|
private _purchasedItems;
|
|
72
73
|
private _activationKeys;
|
package/MemoryStore.js
CHANGED
|
@@ -244,6 +244,9 @@ export class MemoryStore {
|
|
|
244
244
|
else if (key === 'ab1Bootstrap') {
|
|
245
245
|
this._ab1Bootstrap = finalValue;
|
|
246
246
|
}
|
|
247
|
+
else if (key === 'metadata') {
|
|
248
|
+
this._serverMetadata = finalValue;
|
|
249
|
+
}
|
|
247
250
|
else {
|
|
248
251
|
throw new Error('Unsupported configuration key: ' + key);
|
|
249
252
|
}
|
|
@@ -282,6 +285,12 @@ export class MemoryStore {
|
|
|
282
285
|
else if (key === 'ab1Bootstrap') {
|
|
283
286
|
return (this._ab1Bootstrap ?? null);
|
|
284
287
|
}
|
|
288
|
+
else if (key === 'metadata') {
|
|
289
|
+
return (this._serverMetadata ??
|
|
290
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
291
|
+
.nullable()
|
|
292
|
+
.parse(defaultValue ?? null));
|
|
293
|
+
}
|
|
285
294
|
else {
|
|
286
295
|
throw new Error('Unsupported configuration key: ' + key);
|
|
287
296
|
}
|
|
@@ -316,6 +325,7 @@ export class MemoryStore {
|
|
|
316
325
|
studioId: domain.studioId,
|
|
317
326
|
verificationKey: domain.verificationKey,
|
|
318
327
|
verified: domain.verified,
|
|
328
|
+
expectedHostName: domain.expectedHostName,
|
|
319
329
|
studio,
|
|
320
330
|
};
|
|
321
331
|
}
|
|
@@ -334,6 +344,7 @@ export class MemoryStore {
|
|
|
334
344
|
studioId: domain.studioId,
|
|
335
345
|
verificationKey: domain.verificationKey,
|
|
336
346
|
verified: domain.verified,
|
|
347
|
+
expectedHostName: domain.expectedHostName,
|
|
337
348
|
studio,
|
|
338
349
|
};
|
|
339
350
|
}
|