@metamask/profile-sync-controller 9.0.0 → 10.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/CHANGELOG.md +20 -1
- package/dist/controllers/authentication/AuthenticationController.cjs +53 -90
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +53 -90
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +10 -23
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +42 -10
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +42 -10
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +9 -22
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +76 -127
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +10 -4
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +10 -4
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +76 -127
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.cjs +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.mjs +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.cjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.cts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.mts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.mjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
- package/dist/controllers/user-storage/types.cjs +3 -0
- package/dist/controllers/user-storage/types.cjs.map +1 -0
- package/dist/controllers/user-storage/types.d.cts +23 -0
- package/dist/controllers/user-storage/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/types.d.mts +23 -0
- package/dist/controllers/user-storage/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/types.mjs +2 -0
- package/dist/controllers/user-storage/types.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +7 -8
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +8 -9
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +10 -2
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +10 -2
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +1 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +1 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/mocks/auth.cjs +44 -0
- package/dist/sdk/mocks/auth.cjs.map +1 -0
- package/dist/sdk/mocks/auth.d.cts +39 -0
- package/dist/sdk/mocks/auth.d.cts.map +1 -0
- package/dist/sdk/mocks/auth.d.mts +39 -0
- package/dist/sdk/mocks/auth.d.mts.map +1 -0
- package/dist/sdk/mocks/auth.mjs +41 -0
- package/dist/sdk/mocks/auth.mjs.map +1 -0
- package/dist/sdk/mocks/userstorage.cjs +43 -0
- package/dist/sdk/mocks/userstorage.cjs.map +1 -0
- package/dist/sdk/mocks/userstorage.d.cts +10 -0
- package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
- package/dist/sdk/mocks/userstorage.d.mts +10 -0
- package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
- package/dist/sdk/mocks/userstorage.mjs +15 -0
- package/dist/sdk/mocks/userstorage.mjs.map +1 -0
- package/dist/sdk/user-storage.cjs +39 -43
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +13 -8
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +13 -8
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +39 -43
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +12 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +10 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/shared/types/services.cjs +3 -0
- package/dist/shared/types/services.cjs.map +1 -0
- package/dist/shared/types/services.d.cts +10 -0
- package/dist/shared/types/services.d.cts.map +1 -0
- package/dist/shared/types/services.d.mts +10 -0
- package/dist/shared/types/services.d.mts.map +1 -0
- package/dist/shared/types/services.mjs +2 -0
- package/dist/shared/types/services.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/controllers/authentication/services.cjs +0 -132
- package/dist/controllers/authentication/services.cjs.map +0 -1
- package/dist/controllers/authentication/services.d.cts +0 -72
- package/dist/controllers/authentication/services.d.cts.map +0 -1
- package/dist/controllers/authentication/services.d.mts +0 -72
- package/dist/controllers/authentication/services.d.mts.map +0 -1
- package/dist/controllers/authentication/services.mjs +0 -129
- package/dist/controllers/authentication/services.mjs.map +0 -1
- package/dist/controllers/user-storage/services.cjs +0 -306
- package/dist/controllers/user-storage/services.cjs.map +0 -1
- package/dist/controllers/user-storage/services.d.cts +0 -85
- package/dist/controllers/user-storage/services.d.cts.map +0 -1
- package/dist/controllers/user-storage/services.d.mts +0 -85
- package/dist/controllers/user-storage/services.d.mts.map +0 -1
- package/dist/controllers/user-storage/services.mjs +0 -276
- package/dist/controllers/user-storage/services.mjs.map +0 -1
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.deleteUserStorageAllFeatureEntries = exports.batchDeleteUserStorage = exports.deleteUserStorage = exports.batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries = exports.batchUpsertUserStorage = exports.upsertUserStorage = exports.getUserStorageAllFeatureEntries = exports.getUserStorage = exports.USER_STORAGE_ENDPOINT = exports.USER_STORAGE_API = void 0;
|
|
30
|
-
const loglevel_1 = __importDefault(require("loglevel"));
|
|
31
|
-
const encryption_1 = __importStar(require("../../shared/encryption/index.cjs"));
|
|
32
|
-
const constants_1 = require("../../shared/encryption/constants.cjs");
|
|
33
|
-
const env_1 = require("../../shared/env.cjs");
|
|
34
|
-
const storage_schema_1 = require("../../shared/storage-schema.cjs");
|
|
35
|
-
const ENV_URLS = (0, env_1.getEnvUrls)(env_1.Env.PRD);
|
|
36
|
-
exports.USER_STORAGE_API = ENV_URLS.userStorageApiUrl;
|
|
37
|
-
exports.USER_STORAGE_ENDPOINT = `${exports.USER_STORAGE_API}/api/v1/userstorage`;
|
|
38
|
-
/**
|
|
39
|
-
* User Storage Service - Get Storage Entry.
|
|
40
|
-
*
|
|
41
|
-
* @param opts - User Storage Options
|
|
42
|
-
* @returns The storage entry, or null if fails to find entry
|
|
43
|
-
*/
|
|
44
|
-
async function getUserStorage(opts) {
|
|
45
|
-
try {
|
|
46
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
47
|
-
const encryptedPath = (0, storage_schema_1.createEntryPath)(path, storageKey);
|
|
48
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
49
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
50
|
-
headers: {
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
// Acceptable error - since indicates entry does not exist.
|
|
56
|
-
if (userStorageResponse.status === 404) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
if (userStorageResponse.status !== 200) {
|
|
60
|
-
throw new Error(`Unable to get User Storage - HTTP ${userStorageResponse.status}`);
|
|
61
|
-
}
|
|
62
|
-
const userStorage = await userStorageResponse.json();
|
|
63
|
-
const encryptedData = userStorage?.Data ?? null;
|
|
64
|
-
/* istanbul ignore if - this is an edge case where our endpoint returns invalid JSON payload */
|
|
65
|
-
if (!encryptedData) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const decryptedData = await encryption_1.default.decryptString(encryptedData, opts.storageKey, nativeScryptCrypto);
|
|
69
|
-
// Re-encrypt and re-upload the entry if the salt is random
|
|
70
|
-
const salt = encryption_1.default.getSalt(encryptedData);
|
|
71
|
-
if (salt.toString() !== constants_1.SHARED_SALT.toString()) {
|
|
72
|
-
await upsertUserStorage(decryptedData, opts);
|
|
73
|
-
}
|
|
74
|
-
return decryptedData;
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
loglevel_1.default.error('Failed to get user storage', e);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.getUserStorage = getUserStorage;
|
|
82
|
-
/**
|
|
83
|
-
* User Storage Service - Get all storage entries for a specific feature.
|
|
84
|
-
*
|
|
85
|
-
* @param opts - User Storage Options
|
|
86
|
-
* @returns The storage entry, or null if fails to find entry
|
|
87
|
-
*/
|
|
88
|
-
async function getUserStorageAllFeatureEntries(opts) {
|
|
89
|
-
try {
|
|
90
|
-
const { bearerToken, path, nativeScryptCrypto } = opts;
|
|
91
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
92
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
93
|
-
headers: {
|
|
94
|
-
'Content-Type': 'application/json',
|
|
95
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
// Acceptable error - since indicates feature does not exist.
|
|
99
|
-
if (userStorageResponse.status === 404) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
if (userStorageResponse.status !== 200) {
|
|
103
|
-
throw new Error(`Unable to get User Storage - HTTP ${userStorageResponse.status}`);
|
|
104
|
-
}
|
|
105
|
-
const userStorage = await userStorageResponse.json();
|
|
106
|
-
if (!Array.isArray(userStorage)) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const decryptedData = [];
|
|
110
|
-
const reEncryptedEntries = [];
|
|
111
|
-
for (const entry of userStorage) {
|
|
112
|
-
/* istanbul ignore if - unreachable if statement, but kept as edge case */
|
|
113
|
-
if (!entry.Data) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
try {
|
|
117
|
-
const data = await encryption_1.default.decryptString(entry.Data, opts.storageKey, nativeScryptCrypto);
|
|
118
|
-
decryptedData.push(data);
|
|
119
|
-
// Re-encrypt the entry if the salt is different from the shared one
|
|
120
|
-
const salt = encryption_1.default.getSalt(entry.Data);
|
|
121
|
-
if (salt.toString() !== constants_1.SHARED_SALT.toString()) {
|
|
122
|
-
reEncryptedEntries.push([
|
|
123
|
-
entry.HashedKey,
|
|
124
|
-
await encryption_1.default.encryptString(data, opts.storageKey, nativeScryptCrypto),
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
// do nothing
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// Re-upload the re-encrypted entries
|
|
133
|
-
if (reEncryptedEntries.length) {
|
|
134
|
-
await batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(reEncryptedEntries, opts);
|
|
135
|
-
}
|
|
136
|
-
return decryptedData;
|
|
137
|
-
}
|
|
138
|
-
catch (e) {
|
|
139
|
-
loglevel_1.default.error('Failed to get user storage', e);
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.getUserStorageAllFeatureEntries = getUserStorageAllFeatureEntries;
|
|
144
|
-
/**
|
|
145
|
-
* User Storage Service - Set Storage Entry.
|
|
146
|
-
*
|
|
147
|
-
* @param data - data to store
|
|
148
|
-
* @param opts - storage options
|
|
149
|
-
*/
|
|
150
|
-
async function upsertUserStorage(data, opts) {
|
|
151
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
152
|
-
const encryptedData = await encryption_1.default.encryptString(data, opts.storageKey, nativeScryptCrypto);
|
|
153
|
-
const encryptedPath = (0, storage_schema_1.createEntryPath)(path, storageKey);
|
|
154
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
155
|
-
const res = await fetch(url.toString(), {
|
|
156
|
-
method: 'PUT',
|
|
157
|
-
headers: {
|
|
158
|
-
'Content-Type': 'application/json',
|
|
159
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
160
|
-
},
|
|
161
|
-
body: JSON.stringify({ data: encryptedData }),
|
|
162
|
-
});
|
|
163
|
-
if (!res.ok) {
|
|
164
|
-
throw new Error(`user-storage - unable to upsert data - HTTP ${res.status}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.upsertUserStorage = upsertUserStorage;
|
|
168
|
-
/**
|
|
169
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
170
|
-
* You cannot use this method to set multiple features at once.
|
|
171
|
-
*
|
|
172
|
-
* @param data - data to store, in the form of an array of [entryKey, entryValue] pairs
|
|
173
|
-
* @param opts - storage options
|
|
174
|
-
*/
|
|
175
|
-
async function batchUpsertUserStorage(data, opts) {
|
|
176
|
-
if (!data.length) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
180
|
-
const encryptedData = [];
|
|
181
|
-
for (const d of data) {
|
|
182
|
-
encryptedData.push([
|
|
183
|
-
(0, encryption_1.createSHA256Hash)(d[0] + storageKey),
|
|
184
|
-
await encryption_1.default.encryptString(d[1], opts.storageKey, nativeScryptCrypto),
|
|
185
|
-
]);
|
|
186
|
-
}
|
|
187
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
188
|
-
const formattedData = Object.fromEntries(encryptedData);
|
|
189
|
-
const res = await fetch(url.toString(), {
|
|
190
|
-
method: 'PUT',
|
|
191
|
-
headers: {
|
|
192
|
-
'Content-Type': 'application/json',
|
|
193
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
194
|
-
},
|
|
195
|
-
body: JSON.stringify({ data: formattedData }),
|
|
196
|
-
});
|
|
197
|
-
if (!res.ok) {
|
|
198
|
-
throw new Error(`user-storage - unable to batch upsert data - HTTP ${res.status}`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.batchUpsertUserStorage = batchUpsertUserStorage;
|
|
202
|
-
/**
|
|
203
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
204
|
-
* You cannot use this method to set multiple features at once.
|
|
205
|
-
*
|
|
206
|
-
* @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs
|
|
207
|
-
* @param opts - storage options
|
|
208
|
-
*/
|
|
209
|
-
async function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(encryptedData, opts) {
|
|
210
|
-
if (!encryptedData.length) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const { bearerToken, path } = opts;
|
|
214
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
215
|
-
const formattedData = Object.fromEntries(encryptedData);
|
|
216
|
-
const res = await fetch(url.toString(), {
|
|
217
|
-
method: 'PUT',
|
|
218
|
-
headers: {
|
|
219
|
-
'Content-Type': 'application/json',
|
|
220
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
221
|
-
},
|
|
222
|
-
body: JSON.stringify({ data: formattedData }),
|
|
223
|
-
});
|
|
224
|
-
if (!res.ok) {
|
|
225
|
-
throw new Error(`user-storage - unable to batch upsert data - HTTP ${res.status}`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
exports.batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries = batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries;
|
|
229
|
-
/**
|
|
230
|
-
* User Storage Service - Delete Storage Entry.
|
|
231
|
-
*
|
|
232
|
-
* @param opts - User Storage Options
|
|
233
|
-
*/
|
|
234
|
-
async function deleteUserStorage(opts) {
|
|
235
|
-
const { bearerToken, path, storageKey } = opts;
|
|
236
|
-
const encryptedPath = (0, storage_schema_1.createEntryPath)(path, storageKey);
|
|
237
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${encryptedPath}`);
|
|
238
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
239
|
-
method: 'DELETE',
|
|
240
|
-
headers: {
|
|
241
|
-
'Content-Type': 'application/json',
|
|
242
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
if (userStorageResponse.status === 404) {
|
|
246
|
-
throw new Error(`user-storage - feature/entry not found - HTTP ${userStorageResponse.status}`);
|
|
247
|
-
}
|
|
248
|
-
if (!userStorageResponse.ok) {
|
|
249
|
-
throw new Error(`user-storage - unable to delete data - HTTP ${userStorageResponse.status}`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
exports.deleteUserStorage = deleteUserStorage;
|
|
253
|
-
/**
|
|
254
|
-
* User Storage Service - Delete multiple storage entries for one specific feature.
|
|
255
|
-
* You cannot use this method to delete multiple features at once.
|
|
256
|
-
*
|
|
257
|
-
* @param data - data to delete, in the form of an array entryKey[]
|
|
258
|
-
* @param opts - storage options
|
|
259
|
-
*/
|
|
260
|
-
async function batchDeleteUserStorage(data, opts) {
|
|
261
|
-
if (!data.length) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
const { bearerToken, path, storageKey } = opts;
|
|
265
|
-
const encryptedData = [];
|
|
266
|
-
for (const d of data) {
|
|
267
|
-
encryptedData.push((0, encryption_1.createSHA256Hash)(d + storageKey));
|
|
268
|
-
}
|
|
269
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
270
|
-
const res = await fetch(url.toString(), {
|
|
271
|
-
method: 'PUT',
|
|
272
|
-
headers: {
|
|
273
|
-
'Content-Type': 'application/json',
|
|
274
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
275
|
-
},
|
|
276
|
-
body: JSON.stringify({ batch_delete: encryptedData }),
|
|
277
|
-
});
|
|
278
|
-
if (!res.ok) {
|
|
279
|
-
throw new Error(`user-storage - unable to batch delete data - HTTP ${res.status}`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
exports.batchDeleteUserStorage = batchDeleteUserStorage;
|
|
283
|
-
/**
|
|
284
|
-
* User Storage Service - Delete all storage entries for a specific feature.
|
|
285
|
-
*
|
|
286
|
-
* @param opts - User Storage Options
|
|
287
|
-
*/
|
|
288
|
-
async function deleteUserStorageAllFeatureEntries(opts) {
|
|
289
|
-
const { bearerToken, path } = opts;
|
|
290
|
-
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
291
|
-
const userStorageResponse = await fetch(url.toString(), {
|
|
292
|
-
method: 'DELETE',
|
|
293
|
-
headers: {
|
|
294
|
-
'Content-Type': 'application/json',
|
|
295
|
-
Authorization: `Bearer ${bearerToken}`,
|
|
296
|
-
},
|
|
297
|
-
});
|
|
298
|
-
if (userStorageResponse.status === 404) {
|
|
299
|
-
throw new Error(`user-storage - feature not found - HTTP ${userStorageResponse.status}`);
|
|
300
|
-
}
|
|
301
|
-
if (!userStorageResponse.ok) {
|
|
302
|
-
throw new Error(`user-storage - unable to delete data - HTTP ${userStorageResponse.status}`);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
exports.deleteUserStorageAllFeatureEntries = deleteUserStorageAllFeatureEntries;
|
|
306
|
-
//# sourceMappingURL=services.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA2B;AAE3B,gFAAuE;AACvE,qEAAgE;AAChE,8CAAmD;AAKnD,oEAA8D;AAG9D,MAAM,QAAQ,GAAG,IAAA,gBAAU,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAExB,QAAA,gBAAgB,GAAW,QAAQ,CAAC,iBAAiB,CAAC;AACtD,QAAA,qBAAqB,GAAG,GAAG,wBAAgB,qBAAqB,CAAC;AA+B9E;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,IAAwB;IAExB,IAAI;QACF,MAAM,EAAE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AC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,IAAI,KAAK,CACb,qDAAqD,GAAG,CAAC,MAAM,EAAE,CAClE,CAAC;KACH;AACH,CAAC;AAjCD,wDAiCC;AAED;;;;GAIG;AACI,KAAK,UAAU,kCAAkC,CACtD,IAAyC;IAEzC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,6BAAqB,IAAI,IAAI,EAAE,CAAC,CAAC;IAExD,MAAM,mBAAmB,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QACtD,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAC;IAEH,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,2CAA2C,mBAAmB,CAAC,MAAM,EAAE,CACxE,CAAC;KACH;IAED,IAAI,CAAC,mBAAmB,CAAC,EAAE,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,+CAA+C,mBAAmB,CAAC,MAAM,EAAE,CAC5E,CAAC;KACH;AACH,CAAC;AAzBD,gFAyBC","sourcesContent":["import log from 'loglevel';\n\nimport encryption, { createSHA256Hash } from '../../shared/encryption';\nimport { SHARED_SALT } from '../../shared/encryption/constants';\nimport { Env, getEnvUrls } from '../../shared/env';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport { createEntryPath } from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nexport const USER_STORAGE_API: string = ENV_URLS.userStorageApiUrl;\nexport const USER_STORAGE_ENDPOINT = `${USER_STORAGE_API}/api/v1/userstorage`;\n\n/**\n * This is the Server Response shape for a feature entry.\n */\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\n/**\n * User Storage Service - Get Storage Entry.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorage(\n opts: UserStorageOptions,\n): Promise<string | null> {\n try {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates entry does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error(\n `Unable to get User Storage - HTTP ${userStorageResponse.status}`,\n );\n }\n\n const userStorage: GetUserStorageResponse | null =\n await userStorageResponse.json();\n const encryptedData = userStorage?.Data ?? null;\n\n /* istanbul ignore if - this is an edge case where our endpoint returns invalid JSON payload */\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n opts.storageKey,\n nativeScryptCrypto,\n );\n\n // Re-encrypt and re-upload the entry if the salt is random\n const salt = encryption.getSalt(encryptedData);\n if (salt.toString() !== SHARED_SALT.toString()) {\n await upsertUserStorage(decryptedData, opts);\n }\n\n return decryptedData;\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Get all storage entries for a specific feature.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorageAllFeatureEntries(\n opts: UserStorageAllFeatureEntriesOptions,\n): Promise<string[] | null> {\n try {\n const { bearerToken, path, nativeScryptCrypto } = opts;\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates feature does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error(\n `Unable to get User Storage - HTTP ${userStorageResponse.status}`,\n );\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await userStorageResponse.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData: string[] = [];\n const reEncryptedEntries: [string, string][] = [];\n\n for (const entry of userStorage) {\n /* istanbul ignore if - unreachable if statement, but kept as edge case */\n if (!entry.Data) {\n continue;\n }\n\n try {\n const data = await encryption.decryptString(\n entry.Data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n decryptedData.push(data);\n\n // Re-encrypt the entry if the salt is different from the shared one\n const salt = encryption.getSalt(entry.Data);\n if (salt.toString() !== SHARED_SALT.toString()) {\n reEncryptedEntries.push([\n entry.HashedKey,\n await encryption.encryptString(\n data,\n opts.storageKey,\n nativeScryptCrypto,\n ),\n ]);\n }\n } catch {\n // do nothing\n }\n }\n\n // Re-upload the re-encrypted entries\n if (reEncryptedEntries.length) {\n await batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n reEncryptedEntries,\n opts,\n );\n }\n\n return decryptedData;\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Set Storage Entry.\n *\n * @param data - data to store\n * @param opts - storage options\n */\nexport async function upsertUserStorage(\n data: string,\n opts: UserStorageOptions,\n): Promise<void> {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedData = await encryption.encryptString(\n data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Set multiple storage entries for one specific feature.\n * You cannot use this method to set multiple features at once.\n *\n * @param data - data to store, in the form of an array of [entryKey, entryValue] pairs\n * @param opts - storage options\n */\nexport async function batchUpsertUserStorage(\n data: [string, string][],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!data.length) {\n return;\n }\n\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedData: string[][] = [];\n\n for (const d of data) {\n encryptedData.push([\n createSHA256Hash(d[0] + storageKey),\n await encryption.encryptString(d[1], opts.storageKey, nativeScryptCrypto),\n ]);\n }\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const formattedData = Object.fromEntries(encryptedData);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: formattedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Set multiple storage entries for one specific feature.\n * You cannot use this method to set multiple features at once.\n *\n * @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs\n * @param opts - storage options\n */\nexport async function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n encryptedData: [string, string][],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!encryptedData.length) {\n return;\n }\n\n const { bearerToken, path } = opts;\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const formattedData = Object.fromEntries(encryptedData);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: formattedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch upsert data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete Storage Entry.\n *\n * @param opts - User Storage Options\n */\nexport async function deleteUserStorage(\n opts: UserStorageOptions,\n): Promise<void> {\n const { bearerToken, path, storageKey } = opts;\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n if (userStorageResponse.status === 404) {\n throw new Error(\n `user-storage - feature/entry not found - HTTP ${userStorageResponse.status}`,\n );\n }\n\n if (!userStorageResponse.ok) {\n throw new Error(\n `user-storage - unable to delete data - HTTP ${userStorageResponse.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete multiple storage entries for one specific feature.\n * You cannot use this method to delete multiple features at once.\n *\n * @param data - data to delete, in the form of an array entryKey[]\n * @param opts - storage options\n */\nexport async function batchDeleteUserStorage(\n data: string[],\n opts: UserStorageBatchUpsertOptions,\n): Promise<void> {\n if (!data.length) {\n return;\n }\n\n const { bearerToken, path, storageKey } = opts;\n\n const encryptedData: string[] = [];\n\n for (const d of data) {\n encryptedData.push(createSHA256Hash(d + storageKey));\n }\n\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n\n body: JSON.stringify({ batch_delete: encryptedData }),\n });\n\n if (!res.ok) {\n throw new Error(\n `user-storage - unable to batch delete data - HTTP ${res.status}`,\n );\n }\n}\n\n/**\n * User Storage Service - Delete all storage entries for a specific feature.\n *\n * @param opts - User Storage Options\n */\nexport async function deleteUserStorageAllFeatureEntries(\n opts: UserStorageAllFeatureEntriesOptions,\n): Promise<void> {\n const { bearerToken, path } = opts;\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n if (userStorageResponse.status === 404) {\n throw new Error(\n `user-storage - feature not found - HTTP ${userStorageResponse.status}`,\n );\n }\n\n if (!userStorageResponse.ok) {\n throw new Error(\n `user-storage - unable to delete data - HTTP ${userStorageResponse.status}`,\n );\n }\n}\n"]}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "../../shared/storage-schema.cjs";
|
|
2
|
-
import type { NativeScrypt } from "../../shared/types/encryption.cjs";
|
|
3
|
-
export declare const USER_STORAGE_API: string;
|
|
4
|
-
export declare const USER_STORAGE_ENDPOINT: string;
|
|
5
|
-
/**
|
|
6
|
-
* This is the Server Response shape for a feature entry.
|
|
7
|
-
*/
|
|
8
|
-
export type GetUserStorageResponse = {
|
|
9
|
-
HashedKey: string;
|
|
10
|
-
Data: string;
|
|
11
|
-
};
|
|
12
|
-
export type GetUserStorageAllFeatureEntriesResponse = {
|
|
13
|
-
HashedKey: string;
|
|
14
|
-
Data: string;
|
|
15
|
-
}[];
|
|
16
|
-
export type UserStorageBaseOptions = {
|
|
17
|
-
bearerToken: string;
|
|
18
|
-
storageKey: string;
|
|
19
|
-
nativeScryptCrypto?: NativeScrypt;
|
|
20
|
-
};
|
|
21
|
-
export type UserStorageOptions = UserStorageBaseOptions & {
|
|
22
|
-
path: UserStoragePathWithFeatureAndKey;
|
|
23
|
-
};
|
|
24
|
-
export type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {
|
|
25
|
-
path: UserStoragePathWithFeatureOnly;
|
|
26
|
-
};
|
|
27
|
-
export type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;
|
|
28
|
-
/**
|
|
29
|
-
* User Storage Service - Get Storage Entry.
|
|
30
|
-
*
|
|
31
|
-
* @param opts - User Storage Options
|
|
32
|
-
* @returns The storage entry, or null if fails to find entry
|
|
33
|
-
*/
|
|
34
|
-
export declare function getUserStorage(opts: UserStorageOptions): Promise<string | null>;
|
|
35
|
-
/**
|
|
36
|
-
* User Storage Service - Get all storage entries for a specific feature.
|
|
37
|
-
*
|
|
38
|
-
* @param opts - User Storage Options
|
|
39
|
-
* @returns The storage entry, or null if fails to find entry
|
|
40
|
-
*/
|
|
41
|
-
export declare function getUserStorageAllFeatureEntries(opts: UserStorageAllFeatureEntriesOptions): Promise<string[] | null>;
|
|
42
|
-
/**
|
|
43
|
-
* User Storage Service - Set Storage Entry.
|
|
44
|
-
*
|
|
45
|
-
* @param data - data to store
|
|
46
|
-
* @param opts - storage options
|
|
47
|
-
*/
|
|
48
|
-
export declare function upsertUserStorage(data: string, opts: UserStorageOptions): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
51
|
-
* You cannot use this method to set multiple features at once.
|
|
52
|
-
*
|
|
53
|
-
* @param data - data to store, in the form of an array of [entryKey, entryValue] pairs
|
|
54
|
-
* @param opts - storage options
|
|
55
|
-
*/
|
|
56
|
-
export declare function batchUpsertUserStorage(data: [string, string][], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
59
|
-
* You cannot use this method to set multiple features at once.
|
|
60
|
-
*
|
|
61
|
-
* @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs
|
|
62
|
-
* @param opts - storage options
|
|
63
|
-
*/
|
|
64
|
-
export declare function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(encryptedData: [string, string][], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* User Storage Service - Delete Storage Entry.
|
|
67
|
-
*
|
|
68
|
-
* @param opts - User Storage Options
|
|
69
|
-
*/
|
|
70
|
-
export declare function deleteUserStorage(opts: UserStorageOptions): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* User Storage Service - Delete multiple storage entries for one specific feature.
|
|
73
|
-
* You cannot use this method to delete multiple features at once.
|
|
74
|
-
*
|
|
75
|
-
* @param data - data to delete, in the form of an array entryKey[]
|
|
76
|
-
* @param opts - storage options
|
|
77
|
-
*/
|
|
78
|
-
export declare function batchDeleteUserStorage(data: string[], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* User Storage Service - Delete all storage entries for a specific feature.
|
|
81
|
-
*
|
|
82
|
-
* @param opts - User Storage Options
|
|
83
|
-
*/
|
|
84
|
-
export declare function deleteUserStorageAllFeatureEntries(opts: UserStorageAllFeatureEntriesOptions): Promise<void>;
|
|
85
|
-
//# sourceMappingURL=services.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,wCAAoC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,0CAAsC;AAIlE,eAAO,MAAM,gBAAgB,EAAE,MAAmC,CAAC;AACnE,eAAO,MAAM,qBAAqB,QAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MA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,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;GAIG;AACH,wBAAsB,kCAAkC,CACtD,IAAI,EAAE,mCAAmC,GACxC,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "../../shared/storage-schema.mjs";
|
|
2
|
-
import type { NativeScrypt } from "../../shared/types/encryption.mjs";
|
|
3
|
-
export declare const USER_STORAGE_API: string;
|
|
4
|
-
export declare const USER_STORAGE_ENDPOINT: string;
|
|
5
|
-
/**
|
|
6
|
-
* This is the Server Response shape for a feature entry.
|
|
7
|
-
*/
|
|
8
|
-
export type GetUserStorageResponse = {
|
|
9
|
-
HashedKey: string;
|
|
10
|
-
Data: string;
|
|
11
|
-
};
|
|
12
|
-
export type GetUserStorageAllFeatureEntriesResponse = {
|
|
13
|
-
HashedKey: string;
|
|
14
|
-
Data: string;
|
|
15
|
-
}[];
|
|
16
|
-
export type UserStorageBaseOptions = {
|
|
17
|
-
bearerToken: string;
|
|
18
|
-
storageKey: string;
|
|
19
|
-
nativeScryptCrypto?: NativeScrypt;
|
|
20
|
-
};
|
|
21
|
-
export type UserStorageOptions = UserStorageBaseOptions & {
|
|
22
|
-
path: UserStoragePathWithFeatureAndKey;
|
|
23
|
-
};
|
|
24
|
-
export type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {
|
|
25
|
-
path: UserStoragePathWithFeatureOnly;
|
|
26
|
-
};
|
|
27
|
-
export type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;
|
|
28
|
-
/**
|
|
29
|
-
* User Storage Service - Get Storage Entry.
|
|
30
|
-
*
|
|
31
|
-
* @param opts - User Storage Options
|
|
32
|
-
* @returns The storage entry, or null if fails to find entry
|
|
33
|
-
*/
|
|
34
|
-
export declare function getUserStorage(opts: UserStorageOptions): Promise<string | null>;
|
|
35
|
-
/**
|
|
36
|
-
* User Storage Service - Get all storage entries for a specific feature.
|
|
37
|
-
*
|
|
38
|
-
* @param opts - User Storage Options
|
|
39
|
-
* @returns The storage entry, or null if fails to find entry
|
|
40
|
-
*/
|
|
41
|
-
export declare function getUserStorageAllFeatureEntries(opts: UserStorageAllFeatureEntriesOptions): Promise<string[] | null>;
|
|
42
|
-
/**
|
|
43
|
-
* User Storage Service - Set Storage Entry.
|
|
44
|
-
*
|
|
45
|
-
* @param data - data to store
|
|
46
|
-
* @param opts - storage options
|
|
47
|
-
*/
|
|
48
|
-
export declare function upsertUserStorage(data: string, opts: UserStorageOptions): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
51
|
-
* You cannot use this method to set multiple features at once.
|
|
52
|
-
*
|
|
53
|
-
* @param data - data to store, in the form of an array of [entryKey, entryValue] pairs
|
|
54
|
-
* @param opts - storage options
|
|
55
|
-
*/
|
|
56
|
-
export declare function batchUpsertUserStorage(data: [string, string][], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
59
|
-
* You cannot use this method to set multiple features at once.
|
|
60
|
-
*
|
|
61
|
-
* @param encryptedData - data to store, in the form of an array of [hashedKey, encryptedData] pairs
|
|
62
|
-
* @param opts - storage options
|
|
63
|
-
*/
|
|
64
|
-
export declare function batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(encryptedData: [string, string][], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* User Storage Service - Delete Storage Entry.
|
|
67
|
-
*
|
|
68
|
-
* @param opts - User Storage Options
|
|
69
|
-
*/
|
|
70
|
-
export declare function deleteUserStorage(opts: UserStorageOptions): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* User Storage Service - Delete multiple storage entries for one specific feature.
|
|
73
|
-
* You cannot use this method to delete multiple features at once.
|
|
74
|
-
*
|
|
75
|
-
* @param data - data to delete, in the form of an array entryKey[]
|
|
76
|
-
* @param opts - storage options
|
|
77
|
-
*/
|
|
78
|
-
export declare function batchDeleteUserStorage(data: string[], opts: UserStorageBatchUpsertOptions): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* User Storage Service - Delete all storage entries for a specific feature.
|
|
81
|
-
*
|
|
82
|
-
* @param opts - User Storage Options
|
|
83
|
-
*/
|
|
84
|
-
export declare function deleteUserStorageAllFeatureEntries(opts: UserStorageAllFeatureEntriesOptions): Promise<void>;
|
|
85
|
-
//# sourceMappingURL=services.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,wCAAoC;AAErC,OAAO,KAAK,EAAE,YAAY,EAAE,0CAAsC;AAIlE,eAAO,MAAM,gBAAgB,EAAE,MAAmC,CAAC;AACnE,eAAO,MAAM,qBAAqB,QAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,IAAI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