{"_id":"@dmsierra/notifi-frontend-client","_rev":"3-daff998b99f0ca3eb126a010261796d4","name":"@dmsierra/notifi-frontend-client","dist-tags":{"latest":"0.88.5"},"versions":{"0.88.1":{"name":"@dmsierra/notifi-frontend-client","version":"0.88.1","description":"The frontend client for Notifi","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"scripts":{"build":"npm run clean && npm run compile","compile":"tsup lib/index.ts --format cjs,esm --dts --clean","clean":"rimraf ./dist","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/notifi-network/notifi-sdk-ts.git"},"author":{"name":"juni-notifi","email":"hyungjoon.kim@notifi.network"},"license":"MIT","bugs":{"url":"https://github.com/notifi-network/notifi-sdk-ts/issues"},"homepage":"https://github.com/notifi-network/notifi-sdk-ts#readme","dependencies":{"@dmsierra/notifi-graphql":"^0.88.1","graphql-request":"^6.0.0","localforage":"^1.10.0"},"gitHead":"be5adc9316ca9f254e358698fb04e6245f2ee79a","_id":"@dmsierra/notifi-frontend-client@0.88.1","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-vmthEOSfxcTtoDzphXQDVwnMM89nkUxqzlA3zqpqImTeS0kCQj9ajjuIindwd+tmFL6LI66HG2CoZ8BJ9JYvRw==","shasum":"2a7527658633a65bf1c662e9e829c559267ca1c7","tarball":"https://registry.npmjs.org/@dmsierra/notifi-frontend-client/-/notifi-frontend-client-0.88.1.tgz","fileCount":25,"unpackedSize":88483,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCVa/JD8ed/6TNbmrAcCyO1KESsbym6HfP0V3Qvuk4+IQIgSVRQY5tArUB1d/umbu/ab+X/sG4krVe09Vlc3gn36gI="}]},"_npmUser":{"name":"dmsierra","email":"dmitry@sierra.team"},"directories":{},"maintainers":[{"name":"dmsierra","email":"dmitry@sierra.team"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notifi-frontend-client_0.88.1_1701855187975_0.8746465654714919"},"_hasShrinkwrap":false},"0.88.3":{"name":"@dmsierra/notifi-frontend-client","version":"0.88.3","description":"The frontend client for Notifi","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"scripts":{"build":"npm run clean && npm run compile","compile":"tsup lib/index.ts --format cjs,esm --dts --clean","clean":"rimraf ./dist","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/notifi-network/notifi-sdk-ts.git"},"author":{"name":"juni-notifi","email":"hyungjoon.kim@notifi.network"},"license":"MIT","bugs":{"url":"https://github.com/notifi-network/notifi-sdk-ts/issues"},"homepage":"https://github.com/notifi-network/notifi-sdk-ts#readme","dependencies":{"@notifi-network/notifi-graphql":"^0.88.1","graphql-request":"^6.0.0","localforage":"^1.10.0"},"gitHead":"be5adc9316ca9f254e358698fb04e6245f2ee79a","_id":"@dmsierra/notifi-frontend-client@0.88.3","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-XRiVQTNanBlvFdh+t1qOoGRoIgESeHpbEzFG0Uvvr6KRefyBWNDvX18LB+yO1VY4KkYM73ilbG5Y0Z0+WSyVew==","shasum":"18a6a150be08fd9fe1d4b5d20acbdcca9db7420c","tarball":"https://registry.npmjs.org/@dmsierra/notifi-frontend-client/-/notifi-frontend-client-0.88.3.tgz","fileCount":25,"unpackedSize":88525,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFD1HrDq6W5LISfmq6u82J2iSTpCWY5Ho+Vbm0G9MC5hAiEAyZLbuXZGehb0xa+eU1fGsLABL892RjVpcXw690otxbc="}]},"_npmUser":{"name":"dmsierra","email":"dmitry@sierra.team"},"directories":{},"maintainers":[{"name":"dmsierra","email":"dmitry@sierra.team"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notifi-frontend-client_0.88.3_1701855854584_0.6792815885973245"},"_hasShrinkwrap":false},"0.88.4":{"name":"@dmsierra/notifi-frontend-client","version":"0.88.4","description":"The frontend client for Notifi","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"scripts":{"build":"npm run clean && npm run compile","compile":"tsup lib/index.ts --format cjs,esm --dts --clean","clean":"rimraf ./dist","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/notifi-network/notifi-sdk-ts.git"},"author":{"name":"juni-notifi","email":"hyungjoon.kim@notifi.network"},"license":"MIT","bugs":{"url":"https://github.com/notifi-network/notifi-sdk-ts/issues"},"homepage":"https://github.com/notifi-network/notifi-sdk-ts#readme","dependencies":{"@notifi-network/notifi-graphql":"^0.88.1","graphql-request":"^6.0.0","localforage":"^1.10.0"},"gitHead":"be5adc9316ca9f254e358698fb04e6245f2ee79a","_id":"@dmsierra/notifi-frontend-client@0.88.4","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-5U0TNmeccUA3fVVHkZS8JzMe3696O2TvbtbNYbs2weTr0w76/Qqb+VuCFyjR00/bpyVHOlCdbEEciR5EMbWTaw==","shasum":"bf31e8218ae7fa076137562f13492059c8062d84","tarball":"https://registry.npmjs.org/@dmsierra/notifi-frontend-client/-/notifi-frontend-client-0.88.4.tgz","fileCount":26,"unpackedSize":227985,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDfojiD0OT4U6d45ENQc11zWt5DL8DQ/3I7Y/7BTe1Y3AiEA2ATRpik9fU+PFoER00ahfBoNZrZHAP2EDQpREYWiwjk="}]},"_npmUser":{"name":"dmsierra","email":"dmitry@sierra.team"},"directories":{},"maintainers":[{"name":"dmsierra","email":"dmitry@sierra.team"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notifi-frontend-client_0.88.4_1701856014669_0.26712185900716023"},"_hasShrinkwrap":false},"0.88.5":{"name":"@dmsierra/notifi-frontend-client","version":"0.88.5","description":"The frontend client for Notifi","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"scripts":{"build":"npm run clean && npm run compile","compile":"tsup lib/index.ts --format cjs,esm --dts --clean","clean":"rimraf ./dist","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/notifi-network/notifi-sdk-ts.git"},"author":{"name":"juni-notifi","email":"hyungjoon.kim@notifi.network"},"license":"MIT","bugs":{"url":"https://github.com/notifi-network/notifi-sdk-ts/issues"},"homepage":"https://github.com/notifi-network/notifi-sdk-ts#readme","dependencies":{"@dmsierra/notifi-graphql":"^0.88.3","graphql-request":"^6.0.0","localforage":"^1.10.0"},"gitHead":"be5adc9316ca9f254e358698fb04e6245f2ee79a","_id":"@dmsierra/notifi-frontend-client@0.88.5","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-vxupZ71VTl6hsUfva5YYOBzD2MWy6crRVCDn3vkSgyrbNTMQv4Km76uzb0RNRtHpoQf4yHvr1krg6kC6omhcnA==","shasum":"1489035b0ace1930f5381a1936a74979685a36a5","tarball":"https://registry.npmjs.org/@dmsierra/notifi-frontend-client/-/notifi-frontend-client-0.88.5.tgz","fileCount":26,"unpackedSize":233610,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKJTNpt0SPh00dKySoJE/doIr83qfttLQf2V2BdVObMAIgH7d/KSAJoODYOItAqjHwVpExiAG1D5A+b/LCc/w3dxQ="}]},"_npmUser":{"name":"dmsierra","email":"dmitry@sierra.team"},"directories":{},"maintainers":[{"name":"dmsierra","email":"dmitry@sierra.team"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notifi-frontend-client_0.88.5_1701856480826_0.09444828332756439"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-06T09:33:07.869Z","0.88.1":"2023-12-06T09:33:08.171Z","modified":"2023-12-06T09:54:41.164Z","0.88.3":"2023-12-06T09:44:14.789Z","0.88.4":"2023-12-06T09:46:54.858Z","0.88.5":"2023-12-06T09:54:41.010Z"},"maintainers":[{"name":"dmsierra","email":"dmitry@sierra.team"}],"description":"The frontend client for Notifi","homepage":"https://github.com/notifi-network/notifi-sdk-ts#readme","repository":{"type":"git","url":"git+https://github.com/notifi-network/notifi-sdk-ts.git"},"author":{"name":"juni-notifi","email":"hyungjoon.kim@notifi.network"},"bugs":{"url":"https://github.com/notifi-network/notifi-sdk-ts/issues"},"license":"MIT","readme":"# `@notifi/notifi-frontend-client`\n\n## 🎬 Getting Started using Aptos\n\nIn this README, we'll cover the simple use case of one user authenticating through an Aptos wallet and creating an alert.\n\n## 📥 Installation\n\n```\nnpm i @notifi-network/notifi-frontend-client\n```\n\n## 🪝 Hook up the SDK and initialize the Client\n\nLoad the Notifi Frontend Client SDK into your component.\n\nInstantiate and configure the Notifi Client for your dApp and environment. If your user has not connected their wallet, they will need to do so in order to instantiate the client.\n\n```ts\nconst accountAddress = '<The-wallet-public-account-address>';\nconst walletPublicKey = \"<The wallet's public key>\";\nconst tenantId = '<Tenant ID received through the Notifi Config Tool>';\nconst blockchainEnv = 'Development';\n\nconst client = newFrontendClient({\n  account: {\n    address: accountAddress, // string\n    publicKey: walletPublicKey, // string\n  },\n  tenantId,\n  env: blockchainEnv,\n  walletBlockchain: 'APTOS',\n});\n\nconst newUserState = await client.initialize();\n```\n\n## 🔏 Signature Authorization\n\nFor a user to opt-in for notifications, they will need to provide their signature. This signature will then be used to authorize the user's connected wallet address with Notifi and create the account with Notifi.\n\nUsing the wallet adapter of your choice, prompt the user to sign and use the signed message in the `logIn()` hook.\n\n```ts\nconst signMessage: AptosSignMessageFunction = async (message, nonce) => {\n  if (!wallet) {\n    // the wallet object will be differ based on the wallet adapter you use\n    throw new Error('Wallet not connected');\n  }\n\n  // You will need to use the 'signMessage' method of your wallet adapter to sign the message.\n  const signature = await wallet.signMessage({\n    message,\n  });\n\n  return signature; // string (if the signature is not string format, you will need to convert it to string)\n};\n\nconst logIn = async () => {\n  const userState: UserState = client.userState;\n  if (userState.status === 'authenticated') {\n    return 'User is already logged in';\n  }\n\n  const loginResult = await client.logIn({\n    walletBlockchain: 'APTOS',\n    signMessage,\n  } as SignMessageParams);\n  // client should be authenticated now\n  console.log('loginResult', loginResult);\n  return loginResult;\n};\n```\n\n## 🪢 Create the Alert\n\nOnce your user enters their contact information and options for their first alert, use the `ensureTargetGroup()` to create a \"target group\" of their contact information and a \"source group\" of their desired alert options.\n\nIn order to create a target group, `ensureTargetGroup()` must pass in least one email address, phone number, telegramId, or webhook url. Dapp admins can update pass in a webhook url to receive all of the notifications instead of a user email address, phone number, or telegramId.\n\nThe following example shows how to create a target group with an email address (user sign up with email).\n\n```ts\nconst targetGroup = client.ensureTargetGroup({\n  name: 'Default',\n  emailAddress: 'user-email',\n});\n```\n\nThen, use the `ensureAlert()` to create the first alert when your user tends to subscribe an alert.\n\nThis example shows how to create (user subscribe) a Broadcast message alert.\n\n```ts\n// Given that you have one Broadcast Topic in Notifi Admin Panel.\n\nconst subscribeAlert = () => {\n  const subscriptionCardConfig = await client.fetchSubscriptionCard();\n\n  const broadcastEventType: EventTypeItem = subscriptionCardConfig.eventTypes[0];\n\n  await client.ensureAlert({\n    eventType: broadcastEventType,\n    inputs: {},\n  });\n}\n\n```\n\n## 🔃 Updating the Alert\n\nIf a user wants to update their alert by changing the email address notifications are sent to, or to add a phone number for SMS notifications, you can repeat the process above by calling `ensureTargetGroup()` and `ensureAlert()` again.\n\n## 🗑 Deleting the Alert\n\nTo delete an alert, use `deleteAlert()`, which simply [takes the `id` of the alert] to be deleted. In our use case where the user only has 1 alert in their account:\n\n```ts\nconst handleDeleteAlert = async () => {\n  try {\n    const alerts = await getAlert();\n    const response = await deleteAlert({\n      alertId: alerts?.[0]?.id,\n    });\n    return response;\n  } catch (e) {\n    if (e instanceof GqlError) {\n      // handle the Notifi GqlError\n    }\n  }\n};\n```\n\n## 🔔 Get Notification History\n\nTo get notification history, use the getNotificationHistory()\n\n```ts\nconst getNotificationHistory = async (first?: number, after?: string) => {\n  // Fetch `first` items after the `after` cursor (leave undefined for first page)\n  const { nodes, pageInfo } = await client.getNotificationHistory({\n    first,\n    after,\n  });\n\n  nodes.forEach((item) => {\n    if (item.detail?.__typename === 'BroadcastMessageEventDetails') {\n      console.log(\n        'I have a broadcast message',\n        item.detail?.subject,\n        item.detail?.message,\n      );\n    }\n  });\n\n  console.log('pageInfo', pageInfo.hasNextPage, pageInfo.endCursor);\n\n  return {\n    nodes,\n    pageInfo,\n  };\n};\n```\n\n## 📝 Check out more example\n\nFor more example in different blockchain, please visit [notifi-react-example](https://github.com/notifi-network/notifi-sdk-ts/blob/main/packages/notifi-react-example/src/FrontendClient/SolanaFrontendClient.tsx)\n\nYou can also clone the example and run it locally.\n","readmeFilename":"README.md"}