@saazpayhq/node-sdk
Version:
Node client for saazpay
1 lines • 1.24 kB
Source Map (JSON)
{"version":3,"sources":["../index.ts"],"sourcesContent":["import jwt from \"jsonwebtoken\";\n\nconst secretKey: jwt.Secret | undefined = process.env.SAAZPAY_SECRET_KEY;\n\ntype TokenProps = {\n appId: string;\n userId?: string;\n expiresIn?: number;\n};\n\nexport const getAccessToken = ({\n appId,\n userId,\n expiresIn = 60,\n}: TokenProps): string => {\n if (!secretKey) {\n throw new Error(\"Saazpay secret key is not defined\");\n }\n\n const formattedPrivateKey = `-----BEGIN PRIVATE KEY-----\\n${secretKey}\\n-----END PRIVATE KEY-----`;\n return jwt.sign(\n {\n userId,\n appId,\n },\n formattedPrivateKey,\n { expiresIn: expiresIn, algorithm: \"ES256\" }\n );\n};\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgB,6BAEVC,EAAoC,QAAQ,IAAI,mBAQzCH,EAAiB,CAAC,CAC7B,MAAAI,EACA,OAAAC,EACA,UAAAC,EAAY,EACd,IAA0B,CACxB,GAAI,CAACH,EACH,MAAM,IAAI,MAAM,mCAAmC,EAGrD,IAAMI,EAAsB;AAAA,EAAgCJ;AAAA,2BAC5D,OAAO,EAAAK,QAAI,KACT,CACE,OAAAH,EACA,MAAAD,CACF,EACAG,EACA,CAAE,UAAWD,EAAW,UAAW,OAAQ,CAC7C,CACF","names":["node_sdk_exports","__export","getAccessToken","__toCommonJS","import_jsonwebtoken","secretKey","appId","userId","expiresIn","formattedPrivateKey","jwt"]}