@notifi-network/notifi-frontend-client
Advanced tools
Comparing version 3.0.2-alpha.7 to 3.0.2-alpha.10
@@ -485,6 +485,7 @@ import { Types, Operations, NotifiService } from '@notifi-network/notifi-graphql'; | ||
type OidcSignInFunction = () => Promise<OidcCredentials>; | ||
type AuthenticateResult = { | ||
type SignMessageResult = { | ||
signature: string; | ||
signedMessage: string; | ||
} | OidcCredentials; | ||
}; | ||
type AuthenticateResult = SignMessageResult | OidcCredentials; | ||
type CardConfigType = CardConfigItemV1; | ||
@@ -497,3 +498,3 @@ type BeginLoginProps = Omit<Types.BeginLogInByTransactionInput, 'dappAddress'>; | ||
type FindSubscriptionCardParams = Omit<Types.FindTenantConfigInput, 'tenant'>; | ||
declare const SIGNING_MESSAGE = "Sign in with Notifi \n\n No password needed or gas is needed. \n\n Clicking \u201CApprove\u201D only means you have proved this wallet is owned by you! \n\n This request will not trigger any transaction or cost any gas fees. \n\n Use of our website and service is subject to our terms of service and privacy policy. \n \n 'Nonce:' "; | ||
declare const SIGNING_MESSAGE: string; | ||
type SupportedCardConfigType = CardConfigItemV1; | ||
@@ -536,3 +537,3 @@ type UserState = Readonly<{ | ||
private logInWithWeb3; | ||
logIn(signMessageParams: LoginParams): Promise<Types.UserFragmentFragment>; | ||
logIn(loginParams: LoginParams): Promise<Types.UserFragmentFragment>; | ||
private _authenticate; | ||
@@ -938,2 +939,2 @@ private _handleLogInResult; | ||
export { type AcalaSignMessageFunction, type AcalaUserParams, type AgoricUserParams, type AlertFilter, type AlertFrequency, type AptosSignMessageFunction, type AptosUserParams, type ArchUserParams, type ArchwayUserParams, type AuthenticateResult, type Authorization, type AuthorizationStorage, type AxelarUserParams, type BitcoinUserParams, type BroadcastEventTypeItem, type CardConfigItemV1, type CardConfigType, type CelestiaUserParams, type CheckRatio, type ConfigFactoryInput, type ConfigFactoryInputDelegated, type ConfigFactoryInputOidc, type ConfigFactoryInputPublicKey, type ConfigFactoryInputPublicKeyAndAddress, type ConnectWalletParams, type ContactInfo, type ContactInfoConfig, type CosmosUserParams, type CountryCode, type CreateFunc, type CustomHealthCheckItem, type CustomInputConstraints, type CustomToggleTypeItem, type CustomTopicTypeItem, type CustomTypeBase, type DeepPartialReadonly, type DirectPushEventTypeItem, type DiscordContactInfo, type DydxUserParams, type DymensionUserParams, type ElysUserParams, type EmailContactInfo, type EnsureWebhookParams$1 as EnsureWebhookParams, type EventTypeConfig, type EventTypeItem, type EvmUserParams, type FetchFunc, type Filter, type FilterBase, type FilterOptions, type FilterType, type FrequencyFilter, type FrontendClientConfigFactory, type FusionEventMetadata, type FusionEventTopic, type FusionEventTypeItem, type FusionFilterOptions, type FusionHealthCheckEventTypeItem, type FusionMultiThreshholdEventTypeItem, type FusionToggleEventTypeItem, type FusionTypeBase, type GetStorageType, type HasStorageType, type HealthCheckEventInputsWithCustomPercentage, type HealthCheckEventInputsWithIndex, type HealthCheckEventTypeItem, type HealthCheckInputs, type IdentifyFunc, type InjectiveUserParams, type InputItem, type InputObject, type InputType, type InputsConfig, type KavaUserParams, type LabelEventTypeItem, type MovementUserParams, type NearUserParams, type NeutronUserParams, type NotifiConfigWithDelegate, type NotifiConfigWithOidc, type NotifiConfigWithPublicKey, type NotifiConfigWithPublicKeyAndAddress, type NotifiEnvironment, type NotifiEnvironmentConfiguration, NotifiFrontendClient, type NotifiFrontendConfiguration, NotifiFrontendStorage, type NotifiStorage, type NumberTypeSelect, type OffChainUserParams, type OidcCredentials, type OidcSignInFunction, type OraiUserParams, type PersistenceUserParams, type PrefixAndSuffix, type PriceChangeDataSource, type PriceChangeEventTypeItem, type RequiredParserVariable, type Roles, type RolesStorage, SIGNING_MESSAGE, type SetStorageType, type SignMessageParams, type SlackContactInfo, type SmsContactInfo, type SolanaUserParams, type StorageDriver, type StorageType, type SuiUserParams, type SupportedCardConfigType, type TelegramContactInfo, type TenantConfig, type ThresholdDirection, type TitleSubtitleConfig, type TitleSubtitleConfigActive, type TitleSubtitleConfigInactive, type TradingPairEventTypeItem, type TradingPairInputs, type UiType, type Uint8SignMessageFunction, type UserInputOptions, type UserInputParam, type UserParams, type UserState, type ValidInputRange, type ValueItemConfig, type ValueOrRef, type ValueTransformFunc, type ValueType, type WalletBalanceEventTypeItem, type WalletContactInfo, type WalletWithSignParams, type WebhookContactInfo, type WebhookHeaders, type XMTPTopicTypeItem, type XionSignMessageFunction, type XionUserParams, checkIsConfigWithDelegate, checkIsConfigWithOidc, checkIsConfigWithPublicKeyAndAddress, createInMemoryStorageDriver, createLocalForageStorageDriver, ensureDiscord, ensureEmail, ensureSlack, ensureSms, ensureSourceAndFilters, ensureTarget, ensureTelegram, ensureWeb3, ensureWebhook, envUrl, instantiateFrontendClient, isEvmChain, newFrontendClient, newFrontendConfig, newNotifiService, newNotifiStorage, normalizeHexString, notNullOrEmpty, objectKeys, packFilterOptions, resolveCheckRatioArrayRef, resolveNumberRef, resolveObjectArrayRef, resolveStringArrayRef, resolveStringRef }; | ||
export { type AcalaSignMessageFunction, type AcalaUserParams, type AgoricUserParams, type AlertFilter, type AlertFrequency, type AptosSignMessageFunction, type AptosUserParams, type ArchUserParams, type ArchwayUserParams, type AuthenticateResult, type Authorization, type AuthorizationStorage, type AxelarUserParams, type BitcoinUserParams, type BroadcastEventTypeItem, type CardConfigItemV1, type CardConfigType, type CelestiaUserParams, type CheckRatio, type ConfigFactoryInput, type ConfigFactoryInputDelegated, type ConfigFactoryInputOidc, type ConfigFactoryInputPublicKey, type ConfigFactoryInputPublicKeyAndAddress, type ConnectWalletParams, type ContactInfo, type ContactInfoConfig, type CosmosUserParams, type CountryCode, type CreateFunc, type CustomHealthCheckItem, type CustomInputConstraints, type CustomToggleTypeItem, type CustomTopicTypeItem, type CustomTypeBase, type DeepPartialReadonly, type DirectPushEventTypeItem, type DiscordContactInfo, type DydxUserParams, type DymensionUserParams, type ElysUserParams, type EmailContactInfo, type EnsureWebhookParams$1 as EnsureWebhookParams, type EventTypeConfig, type EventTypeItem, type EvmUserParams, type FetchFunc, type Filter, type FilterBase, type FilterOptions, type FilterType, type FrequencyFilter, type FrontendClientConfigFactory, type FusionEventMetadata, type FusionEventTopic, type FusionEventTypeItem, type FusionFilterOptions, type FusionHealthCheckEventTypeItem, type FusionMultiThreshholdEventTypeItem, type FusionToggleEventTypeItem, type FusionTypeBase, type GetStorageType, type HasStorageType, type HealthCheckEventInputsWithCustomPercentage, type HealthCheckEventInputsWithIndex, type HealthCheckEventTypeItem, type HealthCheckInputs, type IdentifyFunc, type InjectiveUserParams, type InputItem, type InputObject, type InputType, type InputsConfig, type KavaUserParams, type LabelEventTypeItem, type MovementUserParams, type NearUserParams, type NeutronUserParams, type NotifiConfigWithDelegate, type NotifiConfigWithOidc, type NotifiConfigWithPublicKey, type NotifiConfigWithPublicKeyAndAddress, type NotifiEnvironment, type NotifiEnvironmentConfiguration, NotifiFrontendClient, type NotifiFrontendConfiguration, NotifiFrontendStorage, type NotifiStorage, type NumberTypeSelect, type OffChainUserParams, type OidcCredentials, type OidcSignInFunction, type OraiUserParams, type PersistenceUserParams, type PrefixAndSuffix, type PriceChangeDataSource, type PriceChangeEventTypeItem, type RequiredParserVariable, type Roles, type RolesStorage, SIGNING_MESSAGE, type SetStorageType, type SignMessageParams, type SignMessageResult, type SlackContactInfo, type SmsContactInfo, type SolanaUserParams, type StorageDriver, type StorageType, type SuiUserParams, type SupportedCardConfigType, type TelegramContactInfo, type TenantConfig, type ThresholdDirection, type TitleSubtitleConfig, type TitleSubtitleConfigActive, type TitleSubtitleConfigInactive, type TradingPairEventTypeItem, type TradingPairInputs, type UiType, type Uint8SignMessageFunction, type UserInputOptions, type UserInputParam, type UserParams, type UserState, type ValidInputRange, type ValueItemConfig, type ValueOrRef, type ValueTransformFunc, type ValueType, type WalletBalanceEventTypeItem, type WalletContactInfo, type WalletWithSignParams, type WebhookContactInfo, type WebhookHeaders, type XMTPTopicTypeItem, type XionSignMessageFunction, type XionUserParams, checkIsConfigWithDelegate, checkIsConfigWithOidc, checkIsConfigWithPublicKeyAndAddress, createInMemoryStorageDriver, createLocalForageStorageDriver, ensureDiscord, ensureEmail, ensureSlack, ensureSms, ensureSourceAndFilters, ensureTarget, ensureTelegram, ensureWeb3, ensureWebhook, envUrl, instantiateFrontendClient, isEvmChain, newFrontendClient, newFrontendConfig, newNotifiService, newNotifiStorage, normalizeHexString, notNullOrEmpty, objectKeys, packFilterOptions, resolveCheckRatioArrayRef, resolveNumberRef, resolveObjectArrayRef, resolveStringArrayRef, resolveStringRef }; |
@@ -450,6 +450,5 @@ import { Types } from '@notifi-network/notifi-graphql'; | ||
export type OidcSignInFunction = () => Promise<OidcCredentials>; | ||
export type SignMessageResult = { signature: string; signedMessage: string }; | ||
export type AuthenticateResult = | ||
| { signature: string; signedMessage: string } | ||
| OidcCredentials; | ||
export type AuthenticateResult = SignMessageResult | OidcCredentials; | ||
@@ -481,4 +480,4 @@ export type CardConfigType = CardConfigItemV1; | ||
// modify the string literal, which then causes authentication to fail due to different strings | ||
export const SIGNING_MESSAGE = `Sign in with Notifi \n\n No password needed or gas is needed. \n\n Clicking “Approve” only means you have proved this wallet is owned by you! \n\n This request will not trigger any transaction or cost any gas fees. \n\n Use of our website and service is subject to our terms of service and privacy policy. \n \n 'Nonce:' `; | ||
const SIGNING_MESSAGE_WITHOUT_NONCE = `Sign in with Notifi \n\n No password needed or gas is needed. \n\n Clicking “Approve” only means you have proved this wallet is owned by you! \n\n This request will not trigger any transaction or cost any gas fees. \n\n Use of our website and service is subject to our terms of service and privacy policy.`; | ||
export const SIGNING_MESSAGE = `${SIGNING_MESSAGE_WITHOUT_NONCE} \n \n 'Nonce:' `; | ||
@@ -696,5 +695,3 @@ const CHAINS_WITH_LOGIN_WEB3 = ['XION', 'APTOS', 'MOVEMENT'] as const; | ||
loginWeb3Params: LoginWeb3Params, | ||
): Promise<Types.UserFragmentFragment> { | ||
let user: Types.UserFragmentFragment | undefined = undefined; | ||
): Promise<Types.UserFragmentFragment | undefined> { | ||
if ( | ||
@@ -729,124 +726,120 @@ !CHAINS_WITH_LOGIN_WEB3.includes(loginWeb3Params.walletBlockchain) || | ||
user = completeLogInWithWeb3.user; | ||
if (user === undefined) { | ||
return Promise.reject('Failed to login'); | ||
} | ||
await this._handleLogInResult(user); | ||
return user; | ||
return completeLogInWithWeb3.user; | ||
} | ||
async logIn( | ||
signMessageParams: LoginParams, | ||
): Promise<Types.UserFragmentFragment> { | ||
async logIn(loginParams: LoginParams): Promise<Types.UserFragmentFragment> { | ||
const timestamp = Math.round(Date.now() / 1000); | ||
const { tenantId, walletBlockchain } = this._configuration; | ||
if (isLoginWeb3Params(signMessageParams)) { | ||
return this.logInWithWeb3(signMessageParams); | ||
} | ||
let user: Types.UserFragmentFragment | undefined = undefined; | ||
const signature = await this._authenticate({ | ||
signMessageParams, | ||
timestamp, | ||
}); | ||
if (isLoginWeb3Params(loginParams)) { | ||
user = await this.logInWithWeb3(loginParams); | ||
} else if (walletBlockchain === 'OFF_CHAIN') { | ||
const authentication = await this._authenticate({ | ||
signMessageParams: loginParams, | ||
timestamp, | ||
}); | ||
let loginResult: Types.UserFragmentFragment | undefined = undefined; | ||
switch (walletBlockchain) { | ||
case 'BLAST': | ||
case 'BERACHAIN': | ||
case 'CELO': | ||
case 'MANTLE': | ||
case 'LINEA': | ||
case 'SCROLL': | ||
case 'MANTA': | ||
case 'MONAD': | ||
case 'BASE': | ||
case 'THE_ROOT_NETWORK': | ||
case 'ETHEREUM': | ||
case 'POLYGON': | ||
case 'ARBITRUM': | ||
case 'AVALANCHE': | ||
case 'BINANCE': | ||
case 'OPTIMISM': | ||
case 'ZKSYNC': | ||
case 'EVMOS': | ||
case 'SOLANA': { | ||
if (typeof signature !== 'string') | ||
throw new Error( | ||
`logIn - Invalid signature - expected string, but got ${signature}`, | ||
); | ||
const result = await this._service.logInFromDapp({ | ||
walletBlockchain, | ||
walletPublicKey: this._configuration.walletPublicKey, | ||
dappAddress: tenantId, | ||
timestamp, | ||
signature, | ||
}); | ||
loginResult = result.logInFromDapp; | ||
break; | ||
if (!('oidcProvider' in authentication)) { | ||
throw new Error('logIn - Invalid signature - expected OidcCredentials'); | ||
} | ||
case 'SUI': | ||
case 'ACALA': | ||
case 'NEAR': | ||
case 'INJECTIVE': | ||
case 'OSMOSIS': | ||
case 'ELYS': | ||
case 'ARCHWAY': | ||
case 'AXELAR': | ||
case 'AGORIC': | ||
case 'CELESTIA': | ||
case 'COSMOS': | ||
case 'DYMENSION': | ||
case 'PERSISTENCE': | ||
case 'DYDX': | ||
case 'ORAI': | ||
case 'KAVA': | ||
case 'NEUTRON': | ||
case 'NIBIRU': | ||
case 'MOVEMENT': | ||
case 'ARCH': | ||
case 'APTOS': { | ||
if (typeof signature !== 'string') | ||
throw new Error( | ||
`logIn - Invalid signature - expected string, but got ${signature}`, | ||
); | ||
const result = await this._service.logInFromDapp({ | ||
walletBlockchain, | ||
walletPublicKey: this._configuration.authenticationKey, | ||
accountId: this._configuration.accountAddress, | ||
dappAddress: tenantId, | ||
timestamp, | ||
signature, | ||
}); | ||
loginResult = result.logInFromDapp; | ||
break; | ||
// 3rd party OIDC login | ||
const { oidcProvider, jwt } = authentication; | ||
const result = await this._service.logInByOidc({ | ||
dappId: tenantId, | ||
oidcProvider, | ||
idToken: jwt, | ||
}); | ||
user = result.logInByOidc.user; | ||
} else { | ||
const authentication = await this._authenticate({ | ||
signMessageParams: loginParams, | ||
timestamp, | ||
}); | ||
if ( | ||
!('signature' in authentication) || | ||
typeof authentication.signature !== 'string' | ||
) { | ||
throw new Error( | ||
'logIn - Invalid signature - expected string signature and signedMessage', | ||
); | ||
} | ||
case 'OFF_CHAIN': { | ||
if (typeof signature === 'string') | ||
throw new Error( | ||
`logIn - Invalid signature - expected OidcCredentials, but got string: ${signature}`, | ||
); | ||
if (!('oidcProvider' in signature)) | ||
throw new Error( | ||
`logIn - Invalid signature - expected OidcCredentials, but got invalid object ${signature}`, | ||
); | ||
// 3rd party OIDC login | ||
const { oidcProvider, jwt } = signature; | ||
const result = await this._service.logInByOidc({ | ||
dappId: tenantId, | ||
oidcProvider, | ||
idToken: jwt, | ||
}); | ||
loginResult = result.logInByOidc.user; | ||
switch (walletBlockchain) { | ||
case 'BLAST': | ||
case 'BERACHAIN': | ||
case 'CELO': | ||
case 'MANTLE': | ||
case 'LINEA': | ||
case 'SCROLL': | ||
case 'MANTA': | ||
case 'MONAD': | ||
case 'BASE': | ||
case 'THE_ROOT_NETWORK': | ||
case 'ETHEREUM': | ||
case 'POLYGON': | ||
case 'ARBITRUM': | ||
case 'AVALANCHE': | ||
case 'BINANCE': | ||
case 'OPTIMISM': | ||
case 'ZKSYNC': | ||
case 'EVMOS': | ||
case 'SOLANA': { | ||
const result = await this._service.logInFromDapp({ | ||
walletBlockchain, | ||
walletPublicKey: this._configuration.walletPublicKey, | ||
dappAddress: tenantId, | ||
timestamp, | ||
signature: authentication.signature, | ||
}); | ||
user = result.logInFromDapp; | ||
break; | ||
} | ||
case 'SUI': | ||
case 'ACALA': | ||
case 'NEAR': | ||
case 'INJECTIVE': | ||
case 'OSMOSIS': | ||
case 'ELYS': | ||
case 'ARCHWAY': | ||
case 'AXELAR': | ||
case 'AGORIC': | ||
case 'CELESTIA': | ||
case 'COSMOS': | ||
case 'DYMENSION': | ||
case 'PERSISTENCE': | ||
case 'DYDX': | ||
case 'ORAI': | ||
case 'KAVA': | ||
case 'NEUTRON': | ||
case 'NIBIRU': | ||
case 'MOVEMENT': | ||
case 'ARCH': | ||
case 'APTOS': { | ||
const result = await this._service.logInFromDapp({ | ||
walletBlockchain, | ||
walletPublicKey: this._configuration.authenticationKey, | ||
accountId: this._configuration.accountAddress, | ||
dappAddress: tenantId, | ||
timestamp, | ||
signature: authentication.signature, | ||
}); | ||
user = result.logInFromDapp; | ||
break; | ||
} | ||
default: { | ||
throw new Error(`Unsupported wallet blockchain: ${walletBlockchain}`); | ||
} | ||
} | ||
} | ||
if (loginResult === undefined) { | ||
if (user === undefined) { | ||
return Promise.reject('Failed to login'); | ||
} | ||
await this._handleLogInResult(loginResult); | ||
return loginResult; | ||
await this._handleLogInResult(user); | ||
return user; | ||
} | ||
@@ -853,0 +846,0 @@ |
{ | ||
"name": "@notifi-network/notifi-frontend-client", | ||
"version": "3.0.2-alpha.7+d48b98e5", | ||
"version": "3.0.2-alpha.10+22a83924", | ||
"description": "The frontend client for Notifi", | ||
@@ -35,3 +35,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@notifi-network/notifi-graphql": "^3.0.2-alpha.7+d48b98e5", | ||
"@notifi-network/notifi-graphql": "^3.0.2-alpha.10+22a83924", | ||
"graphql-request": "^6.0.0", | ||
@@ -43,3 +43,3 @@ "localforage": "^1.10.0" | ||
}, | ||
"gitHead": "d48b98e507a4a6eacd438de82ea0ef213cee3552" | ||
"gitHead": "22a8392415d462652c1ef4220a507f6a7704d7d5" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
372531
9404