@iotize/device-com-nfc.cordova 3.8.0 → 3.9.0-alpha.4
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/bundles/iotize-device-com-nfc.cordova.umd.js +178 -16
- package/bundles/iotize-device-com-nfc.cordova.umd.js.map +1 -1
- package/bundles/iotize-device-com-nfc.cordova.umd.min.js +1 -1
- package/bundles/iotize-device-com-nfc.cordova.umd.min.js.map +1 -1
- package/esm2015/iotize-device-com-nfc.cordova.ngsummary.json +1 -1
- package/esm2015/public_api.ngsummary.json +1 -1
- package/esm2015/www/cordova-interface.js.map +1 -1
- package/esm2015/www/index.js +1 -1
- package/esm2015/www/index.js.map +1 -1
- package/esm2015/www/index.metadata.json +1 -1
- package/esm2015/www/index.ngsummary.json +1 -1
- package/esm2015/www/ndef/parse-ndef-message.js +133 -4
- package/esm2015/www/ndef/parse-ndef-message.js.map +1 -1
- package/esm2015/www/ndef/parse-ndef-message.metadata.json +1 -1
- package/esm2015/www/ndef/parse-ndef-message.ngsummary.json +1 -1
- package/esm2015/www/nfc-com-protocol.js.map +1 -1
- package/fesm2015/iotize-device-com-nfc.cordova.js +134 -6
- package/fesm2015/iotize-device-com-nfc.cordova.js.map +1 -1
- package/iotize-device-com-nfc.cordova.metadata.json +1 -1
- package/package.json +2 -2
- package/plugin.xml +98 -98
- package/src/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
- package/src/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
- package/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +1151 -1151
- package/src/ios/AppDelegate+NFC.swift +51 -51
- package/src/ios/NFCHelpers.swift +144 -144
- package/src/ios/NFCNDEFDelegate.swift +78 -78
- package/src/ios/NFCTagReader.swift +506 -500
- package/src/ios/NFCTapPlugin.swift +2 -2
- package/www/index.d.ts +1 -1
- package/www/ndef/parse-ndef-message.d.ts +10 -67
- package/www/phonegap-nfc.js +911 -911
- package/src/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
22
|
var extendStatics = function (d, b) {
|
|
23
23
|
extendStatics = Object.setPrototypeOf ||
|
|
24
24
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -154,8 +154,8 @@
|
|
|
154
154
|
}
|
|
155
155
|
function __generator(thisArg, body) {
|
|
156
156
|
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
157
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
158
|
-
return g =
|
|
157
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
158
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
159
159
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
160
160
|
function step(op) {
|
|
161
161
|
if (f)
|
|
@@ -310,9 +310,13 @@
|
|
|
310
310
|
if (!Symbol.asyncIterator)
|
|
311
311
|
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
312
312
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
313
|
-
return i =
|
|
314
|
-
function
|
|
315
|
-
|
|
313
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
314
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
315
|
+
function verb(n, f) { if (g[n]) {
|
|
316
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
|
|
317
|
+
if (f)
|
|
318
|
+
i[n] = f(i[n]);
|
|
319
|
+
} }
|
|
316
320
|
function resume(n, v) { try {
|
|
317
321
|
step(g[n](v));
|
|
318
322
|
}
|
|
@@ -392,7 +396,7 @@
|
|
|
392
396
|
if (value !== null && value !== void 0) {
|
|
393
397
|
if (typeof value !== "object" && typeof value !== "function")
|
|
394
398
|
throw new TypeError("Object expected.");
|
|
395
|
-
var dispose;
|
|
399
|
+
var dispose, inner;
|
|
396
400
|
if (async) {
|
|
397
401
|
if (!Symbol.asyncDispose)
|
|
398
402
|
throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
@@ -402,9 +406,18 @@
|
|
|
402
406
|
if (!Symbol.dispose)
|
|
403
407
|
throw new TypeError("Symbol.dispose is not defined.");
|
|
404
408
|
dispose = value[Symbol.dispose];
|
|
409
|
+
if (async)
|
|
410
|
+
inner = dispose;
|
|
405
411
|
}
|
|
406
412
|
if (typeof dispose !== "function")
|
|
407
413
|
throw new TypeError("Object not disposable.");
|
|
414
|
+
if (inner)
|
|
415
|
+
dispose = function () { try {
|
|
416
|
+
inner.call(this);
|
|
417
|
+
}
|
|
418
|
+
catch (e) {
|
|
419
|
+
return Promise.reject(e);
|
|
420
|
+
} };
|
|
408
421
|
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
409
422
|
}
|
|
410
423
|
else if (async) {
|
|
@@ -421,18 +434,26 @@
|
|
|
421
434
|
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
422
435
|
env.hasError = true;
|
|
423
436
|
}
|
|
437
|
+
var r, s = 0;
|
|
424
438
|
function next() {
|
|
425
|
-
while (env.stack.
|
|
426
|
-
var rec = env.stack.pop();
|
|
439
|
+
while (r = env.stack.pop()) {
|
|
427
440
|
try {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
441
|
+
if (!r.async && s === 1)
|
|
442
|
+
return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
443
|
+
if (r.dispose) {
|
|
444
|
+
var result = r.dispose.call(r.value);
|
|
445
|
+
if (r.async)
|
|
446
|
+
return s |= 2, Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
|
|
447
|
+
}
|
|
448
|
+
else
|
|
449
|
+
s |= 1;
|
|
431
450
|
}
|
|
432
451
|
catch (e) {
|
|
433
452
|
fail(e);
|
|
434
453
|
}
|
|
435
454
|
}
|
|
455
|
+
if (s === 1)
|
|
456
|
+
return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
436
457
|
if (env.hasError)
|
|
437
458
|
throw env.error;
|
|
438
459
|
}
|
|
@@ -536,16 +557,22 @@
|
|
|
536
557
|
switch (message.tnf) {
|
|
537
558
|
case exports.TNF.ABSOLUTE_URI:
|
|
538
559
|
return {
|
|
560
|
+
id: message.id,
|
|
561
|
+
type: message.type,
|
|
539
562
|
tnf: 'uri',
|
|
540
563
|
value: toAsciiString(message.payload),
|
|
541
564
|
};
|
|
542
565
|
case exports.TNF.WELL_KNOWN_TYPE:
|
|
543
566
|
return {
|
|
567
|
+
id: message.id,
|
|
568
|
+
type: message.type,
|
|
544
569
|
tnf: 'wkt',
|
|
545
570
|
value: parseWellKnownType(message),
|
|
546
571
|
};
|
|
547
572
|
case exports.TNF.EMPTY:
|
|
548
573
|
return {
|
|
574
|
+
id: message.id,
|
|
575
|
+
type: message.type,
|
|
549
576
|
tnf: 'empty',
|
|
550
577
|
value: {
|
|
551
578
|
type: message.type,
|
|
@@ -554,16 +581,22 @@
|
|
|
554
581
|
};
|
|
555
582
|
case exports.TNF.EXTERNAL:
|
|
556
583
|
return {
|
|
584
|
+
id: message.id,
|
|
585
|
+
type: message.type,
|
|
557
586
|
tnf: 'external',
|
|
558
587
|
value: paseExternalType(message),
|
|
559
588
|
};
|
|
560
589
|
case exports.TNF.MIME_TYPE:
|
|
561
590
|
return {
|
|
591
|
+
id: message.id,
|
|
592
|
+
type: message.type,
|
|
562
593
|
tnf: 'mimetype',
|
|
563
594
|
value: parseMimeType(message),
|
|
564
595
|
};
|
|
565
596
|
case exports.TNF.RFU:
|
|
566
597
|
return {
|
|
598
|
+
id: message.id,
|
|
599
|
+
type: message.type,
|
|
567
600
|
tnf: 'rfu',
|
|
568
601
|
value: {
|
|
569
602
|
type: message.type,
|
|
@@ -572,6 +605,8 @@
|
|
|
572
605
|
};
|
|
573
606
|
case exports.TNF.UNCHANGED:
|
|
574
607
|
return {
|
|
608
|
+
id: message.id,
|
|
609
|
+
type: message.type,
|
|
575
610
|
tnf: 'unchanged',
|
|
576
611
|
value: {
|
|
577
612
|
type: message.type,
|
|
@@ -580,6 +615,8 @@
|
|
|
580
615
|
};
|
|
581
616
|
case exports.TNF.UNKNOWN:
|
|
582
617
|
return {
|
|
618
|
+
id: message.id,
|
|
619
|
+
type: message.type,
|
|
583
620
|
tnf: 'unknown',
|
|
584
621
|
value: {
|
|
585
622
|
type: message.type,
|
|
@@ -588,6 +625,8 @@
|
|
|
588
625
|
};
|
|
589
626
|
default:
|
|
590
627
|
return {
|
|
628
|
+
id: message.id,
|
|
629
|
+
type: message.type,
|
|
591
630
|
tnf: message.tnf,
|
|
592
631
|
value: {
|
|
593
632
|
type: message.type,
|
|
@@ -597,7 +636,7 @@
|
|
|
597
636
|
}
|
|
598
637
|
}
|
|
599
638
|
function parseWellKnownType(message) {
|
|
600
|
-
if (arrayEquals(message.type, WellKnownType.URI)) {
|
|
639
|
+
if (arrayEquals(message.type.slice(), WellKnownType.URI)) {
|
|
601
640
|
var prefixCode = message.payload[0];
|
|
602
641
|
var prefix = WELL_KNOWN_TYPE_URI_PREFIX[prefixCode] || '';
|
|
603
642
|
return {
|
|
@@ -605,7 +644,7 @@
|
|
|
605
644
|
value: prefix + toAsciiString(message.payload.slice(1)),
|
|
606
645
|
};
|
|
607
646
|
}
|
|
608
|
-
else if (arrayEquals(message.type, WellKnownType.TEXT)) {
|
|
647
|
+
else if (arrayEquals(message.type.slice(), WellKnownType.TEXT)) {
|
|
609
648
|
var encodingNumber = message.payload[0];
|
|
610
649
|
var encoding = 'utf8';
|
|
611
650
|
var languageSizeInBytes = 0;
|
|
@@ -620,12 +659,15 @@
|
|
|
620
659
|
languageSizeInBytes = encodingNumber & 63;
|
|
621
660
|
}
|
|
622
661
|
var text = message.payload.slice(languageSizeInBytes + 1);
|
|
662
|
+
var language = message.payload.slice(8, languageSizeInBytes + 1);
|
|
623
663
|
return {
|
|
624
664
|
type: 'text',
|
|
625
665
|
value: buffer.Buffer.from(text).toString(encoding),
|
|
666
|
+
encoding: encoding,
|
|
667
|
+
language: buffer.Buffer.from(language).toString(encoding)
|
|
626
668
|
};
|
|
627
669
|
}
|
|
628
|
-
// else if (arrayEquals(message.type, WellKnownType.SMPART_POSTER)) {
|
|
670
|
+
// else if (arrayEquals(message.type.slice(), WellKnownType.SMPART_POSTER)) {
|
|
629
671
|
// return {
|
|
630
672
|
// type: 'sp',
|
|
631
673
|
// // TODO implement
|
|
@@ -636,7 +678,7 @@
|
|
|
636
678
|
return {
|
|
637
679
|
type: 'unknown',
|
|
638
680
|
value: {
|
|
639
|
-
type: message.type,
|
|
681
|
+
type: message.type.slice(),
|
|
640
682
|
payload: message.payload,
|
|
641
683
|
},
|
|
642
684
|
};
|
|
@@ -689,6 +731,124 @@
|
|
|
689
731
|
};
|
|
690
732
|
function parseMimeType(message) {
|
|
691
733
|
return buffer.Buffer.from(message.payload).toString('utf8');
|
|
734
|
+
}
|
|
735
|
+
function encodeWellKnownType(message) {
|
|
736
|
+
var e_1, _a;
|
|
737
|
+
if (message.value.type == 'uri') {
|
|
738
|
+
//identify the prefix
|
|
739
|
+
var prefixesEntries = Object.entries(WELL_KNOWN_TYPE_URI_PREFIX);
|
|
740
|
+
var prefixByte = 0;
|
|
741
|
+
try {
|
|
742
|
+
for (var prefixesEntries_1 = __values(prefixesEntries), prefixesEntries_1_1 = prefixesEntries_1.next(); !prefixesEntries_1_1.done; prefixesEntries_1_1 = prefixesEntries_1.next()) {
|
|
743
|
+
var _b = __read(prefixesEntries_1_1.value, 2), id = _b[0], prefix = _b[1];
|
|
744
|
+
if (id == '0x0') // Skip first as it is always recognized. (what about 0x1 vs 0x2?)
|
|
745
|
+
continue;
|
|
746
|
+
if (message.value.value.startsWith(prefix)) {
|
|
747
|
+
prefixByte = parseInt(id, 16);
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
753
|
+
finally {
|
|
754
|
+
try {
|
|
755
|
+
if (prefixesEntries_1_1 && !prefixesEntries_1_1.done && (_a = prefixesEntries_1.return)) _a.call(prefixesEntries_1);
|
|
756
|
+
}
|
|
757
|
+
finally { if (e_1) throw e_1.error; }
|
|
758
|
+
}
|
|
759
|
+
var lengthToSlice = WELL_KNOWN_TYPE_URI_PREFIX[prefixByte].length;
|
|
760
|
+
var slicedString = message.value.value.slice(lengthToSlice);
|
|
761
|
+
return __spreadArray([prefixByte], __read((byteConverter.asciiStringToByteBuffer(slicedString))));
|
|
762
|
+
}
|
|
763
|
+
else if (message.value.type === 'text') {
|
|
764
|
+
// b1: RFU (set to 0)
|
|
765
|
+
// b2-b7: la taille en octets de la langue (n)
|
|
766
|
+
// B8-B8+n-1: language
|
|
767
|
+
// Bn: message
|
|
768
|
+
var firstByte = message.value.encoding == 'utf16le' ? 128 : 0;
|
|
769
|
+
firstByte &= (message.value.language & 63);
|
|
770
|
+
var languageBytes = buffer.Buffer.from(message.value.language, message.value.encoding);
|
|
771
|
+
var textBytes = buffer.Buffer.from(message.value.value, message.value.encoding);
|
|
772
|
+
return __spreadArray(__spreadArray([firstByte], __read(languageBytes)), __read(textBytes));
|
|
773
|
+
}
|
|
774
|
+
else
|
|
775
|
+
return __spreadArray(__spreadArray([], __read(message.value.type)), __read(message.value.payload));
|
|
776
|
+
}
|
|
777
|
+
function encodeExternalType(message) {
|
|
778
|
+
return Array.from(buffer.Buffer.from(message.value.value, 'utf8'));
|
|
779
|
+
}
|
|
780
|
+
function encodeMimeType(message) {
|
|
781
|
+
return Array.from(buffer.Buffer.from(message.value, 'utf8'));
|
|
782
|
+
}
|
|
783
|
+
function encodeNDEFMessages(ndefRecords) {
|
|
784
|
+
return (ndefRecords || []).map(encodeNDEFMessage);
|
|
785
|
+
}
|
|
786
|
+
function encodeNDEFMessage(ndefRecord) {
|
|
787
|
+
switch (ndefRecord.tnf) {
|
|
788
|
+
case 'uri':
|
|
789
|
+
return {
|
|
790
|
+
id: ndefRecord.id,
|
|
791
|
+
type: ndefRecord.type,
|
|
792
|
+
tnf: exports.TNF.ABSOLUTE_URI,
|
|
793
|
+
payload: Array.from(byteConverter.asciiStringToByteBuffer(ndefRecord.value))
|
|
794
|
+
};
|
|
795
|
+
case 'wkt':
|
|
796
|
+
return {
|
|
797
|
+
id: ndefRecord.id,
|
|
798
|
+
type: ndefRecord.type,
|
|
799
|
+
tnf: exports.TNF.WELL_KNOWN_TYPE,
|
|
800
|
+
payload: encodeWellKnownType(ndefRecord),
|
|
801
|
+
};
|
|
802
|
+
case 'empty':
|
|
803
|
+
return {
|
|
804
|
+
id: ndefRecord.id,
|
|
805
|
+
type: ndefRecord.type,
|
|
806
|
+
tnf: exports.TNF.EMPTY,
|
|
807
|
+
payload: ndefRecord.payload,
|
|
808
|
+
};
|
|
809
|
+
case 'external':
|
|
810
|
+
return {
|
|
811
|
+
id: ndefRecord.id,
|
|
812
|
+
type: ndefRecord.type,
|
|
813
|
+
tnf: exports.TNF.EXTERNAL,
|
|
814
|
+
payload: encodeExternalType(ndefRecord),
|
|
815
|
+
};
|
|
816
|
+
case 'mimetype':
|
|
817
|
+
return {
|
|
818
|
+
id: ndefRecord.id,
|
|
819
|
+
type: ndefRecord.type,
|
|
820
|
+
tnf: exports.TNF.MIME_TYPE,
|
|
821
|
+
payload: encodeMimeType(ndefRecord),
|
|
822
|
+
};
|
|
823
|
+
case 'rfu':
|
|
824
|
+
return {
|
|
825
|
+
id: ndefRecord.id,
|
|
826
|
+
type: ndefRecord.type,
|
|
827
|
+
tnf: exports.TNF.RFU,
|
|
828
|
+
payload: ndefRecord.payload
|
|
829
|
+
};
|
|
830
|
+
case 'unchanged':
|
|
831
|
+
return {
|
|
832
|
+
id: ndefRecord.id,
|
|
833
|
+
type: ndefRecord.type,
|
|
834
|
+
tnf: exports.TNF.UNCHANGED,
|
|
835
|
+
payload: ndefRecord.payload,
|
|
836
|
+
};
|
|
837
|
+
case 'unknown':
|
|
838
|
+
return {
|
|
839
|
+
id: ndefRecord.id,
|
|
840
|
+
type: ndefRecord.type,
|
|
841
|
+
tnf: exports.TNF.UNKNOWN,
|
|
842
|
+
payload: ndefRecord.payload,
|
|
843
|
+
};
|
|
844
|
+
default:
|
|
845
|
+
return {
|
|
846
|
+
id: ndefRecord.id,
|
|
847
|
+
type: ndefRecord.type,
|
|
848
|
+
tnf: Number(ndefRecord.tnf),
|
|
849
|
+
payload: ndefRecord.payload,
|
|
850
|
+
};
|
|
851
|
+
}
|
|
692
852
|
}
|
|
693
853
|
|
|
694
854
|
var debug = debug$1.createDebugger("@iotize/device-com-nfc.cordova");
|
|
@@ -970,6 +1130,8 @@
|
|
|
970
1130
|
|
|
971
1131
|
exports.NFCComProtocol = NFCComProtocol;
|
|
972
1132
|
exports.WellKnownType = WellKnownType;
|
|
1133
|
+
exports.encodeNDEFMessage = encodeNDEFMessage;
|
|
1134
|
+
exports.encodeNDEFMessages = encodeNDEFMessages;
|
|
973
1135
|
exports.parseNdefMessage = parseNdefMessage;
|
|
974
1136
|
exports.parseNdefMessages = parseNdefMessages;
|
|
975
1137
|
exports.parseTapNdefMessage = parseTapNdefMessage;
|