-
Notifications
You must be signed in to change notification settings - Fork 1
/
payloads.js
120 lines (109 loc) · 4.03 KB
/
payloads.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var serialization = require('./cbaSerialization.js')
function loginRequest(login, password, $usr) {
var result = new Buffer(1024*10);
serialization.setBuffer(result);
serialization.writeHashtable({
'$METHODE': { type: 12, value: 'Identification' },
P4: { type: 12, value: 'IE9WIN7' },
'$CLASSE': { type: 12, value: 'CM_IDENTIFICATION' },
P2: { type: 12, value: password },
'$DOM': { type: 12, value: '' },
P3: { type: 99, value: { N: { type: 5, value: 0 } } },
'$APP': { type: 12, value: 'SilaeClient.exe' },
'$USR': { type: 12, value: $usr },
T3: { type: 12, value: 'SILAE.CListeSerialisable`1[System.String]' },
P1: { type: 12, value: login }
});
return addPadding(serialization.getBuffer());
}
function AcquisitionBulletins($usr, idDroit, idSuperviseur, idClient, idPaiSalarie) {
var cSupervisionContexte = supervisionContext(idDroit, idSuperviseur);
var result = new Buffer(1024*10);
serialization.setBuffer(result);
serialization.writeHashtable({
'$METHODE': { type: 12, value: 'AcquisitionBulletins' },
P4: { type: 5, value: 0 },
'$APP': { type: 12, value: 'SilaeClient.exe' },
P2: { type: 5, value: idDroit },
'$DOM': { type: 12, value: '' },
P5:
{ type: 99,
value:
{ BA:
{ type: 0x62,
value: cSupervisionContexte } }},
T5: { type: 12, value: 'SILAE.CM_SUPERVISION+CSupervisionContexte' },
P3: { type: 5, value: idPaiSalarie },
'$CLASSE': { type: 12, value: 'CM_PAIPORTAILCP' },
'$USR': { type: 12, value: $usr },
P1: { type: 5, value: idClient }
});
return addPadding(serialization.getBuffer());
}
function supervisionContext(idDroit, idSuperviseur) {
var result = new Buffer(1024*10);
serialization.setBuffer(result);
serialization.writeHashtable({
'Option_ListeRecursiveSupervises': { type: 2, value: true },
'OngletNatureUtilisateurSalarie': { type: 2, value: true },
'ID_DROIT': { type: 5, value: idDroit },
'ID_SUPERVISEUR_SVN': { type: 5, value: idSuperviseur } });
return serialization.getBuffer();
}
function GenererPdf($usr, idDroit, idSuperviseur, idClient, idPaiSalarie, idPaiBulletin) {
var cSupervisionContexte = supervisionContext(idDroit, idSuperviseur);
var arrayPaieSalarie = getIntArray([idPaiSalarie]);
var arrayPaiBulletin = getIntArray([idPaiBulletin]);
var result = new Buffer(1024*10);
serialization.setBuffer(result);
serialization.writeHashtable({
'$METHODE': { type: 12, value: 'ConstruirePDF' },
P4: { type: 3, value: 0 },
T2: { type: 12, value: 'SILAE.CListeSerialisable`1[System.Int32]' },
'$APP': { type: 12, value: 'SilaeClient.exe' },
P2:
{ type: 99,
value: { BA: { type: 0x62, value: arrayPaiBulletin } } },
'$DOM': { type: 12, value: '' },
P5:
{ type: 99,
value:
{ BA:
{ type: 0x62,
value: cSupervisionContexte } } },
T5: { type: 12, value: 'SILAE.CM_SUPERVISION+CSupervisionContexte' },
P3:
{ type: 99,
value: { BA: { type: 0x62, value: arrayPaieSalarie } } },
'$CLASSE': { type: 12, value: 'CM_PAIPORTAILCP' },
'$USR': { type: 12, value: $usr },
T3: { type: 12, value: 'SILAE.CListeSerialisable`1[System.Int32]' },
P1: { type: 5, value: idClient }
});
return addPadding(serialization.getBuffer());
}
function getIntArray(intArray) {
var result = new Buffer((intArray.length + 1) * 4);
result.writeInt32LE(intArray.length);
var offset = 4;
for(var i=0; i<intArray.length; i++) {
result.writeInt32LE(intArray[i], offset);
offset += 4;
}
return result;
}
function addPadding(buffer) {
var paddingToAdd = 32 - buffer.length % 32;
var bufferLength = buffer.length + paddingToAdd;
var result = new Buffer(bufferLength);
for(var i=buffer.length; i<bufferLength; i++) {
result[i] = paddingToAdd;
}
buffer.copy(result)
return result;
}
module.exports = {
loginRequest: loginRequest,
AcquisitionBulletins: AcquisitionBulletins,
GenererPdf: GenererPdf
}