@aooth/auth 0.2.5 → 0.2.7
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/dist/atscript-db.cjs +6 -6
- package/dist/atscript-db.mjs +6 -6
- package/dist/index.cjs +12 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +12 -11
- package/package.json +10 -10
package/dist/atscript-db.cjs
CHANGED
|
@@ -428,14 +428,14 @@ function rowToState(row, metadataField) {
|
|
|
428
428
|
if (metadataField !== void 0) {
|
|
429
429
|
delete state[metadataField];
|
|
430
430
|
const metadata = row[metadataField];
|
|
431
|
-
if (metadata
|
|
431
|
+
if (metadata != null) state.metadata = metadata;
|
|
432
432
|
}
|
|
433
433
|
if (row.kind === "access" || row.kind === "refresh") state.kind = row.kind;
|
|
434
|
-
if (row.parentCredentialId
|
|
435
|
-
if (row.rotatedAt
|
|
436
|
-
if (row.successor
|
|
437
|
-
if (row.sessionId
|
|
438
|
-
if (row.lastSeenAt
|
|
434
|
+
if (row.parentCredentialId != null) state.parentCredentialId = row.parentCredentialId;
|
|
435
|
+
if (row.rotatedAt != null) state.rotatedAt = row.rotatedAt;
|
|
436
|
+
if (row.successor != null) state.successor = row.successor;
|
|
437
|
+
if (row.sessionId != null) state.sessionId = row.sessionId;
|
|
438
|
+
if (row.lastSeenAt != null) state.lastSeenAt = row.lastSeenAt;
|
|
439
439
|
return state;
|
|
440
440
|
}
|
|
441
441
|
exports.AUTHORITY_METADATA_KEYS = AUTHORITY_METADATA_KEYS;
|
package/dist/atscript-db.mjs
CHANGED
|
@@ -427,14 +427,14 @@ function rowToState(row, metadataField) {
|
|
|
427
427
|
if (metadataField !== void 0) {
|
|
428
428
|
delete state[metadataField];
|
|
429
429
|
const metadata = row[metadataField];
|
|
430
|
-
if (metadata
|
|
430
|
+
if (metadata != null) state.metadata = metadata;
|
|
431
431
|
}
|
|
432
432
|
if (row.kind === "access" || row.kind === "refresh") state.kind = row.kind;
|
|
433
|
-
if (row.parentCredentialId
|
|
434
|
-
if (row.rotatedAt
|
|
435
|
-
if (row.successor
|
|
436
|
-
if (row.sessionId
|
|
437
|
-
if (row.lastSeenAt
|
|
433
|
+
if (row.parentCredentialId != null) state.parentCredentialId = row.parentCredentialId;
|
|
434
|
+
if (row.rotatedAt != null) state.rotatedAt = row.rotatedAt;
|
|
435
|
+
if (row.successor != null) state.successor = row.successor;
|
|
436
|
+
if (row.sessionId != null) state.sessionId = row.sessionId;
|
|
437
|
+
if (row.lastSeenAt != null) state.lastSeenAt = row.lastSeenAt;
|
|
438
438
|
return state;
|
|
439
439
|
}
|
|
440
440
|
export { AUTHORITY_METADATA_KEYS, AuthCodeStoreAtscriptDb, CredentialStoreAtscriptDb, DynamicClientStoreAtscriptDb, PendingAuthorizationStoreAtscriptDb, getAoothCredentialMetadataSpec };
|
package/dist/index.cjs
CHANGED
|
@@ -479,6 +479,7 @@ var CredentialStoreEncapsulated = class {
|
|
|
479
479
|
decrypt(token) {
|
|
480
480
|
try {
|
|
481
481
|
const blob = Buffer.from(token, "base64url");
|
|
482
|
+
if (blob.toString("base64url") !== token) return null;
|
|
482
483
|
if (blob.length < 29) return null;
|
|
483
484
|
const iv = blob.subarray(0, IV_LEN);
|
|
484
485
|
const authTag = blob.subarray(blob.length - TAG_LEN);
|
|
@@ -894,7 +895,7 @@ var AuthCredential = class {
|
|
|
894
895
|
userId: oldState.userId,
|
|
895
896
|
iat: oldState.issuedAt,
|
|
896
897
|
exp: oldState.expiresAt,
|
|
897
|
-
...oldState.sessionId
|
|
898
|
+
...oldState.sessionId != null && { sessionId: oldState.sessionId }
|
|
898
899
|
});
|
|
899
900
|
return await this.issueRotatedPair(oldState, refreshToken, key, false, now, true);
|
|
900
901
|
}
|
|
@@ -935,7 +936,7 @@ var AuthCredential = class {
|
|
|
935
936
|
expiresAt: oldState.expiresAt,
|
|
936
937
|
kind: "refresh",
|
|
937
938
|
rotatedAt: oldState.rotatedAt,
|
|
938
|
-
...oldState.sessionId
|
|
939
|
+
...oldState.sessionId != null && { sessionId: oldState.sessionId }
|
|
939
940
|
});
|
|
940
941
|
return {
|
|
941
942
|
accessToken: successor.accessToken,
|
|
@@ -1130,8 +1131,8 @@ var AuthCredential = class {
|
|
|
1130
1131
|
issuedAt: now,
|
|
1131
1132
|
expiresAt: now + accessTtl,
|
|
1132
1133
|
kind: "access",
|
|
1133
|
-
metadata: refreshState.metadata,
|
|
1134
|
-
sessionId: refreshState.sessionId,
|
|
1134
|
+
metadata: refreshState.metadata ?? void 0,
|
|
1135
|
+
sessionId: refreshState.sessionId ?? void 0,
|
|
1135
1136
|
...this.trackLastSeen === "refresh" && { lastSeenAt: now }
|
|
1136
1137
|
});
|
|
1137
1138
|
return {
|
|
@@ -1156,9 +1157,9 @@ var AuthCredential = class {
|
|
|
1156
1157
|
issuedAt: now,
|
|
1157
1158
|
expiresAt: refreshExpiresAt,
|
|
1158
1159
|
kind: "refresh",
|
|
1159
|
-
metadata: oldRefreshState.metadata,
|
|
1160
|
+
metadata: oldRefreshState.metadata ?? void 0,
|
|
1160
1161
|
parentCredentialId: this.hashAtRest ? fingerprint(oldRefreshToken) : oldRefreshToken,
|
|
1161
|
-
sessionId: oldRefreshState.sessionId,
|
|
1162
|
+
sessionId: oldRefreshState.sessionId ?? void 0,
|
|
1162
1163
|
...this.trackLastSeen === "refresh" && { lastSeenAt: now }
|
|
1163
1164
|
});
|
|
1164
1165
|
const access = await this.issueAccessFromRefresh(oldRefreshState, now);
|
|
@@ -1266,15 +1267,15 @@ var AuthCredential = class {
|
|
|
1266
1267
|
issuedAt: reuse.issuedAt,
|
|
1267
1268
|
expiresAt: reuse.expiresAt,
|
|
1268
1269
|
kind: "refresh",
|
|
1269
|
-
...reuse.sessionId
|
|
1270
|
-
...reuse.rotatedAt
|
|
1270
|
+
...reuse.sessionId != null && { sessionId: reuse.sessionId },
|
|
1271
|
+
...reuse.rotatedAt != null && { rotatedAt: reuse.rotatedAt }
|
|
1271
1272
|
});
|
|
1272
|
-
if ((this.refreshConfig?.reuseResponse ?? "session") === "session" && reuse.sessionId
|
|
1273
|
+
if ((this.refreshConfig?.reuseResponse ?? "session") === "session" && reuse.sessionId != null && this.store.listForUser) await this.revokeSession(reuse.userId, reuse.sessionId);
|
|
1273
1274
|
else await this.revokeAllForUser(reuse.userId);
|
|
1274
1275
|
throw new require_payload.AuthError("REFRESH_REUSE_DETECTED", void 0, {
|
|
1275
1276
|
userId: reuse.userId,
|
|
1276
|
-
...reuse.sessionId
|
|
1277
|
-
...reuse.rotatedAt
|
|
1277
|
+
...reuse.sessionId != null && { sessionId: reuse.sessionId },
|
|
1278
|
+
...reuse.rotatedAt != null && { rotatedAt: reuse.rotatedAt }
|
|
1278
1279
|
});
|
|
1279
1280
|
}
|
|
1280
1281
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -376,7 +376,7 @@ export declare class RateLimiter {
|
|
|
376
376
|
* consumer-triggered security notice (e.g. impossible-travel from a
|
|
377
377
|
* `resolveRiskStepUp` override) — never auto-sent by the framework.
|
|
378
378
|
*/
|
|
379
|
-
type AuthEmailKind = "recovery.magicLink" | "invite.magicLink" | "mfa.code" | "login.pincode" | "recovery.pincode" | "invite.pincode" | "notifyNewDevice" | "securityAlert";
|
|
379
|
+
type AuthEmailKind = "recovery.magicLink" | "login.magicLink" | "invite.magicLink" | "mfa.code" | "login.pincode" | "recovery.pincode" | "invite.pincode" | "notifyNewDevice" | "securityAlert";
|
|
380
380
|
/**
|
|
381
381
|
* Structured event passed to `EmailSender.send()` from inside the auth
|
|
382
382
|
* workflows. Flat and serialisable so consumers can route it to any
|
package/dist/index.d.mts
CHANGED
|
@@ -376,7 +376,7 @@ export declare class RateLimiter {
|
|
|
376
376
|
* consumer-triggered security notice (e.g. impossible-travel from a
|
|
377
377
|
* `resolveRiskStepUp` override) — never auto-sent by the framework.
|
|
378
378
|
*/
|
|
379
|
-
type AuthEmailKind = "recovery.magicLink" | "invite.magicLink" | "mfa.code" | "login.pincode" | "recovery.pincode" | "invite.pincode" | "notifyNewDevice" | "securityAlert";
|
|
379
|
+
type AuthEmailKind = "recovery.magicLink" | "login.magicLink" | "invite.magicLink" | "mfa.code" | "login.pincode" | "recovery.pincode" | "invite.pincode" | "notifyNewDevice" | "securityAlert";
|
|
380
380
|
/**
|
|
381
381
|
* Structured event passed to `EmailSender.send()` from inside the auth
|
|
382
382
|
* workflows. Flat and serialisable so consumers can route it to any
|
package/dist/index.mjs
CHANGED
|
@@ -478,6 +478,7 @@ var CredentialStoreEncapsulated = class {
|
|
|
478
478
|
decrypt(token) {
|
|
479
479
|
try {
|
|
480
480
|
const blob = Buffer.from(token, "base64url");
|
|
481
|
+
if (blob.toString("base64url") !== token) return null;
|
|
481
482
|
if (blob.length < 29) return null;
|
|
482
483
|
const iv = blob.subarray(0, IV_LEN);
|
|
483
484
|
const authTag = blob.subarray(blob.length - TAG_LEN);
|
|
@@ -893,7 +894,7 @@ var AuthCredential = class {
|
|
|
893
894
|
userId: oldState.userId,
|
|
894
895
|
iat: oldState.issuedAt,
|
|
895
896
|
exp: oldState.expiresAt,
|
|
896
|
-
...oldState.sessionId
|
|
897
|
+
...oldState.sessionId != null && { sessionId: oldState.sessionId }
|
|
897
898
|
});
|
|
898
899
|
return await this.issueRotatedPair(oldState, refreshToken, key, false, now, true);
|
|
899
900
|
}
|
|
@@ -934,7 +935,7 @@ var AuthCredential = class {
|
|
|
934
935
|
expiresAt: oldState.expiresAt,
|
|
935
936
|
kind: "refresh",
|
|
936
937
|
rotatedAt: oldState.rotatedAt,
|
|
937
|
-
...oldState.sessionId
|
|
938
|
+
...oldState.sessionId != null && { sessionId: oldState.sessionId }
|
|
938
939
|
});
|
|
939
940
|
return {
|
|
940
941
|
accessToken: successor.accessToken,
|
|
@@ -1129,8 +1130,8 @@ var AuthCredential = class {
|
|
|
1129
1130
|
issuedAt: now,
|
|
1130
1131
|
expiresAt: now + accessTtl,
|
|
1131
1132
|
kind: "access",
|
|
1132
|
-
metadata: refreshState.metadata,
|
|
1133
|
-
sessionId: refreshState.sessionId,
|
|
1133
|
+
metadata: refreshState.metadata ?? void 0,
|
|
1134
|
+
sessionId: refreshState.sessionId ?? void 0,
|
|
1134
1135
|
...this.trackLastSeen === "refresh" && { lastSeenAt: now }
|
|
1135
1136
|
});
|
|
1136
1137
|
return {
|
|
@@ -1155,9 +1156,9 @@ var AuthCredential = class {
|
|
|
1155
1156
|
issuedAt: now,
|
|
1156
1157
|
expiresAt: refreshExpiresAt,
|
|
1157
1158
|
kind: "refresh",
|
|
1158
|
-
metadata: oldRefreshState.metadata,
|
|
1159
|
+
metadata: oldRefreshState.metadata ?? void 0,
|
|
1159
1160
|
parentCredentialId: this.hashAtRest ? fingerprint(oldRefreshToken) : oldRefreshToken,
|
|
1160
|
-
sessionId: oldRefreshState.sessionId,
|
|
1161
|
+
sessionId: oldRefreshState.sessionId ?? void 0,
|
|
1161
1162
|
...this.trackLastSeen === "refresh" && { lastSeenAt: now }
|
|
1162
1163
|
});
|
|
1163
1164
|
const access = await this.issueAccessFromRefresh(oldRefreshState, now);
|
|
@@ -1265,15 +1266,15 @@ var AuthCredential = class {
|
|
|
1265
1266
|
issuedAt: reuse.issuedAt,
|
|
1266
1267
|
expiresAt: reuse.expiresAt,
|
|
1267
1268
|
kind: "refresh",
|
|
1268
|
-
...reuse.sessionId
|
|
1269
|
-
...reuse.rotatedAt
|
|
1269
|
+
...reuse.sessionId != null && { sessionId: reuse.sessionId },
|
|
1270
|
+
...reuse.rotatedAt != null && { rotatedAt: reuse.rotatedAt }
|
|
1270
1271
|
});
|
|
1271
|
-
if ((this.refreshConfig?.reuseResponse ?? "session") === "session" && reuse.sessionId
|
|
1272
|
+
if ((this.refreshConfig?.reuseResponse ?? "session") === "session" && reuse.sessionId != null && this.store.listForUser) await this.revokeSession(reuse.userId, reuse.sessionId);
|
|
1272
1273
|
else await this.revokeAllForUser(reuse.userId);
|
|
1273
1274
|
throw new AuthError("REFRESH_REUSE_DETECTED", void 0, {
|
|
1274
1275
|
userId: reuse.userId,
|
|
1275
|
-
...reuse.sessionId
|
|
1276
|
-
...reuse.rotatedAt
|
|
1276
|
+
...reuse.sessionId != null && { sessionId: reuse.sessionId },
|
|
1277
|
+
...reuse.rotatedAt != null && { rotatedAt: reuse.rotatedAt }
|
|
1277
1278
|
});
|
|
1278
1279
|
}
|
|
1279
1280
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aooth/auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Auth method layer for aoothjs (sessions, tokens, password reset, MFA primitives)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aoothjs",
|
|
@@ -104,22 +104,22 @@
|
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"jose": "^6.2.3",
|
|
107
|
-
"@aooth/user": "0.2.
|
|
107
|
+
"@aooth/user": "0.2.7"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@atscript/core": "^0.2.
|
|
111
|
-
"@atscript/db": "^0.1.
|
|
112
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
113
|
-
"@atscript/db-sqlite": "^0.1.
|
|
114
|
-
"@atscript/typescript": "^0.2.
|
|
110
|
+
"@atscript/core": "^0.2.11",
|
|
111
|
+
"@atscript/db": "^0.1.175",
|
|
112
|
+
"@atscript/db-sql-tools": "^0.1.175",
|
|
113
|
+
"@atscript/db-sqlite": "^0.1.175",
|
|
114
|
+
"@atscript/typescript": "^0.2.11",
|
|
115
115
|
"@types/better-sqlite3": "^7.6.13",
|
|
116
|
-
"@uniqu/core": "^0.2.
|
|
116
|
+
"@uniqu/core": "^0.2.2",
|
|
117
117
|
"better-sqlite3": "^12.6.2",
|
|
118
118
|
"ioredis": "^5.11.1",
|
|
119
|
-
"unplugin-atscript": "^0.2.
|
|
119
|
+
"unplugin-atscript": "^0.2.11"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
|
-
"@atscript/db": "^0.1.
|
|
122
|
+
"@atscript/db": "^0.1.175"
|
|
123
123
|
},
|
|
124
124
|
"peerDependenciesMeta": {
|
|
125
125
|
"@atscript/db": {
|