@riocrypto/common-server 1.0.2269 → 1.0.2271
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/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/models/dashboard-push-notification-subscription.d.ts +2 -0
- package/build/models/dashboard-push-notification-subscription.js +4 -0
- package/build/models/webauthn-credential.d.ts +30 -0
- package/build/models/webauthn-credential.js +68 -0
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export * from "./models/STP-mxn-withdrawal";
|
|
|
89
89
|
export * from "./models/STP-deposit-CLABE";
|
|
90
90
|
export * from "./models/STP-settings";
|
|
91
91
|
export * from "./models/dashboard-push-notification-subscription";
|
|
92
|
+
export * from "./models/webauthn-credential";
|
|
92
93
|
export * from "./clients/axios-with-logging";
|
|
93
94
|
export * from "./clients/slack-client";
|
|
94
95
|
export * from "./clients/fireblocks-client";
|
package/build/index.js
CHANGED
|
@@ -105,6 +105,7 @@ __exportStar(require("./models/STP-mxn-withdrawal"), exports);
|
|
|
105
105
|
__exportStar(require("./models/STP-deposit-CLABE"), exports);
|
|
106
106
|
__exportStar(require("./models/STP-settings"), exports);
|
|
107
107
|
__exportStar(require("./models/dashboard-push-notification-subscription"), exports);
|
|
108
|
+
__exportStar(require("./models/webauthn-credential"), exports);
|
|
108
109
|
__exportStar(require("./clients/axios-with-logging"), exports);
|
|
109
110
|
__exportStar(require("./clients/slack-client"), exports);
|
|
110
111
|
__exportStar(require("./clients/fireblocks-client"), exports);
|
|
@@ -2,6 +2,7 @@ import mongoose from "mongoose";
|
|
|
2
2
|
interface DashboardPushNotificationSubscriptionAttrs {
|
|
3
3
|
authId?: string;
|
|
4
4
|
adminAuthId?: string;
|
|
5
|
+
userId?: string;
|
|
5
6
|
endpoint: string;
|
|
6
7
|
p256dh: string;
|
|
7
8
|
auth: string;
|
|
@@ -9,6 +10,7 @@ interface DashboardPushNotificationSubscriptionAttrs {
|
|
|
9
10
|
interface DashboardPushNotificationSubscriptionDoc extends mongoose.Document {
|
|
10
11
|
authId?: string;
|
|
11
12
|
adminAuthId?: string;
|
|
13
|
+
userId?: string;
|
|
12
14
|
endpoint: string;
|
|
13
15
|
p256dh: string;
|
|
14
16
|
auth: string;
|
|
@@ -8,6 +8,10 @@ const buildDashboardPushNotificationSubscription = (mongooseInstance) => {
|
|
|
8
8
|
return mongooseInstance.model("DashboardPushNotificationSubscription");
|
|
9
9
|
}
|
|
10
10
|
const dashboardPushNotificationSubscriptionSchema = new mongooseInstance.Schema({
|
|
11
|
+
userId: {
|
|
12
|
+
type: String,
|
|
13
|
+
index: true, // Good to index if you query by userId often
|
|
14
|
+
},
|
|
11
15
|
authId: {
|
|
12
16
|
type: String,
|
|
13
17
|
index: true, // Good to index if you query by authId often
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Mongoose, Model, Document } from "mongoose";
|
|
3
|
+
import { AuthDoc } from "./auth";
|
|
4
|
+
export interface WebAuthnCredentialAttrs {
|
|
5
|
+
authId: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
credentialID: string;
|
|
8
|
+
publicKey: Buffer;
|
|
9
|
+
counter: number;
|
|
10
|
+
transports?: AuthenticatorTransport[];
|
|
11
|
+
backedUp: boolean;
|
|
12
|
+
aaguid: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WebAuthnCredentialDoc extends Document {
|
|
15
|
+
authId: AuthDoc["_id"];
|
|
16
|
+
name?: string;
|
|
17
|
+
credentialID: string;
|
|
18
|
+
publicKey: Buffer;
|
|
19
|
+
counter: number;
|
|
20
|
+
transports?: AuthenticatorTransport[];
|
|
21
|
+
backedUp: boolean;
|
|
22
|
+
aaguid: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
interface WebAuthnCredentialModel extends Model<WebAuthnCredentialDoc> {
|
|
27
|
+
build(attrs: WebAuthnCredentialAttrs): WebAuthnCredentialDoc;
|
|
28
|
+
}
|
|
29
|
+
declare const buildWebAuthnCredential: (mongoose: Mongoose) => WebAuthnCredentialModel;
|
|
30
|
+
export { buildWebAuthnCredential };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildWebAuthnCredential = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const buildWebAuthnCredential = (mongoose) => {
|
|
6
|
+
// If model is already defined, return it to prevent OverwriteModelError
|
|
7
|
+
if (mongoose.models.WebAuthnCredential) {
|
|
8
|
+
return mongoose.model("WebAuthnCredential");
|
|
9
|
+
}
|
|
10
|
+
const webAuthnCredentialSchema = new mongoose.Schema({
|
|
11
|
+
authId: {
|
|
12
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
13
|
+
ref: "Auth",
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
name: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
credentialID: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
unique: true, // WebAuthn Level 1 spec: credential IDs are globally unique.
|
|
24
|
+
},
|
|
25
|
+
publicKey: {
|
|
26
|
+
type: Buffer,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
counter: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
transports: {
|
|
34
|
+
type: [String],
|
|
35
|
+
required: false,
|
|
36
|
+
},
|
|
37
|
+
backedUp: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: true,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
aaguid: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
}, {
|
|
47
|
+
timestamps: true,
|
|
48
|
+
toJSON: {
|
|
49
|
+
transform(doc, ret) {
|
|
50
|
+
ret.id = ret._id.valueOf();
|
|
51
|
+
delete ret._id;
|
|
52
|
+
delete ret.__v;
|
|
53
|
+
// Do not serialize publicKey by default
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Index for efficient lookup by authId, if you often query credentials for a user
|
|
58
|
+
webAuthnCredentialSchema.index({ authId: 1 });
|
|
59
|
+
// Index for efficient lookup by credentialID as it's used during authentication
|
|
60
|
+
// This is already unique, but an explicit index can sometimes be beneficial for queries
|
|
61
|
+
// webAuthnCredentialSchema.index({ credentialID: 1 }); // unique:true already creates an index
|
|
62
|
+
webAuthnCredentialSchema.statics.build = (attrs) => {
|
|
63
|
+
return new WebAuthnCredential(attrs);
|
|
64
|
+
};
|
|
65
|
+
const WebAuthnCredential = mongoose.model("WebAuthnCredential", webAuthnCredentialSchema);
|
|
66
|
+
return WebAuthnCredential;
|
|
67
|
+
};
|
|
68
|
+
exports.buildWebAuthnCredential = buildWebAuthnCredential;
|