@tonysamperi/ts-mapi-core 1.8.0 → 2.0.0-beta.1
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/dist/cjs/dynamo.cjs +2 -0
- package/dist/cjs/dynamo.cjs.map +1 -0
- package/dist/cjs/firebase.cjs +2 -0
- package/dist/cjs/firebase.cjs.map +1 -0
- package/dist/cjs/firebase.d.cts +61 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +8 -291
- package/dist/cjs/rxjs.cjs +2 -0
- package/dist/cjs/rxjs.cjs.map +1 -0
- package/dist/cjs/rxjs.d.cts +106 -0
- package/dist/{esm/shared/utils/cache/smp-abstract-cache-strategy.class.d.ts → cjs/smp-cached-value.interface-BdPg-J7L.d.cts} +6 -1
- package/dist/cjs/smp-generic-response-base.interface-D0jHrkjw.d.cts +27 -0
- package/dist/cjs/smp-social-sign-in-ux-modes.enum-Cw9H3EqT.d.cts +12 -0
- package/dist/cjs/zod.cjs +2 -0
- package/dist/cjs/zod.cjs.map +1 -0
- package/dist/cjs/zod.d.cts +45 -0
- package/dist/esm/chunk-DIVAYUSN.js +1 -0
- package/dist/esm/chunk-VBEMFJKM.js +1 -0
- package/dist/esm/dynamo.d.ts +39 -0
- package/dist/esm/{chunk-XF457SYA.js → dynamo.js} +1 -1
- package/dist/esm/{services/firebase/smp-firebase.service.d.ts → firebase.d.ts} +9 -4
- package/dist/esm/firebase.js +1 -0
- package/dist/esm/index.d.ts +999 -62
- package/dist/esm/index.js +1 -1
- package/dist/esm/rxjs.d.ts +106 -0
- package/dist/esm/rxjs.js +1 -0
- package/dist/esm/smp-cached-value.interface-BdPg-J7L.d.ts +21 -0
- package/dist/esm/smp-generic-response-base.interface-D0jHrkjw.d.ts +27 -0
- package/dist/esm/smp-social-sign-in-ux-modes.enum-Cw9H3EqT.d.ts +12 -0
- package/dist/esm/zod.d.ts +45 -0
- package/dist/esm/zod.js +1 -0
- package/package.json +60 -1
- package/dist/esm/chunk-2JBVVJ2E.js +0 -0
- package/dist/esm/chunk-2UDNZC5A.js +0 -1
- package/dist/esm/chunk-2YYH6VGI.js +0 -1
- package/dist/esm/chunk-3HRZ6R3F.js +0 -1
- package/dist/esm/chunk-4LYXZUNL.js +0 -0
- package/dist/esm/chunk-4TNTWTMN.js +0 -1
- package/dist/esm/chunk-4UTF5FWK.js +0 -1
- package/dist/esm/chunk-553CS7VH.js +0 -0
- package/dist/esm/chunk-5VCNTUI6.js +0 -1
- package/dist/esm/chunk-5WULAY6L.js +0 -1
- package/dist/esm/chunk-7CWGJ3NF.js +0 -1
- package/dist/esm/chunk-AV6X4R7W.js +0 -0
- package/dist/esm/chunk-BHFFGFHY.js +0 -0
- package/dist/esm/chunk-CFV5G67M.js +0 -1
- package/dist/esm/chunk-D2XOH6K4.js +0 -1
- package/dist/esm/chunk-D66G2KIE.js +0 -0
- package/dist/esm/chunk-DADFHUII.js +0 -1
- package/dist/esm/chunk-DGUMFWCQ.js +0 -0
- package/dist/esm/chunk-DOKJQH4K.js +0 -1
- package/dist/esm/chunk-EB55SS67.js +0 -0
- package/dist/esm/chunk-ELQKTQ6W.js +0 -0
- package/dist/esm/chunk-ET5LYR3A.js +0 -1
- package/dist/esm/chunk-FLTR4ZY6.js +0 -1
- package/dist/esm/chunk-FTXCYY5S.js +0 -1
- package/dist/esm/chunk-G7PUYG2K.js +0 -1
- package/dist/esm/chunk-GRXWCGMW.js +0 -1
- package/dist/esm/chunk-HM7F3YYW.js +0 -0
- package/dist/esm/chunk-HOM5S5W3.js +0 -0
- package/dist/esm/chunk-I3CNDIWD.js +0 -0
- package/dist/esm/chunk-JXSMI3MI.js +0 -1
- package/dist/esm/chunk-L7KNFRNV.js +0 -1
- package/dist/esm/chunk-LD5COSFG.js +0 -1
- package/dist/esm/chunk-MLBCWEB4.js +0 -1
- package/dist/esm/chunk-MRKAFTDG.js +0 -1
- package/dist/esm/chunk-NQICKEAS.js +0 -0
- package/dist/esm/chunk-O7TJDNO6.js +0 -0
- package/dist/esm/chunk-OUSY7GMI.js +0 -1
- package/dist/esm/chunk-PKEW426R.js +0 -0
- package/dist/esm/chunk-Q77KUWBZ.js +0 -0
- package/dist/esm/chunk-QK6DPGU6.js +0 -1
- package/dist/esm/chunk-QPKVVZUA.js +0 -1
- package/dist/esm/chunk-QRCMHI3B.js +0 -1
- package/dist/esm/chunk-QW43DOPY.js +0 -1
- package/dist/esm/chunk-QWZP25QT.js +0 -1
- package/dist/esm/chunk-R6VG4656.js +0 -1
- package/dist/esm/chunk-RAJGA43T.js +0 -1
- package/dist/esm/chunk-RAVJJJYE.js +0 -1
- package/dist/esm/chunk-RGLXAD7B.js +0 -1
- package/dist/esm/chunk-RJBWCWAE.js +0 -1
- package/dist/esm/chunk-SDQLEPBS.js +0 -0
- package/dist/esm/chunk-SJOEBOGG.js +0 -1
- package/dist/esm/chunk-SPPRTVHH.js +0 -1
- package/dist/esm/chunk-STU5GUNH.js +0 -1
- package/dist/esm/chunk-SXISZIFJ.js +0 -0
- package/dist/esm/chunk-SZM4WHQJ.js +0 -0
- package/dist/esm/chunk-TGY6ZSQU.js +0 -1
- package/dist/esm/chunk-U5DBFRKV.js +0 -0
- package/dist/esm/chunk-V6NBH54E.js +0 -1
- package/dist/esm/chunk-VHMV4QQT.js +0 -1
- package/dist/esm/chunk-WTEJYEK2.js +0 -0
- package/dist/esm/chunk-WTLVPDI2.js +0 -1
- package/dist/esm/chunk-XZEYUIQ6.js +0 -1
- package/dist/esm/chunk-YEQJ4M3P.js +0 -1
- package/dist/esm/chunk-ZKODHJSY.js +0 -1
- package/dist/esm/chunk-ZTDFA2UA.js +0 -1
- package/dist/esm/chunk-ZYPNYJVE.js +0 -0
- package/dist/esm/services/firebase/index.d.ts +0 -7
- package/dist/esm/services/firebase/index.js +0 -1
- package/dist/esm/services/firebase/smp-firebase-service-config.interface.d.ts +0 -12
- package/dist/esm/services/firebase/smp-firebase-service-config.interface.js +0 -0
- package/dist/esm/services/firebase/smp-firebase.service.js +0 -1
- package/dist/esm/services/http/index.d.ts +0 -12
- package/dist/esm/services/http/index.js +0 -1
- package/dist/esm/services/http/smp-dynamic-fetch-return.type.d.ts +0 -3
- package/dist/esm/services/http/smp-dynamic-fetch-return.type.js +0 -0
- package/dist/esm/services/http/smp-http-config.interface.d.ts +0 -16
- package/dist/esm/services/http/smp-http-config.interface.js +0 -1
- package/dist/esm/services/http/smp-http-session-storage-cache.class.d.ts +0 -11
- package/dist/esm/services/http/smp-http-session-storage-cache.class.js +0 -1
- package/dist/esm/services/http/smp-http-status-code.enum.d.ts +0 -70
- package/dist/esm/services/http/smp-http-status-code.enum.js +0 -1
- package/dist/esm/services/http/smp-http.service.d.ts +0 -46
- package/dist/esm/services/http/smp-http.service.js +0 -1
- package/dist/esm/services/index.d.ts +0 -22
- package/dist/esm/services/index.js +0 -1
- package/dist/esm/services/smp-dynamo.service.js +0 -1
- package/dist/esm/shared/api/index.d.ts +0 -11
- package/dist/esm/shared/api/index.js +0 -1
- package/dist/esm/shared/api/smp-api-common-utils.class.d.ts +0 -15
- package/dist/esm/shared/api/smp-api-common-utils.class.js +0 -1
- package/dist/esm/shared/api/smp-error-response-create-opts.interface.d.ts +0 -13
- package/dist/esm/shared/api/smp-error-response-create-opts.interface.js +0 -1
- package/dist/esm/shared/api/smp-error-response.class.d.ts +0 -25
- package/dist/esm/shared/api/smp-error-response.class.js +0 -1
- package/dist/esm/shared/api/smp-generic-response-base.interface.d.ts +0 -9
- package/dist/esm/shared/api/smp-generic-response-base.interface.js +0 -1
- package/dist/esm/shared/api/smp-generic-response.class.d.ts +0 -20
- package/dist/esm/shared/api/smp-generic-response.class.js +0 -1
- package/dist/esm/shared/api/smp-healtz.const.d.ts +0 -5
- package/dist/esm/shared/api/smp-healtz.const.js +0 -1
- package/dist/esm/shared/api/smp-response-message-base.interface.d.ts +0 -8
- package/dist/esm/shared/api/smp-response-message-base.interface.js +0 -1
- package/dist/esm/shared/api/smp-response-message-types.enum.d.ts +0 -8
- package/dist/esm/shared/api/smp-response-message-types.enum.js +0 -1
- package/dist/esm/shared/api/smp-response-message.class.d.ts +0 -13
- package/dist/esm/shared/api/smp-response-message.class.js +0 -1
- package/dist/esm/shared/api/smp-rest-verbs.enum.d.ts +0 -9
- package/dist/esm/shared/api/smp-rest-verbs.enum.js +0 -1
- package/dist/esm/shared/common/index.d.ts +0 -6
- package/dist/esm/shared/common/index.js +0 -1
- package/dist/esm/shared/common/smp-base-jwt-token-plain.interface.d.ts +0 -7
- package/dist/esm/shared/common/smp-base-jwt-token-plain.interface.js +0 -1
- package/dist/esm/shared/common/smp-base-jwt-token.class.d.ts +0 -14
- package/dist/esm/shared/common/smp-base-jwt-token.class.js +0 -1
- package/dist/esm/shared/common/smp-generic-constructor.type.d.ts +0 -3
- package/dist/esm/shared/common/smp-generic-constructor.type.js +0 -1
- package/dist/esm/shared/common/smp-primitive.type.d.ts +0 -3
- package/dist/esm/shared/common/smp-primitive.type.js +0 -1
- package/dist/esm/shared/common/smp-social-sign-in-keys.enum.d.ts +0 -7
- package/dist/esm/shared/common/smp-social-sign-in-keys.enum.js +0 -1
- package/dist/esm/shared/common/smp-social-sign-in-ux-modes.enum.d.ts +0 -6
- package/dist/esm/shared/common/smp-social-sign-in-ux-modes.enum.js +0 -1
- package/dist/esm/shared/crypto/index.d.ts +0 -3
- package/dist/esm/shared/crypto/index.js +0 -1
- package/dist/esm/shared/crypto/smp-aes-crypt.class.d.ts +0 -1
- package/dist/esm/shared/crypto/smp-aes-crypt.class.js +0 -1
- package/dist/esm/shared/crypto/smp-crypto.class.d.ts +0 -10
- package/dist/esm/shared/crypto/smp-crypto.class.js +0 -1
- package/dist/esm/shared/crypto/smp-secure-code.class.d.ts +0 -20
- package/dist/esm/shared/crypto/smp-secure-code.class.js +0 -1
- package/dist/esm/shared/firebase/index.d.ts +0 -1
- package/dist/esm/shared/firebase/index.js +0 -1
- package/dist/esm/shared/firebase/smp-firebase-errors.enum.d.ts +0 -14
- package/dist/esm/shared/firebase/smp-firebase-errors.enum.js +0 -1
- package/dist/esm/shared/giftcard/index.d.ts +0 -8
- package/dist/esm/shared/giftcard/index.js +0 -1
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-config.interface.d.ts +0 -11
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-config.interface.js +0 -1
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-hash-strategies.enum.d.ts +0 -8
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-hash-strategies.enum.js +0 -1
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-ops.enum.d.ts +0 -16
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-ops.enum.js +0 -1
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-plain.interface.d.ts +0 -8
- package/dist/esm/shared/giftcard/smp-giftcard-transaction-plain.interface.js +0 -1
- package/dist/esm/shared/giftcard/smp-giftcard-transaction.class.d.ts +0 -56
- package/dist/esm/shared/giftcard/smp-giftcard-transaction.class.js +0 -1
- package/dist/esm/shared/marketing-cloud/index.d.ts +0 -2
- package/dist/esm/shared/marketing-cloud/index.js +0 -1
- package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.d.ts +0 -14
- package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validation-response.interface.js +0 -1
- package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validators.enum.d.ts +0 -7
- package/dist/esm/shared/marketing-cloud/smp-marketing-cloud-validators.enum.js +0 -1
- package/dist/esm/shared/rxjs/index.d.ts +0 -10
- package/dist/esm/shared/rxjs/index.js +0 -1
- package/dist/esm/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.d.ts +0 -17
- package/dist/esm/shared/rxjs/smp-abstract-rxjs-ttl-cache-strategy.class.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-catch-only.function.d.ts +0 -5
- package/dist/esm/shared/rxjs/smp-rxjs-catch-only.function.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.d.ts +0 -15
- package/dist/esm/shared/rxjs/smp-rxjs-in-memory-cache.class.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-queue.function.d.ts +0 -11
- package/dist/esm/shared/rxjs/smp-rxjs-queue.function.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-sequence.function.d.ts +0 -12
- package/dist/esm/shared/rxjs/smp-rxjs-sequence.function.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-throw-if-empty.function.d.ts +0 -38
- package/dist/esm/shared/rxjs/smp-rxjs-throw-if-empty.function.js +0 -1
- package/dist/esm/shared/rxjs/smp-rxjs-throw-on-condition.function.d.ts +0 -30
- package/dist/esm/shared/rxjs/smp-rxjs-throw-on-condition.function.js +0 -1
- package/dist/esm/shared/utils/cache/index.d.ts +0 -7
- package/dist/esm/shared/utils/cache/index.js +0 -1
- package/dist/esm/shared/utils/cache/smp-abstract-cache-strategy.class.js +0 -1
- package/dist/esm/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.d.ts +0 -17
- package/dist/esm/shared/utils/cache/smp-abstract-ttl-cache-strategy.class.js +0 -1
- package/dist/esm/shared/utils/cache/smp-browser-cache.class.d.ts +0 -16
- package/dist/esm/shared/utils/cache/smp-browser-cache.class.js +0 -1
- package/dist/esm/shared/utils/cache/smp-cached-value.interface.d.ts +0 -6
- package/dist/esm/shared/utils/cache/smp-cached-value.interface.js +0 -1
- package/dist/esm/shared/utils/cache/smp-in-memory-cache.class.d.ts +0 -15
- package/dist/esm/shared/utils/cache/smp-in-memory-cache.class.js +0 -1
- package/dist/esm/shared/utils/cache/smp-is-smp-cached-value.function.d.ts +0 -9
- package/dist/esm/shared/utils/cache/smp-is-smp-cached-value.function.js +0 -1
- package/dist/esm/shared/utils/index.d.ts +0 -15
- package/dist/esm/shared/utils/index.js +0 -1
- package/dist/esm/shared/utils/smp-apply-mixin.function.d.ts +0 -5
- package/dist/esm/shared/utils/smp-apply-mixin.function.js +0 -1
- package/dist/esm/shared/utils/smp-ascii-words.function.d.ts +0 -3
- package/dist/esm/shared/utils/smp-ascii-words.function.js +0 -1
- package/dist/esm/shared/utils/smp-common-utils.class.d.ts +0 -101
- package/dist/esm/shared/utils/smp-common-utils.class.js +0 -1
- package/dist/esm/shared/utils/smp-filter-exception.class.d.ts +0 -7
- package/dist/esm/shared/utils/smp-filter-exception.class.js +0 -1
- package/dist/esm/shared/utils/smp-noop.function.d.ts +0 -1
- package/dist/esm/shared/utils/smp-noop.function.js +0 -1
- package/dist/esm/shared/utils/smp-regular-expressions.class.d.ts +0 -16
- package/dist/esm/shared/utils/smp-regular-expressions.class.js +0 -1
- package/dist/esm/shared/utils/smp-sid.class.d.ts +0 -18
- package/dist/esm/shared/utils/smp-sid.class.js +0 -1
- package/dist/esm/shared/utils/smp-unicode-words.class.d.ts +0 -15
- package/dist/esm/shared/utils/smp-unicode-words.class.js +0 -1
- package/dist/esm/shared/zod/index.d.ts +0 -3
- package/dist/esm/shared/zod/index.js +0 -1
- package/dist/esm/shared/zod/smp-zod-date-time.definition.d.ts +0 -28
- package/dist/esm/shared/zod/smp-zod-date-time.definition.js +0 -1
- package/dist/esm/smp-aes-crypt.class-CI82T7GV.d.ts +0 -470
- /package/dist/{esm/services/smp-dynamo.service.d.ts → cjs/dynamo.d.cts} +0 -0
- /package/dist/esm/{chunk-QYDMV6LH.js → chunk-F3OJMKBL.js} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as _aws_sdk_util_dynamodb from '@aws-sdk/util-dynamodb';
|
|
2
|
+
import { marshall } from '@aws-sdk/util-dynamodb';
|
|
3
|
+
import * as _aws_sdk_client_dynamodb from '@aws-sdk/client-dynamodb';
|
|
4
|
+
import { DynamoDBClientConfig, DynamoDB, DeleteItemInput, GetItemInput, PutItemInput } from '@aws-sdk/client-dynamodb';
|
|
5
|
+
import { SmpLoggerMethods } from '@tonysamperi/logger';
|
|
6
|
+
|
|
7
|
+
declare class SmpDynamoService<BaseKey extends object = object, PartitionKey extends string = string> {
|
|
8
|
+
protected _config: DynamoDBClientConfig;
|
|
9
|
+
protected _tableName: string;
|
|
10
|
+
get marshall(): typeof marshall;
|
|
11
|
+
get unmarshall(): (data: Record<string, _aws_sdk_client_dynamodb.AttributeValue> | _aws_sdk_client_dynamodb.AttributeValue, options?: _aws_sdk_util_dynamodb.unmarshallOptions) => Record<string, _aws_sdk_util_dynamodb.NativeAttributeValue>;
|
|
12
|
+
protected _db: DynamoDB;
|
|
13
|
+
protected _logger: SmpLoggerMethods;
|
|
14
|
+
protected constructor(_config: DynamoDBClientConfig, _tableName: string);
|
|
15
|
+
/**
|
|
16
|
+
* Just for override purposes
|
|
17
|
+
* @protected
|
|
18
|
+
*/
|
|
19
|
+
protected _buildConfig(): DynamoDBClientConfig;
|
|
20
|
+
protected _delete<T extends Record<PartitionKey, string> = Record<PartitionKey, string>>(Key: T, TableName?: string, opts?: Omit<DeleteItemInput, "Key" | "TableName">): Promise<_aws_sdk_client_dynamodb.DeleteItemCommandOutput>;
|
|
21
|
+
/**
|
|
22
|
+
* Read data from Dynamo passing a normal object
|
|
23
|
+
* @param Key the index you're searching, as standard object es. {myPartitionKey: "someValue"}
|
|
24
|
+
* @param TableName optionally override the table you're writing to
|
|
25
|
+
* @param opts attribute names mapping, values, etc...
|
|
26
|
+
* @protected
|
|
27
|
+
*/
|
|
28
|
+
protected _read<T extends Record<PartitionKey, string> = Record<PartitionKey, string>>(Key: T, TableName?: string, opts?: Omit<GetItemInput, "TableName" | "Item">): Promise<_aws_sdk_client_dynamodb.GetItemCommandOutput>;
|
|
29
|
+
/**
|
|
30
|
+
* Write data to Dynamo passing a normal object
|
|
31
|
+
* @param Item
|
|
32
|
+
* @param TableName
|
|
33
|
+
* @param opts
|
|
34
|
+
* @protected
|
|
35
|
+
*/
|
|
36
|
+
protected _write<T extends BaseKey = BaseKey>(Item: T, TableName: string | undefined, opts: Omit<PutItemInput, "Item" | "TableName">): Promise<_aws_sdk_client_dynamodb.PutItemCommandOutput>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { SmpDynamoService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-EI7MMDWY.js";import{DynamoDB as s}from"@aws-sdk/client-dynamodb";import{marshall as c,unmarshall as m}from"@aws-sdk/util-dynamodb";import{SmpLoggerMethods as h}from"@tonysamperi/logger";var _=(function(r){return r.CouldNotDelete="ERR_COULD_NOT_DELETE",r.CouldNotRead="ERR_COULD_NOT_READ",r.CouldNotWrite="ERR_COULD_NOT_WRITE",r.ConditionalCheckFailedException="ERR_DUPE_TOKEN",r})(_||{}),l=class{static{a(this,"SmpDynamoService")}_config;_tableName;get marshall(){return c}get unmarshall(){return m}_db=new s([this._buildConfig()]);_logger=new h;constructor(e,o){this._config=e,this._tableName=o}_buildConfig(){return this._config}_delete(e,o=this._tableName,i){let n={TableName:o,Key:this.marshall(e),...i};return this._db.deleteItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_DELETE")))}_read(e,o=this._tableName,i){let n={TableName:o,Key:this.marshall(e),...i};return this._db.getItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_READ")))}_write(e,o=this._tableName,i){let n={TableName:o,Item:this.marshall(e),...i};return this._db.putItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_WRITE")))}};export{l as
|
|
1
|
+
import{a}from"./chunk-EI7MMDWY.js";import{DynamoDB as s}from"@aws-sdk/client-dynamodb";import{marshall as c,unmarshall as m}from"@aws-sdk/util-dynamodb";import{SmpLoggerMethods as h}from"@tonysamperi/logger";var _=(function(r){return r.CouldNotDelete="ERR_COULD_NOT_DELETE",r.CouldNotRead="ERR_COULD_NOT_READ",r.CouldNotWrite="ERR_COULD_NOT_WRITE",r.ConditionalCheckFailedException="ERR_DUPE_TOKEN",r})(_||{}),l=class{static{a(this,"SmpDynamoService")}_config;_tableName;get marshall(){return c}get unmarshall(){return m}_db=new s([this._buildConfig()]);_logger=new h;constructor(e,o){this._config=e,this._tableName=o}_buildConfig(){return this._config}_delete(e,o=this._tableName,i){let n={TableName:o,Key:this.marshall(e),...i};return this._db.deleteItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_DELETE")))}_read(e,o=this._tableName,i){let n={TableName:o,Key:this.marshall(e),...i};return this._db.getItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_READ")))}_write(e,o=this._tableName,i){let n={TableName:o,Item:this.marshall(e),...i};return this._db.putItem(n).catch(t=>(this._logger.error("DynamoActionTokensService: couldn't write token to DB",t),Promise.reject(_[t.code]||"ERR_COULD_NOT_WRITE")))}};export{l as SmpDynamoService};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { SmpLoggerMethods } from '@tonysamperi/logger';
|
|
2
2
|
import { FirebaseOptions, FirebaseApp } from 'firebase/app';
|
|
3
3
|
import { User, Auth, AuthProvider, ActionCodeInfo, UserCredential, IdTokenResult } from 'firebase/auth';
|
|
4
|
-
import { SmpSocialSignInKeys } from '
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { S as SmpSocialSignInKeys, a as SmpSocialSignInUxModes } from './smp-social-sign-in-ux-modes.enum-Cw9H3EqT.js';
|
|
5
|
+
|
|
6
|
+
interface SmpFirebaseServiceConfig {
|
|
7
|
+
enabledSocials?: SmpSocialSignInKeys[];
|
|
8
|
+
logger?: SmpLoggerMethods;
|
|
9
|
+
popupFallsBackToRedirect?: boolean;
|
|
10
|
+
socialLoginUxMode?: SmpSocialSignInUxModes;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
declare class SmpFirebaseService {
|
|
9
14
|
static get INSTANCE(): SmpFirebaseService;
|
|
@@ -53,4 +58,4 @@ declare class SmpFirebaseService {
|
|
|
53
58
|
protected _watchAuthState(): void;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
export { SmpFirebaseService };
|
|
61
|
+
export { SmpFirebaseService, type SmpFirebaseServiceConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as o,c as n}from"./chunk-DIVAYUSN.js";import{a}from"./chunk-EI7MMDWY.js";import{SmpLoggerMethods as c}from"@tonysamperi/logger";import{getApps as l,initializeApp as g}from"firebase/app";import{browserLocalPersistence as u,browserSessionPersistence as p,EmailAuthProvider as _,FacebookAuthProvider as m,GoogleAuthProvider as f,OAuthProvider as P,checkActionCode as U,confirmPasswordReset as E,fetchSignInMethodsForEmail as b,getAuth as S,getRedirectResult as w,reauthenticateWithCredential as I,sendEmailVerification as F,sendPasswordResetEmail as v,setPersistence as A,signInWithCustomToken as C,signInWithEmailAndPassword as R,signInWithPopup as L,signInWithRedirect as O,signOut as T,updatePassword as k,updateProfile as x}from"firebase/auth";var h=class d{static{a(this,"SmpFirebaseService")}static get INSTANCE(){if(!(this._instance instanceof d))throw Error(`${this.constructor.name} instance doesn't exist! Call ${this.constructor.name}.init first!`);return this._instance}static _instance;get config(){return this._config}get enabledSocials(){return this._enabledSocials}get loggedUser(){return this._loggedUser||(this._loggedUser=this._readStoredUser()),this._auth.currentUser||this._loggedUser||void 0}get providersRelation(){return{"facebook.com":s.FACEBOOK,"google.com":s.GOOGLE,"apple.com":s.APPLE}}get socialLoginUXMode(){return this._socialLoginUxMode}get storedUserKey(){return"firebaseUser"}get _auth(){return S(this._app)}_app;_config;_enabledSocials=[];_loggedUser;_logger;_popupErrors=0;_popupFallsBackToRedirect;_providers;_socialLoginUxMode=o.POPUP;constructor(e,t){this._config=e,this._enabledSocials=t.enabledSocials||[],this._socialLoginUxMode=t.socialLoginUxMode||o.POPUP,this._popupFallsBackToRedirect=!!t.popupFallsBackToRedirect,this._buildProviders(),this._logger=t.logger||new c,this._app=l().length?l()[0]:g(e),this._watchAuthState()}static init(e,t){return this._instance||(this._instance=new d(e,t)),this._instance}addAuthStateChangedCallback(e){return this._auth.onAuthStateChanged(t=>{e(t||this.loggedUser||null)})}checkActionCode(e){return U(this._auth,e)}confirmPasswordReset(e,t){return E(this._auth,e,t)}fetchSignInMethodsForEmail(e){return b(this._auth,e).then(t=>t.map(r=>this.providersRelation[r]||r))}getRedirectResult(){return w(this._auth).catch(async e=>(await this._expandDifferentCredential(e),Promise.reject(e)))}initAppCheck(){}sendEmailVerification(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return F(this.loggedUser,e?{url:e}:void 0)}sendPasswordResetEmail(e,t){return v(this._auth,e,{url:t})}setPersistence(e){return A(this._auth,e?u:p)}signInWithCustomToken(e){return C(this._auth,e)}signInWithEmailAndPassword(e,t){return R(this._auth,e,t).then(async r=>r.user)}signInWithSocialProvider(e){if(!this._providers[e])throw Error(`Firebase: invalid social key provided! Expected one of ${this.enabledSocials}, got ${e}`);return this._signInWithProvider(this._providers[e])}signOut(){return T(this._auth)}updatePassword(e,t){if(!this.loggedUser)throw Error("Firebase: user is not logged!");let r=_.credential(this.loggedUser.email,e);return I(this.loggedUser,r).then(()=>k(this.loggedUser,t))}updateUserProfile(e){if(!this.loggedUser)throw Error("Firebase: user is not logged!");return x(this.loggedUser,e)}async verifyIdToken(){return this._auth.currentUser?.getIdTokenResult()}_buildProviders(){this._providers=this._enabledSocials.reduce((e,t)=>(t in e&&(e[t]=e[t]),e),{[s.APPLE]:new P("apple.com"),[s.FACEBOOK]:new m().setCustomParameters({prompt:"select_account"}),[s.GOOGLE]:new f().setCustomParameters({prompt:"select_account"})})}async _expandDifferentCredential(e){if(e?.code===n.DIFFERENT_CREDENTIAL){let t=await this.fetchSignInMethodsForEmail(e.customData.email);throw e.code=n["DIFFERENT_CREDENTIAL_"+t[0]],e}}_readStoredUser(){try{let e=localStorage.getItem(this.storedUserKey);if(e){this._logger?.debug("Firebase: found local user",e);let t=JSON.parse(e);return{...t,getIdToken:a(()=>Promise.resolve(t.stsTokenManager.accessToken),"getIdToken")}}}catch(e){this._logger.debug("Firebase: error while getting stored user",e)}}async _signInWithProvider(e,t=this.socialLoginUXMode){return(t===o.POPUP?L:O)(this._auth,e).then(i=>(this._logger.info(`Firebase: signin with provider ${e.providerId} was successful`),i.user)).catch(async i=>i?.code===n.POPUP_BLOCKED&&(this._logger.warn(`Firebase: social signin popup blocked (${++this._popupErrors}`),this._popupFallsBackToRedirect&&this._popupErrors>1)?(this._popupErrors=0,this._signInWithProvider(e,o.REDIRECT)):(this._logger.error(`Firebase: sign in with ${e.providerId} errored`,i),await this._expandDifferentCredential(i),Promise.reject(i)))}_updateLocalUser(e){try{e?localStorage.setItem(this.storedUserKey,JSON.stringify(e)):localStorage.removeItem(this.storedUserKey),this._logger.debug("Firebase: updating local user",e),this._loggedUser=e}catch(t){this._logger.warn("Firebase: couldn't update local user",{user:e,error:t})}}_watchAuthState(){this._auth.onAuthStateChanged(e=>{this._logger.debug("Firebase: firebase detected auth state change",e),this._updateLocalUser(e||void 0)})}};export{h as SmpFirebaseService};
|