@proteinjs/user 1.7.2 → 1.9.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 +26 -0
- package/dist/generated/index.d.ts +0 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +7 -3
- package/dist/generated/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/src/MachineAccount.d.ts +47 -0
- package/dist/src/MachineAccount.d.ts.map +1 -0
- package/dist/src/MachineAccount.js +100 -0
- package/dist/src/MachineAccount.js.map +1 -0
- package/dist/src/ScopedRecord.d.ts +12 -1
- package/dist/src/ScopedRecord.d.ts.map +1 -1
- package/dist/src/ScopedRecord.js +19 -3
- package/dist/src/ScopedRecord.js.map +1 -1
- package/dist/src/UserRepo.d.ts +8 -0
- package/dist/src/UserRepo.d.ts.map +1 -1
- package/dist/src/UserRepo.js +22 -0
- package/dist/src/UserRepo.js.map +1 -1
- package/dist/src/routes.d.ts +11 -0
- package/dist/src/routes.d.ts.map +1 -1
- package/dist/src/routes.js +14 -1
- package/dist/src/routes.js.map +1 -1
- package/dist/src/services/AccountDeletionService.d.ts +27 -0
- package/dist/src/services/AccountDeletionService.d.ts.map +1 -0
- package/dist/src/services/AccountDeletionService.js +6 -0
- package/dist/src/services/AccountDeletionService.js.map +1 -0
- package/dist/src/services/MachineCredentialsService.d.ts +38 -0
- package/dist/src/services/MachineCredentialsService.d.ts.map +1 -0
- package/dist/src/services/MachineCredentialsService.js +6 -0
- package/dist/src/services/MachineCredentialsService.js.map +1 -0
- package/dist/src/services/SetUserStatusService.d.ts +15 -0
- package/dist/src/services/SetUserStatusService.d.ts.map +1 -0
- package/dist/src/services/SetUserStatusService.js +6 -0
- package/dist/src/services/SetUserStatusService.js.map +1 -0
- package/dist/src/services/UpdateUserInfoService.d.ts +16 -1
- package/dist/src/services/UpdateUserInfoService.d.ts.map +1 -1
- package/dist/src/services/UpdateUserInfoService.js.map +1 -1
- package/dist/src/tables/AccountDeletionTable.d.ts +85 -0
- package/dist/src/tables/AccountDeletionTable.d.ts.map +1 -0
- package/dist/src/tables/AccountDeletionTable.js +62 -0
- package/dist/src/tables/AccountDeletionTable.js.map +1 -0
- package/dist/src/tables/SessionTable.d.ts +1 -1
- package/dist/src/tables/UserStatusEventTable.d.ts +30 -0
- package/dist/src/tables/UserStatusEventTable.d.ts.map +1 -0
- package/dist/src/tables/UserStatusEventTable.js +43 -0
- package/dist/src/tables/UserStatusEventTable.js.map +1 -0
- package/dist/src/tables/UserTable.d.ts +48 -2
- package/dist/src/tables/UserTable.d.ts.map +1 -1
- package/dist/src/tables/UserTable.js +75 -4
- package/dist/src/tables/UserTable.js.map +1 -1
- package/dist/src/tables/tables.d.ts +4 -0
- package/dist/src/tables/tables.d.ts.map +1 -1
- package/dist/src/tables/tables.js +4 -0
- package/dist/src/tables/tables.js.map +1 -1
- package/dist/test/tablesAuth.test.js +20 -4
- package/dist/test/tablesAuth.test.js.map +1 -1
- package/generated/index.ts +7 -3
- package/index.ts +6 -0
- package/package.json +4 -4
- package/src/MachineAccount.ts +103 -0
- package/src/ScopedRecord.ts +16 -3
- package/src/UserRepo.ts +25 -0
- package/src/routes.ts +13 -0
- package/src/services/AccountDeletionService.ts +28 -0
- package/src/services/MachineCredentialsService.ts +43 -0
- package/src/services/SetUserStatusService.ts +16 -0
- package/src/services/UpdateUserInfoService.ts +17 -1
- package/src/tables/AccountDeletionTable.ts +98 -0
- package/src/tables/UserStatusEventTable.ts +34 -0
- package/src/tables/UserTable.ts +69 -6
- package/src/tables/tables.ts +4 -0
- package/test/tablesAuth.test.ts +22 -4
|
@@ -6,6 +6,14 @@ export declare const getScopedDb: () => Db<ScopedRecord>;
|
|
|
6
6
|
export declare const getScopedDbAsSystem: <R extends ScopedRecord = ScopedRecord>() => Db<R>;
|
|
7
7
|
export declare function getScopedTables(): Table<ScopedRecord>[];
|
|
8
8
|
export declare function isScopedTable(table: Table<any>): boolean;
|
|
9
|
+
/** Declares a scoped table whose rows deliberately SURVIVE account purge (billing ledger,
|
|
10
|
+
* ops records — casing §7.2/§7.4). Rows become pseudonymous when the user row purges
|
|
11
|
+
* (scope keeps the bare 36-char id). Default is PURGE: a new scoped table is erased unless
|
|
12
|
+
* it declares otherwise — the safe default for a privacy obligation. */
|
|
13
|
+
export interface AccountPurgePolicy {
|
|
14
|
+
readonly retainOnAccountPurge: true;
|
|
15
|
+
}
|
|
16
|
+
export declare function retainedOnAccountPurge(table: Table<any>): boolean;
|
|
9
17
|
/**
|
|
10
18
|
* Wrapper function to add default ScopedRecord columns to your table's columns.
|
|
11
19
|
*
|
|
@@ -18,14 +26,17 @@ export declare function withScopedRecordColumns<T extends ScopedRecord>(columns:
|
|
|
18
26
|
/**
|
|
19
27
|
* Adds the `scope` column as the first column to the provided index.
|
|
20
28
|
*
|
|
21
|
-
* @param args Index to create
|
|
29
|
+
* @param args Index to create (`unique: true` for a scoped UNIQUE index — name it with a
|
|
30
|
+
* `_unique` suffix, matching schema-metadata classification)
|
|
22
31
|
* @returns Index with `scope` column added first
|
|
23
32
|
*/
|
|
24
33
|
export declare function createScopedIndex<T extends ScopedRecord>(args: {
|
|
25
34
|
columns: (keyof T)[];
|
|
26
35
|
name?: string;
|
|
36
|
+
unique?: boolean;
|
|
27
37
|
}): {
|
|
28
38
|
columns: (keyof T)[];
|
|
29
39
|
name?: string;
|
|
40
|
+
unique?: boolean;
|
|
30
41
|
};
|
|
31
42
|
//# sourceMappingURL=ScopedRecord.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedRecord.d.ts","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,EAGN,KAAK,EAGL,EAAE,EACH,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,YAAa,SAAQ,M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AM,YAAY,CAAC,CAAC,EAC7C,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC,CAK9D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE;IAC9D,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG;IAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAM5D"}
|
package/dist/src/ScopedRecord.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,7 +56,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
56
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
57
|
};
|
|
47
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.createScopedIndex = exports.withScopedRecordColumns = exports.isScopedTable = exports.getScopedTables = exports.getScopedDbAsSystem = exports.getScopedDb = void 0;
|
|
59
|
+
exports.createScopedIndex = exports.withScopedRecordColumns = exports.retainedOnAccountPurge = exports.isScopedTable = exports.getScopedTables = exports.getScopedDbAsSystem = exports.getScopedDb = void 0;
|
|
49
60
|
var db_1 = require("@proteinjs/db");
|
|
50
61
|
var UserRepo_1 = require("./UserRepo");
|
|
51
62
|
exports.getScopedDb = (db_1.getDb);
|
|
@@ -109,6 +120,10 @@ function isScopedTable(table) {
|
|
|
109
120
|
return !!scopeColumn;
|
|
110
121
|
}
|
|
111
122
|
exports.isScopedTable = isScopedTable;
|
|
123
|
+
function retainedOnAccountPurge(table) {
|
|
124
|
+
return table.retainOnAccountPurge === true;
|
|
125
|
+
}
|
|
126
|
+
exports.retainedOnAccountPurge = retainedOnAccountPurge;
|
|
112
127
|
/**
|
|
113
128
|
* Wrapper function to add default ScopedRecord columns to your table's columns.
|
|
114
129
|
*
|
|
@@ -124,14 +139,15 @@ exports.withScopedRecordColumns = withScopedRecordColumns;
|
|
|
124
139
|
/**
|
|
125
140
|
* Adds the `scope` column as the first column to the provided index.
|
|
126
141
|
*
|
|
127
|
-
* @param args Index to create
|
|
142
|
+
* @param args Index to create (`unique: true` for a scoped UNIQUE index — name it with a
|
|
143
|
+
* `_unique` suffix, matching schema-metadata classification)
|
|
128
144
|
* @returns Index with `scope` column added first
|
|
129
145
|
*/
|
|
130
146
|
function createScopedIndex(args) {
|
|
131
147
|
if (args.columns.includes('scope')) {
|
|
132
148
|
return args;
|
|
133
149
|
}
|
|
134
|
-
return { columns: __spreadArray(['scope'], args.columns, true), name: args.name };
|
|
150
|
+
return __assign({ columns: __spreadArray(['scope'], args.columns, true), name: args.name }, (args.unique ? { unique: true } : {}));
|
|
135
151
|
}
|
|
136
152
|
exports.createScopedIndex = createScopedIndex;
|
|
137
153
|
//# sourceMappingURL=ScopedRecord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedRecord.js","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScopedRecord.js","sourceRoot":"","sources":["../../src/ScopedRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAUuB;AACvB,uCAAsC;AAMzB,QAAA,WAAW,GAAG,CAAA,UAAmB,CAAA,CAAC;AAExC,IAAM,mBAAmB,GAAG;IACjC,OAAA,IAAI,OAAE,CAAI,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC;AAAhD,CAAgD,CAAC;AADtC,QAAA,mBAAmB,uBACmB;AAEnD;;;;;;;;GAQG;AACH,IAAM,kBAAkB,GAAG,UAAC,SAAiB;IAC3C,IAAM,MAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,gDAAyC,SAAS,+CAA4C;YAC5F,yFAAyF;YACzF,8DAA8D,CACjE,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,IAAM,sBAAsB,GAAG,UAAC,gBAA+B;IAA/B,iCAAA,EAAA,qBAA+B;IAC7D,OAAO;QACL,KAAK,EAAE,IAAI,iBAAY,CAAC,OAAO,EAAE;YAC/B,YAAY,EAAE;gBAAY,sBAAA,kBAAkB,CAAC,OAAO,CAAC,EAAA;qBAAA;YACrD,iBAAiB,EAAE,UAAC,WAAW,IAAK,OAAA,CAAC,WAAW,EAAZ,CAAY;YAChD,0FAA0F;YAC1F,4FAA4F;YAC5F,4FAA4F;YAC5F,uFAAuF;YACvF,SAAS,EAAE,UAAC,WAAW,IAAK,OAAA,CAAC,WAAW,EAAZ,CAAY;YACxC,UAAU,EAAE,UAAO,EAAE,EAAE,WA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,CAAC,OAAO,SAAG,IAAI,EAAE,IAAI,CAAC,IAAI,IAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAG;AAC5G,CAAC;AAVD,8CAUC"}
|
package/dist/src/UserRepo.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { AuthenticatedUser, AuthenticatedUserRepo } from '@proteinjs/user-auth';
|
|
2
2
|
import { User } from './tables/UserTable';
|
|
3
|
+
export type UserChangedListener = (user: User) => void;
|
|
3
4
|
export declare class UserRepo implements AuthenticatedUserRepo {
|
|
5
|
+
private static userChangedListeners;
|
|
6
|
+
/**
|
|
7
|
+
* Subscribe to user-record changes (every `setUser`, i.e. every session-cache refresh after a
|
|
8
|
+
* user-info mutation). Lets UI surfaces (avatar chips, account header) re-render without a
|
|
9
|
+
* reload. Returns an unsubscribe function.
|
|
10
|
+
*/
|
|
11
|
+
static onUserChanged(listener: UserChangedListener): () => void;
|
|
4
12
|
getUser(): Omit<User, 'roles'> & AuthenticatedUser;
|
|
5
13
|
setUser(user: User): void;
|
|
6
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserRepo.d.ts","sourceRoot":"","sources":["../../src/UserRepo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,qBAAa,QAAS,YAAW,qBAAqB;IACpD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,iBAAiB;IAQlD,OAAO,CAAC,IAAI,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"UserRepo.d.ts","sourceRoot":"","sources":["../../src/UserRepo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AAEvD,qBAAa,QAAS,YAAW,qBAAqB;IACpD,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAkC;IAErE;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAO/D,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,iBAAiB;IAQlD,OAAO,CAAC,IAAI,EAAE,IAAI;CAYnB"}
|
package/dist/src/UserRepo.js
CHANGED
|
@@ -6,6 +6,17 @@ var cacheKeys_1 = require("./cacheKeys");
|
|
|
6
6
|
var UserRepo = /** @class */ (function () {
|
|
7
7
|
function UserRepo() {
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Subscribe to user-record changes (every `setUser`, i.e. every session-cache refresh after a
|
|
11
|
+
* user-info mutation). Lets UI surfaces (avatar chips, account header) re-render without a
|
|
12
|
+
* reload. Returns an unsubscribe function.
|
|
13
|
+
*/
|
|
14
|
+
UserRepo.onUserChanged = function (listener) {
|
|
15
|
+
UserRepo.userChangedListeners.add(listener);
|
|
16
|
+
return function () {
|
|
17
|
+
UserRepo.userChangedListeners.delete(listener);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
9
20
|
UserRepo.prototype.getUser = function () {
|
|
10
21
|
var _a;
|
|
11
22
|
var user = Object.assign({}, server_api_1.Session.getDataByKey(cacheKeys_1.USER_SESSION_CACHE_KEY));
|
|
@@ -16,7 +27,18 @@ var UserRepo = /** @class */ (function () {
|
|
|
16
27
|
};
|
|
17
28
|
UserRepo.prototype.setUser = function (user) {
|
|
18
29
|
server_api_1.Session.setDataByKey(cacheKeys_1.USER_SESSION_CACHE_KEY, user);
|
|
30
|
+
UserRepo.userChangedListeners.forEach(function (listener) {
|
|
31
|
+
// Standard emitter isolation: one subscriber throwing must not break the mutation path
|
|
32
|
+
// (or starve the remaining subscribers).
|
|
33
|
+
try {
|
|
34
|
+
listener(user);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('UserRepo userChanged listener threw', error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
19
40
|
};
|
|
41
|
+
UserRepo.userChangedListeners = new Set();
|
|
20
42
|
return UserRepo;
|
|
21
43
|
}());
|
|
22
44
|
exports.UserRepo = UserRepo;
|
package/dist/src/UserRepo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserRepo.js","sourceRoot":"","sources":["../../src/UserRepo.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAGhD,yCAAqD;
|
|
1
|
+
{"version":3,"file":"UserRepo.js","sourceRoot":"","sources":["../../src/UserRepo.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAGhD,yCAAqD;AAIrD;IAAA;IAmCA,CAAC;IAhCC;;;;OAIG;IACI,sBAAa,GAApB,UAAqB,QAA6B;QAChD,QAAQ,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO;YACL,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC;IAED,0BAAO,GAAP;;QACE,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,oBAAO,CAAC,YAAY,CAAO,kCAAsB,CAAC,CAAC,CAAC;QACnF,4FAA4F;QAC5F,+EAA+E;QAC/E,IAAM,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,0BAAO,GAAP,UAAQ,IAAU;QAChB,oBAAO,CAAC,YAAY,CAAC,kCAAsB,EAAE,IAAI,CAAC,CAAC;QACnD,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAC,QAAQ;YAC7C,uFAAuF;YACvF,yCAAyC;YACzC,IAAI;gBACF,QAAQ,CAAC,IAAI,CAAC,CAAC;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;aAC7D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAjCc,6BAAoB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAkCvE,eAAC;CAAA,AAnCD,IAmCC;AAnCY,4BAAQ"}
|
package/dist/src/routes.d.ts
CHANGED
|
@@ -4,6 +4,17 @@ export declare const routes: {
|
|
|
4
4
|
method: 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Avatar-photo URL contract (server route: user-server src/routes/avatar.ts): the path is stable
|
|
9
|
+
* per user, so responses are cached hard (max-age=86400, immutable) and the `v` query param busts
|
|
10
|
+
* the cache — pass the user's current `avatarFileId`, which changes on every photo update. Users
|
|
11
|
+
* with an emoji avatar or no avatar answer 404 (clients render emoji/initials from the user
|
|
12
|
+
* record; the route serves photos only).
|
|
13
|
+
*/
|
|
14
|
+
export declare const avatarRoute: {
|
|
15
|
+
path: (userId: string, avatarFileId: string) => string;
|
|
16
|
+
method: "get";
|
|
17
|
+
};
|
|
7
18
|
export declare const uiRoutes: {
|
|
8
19
|
auth: {
|
|
9
20
|
login: string;
|
package/dist/src/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;KAAE,CAAA;CAM3G,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;CAOpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;KAAE,CAAA;CAM3G,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;mBACP,MAAM,gBAAgB,MAAM;;CAG5C,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;CAOpB,CAAC"}
|
package/dist/src/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uiRoutes = exports.routes = void 0;
|
|
3
|
+
exports.uiRoutes = exports.avatarRoute = exports.routes = void 0;
|
|
4
4
|
exports.routes = {
|
|
5
5
|
login: { path: '/user/login', method: 'post' },
|
|
6
6
|
initiatePasswordReset: { path: '/user/initiate-password-reset', method: 'post' },
|
|
@@ -8,6 +8,19 @@ exports.routes = {
|
|
|
8
8
|
validateResetToken: { path: '/user/validate-reset-token', method: 'get' },
|
|
9
9
|
logout: { path: '/user/logout', method: 'get' },
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Avatar-photo URL contract (server route: user-server src/routes/avatar.ts): the path is stable
|
|
13
|
+
* per user, so responses are cached hard (max-age=86400, immutable) and the `v` query param busts
|
|
14
|
+
* the cache — pass the user's current `avatarFileId`, which changes on every photo update. Users
|
|
15
|
+
* with an emoji avatar or no avatar answer 404 (clients render emoji/initials from the user
|
|
16
|
+
* record; the route serves photos only).
|
|
17
|
+
*/
|
|
18
|
+
exports.avatarRoute = {
|
|
19
|
+
path: function (userId, avatarFileId) {
|
|
20
|
+
return "/avatar/".concat(encodeURIComponent(userId), "?v=").concat(encodeURIComponent(avatarFileId));
|
|
21
|
+
},
|
|
22
|
+
method: 'get',
|
|
23
|
+
};
|
|
11
24
|
exports.uiRoutes = {
|
|
12
25
|
auth: {
|
|
13
26
|
login: 'login',
|
package/dist/src/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAA8F;IAC/G,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE;IAC9C,qBAAqB,EAAE,EAAE,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,EAAE;IAChF,oBAAoB,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE;IAC9E,kBAAkB,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE,MAAM,EAAE,KAAK,EAAE;IACzE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE;CAChD,CAAC;AAEW,QAAA,QAAQ,GAAG;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;QACd,cAAc,EAAE,uBAAuB;QACvC,aAAa,EAAE,sBAAsB;QACrC,MAAM,EAAE,QAAQ;KACjB;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAA8F;IAC/G,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE;IAC9C,qBAAqB,EAAE,EAAE,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,EAAE;IAChF,oBAAoB,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,EAAE;IAC9E,kBAAkB,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE,MAAM,EAAE,KAAK,EAAE;IACzE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE;CAChD,CAAC;AAEF;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,UAAC,MAAc,EAAE,YAAoB;QACzC,OAAA,kBAAW,kBAAkB,CAAC,MAAM,CAAC,gBAAM,kBAAkB,CAAC,YAAY,CAAC,CAAE;IAA7E,CAA6E;IAC/E,MAAM,EAAE,KAAc;CACvB,CAAC;AAEW,QAAA,QAAQ,GAAG;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;QACd,cAAc,EAAE,uBAAuB;QACvC,aAAa,EAAE,sBAAsB;QACrC,MAAM,EAAE,QAAQ;KACjB;CACF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Service } from '@proteinjs/service';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
export declare const getAccountDeletionService: () => AccountDeletionService;
|
|
4
|
+
/**
|
|
5
|
+
* In-app account deletion, archive-then-purge: the synchronous call deactivates the account
|
|
6
|
+
* ("gone right away" — shares revoked both directions, sessions killed), and the background
|
|
7
|
+
* purge walker erases everything after the grace window. Logging back in during grace cancels
|
|
8
|
+
* (full restore, including shares — the login route runs the cancel hook, not this service).
|
|
9
|
+
*
|
|
10
|
+
* Acts ONLY on the session user — no target parameter, so the only authz surface beyond the
|
|
11
|
+
* door is the password re-auth inside the call. Door: any authenticated user (`allUsers`,
|
|
12
|
+
* declared on the implementation's serviceMetadata).
|
|
13
|
+
*/
|
|
14
|
+
export interface AccountDeletionService extends Service {
|
|
15
|
+
/**
|
|
16
|
+
* Deactivate the session user's account and schedule the purge. Idempotent: a re-call after a
|
|
17
|
+
* partial failure resumes from the stored deletion manifest (never re-enumerates). The
|
|
18
|
+
* caller's sessions are killed last — the response is the last authenticated exchange.
|
|
19
|
+
*
|
|
20
|
+
* @param password re-auth — must match the session user's password
|
|
21
|
+
* @returns the purge date, for the UI's confirmation copy
|
|
22
|
+
*/
|
|
23
|
+
requestDeletion(password: string): Promise<{
|
|
24
|
+
purgeAfter: Moment;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=AccountDeletionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionService.d.ts","sourceRoot":"","sources":["../../../src/services/AccountDeletionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,yBAAyB,8BAErC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO;IACrD;;;;;;;OAOG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccountDeletionService = void 0;
|
|
4
|
+
var service_1 = require("@proteinjs/service");
|
|
5
|
+
exports.getAccountDeletionService = (0, service_1.serviceFactory)('@proteinjs/user/AccountDeletionService');
|
|
6
|
+
//# sourceMappingURL=AccountDeletionService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionService.js","sourceRoot":"","sources":["../../../src/services/AccountDeletionService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAGhD,QAAA,yBAAyB,GAAG,IAAA,wBAAc,EACrD,wCAAwC,CACzC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Service } from '@proteinjs/service';
|
|
2
|
+
export declare const getMachineCredentialsService: () => MachineCredentialsService;
|
|
3
|
+
/** The one-time view of a minted machine credential — the plaintext is never stored. */
|
|
4
|
+
export type MintedMachineCredential = {
|
|
5
|
+
/** The machine account the credential was minted for. */
|
|
6
|
+
email: string;
|
|
7
|
+
/** The generated password — shown exactly ONCE; only its hash is stored. */
|
|
8
|
+
password: string;
|
|
9
|
+
/** The Secret Manager secret the declaration names as the credential's home. */
|
|
10
|
+
secretName: string;
|
|
11
|
+
/** Operator instruction: where to paste the plaintext and what activates it. */
|
|
12
|
+
note: string;
|
|
13
|
+
};
|
|
14
|
+
/** A declared machine account joined with its row state — the admin surface renders these. */
|
|
15
|
+
export type MachineAccountView = {
|
|
16
|
+
email: string;
|
|
17
|
+
accountName: string;
|
|
18
|
+
roles: string[];
|
|
19
|
+
secretName: string;
|
|
20
|
+
/** 'pending first boot' until the boot sync has created/adopted the row. */
|
|
21
|
+
status: 'active' | 'deactivated' | 'pending first boot';
|
|
22
|
+
/** Whether a credential has ever been minted/provisioned (hash present on the row). */
|
|
23
|
+
hasCredential: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Credential minting for code-declared machine accounts (`MachineAccount`): identity and grants
|
|
27
|
+
* live in source; the credential is the ONLY runtime-provisioned piece. Minting generates a
|
|
28
|
+
* strong random password, stores its hash on the account row (no human-chosen passwords), kills
|
|
29
|
+
* the account's sessions, and returns the plaintext once for pasting into the declaration's
|
|
30
|
+
* Secret Manager secret. The same call rotates. Machine rows only — human credentials go
|
|
31
|
+
* through the password-reset flow.
|
|
32
|
+
*/
|
|
33
|
+
export interface MachineCredentialsService extends Service {
|
|
34
|
+
/** Every declared machine account with its row state, for the admin surface. */
|
|
35
|
+
listMachineAccounts(): Promise<MachineAccountView[]>;
|
|
36
|
+
mintCredential(email: string): Promise<MintedMachineCredential>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=MachineCredentialsService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MachineCredentialsService.d.ts","sourceRoot":"","sources":["../../../src/services/MachineCredentialsService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAE7D,eAAO,MAAM,4BAA4B,iCAExC,CAAC;AAEF,wFAAwF;AACxF,MAAM,MAAM,uBAAuB,GAAG;IACpC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE,QAAQ,GAAG,aAAa,GAAG,oBAAoB,CAAC;IACxD,uFAAuF;IACvF,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,yBAA0B,SAAQ,OAAO;IACxD,gFAAgF;IAChF,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACjE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMachineCredentialsService = void 0;
|
|
4
|
+
var service_1 = require("@proteinjs/service");
|
|
5
|
+
exports.getMachineCredentialsService = (0, service_1.serviceFactory)('@proteinjs/user/MachineCredentialsService');
|
|
6
|
+
//# sourceMappingURL=MachineCredentialsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MachineCredentialsService.js","sourceRoot":"","sources":["../../../src/services/MachineCredentialsService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAEhD,QAAA,4BAA4B,GAAG,IAAA,wBAAc,EACxD,2CAA2C,CAC5C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Service } from '@proteinjs/service';
|
|
2
|
+
import { UserStatus } from '../tables/UserTable';
|
|
3
|
+
export declare const getSetUserStatusService: () => SetUserStatusService;
|
|
4
|
+
/**
|
|
5
|
+
* The ONE write path for a user's account standing. The `user.status` column is
|
|
6
|
+
* service-protected (generic record writes cannot touch it); every change lands here and writes
|
|
7
|
+
* a `user_status_event` audit row (actor, target, status; `created` is the timestamp).
|
|
8
|
+
* Admin-only: deactivation locks the target out of the product (login refused, live sessions
|
|
9
|
+
* stop resolving), so the door is the break-glass role, not a mapped permission.
|
|
10
|
+
*/
|
|
11
|
+
export interface SetUserStatusService extends Service {
|
|
12
|
+
/** Set a user's standing. Already in that standing: no change, no audit row. */
|
|
13
|
+
setUserStatus(userId: string, status: UserStatus): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=SetUserStatusService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetUserStatusService.d.ts","sourceRoot":"","sources":["../../../src/services/SetUserStatusService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,uBAAuB,4BAA+E,CAAC;AAEpH;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,OAAO;IACnD,gFAAgF;IAChF,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSetUserStatusService = void 0;
|
|
4
|
+
var service_1 = require("@proteinjs/service");
|
|
5
|
+
exports.getSetUserStatusService = (0, service_1.serviceFactory)('@proteinjs/user/SetUserStatusService');
|
|
6
|
+
//# sourceMappingURL=SetUserStatusService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetUserStatusService.js","sourceRoot":"","sources":["../../../src/services/SetUserStatusService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAGhD,QAAA,uBAAuB,GAAG,IAAA,wBAAc,EAAuB,sCAAsC,CAAC,CAAC"}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { Service } from '@proteinjs/service';
|
|
2
|
+
import { User } from '../tables/UserTable';
|
|
2
3
|
export declare const getUpdateUserInfoService: () => UpdateUserInfoService;
|
|
4
|
+
/** What user-info mutations return: the updated user record, never the password hash. */
|
|
5
|
+
export type UpdatedUser = Omit<User, 'password'>;
|
|
3
6
|
export interface UpdatePasswordResponse {
|
|
4
7
|
updated: boolean;
|
|
5
8
|
error?: string;
|
|
6
9
|
}
|
|
7
10
|
export interface UpdateUserInfoService extends Service {
|
|
8
|
-
updateName(name: string): Promise<
|
|
11
|
+
updateName(name: string): Promise<UpdatedUser>;
|
|
9
12
|
updatePassword(currentPassword: string, newPassword: string): Promise<UpdatePasswordResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Set a photo avatar: the image is re-encoded server-side to a 512x512 JPEG (EXIF stripped),
|
|
15
|
+
* stored via FileStorage, and any previous avatar photo is deleted. Nulls `avatarEmoji`
|
|
16
|
+
* (avatars are photo OR emoji, exactly one active).
|
|
17
|
+
* @param fileData base64-encoded image bytes (max 10MB decoded)
|
|
18
|
+
* @param mimeType one of image/jpeg, image/png, image/webp, image/heic, image/heif
|
|
19
|
+
*/
|
|
20
|
+
updateAvatarPhoto(fileData: string, mimeType: string): Promise<UpdatedUser>;
|
|
21
|
+
/** Set an emoji avatar. Nulls `avatarFileId` and deletes any previous avatar photo file. */
|
|
22
|
+
updateAvatarEmoji(emoji: string): Promise<UpdatedUser>;
|
|
23
|
+
/** Remove the avatar entirely (both representations; deletes any stored photo file). */
|
|
24
|
+
clearAvatar(): Promise<UpdatedUser>;
|
|
10
25
|
}
|
|
11
26
|
//# sourceMappingURL=UpdateUserInfoService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateUserInfoService.d.ts","sourceRoot":"","sources":["../../../src/services/UpdateUserInfoService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"UpdateUserInfoService.d.ts","sourceRoot":"","sources":["../../../src/services/UpdateUserInfoService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,eAAO,MAAM,wBAAwB,6BAAiF,CAAC;AAEvH,yFAAyF;AACzF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAEjD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAsB,SAAQ,OAAO;IACpD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC9F;;;;;;OAMG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5E,4FAA4F;IAC5F,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACvD,wFAAwF;IACxF,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateUserInfoService.js","sourceRoot":"","sources":["../../../src/services/UpdateUserInfoService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;
|
|
1
|
+
{"version":3,"file":"UpdateUserInfoService.js","sourceRoot":"","sources":["../../../src/services/UpdateUserInfoService.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAGhD,QAAA,wBAAwB,GAAG,IAAA,wBAAc,EAAwB,uCAAuC,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Table, Record } from '@proteinjs/db';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
import { AccessGrant } from './AccessGrantTable';
|
|
4
|
+
/** Purge-machine phases. `grace` = cancelable window; `restoring` = a cancel-by-login claimed the
|
|
5
|
+
* row; `purging` = the walker claimed it; `purged` = rows erased, completion email pending. */
|
|
6
|
+
export declare const ACCOUNT_DELETION_PHASES: readonly ["grace", "restoring", "purging", "purged"];
|
|
7
|
+
export type AccountDeletionPhase = (typeof ACCOUNT_DELETION_PHASES)[number];
|
|
8
|
+
/**
|
|
9
|
+
* A revoked `access_grant` row serialized verbatim into the deletion manifest. The stored `id`
|
|
10
|
+
* lets revocation delete precisely and resume idempotently; cancel re-inserts WITHOUT ids
|
|
11
|
+
* (fresh rows), matched by `(principal, resource, accessLevel)`.
|
|
12
|
+
*/
|
|
13
|
+
export type ManifestGrant = {
|
|
14
|
+
/** id of the revoked access_grant row */
|
|
15
|
+
id: string;
|
|
16
|
+
/** user id (the grant's principal) */
|
|
17
|
+
principal: string;
|
|
18
|
+
/** resource id (the grant's resource) */
|
|
19
|
+
resource: string;
|
|
20
|
+
resourceTable?: string;
|
|
21
|
+
accessLevel: AccessGrant['accessLevel'];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* One row per in-flight account deletion: the deletion manifest plus the purge machine's own
|
|
25
|
+
* state. Deliberately a plain `Record`, NOT scoped — it must survive the purge walker's scope
|
|
26
|
+
* sweep and outlive the `user` row (the completion email sends after the user is gone).
|
|
27
|
+
*/
|
|
28
|
+
export interface AccountDeletion extends Record {
|
|
29
|
+
/** unique — one in-flight deletion per account */
|
|
30
|
+
userId: string;
|
|
31
|
+
/** Completion-email addressee after the user row is gone; login-cancel lookup key. */
|
|
32
|
+
userEmail: string;
|
|
33
|
+
phase: AccountDeletionPhase;
|
|
34
|
+
/** Write-once copy of `user.purgeAfter` (same logical step; this row is the machine's own stamp). */
|
|
35
|
+
purgeAfter: Moment;
|
|
36
|
+
/**
|
|
37
|
+
* Revoked grants, BOTH directions (inbound: my non-owner grants on others' content; outbound:
|
|
38
|
+
* others' grants on my content), verbatim. Persisted BEFORE any mutation — after a partial
|
|
39
|
+
* revocation the live grants under-count, so resume must never re-enumerate.
|
|
40
|
+
*/
|
|
41
|
+
manifestGrants: ManifestGrant[];
|
|
42
|
+
/**
|
|
43
|
+
* Owner-grant resource ids snapshotted at deactivation — the purge walker's thought-domain id
|
|
44
|
+
* source. LOAD-BEARING: ThoughtAccessGrantCleanupTableWatcher deletes a thought's grants the
|
|
45
|
+
* moment its row dies, so live re-enumeration after a mid-tree crash would strand orphan
|
|
46
|
+
* children forever.
|
|
47
|
+
*/
|
|
48
|
+
ownedResourceIds: string[];
|
|
49
|
+
/** CAS token (RoutineTicker.tickSeq pattern), bumped on every claim. */
|
|
50
|
+
leaseSeq: number;
|
|
51
|
+
ownerNodeId?: string | null;
|
|
52
|
+
/** JS-compared (Spanner timestamp-condition house rule). */
|
|
53
|
+
heartbeatAt?: Moment | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Locked like `SessionTable`: readable behind the 'users' permission, and NO write doors — rows
|
|
57
|
+
* are system-written only (the deletion service and the purge walker ride system paths, which
|
|
58
|
+
* bypass TableAuth). The manifest holds cross-user grant data, so even break-glass admin gets
|
|
59
|
+
* no generic write surface.
|
|
60
|
+
*/
|
|
61
|
+
export declare class AccountDeletionTable extends Table<AccountDeletion> {
|
|
62
|
+
name: string;
|
|
63
|
+
auth: Table<AccountDeletion>['auth'];
|
|
64
|
+
indexes: {
|
|
65
|
+
name: string;
|
|
66
|
+
columns: (keyof AccountDeletion)[];
|
|
67
|
+
unique: boolean;
|
|
68
|
+
}[];
|
|
69
|
+
columns: {
|
|
70
|
+
id: import("@proteinjs/db").Column<string, any>;
|
|
71
|
+
created: import("@proteinjs/db").Column<Moment, any>;
|
|
72
|
+
updated: import("@proteinjs/db").Column<Moment, any>;
|
|
73
|
+
} & {} & {
|
|
74
|
+
purgeAfter: import("@proteinjs/db").Column<Moment, any>;
|
|
75
|
+
userId: import("@proteinjs/db").Column<string, any>;
|
|
76
|
+
userEmail: import("@proteinjs/db").Column<string, any>;
|
|
77
|
+
phase: import("@proteinjs/db").Column<"grace" | "restoring" | "purging" | "purged", any>;
|
|
78
|
+
manifestGrants: import("@proteinjs/db").Column<ManifestGrant[], any>;
|
|
79
|
+
ownedResourceIds: import("@proteinjs/db").Column<string[], any>;
|
|
80
|
+
leaseSeq: import("@proteinjs/db").Column<number, any>;
|
|
81
|
+
ownerNodeId: import("@proteinjs/db").Column<string | null | undefined, any>;
|
|
82
|
+
heartbeatAt: import("@proteinjs/db").Column<Moment | null | undefined, any>;
|
|
83
|
+
} & {};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=AccountDeletionTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionTable.d.ts","sourceRoot":"","sources":["../../../src/tables/AccountDeletionTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EACL,MAAM,EAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE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
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AccountDeletionTable = exports.ACCOUNT_DELETION_PHASES = void 0;
|
|
19
|
+
var db_1 = require("@proteinjs/db");
|
|
20
|
+
var permissions_1 = require("../permissions");
|
|
21
|
+
/** Purge-machine phases. `grace` = cancelable window; `restoring` = a cancel-by-login claimed the
|
|
22
|
+
* row; `purging` = the walker claimed it; `purged` = rows erased, completion email pending. */
|
|
23
|
+
exports.ACCOUNT_DELETION_PHASES = ['grace', 'restoring', 'purging', 'purged'];
|
|
24
|
+
/**
|
|
25
|
+
* Locked like `SessionTable`: readable behind the 'users' permission, and NO write doors — rows
|
|
26
|
+
* are system-written only (the deletion service and the purge walker ride system paths, which
|
|
27
|
+
* bypass TableAuth). The manifest holds cross-user grant data, so even break-glass admin gets
|
|
28
|
+
* no generic write surface.
|
|
29
|
+
*/
|
|
30
|
+
var AccountDeletionTable = /** @class */ (function (_super) {
|
|
31
|
+
__extends(AccountDeletionTable, _super);
|
|
32
|
+
function AccountDeletionTable() {
|
|
33
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
34
|
+
_this.name = 'account_deletion';
|
|
35
|
+
_this.auth = {
|
|
36
|
+
db: {
|
|
37
|
+
query: { permission: permissions_1.USER_PERMISSIONS.users },
|
|
38
|
+
},
|
|
39
|
+
service: {
|
|
40
|
+
query: { permission: permissions_1.USER_PERMISSIONS.users },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
_this.indexes = [
|
|
44
|
+
{ name: 'idx_account_deletion_user_id_unique', columns: ['userId'], unique: true },
|
|
45
|
+
];
|
|
46
|
+
_this.columns = (0, db_1.withRecordColumns)({
|
|
47
|
+
userId: new db_1.StringColumn('user_id', {}, 36),
|
|
48
|
+
userEmail: new db_1.StringColumn('user_email', {}, 250),
|
|
49
|
+
phase: new db_1.StringColumn('phase', {}, 16),
|
|
50
|
+
purgeAfter: new db_1.DateTimeColumn('purge_after'),
|
|
51
|
+
manifestGrants: new db_1.ObjectColumn('manifest_grants'),
|
|
52
|
+
ownedResourceIds: new db_1.ObjectColumn('owned_resource_ids'),
|
|
53
|
+
leaseSeq: new db_1.IntegerColumn('lease_seq'),
|
|
54
|
+
ownerNodeId: new db_1.StringColumn('owner_node_id'),
|
|
55
|
+
heartbeatAt: new db_1.DateTimeColumn('heartbeat_at'),
|
|
56
|
+
});
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
return AccountDeletionTable;
|
|
60
|
+
}(db_1.Table));
|
|
61
|
+
exports.AccountDeletionTable = AccountDeletionTable;
|
|
62
|
+
//# sourceMappingURL=AccountDeletionTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionTable.js","sourceRoot":"","sources":["../../../src/tables/AccountDeletionTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oCAQuB;AAEvB,8CAAkD;AAGlD;gGACgG;AACnF,QAAA,uBAAuB,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAoD5F;;;;;GAKG;AACH;IAA0C,wCAAsB;IAAhE;QAAA,qEAwBC;QAvBC,UAAI,GAAG,kBAAkB,CAAC;QAC1B,UAAI,GAAmC;YACrC,EAAE,EAAE;gBACF,KAAK,EAAE,EAAE,UAAU,EAAE,8BAAgB,CAAC,KAAK,EAAE;aAC9C;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,EAAE,UAAU,EAAE,8BAAgB,CAAC,KAAK,EAAE;aAC9C;SACF,CAAC;QACF,aAAO,GAAG;YACR,EAAE,IAAI,EAAE,qCAAqC,EAAE,OAAO,EAAE,CAAC,QAAQ,CAA8B,EAAE,MAAM,EAAE,IAAI,EAAE;SAChH,CAAC;QACF,aAAO,GAAG,IAAA,sBAAiB,EAAkB;YAC3C,MAAM,EAAE,IAAI,iBAAY,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC;YAC3C,SAAS,EAAE,IAAI,iBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC;YAClD,KAAK,EAAE,IAAI,iBAAY,CAAuB,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC;YAC9D,UAAU,EAAE,IAAI,mBAAc,CAAC,aAAa,CAAC;YAC7C,cAAc,EAAE,IAAI,iBAAY,CAAkB,iBAAiB,CAAC;YACpE,gBAAgB,EAAE,IAAI,iBAAY,CAAW,oBAAoB,CAAC;YAClE,QAAQ,EAAE,IAAI,kBAAa,CAAC,WAAW,CAAC;YACxC,WAAW,EAAE,IAAI,iBAAY,CAAC,eAAe,CAAC;YAC9C,WAAW,EAAE,IAAI,mBAAc,CAAC,cAAc,CAAC;SAChD,CAAC,CAAC;;IACL,CAAC;IAAD,2BAAC;AAAD,CAAC,AAxBD,CAA0C,UAAK,GAwB9C;AAxBY,oDAAoB"}
|
|
@@ -19,10 +19,10 @@ export declare class SessionTable extends Table<Session> {
|
|
|
19
19
|
created: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
20
20
|
updated: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
21
21
|
} & {} & {
|
|
22
|
+
userEmail: import("@proteinjs/db").Column<string, any>;
|
|
22
23
|
session: import("@proteinjs/db").Column<string, any>;
|
|
23
24
|
sessionId: import("@proteinjs/db").Column<string, any>;
|
|
24
25
|
expires: import("@proteinjs/db").Column<Date, any>;
|
|
25
|
-
userEmail: import("@proteinjs/db").Column<string, any>;
|
|
26
26
|
} & {};
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=SessionTable.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Table, Record } from '@proteinjs/db';
|
|
2
|
+
import { UserStatus } from './UserTable';
|
|
3
|
+
/**
|
|
4
|
+
* Audit row written by the SetUserStatus service for EVERY status change. The base `created`
|
|
5
|
+
* column is the change timestamp. Rows are append-only: readable by admins (the same scope as
|
|
6
|
+
* the service that writes them), written only by the service's system path — no generic door
|
|
7
|
+
* grants writes, so the trail cannot be edited from the record surfaces.
|
|
8
|
+
*/
|
|
9
|
+
export type UserStatusEvent = Record & {
|
|
10
|
+
/** id of the user who made the change */
|
|
11
|
+
actor: string;
|
|
12
|
+
/** id of the user whose status changed */
|
|
13
|
+
target: string;
|
|
14
|
+
/** the standing the target was set to */
|
|
15
|
+
status: UserStatus;
|
|
16
|
+
};
|
|
17
|
+
export declare class UserStatusEventTable extends Table<UserStatusEvent> {
|
|
18
|
+
name: string;
|
|
19
|
+
auth: Table<UserStatusEvent>['auth'];
|
|
20
|
+
columns: {
|
|
21
|
+
id: import("@proteinjs/db").Column<string, any>;
|
|
22
|
+
created: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
23
|
+
updated: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
24
|
+
} & {} & {
|
|
25
|
+
status: import("@proteinjs/db").Column<"active" | "deactivated", any>;
|
|
26
|
+
actor: import("@proteinjs/db").Column<string, any>;
|
|
27
|
+
target: import("@proteinjs/db").Column<string, any>;
|
|
28
|
+
} & {};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=UserStatusEventTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserStatusEventTable.d.ts","sourceRoot":"","sources":["../../../src/tables/UserStatusEventTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,EAAqB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IACrC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,KAAK,CAAC,eAAe,CAAC;IAC9D,IAAI,SAAuB;IAC3B,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAOlC;IACF,OAAO;;;;;;;;WAIJ;CACJ"}
|