ofauth-shared-core 0.1.0-alpha.0 → 0.2.0-alpha.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/README.md +10 -0
- package/dist/OfauthCore.d.ts +0 -1
- package/dist/contracts/AuthAuditContract.d.ts +6 -0
- package/dist/contracts/AuthErrorContract.d.ts +1 -1
- package/dist/contracts/AuthPolicyContract.d.ts +13 -0
- package/dist/contracts/ContextContract.d.ts +23 -4
- package/dist/contracts/IdentityContract.d.ts +14 -0
- package/dist/contracts/SessionContract.d.ts +20 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -36
- package/dist/services/AuthAuthorityAdapter.d.ts +42 -0
- package/dist/services/AuthHostComposition.d.ts +5 -2
- package/dist/services/AuthOfflinePolicy.d.ts +11 -0
- package/dist/services/AuthSessionCacheAdapter.d.ts +16 -0
- package/dist/services/contractCompatibility.d.ts +12 -0
- package/dist/services/createContractOnlyOfauthServices.d.ts +8 -8
- package/dist/services/createDbAdapterOfauthServices.d.ts +0 -8
- package/dist/services/createServerAuthoritativeAuthBridge.d.ts +25 -0
- package/dist/services/errors.d.ts +10 -0
- package/dist/services/impl/DbAdapterSessionService.d.ts +2 -0
- package/dist/services/impl/runtimeSupport.d.ts +1 -1
- package/dist/services/localProvisioning.d.ts +23 -0
- package/dist/services/responseEnvelope.d.ts +10 -0
- package/package.json +21 -10
- package/dist/OfauthCore.js +0 -200
- package/dist/contracts/AuthAuditContract.js +0 -16
- package/dist/contracts/AuthErrorContract.js +0 -2
- package/dist/contracts/AuthPolicyContract.js +0 -2
- package/dist/contracts/ContextContract.js +0 -8
- package/dist/contracts/IdentityContract.js +0 -2
- package/dist/contracts/SessionContract.js +0 -10
- package/dist/data/applyPendingMigrations.js +0 -30
- package/dist/data/migrations.js +0 -47
- package/dist/data/schemas.js +0 -109
- package/dist/runtime/ContractStage.js +0 -4
- package/dist/services/AuthAuditService.js +0 -2
- package/dist/services/AuthHostComposition.js +0 -100
- package/dist/services/AuthPolicyService.js +0 -2
- package/dist/services/ContextService.js +0 -2
- package/dist/services/IdentityService.js +0 -2
- package/dist/services/SessionService.js +0 -2
- package/dist/services/createContractOnlyOfauthServices.js +0 -82
- package/dist/services/createDbAdapterOfauthServices.js +0 -22
- package/dist/services/errors.js +0 -20
- package/dist/services/impl/DbAdapterAuthAuditService.js +0 -107
- package/dist/services/impl/DbAdapterAuthPolicyService.js +0 -114
- package/dist/services/impl/DbAdapterContextService.js +0 -79
- package/dist/services/impl/DbAdapterIdentityService.js +0 -146
- package/dist/services/impl/DbAdapterSessionService.js +0 -63
- package/dist/services/impl/runtimeSupport.js +0 -112
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SESSION_TTL_SECONDS = exports.DEFAULT_LOCKOUT_COOLDOWN_SECONDS = exports.DEFAULT_LOCKOUT_THRESHOLD = void 0;
|
|
4
|
-
exports.nowIso = nowIso;
|
|
5
|
-
exports.plusSecondsIso = plusSecondsIso;
|
|
6
|
-
exports.isPast = isPast;
|
|
7
|
-
exports.makeIdFactory = makeIdFactory;
|
|
8
|
-
exports.toIdentityRef = toIdentityRef;
|
|
9
|
-
exports.toAssignment = toAssignment;
|
|
10
|
-
exports.toSessionRef = toSessionRef;
|
|
11
|
-
exports.verifySecret = verifySecret;
|
|
12
|
-
exports.emitAuthActivity = emitAuthActivity;
|
|
13
|
-
exports.getAssignmentById = getAssignmentById;
|
|
14
|
-
exports.fallbackPolicyProfiles = fallbackPolicyProfiles;
|
|
15
|
-
const schemas_1 = require("../../data/schemas");
|
|
16
|
-
exports.DEFAULT_LOCKOUT_THRESHOLD = 5;
|
|
17
|
-
exports.DEFAULT_LOCKOUT_COOLDOWN_SECONDS = 15 * 60;
|
|
18
|
-
exports.DEFAULT_SESSION_TTL_SECONDS = 8 * 60 * 60;
|
|
19
|
-
function nowIso() {
|
|
20
|
-
return new Date().toISOString();
|
|
21
|
-
}
|
|
22
|
-
function plusSecondsIso(baseIso, seconds) {
|
|
23
|
-
return new Date(new Date(baseIso).getTime() + seconds * 1000).toISOString();
|
|
24
|
-
}
|
|
25
|
-
function isPast(iso) {
|
|
26
|
-
return new Date(iso).getTime() <= Date.now();
|
|
27
|
-
}
|
|
28
|
-
function makeIdFactory(prefix) {
|
|
29
|
-
let counter = 0;
|
|
30
|
-
return () => {
|
|
31
|
-
counter += 1;
|
|
32
|
-
return `${prefix}-${Date.now()}-${counter}`;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function toIdentityRef(row) {
|
|
36
|
-
return {
|
|
37
|
-
identityId: row.id,
|
|
38
|
-
principal: row.principal,
|
|
39
|
-
status: row.status,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function toAssignment(row) {
|
|
43
|
-
return {
|
|
44
|
-
assignmentId: row.id,
|
|
45
|
-
identityId: row.identityId,
|
|
46
|
-
roleRef: row.roleRef,
|
|
47
|
-
scopeRef: {
|
|
48
|
-
...(row.tenantId ? { tenantId: row.tenantId } : {}),
|
|
49
|
-
...(row.branchId ? { branchId: row.branchId } : {}),
|
|
50
|
-
...(row.scopeAttributes ? { attributes: row.scopeAttributes } : {}),
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function toSessionRef(row, assignment) {
|
|
55
|
-
return {
|
|
56
|
-
sessionId: row.id,
|
|
57
|
-
identityId: row.identityId,
|
|
58
|
-
activeScopeRef: assignment
|
|
59
|
-
? {
|
|
60
|
-
...(assignment.tenantId ? { tenantId: assignment.tenantId } : {}),
|
|
61
|
-
...(assignment.branchId ? { branchId: assignment.branchId } : {}),
|
|
62
|
-
...(assignment.scopeAttributes ? { attributes: assignment.scopeAttributes } : {}),
|
|
63
|
-
}
|
|
64
|
-
: undefined,
|
|
65
|
-
assuranceLevel: row.assuranceLevel,
|
|
66
|
-
issuedAt: row.issuedAt,
|
|
67
|
-
expiresAt: row.expiresAt,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async function verifySecret(platformAdapter, plainSecret, secretHash) {
|
|
71
|
-
if (platformAdapter) {
|
|
72
|
-
return platformAdapter.verifyPin(plainSecret, secretHash);
|
|
73
|
-
}
|
|
74
|
-
return plainSecret === secretHash;
|
|
75
|
-
}
|
|
76
|
-
async function emitAuthActivity(options, event) {
|
|
77
|
-
if (!options.emitActivity)
|
|
78
|
-
return;
|
|
79
|
-
await options.emitActivity({
|
|
80
|
-
activityId: event.eventId,
|
|
81
|
-
activityType: `ofauth.${event.eventType.toLowerCase()}`,
|
|
82
|
-
occurredAt: event.timestamp,
|
|
83
|
-
scopeRef: {
|
|
84
|
-
domain: 'ofauth',
|
|
85
|
-
...(event.scopeRef?.tenantId ? { tenantId: event.scopeRef.tenantId } : {}),
|
|
86
|
-
...(event.scopeRef?.branchId ? { branchId: event.scopeRef.branchId } : {}),
|
|
87
|
-
},
|
|
88
|
-
actor: event.identityId ? { userId: event.identityId } : undefined,
|
|
89
|
-
payload: {
|
|
90
|
-
eventType: event.eventType,
|
|
91
|
-
result: event.result,
|
|
92
|
-
reasonCode: event.reasonCode ?? null,
|
|
93
|
-
sessionId: event.sessionId ?? null,
|
|
94
|
-
scopeAttributes: event.scopeRef?.attributes ?? null,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
async function getAssignmentById(db, id) {
|
|
99
|
-
if (!id)
|
|
100
|
-
return null;
|
|
101
|
-
const row = await db.get(schemas_1.OFAUTH_TABLES.assignments, id);
|
|
102
|
-
if (!row || row.deleted)
|
|
103
|
-
return null;
|
|
104
|
-
return row;
|
|
105
|
-
}
|
|
106
|
-
function fallbackPolicyProfiles() {
|
|
107
|
-
return [
|
|
108
|
-
{ profileId: 'cashier_fast', defaultAssuranceLevel: 'basic', lockoutPolicyRef: 'default' },
|
|
109
|
-
{ profileId: 'supervisor_strict', defaultAssuranceLevel: 'elevated', lockoutPolicyRef: 'strict' },
|
|
110
|
-
{ profileId: 'member_self_service', defaultAssuranceLevel: 'basic', lockoutPolicyRef: 'member' },
|
|
111
|
-
];
|
|
112
|
-
}
|