Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit cb70776

Browse files
committed
Replace protocol with module (#806)
1 parent 4355893 commit cb70776

35 files changed

+145
-202
lines changed

lib/attribute.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const assert = require('assert')
44

55
const asn1 = require('@ldapjs/asn1')
66

7-
const Protocol = require('./protocol')
7+
const Protocol = require('@ldapjs/protocol')
88

99
/// --- API
1010

@@ -96,8 +96,8 @@ Attribute.prototype.parse = function parse (ber) {
9696
ber.readSequence()
9797
this.type = ber.readString()
9898

99-
if (ber.peek() === Protocol.LBER_SET) {
100-
if (ber.readSequence(Protocol.LBER_SET)) {
99+
if (ber.peek() === Protocol.core.LBER_SET) {
100+
if (ber.readSequence(Protocol.core.LBER_SET)) {
101101
const end = ber.offset + ber.length
102102
while (ber.offset < end) { this._vals.push(ber.readString(asn1.Ber.OctetString, true)) }
103103
}
@@ -111,7 +111,7 @@ Attribute.prototype.toBer = function toBer (ber) {
111111

112112
ber.startSequence()
113113
ber.writeString(this.type)
114-
ber.startSequence(Protocol.LBER_SET)
114+
ber.startSequence(Protocol.core.LBER_SET)
115115
if (this._vals.length) {
116116
this._vals.forEach(function (b) {
117117
ber.writeByte(asn1.Ber.OctetString)

lib/change.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const assert = require('assert-plus')
44

55
const Attribute = require('./attribute')
6-
// var Protocol = require('./protocol')
76

87
/// --- API
98

lib/client/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Change = require('../change')
2020
const Control = require('../controls/index').Control
2121
const { Control: LdapControl } = require('@ldapjs/controls')
2222
const SearchPager = require('./search_pager')
23-
const Protocol = require('../protocol')
23+
const Protocol = require('@ldapjs/protocol')
2424
const dn = require('../dn')
2525
const errors = require('../errors')
2626
const filters = require('../filters')
@@ -601,7 +601,7 @@ Client.prototype.search = function search (base,
601601
baseObject: baseDN,
602602
scope: options.scope || 'base',
603603
filter: options.filter,
604-
derefAliases: options.derefAliases || Protocol.NEVER_DEREF_ALIASES,
604+
derefAliases: options.derefAliases || Protocol.search.NEVER_DEREF_ALIASES,
605605
sizeLimit: options.sizeLimit || 0,
606606
timeLimit: options.timeLimit || 10,
607607
typesOnly: options.typesOnly || false,

lib/client/search_pager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const assert = require('assert-plus')
77

88
// var dn = require('../dn')
99
// var messages = require('../messages/index')
10-
// var Protocol = require('../protocol')
1110
const { PagedResultsControl } = require('@ldapjs/controls')
1211

1312
const CorkedEmitter = require('../corked_emitter.js')

lib/filters/filter.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
// var assert = require('assert')
44

5-
const Protocol = require('../protocol')
5+
const Protocol = require('@ldapjs/protocol')
66

77
/// --- Globals
88

99
const TYPES = {
10-
and: Protocol.FILTER_AND,
11-
or: Protocol.FILTER_OR,
12-
not: Protocol.FILTER_NOT,
13-
equal: Protocol.FILTER_EQUALITY,
14-
substring: Protocol.FILTER_SUBSTRINGS,
15-
ge: Protocol.FILTER_GE,
16-
le: Protocol.FILTER_LE,
17-
present: Protocol.FILTER_PRESENT,
18-
approx: Protocol.FILTER_APPROX,
19-
ext: Protocol.FILTER_EXT
10+
and: Protocol.search.FILTER_AND,
11+
or: Protocol.search.FILTER_OR,
12+
not: Protocol.search.FILTER_NOT,
13+
equal: Protocol.search.FILTER_EQUALITY,
14+
substring: Protocol.search.FILTER_SUBSTRINGS,
15+
ge: Protocol.search.FILTER_GE,
16+
le: Protocol.search.FILTER_LE,
17+
present: Protocol.search.FILTER_PRESENT,
18+
approx: Protocol.search.FILTER_APPROX,
19+
ext: Protocol.search.FILTER_EXT
2020
}
2121

2222
/// --- API

lib/filters/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const asn1 = require('@ldapjs/asn1')
66

77
const parents = require('ldap-filter')
88

9-
const Protocol = require('../protocol')
9+
const Protocol = require('@ldapjs/protocol')
1010

1111
const Filter = require('./filter')
1212
const AndFilter = require('./and_filter')
@@ -71,53 +71,53 @@ function _parse (ber) {
7171

7272
const type = ber.readSequence()
7373
switch (type) {
74-
case Protocol.FILTER_AND:
74+
case Protocol.search.FILTER_AND:
7575
f = new AndFilter()
7676
parseSet(f)
7777
break
7878

79-
case Protocol.FILTER_APPROX:
79+
case Protocol.search.FILTER_APPROX:
8080
f = new ApproximateFilter()
8181
f.parse(ber)
8282
break
8383

84-
case Protocol.FILTER_EQUALITY:
84+
case Protocol.search.FILTER_EQUALITY:
8585
f = new EqualityFilter()
8686
f.parse(ber)
8787
return f
8888

89-
case Protocol.FILTER_EXT:
89+
case Protocol.search.FILTER_EXT:
9090
f = new ExtensibleFilter()
9191
f.parse(ber)
9292
return f
9393

94-
case Protocol.FILTER_GE:
94+
case Protocol.search.FILTER_GE:
9595
f = new GreaterThanEqualsFilter()
9696
f.parse(ber)
9797
return f
9898

99-
case Protocol.FILTER_LE:
99+
case Protocol.search.FILTER_LE:
100100
f = new LessThanEqualsFilter()
101101
f.parse(ber)
102102
return f
103103

104-
case Protocol.FILTER_NOT:
104+
case Protocol.search.FILTER_NOT:
105105
f = new NotFilter({
106106
filter: _parse(ber)
107107
})
108108
break
109109

110-
case Protocol.FILTER_OR:
110+
case Protocol.search.FILTER_OR:
111111
f = new OrFilter()
112112
parseSet(f)
113113
break
114114

115-
case Protocol.FILTER_PRESENT:
115+
case Protocol.search.FILTER_PRESENT:
116116
f = new PresenceFilter()
117117
f.parse(ber)
118118
break
119119

120-
case Protocol.FILTER_SUBSTRINGS:
120+
case Protocol.search.FILTER_SUBSTRINGS:
121121
f = new SubstringFilter()
122122
f.parse(ber)
123123
break

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const logger = require('./logger')
55
const client = require('./client')
66
const Attribute = require('./attribute')
77
const Change = require('./change')
8-
const Protocol = require('./protocol')
8+
const Protocol = require('@ldapjs/protocol')
99
const Server = require('./server')
1010

1111
const controls = require('./controls')

lib/messages/abandon_request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const assert = require('assert-plus')
44
const util = require('util')
55

66
const LDAPMessage = require('./message')
7-
const Protocol = require('../protocol')
7+
const Protocol = require('@ldapjs/protocol')
88

99
/// --- API
1010

@@ -13,7 +13,7 @@ function AbandonRequest (options) {
1313
assert.object(options)
1414
assert.optionalNumber(options.abandonID)
1515

16-
options.protocolOp = Protocol.LDAP_REQ_ABANDON
16+
options.protocolOp = Protocol.operations.LDAP_REQ_ABANDON
1717
LDAPMessage.call(this, options)
1818

1919
this.abandonID = options.abandonID || 0

lib/messages/abandon_response.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const assert = require('assert-plus')
44
const util = require('util')
55

66
const LDAPMessage = require('./result')
7-
// var Protocol = require('../protocol')
87

98
/// --- API
109

lib/messages/add_request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const util = require('util')
55

66
const LDAPMessage = require('./message')
77
const Attribute = require('../attribute')
8-
const Protocol = require('../protocol')
8+
const Protocol = require('@ldapjs/protocol')
99
const lassert = require('../assert')
1010

1111
/// --- API
@@ -16,7 +16,7 @@ function AddRequest (options) {
1616
lassert.optionalStringDN(options.entry)
1717
lassert.optionalArrayOfAttribute(options.attributes)
1818

19-
options.protocolOp = Protocol.LDAP_REQ_ADD
19+
options.protocolOp = Protocol.operations.LDAP_REQ_ADD
2020
LDAPMessage.call(this, options)
2121

2222
this.entry = options.entry || null

0 commit comments

Comments
 (0)