@sparted/shared-library 1.7.1 → 1.7.3

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.
@@ -95,6 +95,7 @@ export type ContentMetadata = {
95
95
  coverImage?: Image;
96
96
  name: MultilingualLabel;
97
97
  thematic: Thematic;
98
+ type: GameType;
98
99
  };
99
100
  export type Content = {
100
101
  archived: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { Image, Media } from './media';\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Thematic } from './thematic';\n\nexport type ErrorText = {\n id: number;\n type: 'error-text';\n gameMedia: Media;\n wrongText: MultilingualLabel;\n correctText: MultilingualLabel;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type ChoiceQuestion = {\n text: MultilingualLabel;\n correct: boolean;\n};\n\nexport type MultipleChoiceQuestion = {\n id: number;\n type: 'mcq';\n gameMedia: Media;\n question: MultilingualLabel;\n choices: ChoiceQuestion[];\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type NoInteraction = {\n id: number;\n type: 'no-interaction';\n firstMedia: Media;\n title: MultilingualLabel;\n text: MultilingualLabel;\n secondMedia: Media;\n};\n\nexport type OpenQuestion = {\n id: number;\n type: 'open-question';\n gameMedia: Media;\n question: MultilingualLabel;\n answer: MultilingualLabel;\n levenshteinDistance: number;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type OrderingCards = {\n id: number;\n type: 'ordering-cards';\n question: MultilingualLabel;\n topLabel: MultilingualLabel;\n cards: MultilingualLabel[];\n bottomLabel: MultilingualLabel;\n explanation: MultilingualLabel;\n};\n\nexport type Spot = {\n id: number;\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n};\n\nexport type PictureSpot = {\n id: number;\n type: 'picture-spot';\n image: Image;\n items: Spot[];\n explanation: MultilingualLabel;\n};\n\nexport type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';\n\nexport type SwipingCardZone = {\n position: SwipingCardPosition;\n text: MultilingualLabel;\n};\n\nexport type SwipingCard = {\n image?: Image;\n text?: MultilingualLabel;\n answer: SwipingCardPosition;\n};\n\nexport type SwipingCards = {\n id: number;\n type: 'swiping-cards';\n question: MultilingualLabel;\n zones: SwipingCardZone[];\n cards: SwipingCard[];\n explanation: MultilingualLabel;\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type ContentMetadata = {\n identifier: string;\n coverImage?: Image;\n name: MultilingualLabel;\n thematic: Thematic;\n};\n\nexport type Content = {\n archived: boolean;\n id: number;\n metadata: ContentMetadata;\n statuses: ContentStatuses;\n game?: Game;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n"],"names":[],"mappings":";;;;AAsHa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EAC9B;AAqBW,MAAA,4BAA4B,GAAG,CAAC,IAAU,KAAqC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AAC3G,MAAA,eAAe,GAAG,CAAC,IAAU,KAAwB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxF,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AACjG,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,iBAAiB,GAAG,CAAC,IAAU,KAA0B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC9F,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAEjG,MAAA,mCAAmC,GAAG,CACjD,IAAuB,KACyB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AACjE,MAAA,sBAAsB,GAAG,CAAC,IAAuB,KAC5D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxB,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAC3B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,wBAAwB,GAAG,CAAC,IAAuB,KAC9D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC1B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { Image, Media } from './media';\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Thematic } from './thematic';\n\nexport type ErrorText = {\n id: number;\n type: 'error-text';\n gameMedia: Media;\n wrongText: MultilingualLabel;\n correctText: MultilingualLabel;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type ChoiceQuestion = {\n text: MultilingualLabel;\n correct: boolean;\n};\n\nexport type MultipleChoiceQuestion = {\n id: number;\n type: 'mcq';\n gameMedia: Media;\n question: MultilingualLabel;\n choices: ChoiceQuestion[];\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type NoInteraction = {\n id: number;\n type: 'no-interaction';\n firstMedia: Media;\n title: MultilingualLabel;\n text: MultilingualLabel;\n secondMedia: Media;\n};\n\nexport type OpenQuestion = {\n id: number;\n type: 'open-question';\n gameMedia: Media;\n question: MultilingualLabel;\n answer: MultilingualLabel;\n levenshteinDistance: number;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type OrderingCards = {\n id: number;\n type: 'ordering-cards';\n question: MultilingualLabel;\n topLabel: MultilingualLabel;\n cards: MultilingualLabel[];\n bottomLabel: MultilingualLabel;\n explanation: MultilingualLabel;\n};\n\nexport type Spot = {\n id: number;\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n};\n\nexport type PictureSpot = {\n id: number;\n type: 'picture-spot';\n image: Image;\n items: Spot[];\n explanation: MultilingualLabel;\n};\n\nexport type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';\n\nexport type SwipingCardZone = {\n position: SwipingCardPosition;\n text: MultilingualLabel;\n};\n\nexport type SwipingCard = {\n image?: Image;\n text?: MultilingualLabel;\n answer: SwipingCardPosition;\n};\n\nexport type SwipingCards = {\n id: number;\n type: 'swiping-cards';\n question: MultilingualLabel;\n zones: SwipingCardZone[];\n cards: SwipingCard[];\n explanation: MultilingualLabel;\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type ContentMetadata = {\n identifier: string;\n coverImage?: Image;\n name: MultilingualLabel;\n thematic: Thematic;\n type: GameType;\n};\n\nexport type Content = {\n archived: boolean;\n id: number;\n metadata: ContentMetadata;\n statuses: ContentStatuses;\n game?: Game;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n"],"names":[],"mappings":";;;;AAsHa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EAC9B;AAsBW,MAAA,4BAA4B,GAAG,CAAC,IAAU,KAAqC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AAC3G,MAAA,eAAe,GAAG,CAAC,IAAU,KAAwB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxF,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AACjG,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,iBAAiB,GAAG,CAAC,IAAU,KAA0B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC9F,MAAA,mBAAmB,GAAG,CAAC,IAAU,KAA4B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AACpG,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAEjG,MAAA,mCAAmC,GAAG,CACjD,IAAuB,KACyB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AACjE,MAAA,sBAAsB,GAAG,CAAC,IAAuB,KAC5D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxB,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,cAAc;AAC3B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,wBAAwB,GAAG,CAAC,IAAuB,KAC9D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,aAAa;AAC1B,MAAA,0BAA0B,GAAG,CAAC,IAAuB,KAChE,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,eAAe;AAC5B,MAAA,yBAAyB,GAAG,CAAC,IAAuB,KAC/D,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;;;;;;;;;;;;;;;;;;"}
@@ -3,13 +3,7 @@
3
3
  * @param data
4
4
  * @param key Must be a 256 bits hex string
5
5
  * @param iv Must be a 128 bits hex string
6
+ * @returns Encrypted data as a hex string
6
7
  */
7
8
  declare function encrypt(data: string, key: string, iv: string): string;
8
- /**
9
- * Decrypt data using AES-256-CBC
10
- * @param data
11
- * @param key Must be a 256 bits hex string
12
- * @param iv Must be a 128 bits hex string
13
- */
14
- declare function decrypt(data: string, key: string, iv: string): string;
15
- export { encrypt, decrypt };
9
+ export { encrypt };
package/crypto/aes256.js CHANGED
@@ -10,6 +10,7 @@ var cryptoJs = require('crypto-js');
10
10
  * @param data
11
11
  * @param key Must be a 256 bits hex string
12
12
  * @param iv Must be a 128 bits hex string
13
+ * @returns Encrypted data as a hex string
13
14
  */
14
15
  function encrypt(data, key, iv) {
15
16
  if (key.length !== 64)
@@ -21,27 +22,8 @@ function encrypt(data, key, iv) {
21
22
  padding: cryptoJs.pad.Pkcs7,
22
23
  iv: cryptoJs.enc.Hex.parse(iv),
23
24
  });
24
- return cryptoJs.enc.Base64.stringify(cipher.ciphertext);
25
- }
26
- /**
27
- * Decrypt data using AES-256-CBC
28
- * @param data
29
- * @param key Must be a 256 bits hex string
30
- * @param iv Must be a 128 bits hex string
31
- */
32
- function decrypt(data, key, iv) {
33
- if (key.length !== 64)
34
- throw new Error('Key must be 256 bits long');
35
- if (iv.length !== 32)
36
- throw new Error('IV must be 128 bits long');
37
- const cipher = aes.decrypt(data, cryptoJs.enc.Hex.parse(key), {
38
- mode: cryptoJs.mode.CBC,
39
- padding: cryptoJs.pad.Pkcs7,
40
- iv: cryptoJs.enc.Hex.parse(iv),
41
- });
42
- return cryptoJs.enc.Utf8.stringify(cipher);
25
+ return cryptoJs.enc.Hex.stringify(cipher.ciphertext);
43
26
  }
44
27
 
45
- exports.decrypt = decrypt;
46
28
  exports.encrypt = encrypt;
47
29
  //# sourceMappingURL=aes256.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aes256.js","sources":["../../src/crypto/aes256.ts"],"sourcesContent":["import { encrypt as cryptoEncrypt, decrypt as cryptoDecript } from 'crypto-js/aes';\nimport { enc, mode, pad } from 'crypto-js';\n\n/**\n * Encrypt data using AES-256-CBC\n * @param data\n * @param key Must be a 256 bits hex string\n * @param iv Must be a 128 bits hex string\n */\nfunction encrypt(data: string, key: string, iv: string): string {\n if (key.length !== 64) throw new Error('Key must be 256 bits long');\n if (iv.length !== 32) throw new Error('IV must be 128 bits long');\n const cipher = cryptoEncrypt(data, enc.Hex.parse(key), {\n mode: mode.CBC,\n padding: pad.Pkcs7,\n iv: enc.Hex.parse(iv),\n });\n return enc.Base64.stringify(cipher.ciphertext);\n}\n\n/**\n * Decrypt data using AES-256-CBC\n * @param data\n * @param key Must be a 256 bits hex string\n * @param iv Must be a 128 bits hex string\n */\nfunction decrypt(data: string, key: string, iv: string): string {\n if (key.length !== 64) throw new Error('Key must be 256 bits long');\n if (iv.length !== 32) throw new Error('IV must be 128 bits long');\n const cipher = cryptoDecript(data, enc.Hex.parse(key), {\n mode: mode.CBC,\n padding: pad.Pkcs7,\n iv: enc.Hex.parse(iv),\n });\n return enc.Utf8.stringify(cipher);\n}\n\nexport { encrypt, decrypt };\n"],"names":["cryptoEncrypt","enc","mode","pad","cryptoDecript"],"mappings":";;;;;;;AAGA;;;;;AAKG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAA;AACpD,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACpE,IAAA,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAClE,IAAA,MAAM,MAAM,GAAGA,WAAa,CAAC,IAAI,EAAEC,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrD,IAAI,EAAEC,aAAI,CAAC,GAAG;QACd,OAAO,EAAEC,YAAG,CAAC,KAAK;QAClB,EAAE,EAAEF,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;AACtB,KAAA,CAAC,CAAC;IACH,OAAOA,YAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACjD,CAAC;AAED;;;;;AAKG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAA;AACpD,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACpE,IAAA,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAClE,IAAA,MAAM,MAAM,GAAGG,WAAa,CAAC,IAAI,EAAEH,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrD,IAAI,EAAEC,aAAI,CAAC,GAAG;QACd,OAAO,EAAEC,YAAG,CAAC,KAAK;QAClB,EAAE,EAAEF,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;AACtB,KAAA,CAAC,CAAC;IACH,OAAOA,YAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACpC;;;;;"}
1
+ {"version":3,"file":"aes256.js","sources":["../../src/crypto/aes256.ts"],"sourcesContent":["import { encrypt as cryptoEncrypt } from 'crypto-js/aes';\nimport { enc, mode, pad } from 'crypto-js';\n\n/**\n * Encrypt data using AES-256-CBC\n * @param data\n * @param key Must be a 256 bits hex string\n * @param iv Must be a 128 bits hex string\n * @returns Encrypted data as a hex string\n */\nfunction encrypt(data: string, key: string, iv: string): string {\n if (key.length !== 64) throw new Error('Key must be 256 bits long');\n if (iv.length !== 32) throw new Error('IV must be 128 bits long');\n const cipher = cryptoEncrypt(data, enc.Hex.parse(key), {\n mode: mode.CBC,\n padding: pad.Pkcs7,\n iv: enc.Hex.parse(iv),\n });\n return enc.Hex.stringify(cipher.ciphertext);\n}\n\nexport { encrypt };\n"],"names":["cryptoEncrypt","enc","mode","pad"],"mappings":";;;;;;;AAGA;;;;;;AAMG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAA;AACpD,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACpE,IAAA,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAClE,IAAA,MAAM,MAAM,GAAGA,WAAa,CAAC,IAAI,EAAEC,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrD,IAAI,EAAEC,aAAI,CAAC,GAAG;QACd,OAAO,EAAEC,YAAG,CAAC,KAAK;QAClB,EAAE,EAAEF,YAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;AACtB,KAAA,CAAC,CAAC;IACH,OAAOA,YAAG,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC9C;;;;"}
package/crypto/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { encrypt, decrypt } from './aes256';
1
+ export { encrypt } from './aes256';
package/crypto/index.js CHANGED
@@ -6,6 +6,5 @@ var aes256 = require('./aes256.js');
6
6
 
7
7
 
8
8
 
9
- exports.decrypt = aes256.decrypt;
10
9
  exports.encrypt = aes256.encrypt;
11
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/index.js CHANGED
@@ -85,6 +85,5 @@ exports.delay = delay.delay;
85
85
  exports.replaceInTemplate = replaceInTemplate.replaceInTemplate;
86
86
  exports.isStringLengthWithinRange = isStringLengthWithinRange.isStringLengthWithinRange;
87
87
  exports.getContrastColor = getContrastColor.getContrastColor;
88
- exports.decrypt = aes256.decrypt;
89
88
  exports.encrypt = aes256.encrypt;
90
89
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",