@vcard/vcard4-generator
v0.1.0-beta.1
Published
A vCard 4 generator library.
Downloads
97
Maintainers
Readme
@vcard/vcard4-generator
A library for generating v4 vCards
Heads Up!
This is still very much a WIP project and is not feature complete.
Install
npm install @vcard/vcard4-generatorUsage
import Vcard4Generator, { Vcard4GeneratorConfig } from '@vcard/vcard4-generator';
const config: Vcard4GeneratorConfig = {
fn: 'Captain Awesome',
email: '[email protected]',
url: 'http://www.example.com/'
};
const vcard = new Vcard4Generator(config);
vcard.toString();
// >> BEGIN:VCARD
// >> VERSION:4.0
// >> EMAIL:[email protected]
// >> FN:Captain Awesome
// >> URL:http://www.example.com/
// >> END:VCARDBuilding
From the monorepo root:
npx lerna --scope @vcard/vcard4-generator run buildTesting
From the monorepo root:
npm testTo-Do
- [ ] Properties
- [x]
ADR- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LABELParameter - [x]
LANGUAGEParameter - [x]
GEOParameter - [x]
TZParameter - [x]
ALTIDParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter
- [x]
ANNIVERSARY- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
ALTIDParameter - [x]
CALSCALEParameter (fordate-and-or-timetype only)
- [x]
BDAY- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
ALTIDParameter - [x]
CALSCALEParameter (fordate-and-or-timetype only) - [x]
LANGUAGEParameter (fortexttype only)
- [x]
BEGIN- [x] No Parameters
- [x]
BIRTHPLACE(RFC6474)- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter
- [x]
CALADRURI- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
CALURI- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
CATEGORIES- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
ALTIDParameter - [ ] Implement Constructor
ArrayArgument Support
- [x]
CLIENTPIDMAP- [x] Line Folding
- [x] Value Escaping
- [x] No Parameters
- [x] No
VALUEParameter - [ ] Implement Constructor
ArrayArgument Support
- [x]
CONTACT-URI(RFC8605)- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PREFParameter
- [x]
DEATHDATE(RFC6474)- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
CALSCALEParameter (fordate-and-or-timetype only) - [x]
LANGUAGEParameter (fortexttype only) - [x]
ALTIDParameter
- [x]
DEATHPLACE(RFC6474)- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
ALTIDParameter
- [x]
EMAIL- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
ALTIDParameter
- [x]
END- [x] No Parameters
- [x]
EXPERTISE(RFC6715)- [x] Line Folding
- [x] Value Escaping
- [x]
LEVELParameter - [x]
INDEXParameter - [x]
LANGUAGEParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
FBURL- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
ALTIDParameter
- [x]
FN- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
TYPEParameter - [x]
LANGUAGEParameter - [x]
ALTIDParameter - [x]
PIDParameter - [x]
PREFParameter
- [x]
GENDER- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [ ] Implement Constructor
ArrayArgument Support
- [x]
GEO- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
HOBBY(RFC6715)- [x] Line Folding
- [x] Value Escaping
- [x]
LEVELParameter - [x]
INDEXParameter - [x]
LANGUAGEParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
IMPP- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
INTEREST(RFC6715)- [x] Line Folding
- [x] Value Escaping
- [x]
LEVELParameter - [x]
INDEXParameter - [x]
LANGUAGEParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
KEY- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
MEDIATYPEParameter (forURItype only) - [x]
ALTIDParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter
- [x]
KIND- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter
- [x]
LANG- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
LOGO- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
MEMBER- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
MEDIATYPEParameter
- [x]
N- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
SORT-ASParameter - [x]
LANGUAGEParameter - [x]
ALTIDParameter
- [x]
NICKNAME- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
TYPEParameter - [x]
LANGUAGEParameter - [x]
ALTIDParameter - [x]
PIDParameter - [x]
PREFParameter
- [x]
NOTE- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
ALTIDParameter
- [x]
ORG- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
SORT-ASParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
ORG-DIRECTORY(RFC6715)- [x] Line Folding
- [x] Value Escaping
- [x]
INDEXParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
PHOTO- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
ALTIDParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
PREFParameter - [x]
PIDParameter
- [x]
PRODID- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter
- [x]
RELATED- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
MEDIATYPEParameter (forURItype only) - [x]
LANGUAGEParameter (fortexttype only) - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
REV- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter
- [x]
ROLE- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
ALTIDParameter
- [x]
SOUND- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
SOURCE- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
MEDIATYPEParameter
- [x]
TEL- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
MEDIATYPEParameter (forURItype only) - [x]
TYPEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter
- [x]
TITLE- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
LANGUAGEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
ALTIDParameter - [x]
TYPEParameter
- [x]
TZ- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
ALTIDParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter
- [x]
UID- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter
- [x]
URL- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
PIDParameter - [x]
PREFParameter - [x]
TYPEParameter - [x]
MEDIATYPEParameter - [x]
ALTIDParameter
- [x]
VERSION- [x] No Parameters
- [x]
XML- [x] Line Folding
- [x] Value Escaping
- [x]
VALUEParameter - [x]
ALTIDParameter
- [x]
- [x] Implement Parameter Value Encoding as Specified in RFC6868
Reference
Property Cardinalities
Property cardinalities are indicated using the following notation, which is based on ABNF (see [RFC5234], Section 3.6):
| Cardinality | Meaning | |:-----------:|--------------------------------------------------| | 1 | Exactly one instance per vCard MUST be present. | | 1 | Exactly one instance per vCard MAY be present. | | 1 | One or more instances per vCard MUST be present. | | * | One or more instances per vCard MAY be present. |
Properties defined in a vCard instance may have multiple values depending on the property cardinality. The general rule for encoding multi-valued properties is to simply create a new content line for each value (including the property name). However, it should be noted that some value types support encoding multiple values in a single content line by separating the values with a comma ",". This approach has been taken for several of the content types defined below (date, time, integer, float).
Property Parameters
A property can have attributes associated with it. These "property parameters" contain meta-information about the property or the property value. In some cases, the property parameter can be multi- valued in which case the property parameter value elements are separated by a COMMA (U+002C).
Property parameter value elements that contain the COLON (U+003A), SEMICOLON (U+003B), or COMMA (U+002C) character separators MUST be specified as quoted-string text values. Property parameter values MUST NOT contain the DQUOTE (U+0022) character. The DQUOTE character is used as a delimiter for parameter values that contain restricted characters or URI text.
Applications MUST ignore x-param and iana-param values they don't recognize.
Property Value Escaping
Some properties may contain one or more values delimited by a COMMA character (U+002C). Therefore, a COMMA character in a value MUST be escaped with a BACKSLASH character (U+005C), even for properties that don't allow multiple instances (for consistency).
Some properties (e.g., N and ADR) comprise multiple fields delimited by a SEMICOLON character (U+003B). Therefore, a SEMICOLON in a field of such a "compound" property MUST be escaped with a BACKSLASH character. SEMICOLON characters in non-compound properties MAY be escaped. On input, an escaped SEMICOLON character is never a field separator. An unescaped SEMICOLON character may be a field separator, depending on the property in which it appears.
Furthermore, some fields of compound properties may contain a list of values delimited by a COMMA character. Therefore, a COMMA character in one of a field's values MUST be escaped with a BACKSLASH character, even for fields that don't allow multiple values (for consistency). Compound properties allowing multiple instances MUST NOT be encoded in a single content line.
Finally, BACKSLASH characters in values MUST be escaped with a BACKSLASH character. NEWLINE (U+000A) characters in values MUST be encoded by two characters: a BACKSLASH followed by either an 'n' (U+006E) or an 'N' (U+004E).
In all other cases, escaping MUST NOT be used.
Links
- vCard Format Specification
- vCard KIND:application
- vCard Format Extensions: Place of Birth, Place and Date of Death
- vCard Format Extensions: Representing vCard Extensions Defined by the Open Mobile Alliance (OMA) Converged Address Book (CAB) Group
- Additional Data Related to an Emergency Call § vCard Parameter Value Registration
- vCard Format Extensions: ICANN Extensions for the Registration Data Access Protocol (RDAP)
- vCard Elements (IANA Protocol Registry)
License
The MIT License (Expat). See the license file for details.
