@descope/core-js-sdk 0.0.41-alpha.12 → 0.0.41-alpha.13
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/README.md +0 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/httpClient/types.ts","../src/httpClient/helpers/createFetchLogger.ts","../src/httpClient/utils.ts","../src/httpClient/index.ts","../src/httpClient/urlBuilder.ts","../src/sdk/helpers/index.ts","../src/sdk/types.ts","../src/sdk/validations/core.ts","../src/sdk/validations/validators.ts","../src/sdk/validations/index.ts","../src/sdk/otp.ts","../src/sdk/magicLink/validations.ts","../src/sdk/magicLink/crossDevice.ts","../src/constants/index.ts","../src/sdk/magicLink/index.ts","../src/sdk/exchange.ts","../src/sdk/oauth/types.ts","../src/sdk/oauth/index.ts","../src/sdk/flow.ts","../src/sdk/saml.ts","../src/sdk/totp.ts","../src/sdk/webauthn.ts","../src/sdk/index.ts","../src/index.ts"],"sourcesContent":["export default {\n\totp: {\n\t\tverify: '/v1/auth/code/verify',\n\t\tsignIn: '/v1/auth/signin/otp',\n\t\tsignUp: '/v1/auth/signup/otp',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/otp',\n\t\t\tphone: '/v1/user/update/phone/otp'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/otp'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/signin/magiclink',\n\t\tsignUp: '/v1/auth/signup/magiclink',\n\t\tsession: '/v1/auth/magiclink/session',\n\t\tupdate: {\n\t\t\temail: '/v1/user/update/email/magiclink',\n\t\t\tphone: '/v1/user/update/phone/magiclink'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/sign-up-or-in/magiclink'\n\t},\n\toauth: {\n\t\tstart: '/v1/oauth/authorize'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/verify/totp',\n\t\tsignUp: '/v1/auth/signup/totp',\n\t\tupdate: '/v1/user/update/totp'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/webauthn/signup/start',\n\t\t\tfinish: '/v1/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/webauthn/signin/start',\n\t\t\tfinish: '/v1/webauthn/signin/finish'\n\t\t},\n\t\tadd: {\n\t\t\tstart: '/v1/webauthn/device/add/start',\n\t\t\tfinish: '/v1/webauthn/device/add/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logoutall',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t},\n\texchange: '/v1/auth/exchange'\n};\n","import { Logger } from '../sdk/types';\n\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n};\n\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n};\n\nexport type RequestConfig = { \n\tpath: string; \n\theaders?: HeadersInit; \n\tqueryParams?: { [key: string]: string; }; \n\tbody?: any; \n\tmethod: HTTPMethods; \n\ttoken?: string; \n}\n\nexport type Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n}\n","import { Logger } from '../../sdk/types';\n\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await resp.text();\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import { urlBuilder } from './urlBuilder';\nimport { CreateHttpClientConfig, HttpClient, RequestConfig, HTTPMethods } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\n\nimport { mergeHeaders, serializeBody } from './utils';\n\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token !== '') {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\t\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\treturn fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body)\n\t\t});\n\t}\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token })\n\t};\n\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","export const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { SdkResponse } from '../types';\n\nconst isJwtExpired = (token: string) => {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\n\tconst { exp }: JwtPayload = jwtDecode(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\n\treturn currentTime > exp;\n};\n\nexport default isJwtExpired;\n\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\nexport const transformResponse = async (response: Promise<Response>): Promise<SdkResponse> => {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.json();\n\n\tif (resp.ok) {\n\t\tret.data = data;\n\t} else {\n\t\tret.error = data;\n\t}\n\n\treturn ret;\n};\n","type SdkFn = (...args: any[]) => Promise<SdkResponse>;\n\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport type Deliveries<T extends SdkFn> = Record<DeliveryMethods, T>;\n\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\nexport type SdkResponse = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\tcode: string;\n\t};\n\tdata?: any;\n};\n\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport { DeliveryMethods, Deliveries, User, SdkResponse, DeliveryPhone } from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (identifier: string, code: string) => Promise<SdkResponse>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse>;\ntype UpdatePhoneFn = (identifier: string, phone: string) => Promise<SdkResponse>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(externalId: string, code: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signIn, delivery), { externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { externalId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport { MagicLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = MAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || MAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withMagicLinkCrossDevice = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.magicLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: { message: `Session polling timeout exceeded: ${timeoutMs}ms`, code: '0' },\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, email, URI: uri, crossDevice: true },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone, URI: uri, crossDevice: true },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLinkCrossDevice;\n","export const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\nexport const MAGIC_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\nexport const MAGIC_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\nexport { default as apiPaths } from './apiPaths';\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport withMagicLinkCrossDevice from './crossDevice';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), { externalId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { externalId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t},\n\n\tcrossDevice: withMagicLinkCrossDevice(httpClient)\n});\n\nexport default withMagicLink;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withExchange = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.get(apiPaths.exchange, { queryParams: { code } }))\n\t)\n});\n\nexport default withExchange;\n","import { SdkResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\ntype VerifyFn = (code: string) => Promise<SdkResponse>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport withExchange from '../exchange';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\t\tconst resp = await httpClient.get(apiPaths.oauth.start, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) }\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\n\t...withExchange(httpClient)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('actionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tactionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t) => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport withExchange from './exchange';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (tenantNameOrEmail: string, redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\tconst resp = await httpClient.get(apiPaths.saml.start, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl }\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\n\t...withExchange(httpClient)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(identifier: string, code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.verify, { externalId: identifier, code }))\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withAddStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(identifier: string, origin: string, name: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\texternalId: identifier,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tadd: {\n\t\tstart: withAddStartValidations(\n\t\t\t(identifier: string, origin: string, token: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.add.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.add.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport isJwtExpired, { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\n\nconst withValidateValidations = withValidations(stringNonEmpty('token'));\n\nexport default (httpClient: HttpClient) => ({\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) => transformResponse(httpClient.get(apiPaths.refresh, { token })),\n\tlogout: (token?: string) => transformResponse(httpClient.get(apiPaths.logout, { token })),\n\tisJwtExpired: withValidateValidations(isJwtExpired),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { Hooks, HTTPMethods } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\nconst sdk = withSdkConfigValidations(\n\t({ projectId, logger, baseUrl, hooks }: { projectId: string; logger?: Logger; baseUrl?: string; hooks?: Hooks; }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger, hooks }))\n);\n\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\nexport type OAuthProvider = keyof typeof OAuthProviders;\nexport type { HTTPMethods };\nexport type { SdkResponse } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","add","next","HTTPMethods","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","text","Promise","resolve","json","parse","statusText","buildResponseLog","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","URL","search","URLSearchParams","urlBuilder","baseHeaders","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replace","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","httpClient","delivery","assign","externalId","user","identifier","uriValidations","withWaitForSessionValidations","withMagicLinkCrossDevice","URI","crossDevice","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","uri","withMagicLink","withExchangeValidations","withExchange","exchange","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","executionId","stepId","actionId","input","withSaml","tenantNameOrEmail","tenant","withSignUpValidations","withUpdateValidations","withTotp","originValidations","withSignUpStartValidations","withSignInStartValidations","withAddStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"oDAAA,IAAeA,EACT,CACJC,OAAQ,uBACRC,OAAQ,sBACRC,OAAQ,sBACRC,OAAQ,CACPC,MAAO,4BACPC,MAAO,6BAERC,WAAY,8BATCP,EAWH,CACVC,OAAQ,4BACRC,OAAQ,4BACRC,OAAQ,4BACRK,QAAS,6BACTJ,OAAQ,CACPC,MAAO,kCACPC,MAAO,mCAERC,WAAY,oCApBCP,EAsBP,CACNS,MAAO,uBAvBMT,EAyBR,CACLS,MAAO,2BA1BMT,EA4BR,CACLC,OAAQ,uBACRE,OAAQ,uBACRC,OAAQ,wBA/BKJ,EAiCJ,CACTG,OAAQ,CACPM,MAAO,4BACPC,OAAQ,8BAETR,OAAQ,CACPO,MAAO,4BACPC,OAAQ,8BAETC,IAAK,CACJF,MAAO,gCACPC,OAAQ,mCA5CIV,EA+CL,mBA/CKA,EAgDN,qBAhDMA,EAiDR,CACLS,MAAO,iBACPG,KAAM,iBAnDOZ,EAqDJ,oBC7CX,IAAYa,GAAZ,SAAYA,GACXA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,IAAA,KACA,CALD,CAAYA,IAAAA,EAKX,CAAA,ICXD,MAAMC,EAAiB,KACtB,MAAMC,EAOF,CAAA,EAEJ,MAAO,CACNC,QAAQA,GACP,MAAMC,EACsB,mBAApBD,EAAQE,QAAyBC,OAAOC,YAAYJ,EAAQE,WAAaF,EAGjF,OAFAD,EAAIM,QAAUC,KAAKC,UAAUN,GAEtBO,IACP,EAEDC,KAAKA,GAEJ,OADA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
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/constants/apiPaths.ts","../src/httpClient/types.ts","../src/httpClient/helpers/createFetchLogger.ts","../src/httpClient/utils.ts","../src/httpClient/index.ts","../src/httpClient/urlBuilder.ts","../src/sdk/helpers/index.ts","../src/sdk/types.ts","../src/sdk/validations/core.ts","../src/sdk/validations/validators.ts","../src/sdk/validations/index.ts","../src/sdk/otp.ts","../src/sdk/magicLink/validations.ts","../src/sdk/magicLink/crossDevice.ts","../src/constants/index.ts","../src/sdk/magicLink/index.ts","../src/sdk/exchange.ts","../src/sdk/oauth/types.ts","../src/sdk/oauth/index.ts","../src/sdk/flow.ts","../src/sdk/saml.ts","../src/sdk/totp.ts","../src/sdk/webauthn.ts","../src/sdk/index.ts","../src/index.ts"],"sourcesContent":["export default {\n\totp: {\n\t\tverify: '/v1/auth/otp/verify',\n\t\tsignIn: '/v1/auth/otp/signin',\n\t\tsignUp: '/v1/auth/otp/signup',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/otp/update/email',\n\t\t\tphone: '/v1/auth/otp/update/phone'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/otp/signup-in'\n\t},\n\tmagicLink: {\n\t\tverify: '/v1/auth/magiclink/verify',\n\t\tsignIn: '/v1/auth/magiclink/signin',\n\t\tsignUp: '/v1/auth/magiclink/signup',\n\t\tsession: '/v1/auth/magiclink/pending-session',\n\t\tupdate: {\n\t\t\temail: '/v1/auth/magiclink/update/email',\n\t\t\tphone: '/v1/auth/magiclink/update/email'\n\t\t},\n\t\tsignUpOrIn: '/v1/auth/magiclink/signup-in'\n\t},\n\toauth: {\n\t\tstart: '/v1/auth/oauth/authorize'\n\t},\n\tsaml: {\n\t\tstart: '/v1/auth/saml/authorize'\n\t},\n\ttotp: {\n\t\tverify: '/v1/auth/totp/verify',\n\t\tsignUp: '/v1/auth/totp/signup',\n\t\tupdate: '/v1/user/totp/update'\n\t},\n\twebauthn: {\n\t\tsignUp: {\n\t\t\tstart: '/v1/auth/webauthn/signup/start',\n\t\t\tfinish: '/v1/auth/webauthn/signup/finish'\n\t\t},\n\t\tsignIn: {\n\t\t\tstart: '/v1/auth/webauthn/signin/start',\n\t\t\tfinish: '/v1/auth/webauthn/signin/finish'\n\t\t},\n\t\tupdate: {\n\t\t\tstart: 'v1/auth/webauthn/update/start',\n\t\t\tfinish: '/v1/auth/webauthn/update/finish'\n\t\t}\n\t},\n\trefresh: '/v1/auth/refresh',\n\tlogout: '/v1/auth/logoutall',\n\tflow: {\n\t\tstart: '/v1/flow/start',\n\t\tnext: '/v1/flow/next'\n\t},\n\texchange: '/v1/auth/exchange'\n};\n","import { Logger } from '../sdk/types';\n\ntype HttpClientReqConfig = {\n\theaders?: HeadersInit;\n\tqueryParams?: { [key: string]: string };\n\ttoken?: string;\n};\n\nexport enum HTTPMethods {\n\tget = 'GET',\n\tdelete = 'DELETE',\n\tpost = 'POST',\n\tput = 'PUT'\n}\n\nexport type HttpClient = {\n\tget: (path: string, config?: HttpClientReqConfig) => Promise<Response>;\n\tpost: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tput: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n\tdelete: (path: string, body?: any, config?: HttpClientReqConfig) => Promise<Response>;\n};\n\nexport type CreateHttpClientConfig = {\n\tbaseUrl: string;\n\tprojectId: string;\n\tbaseConfig?: { baseHeaders: HeadersInit };\n\tlogger?: Logger;\n\thooks?: Hooks;\n};\n\nexport type RequestConfig = { \n\tpath: string; \n\theaders?: HeadersInit; \n\tqueryParams?: { [key: string]: string; }; \n\tbody?: any; \n\tmethod: HTTPMethods; \n\ttoken?: string; \n}\n\nexport type Hooks = {\n\tbeforeRequest?: (config: RequestConfig) => RequestConfig;\n}\n","import { Logger } from '../../sdk/types';\n\nconst httpLogBuilder = () => {\n\tconst msg: {\n\t\tTitle?: string;\n\t\tUrl?: string;\n\t\tMethod?: string;\n\t\tHeaders?: string;\n\t\tBody?: string;\n\t\tStatus?: string;\n\t} = {};\n\n\treturn {\n\t\theaders(headers: HeadersInit) {\n\t\t\tconst headersObj =\n\t\t\t\ttypeof headers.entries === 'function' ? Object.fromEntries(headers.entries()) : headers;\n\t\t\tmsg.Headers = JSON.stringify(headersObj);\n\n\t\t\treturn this;\n\t\t},\n\n\t\tbody(body: string) {\n\t\t\tmsg.Body = body;\n\t\t\treturn this;\n\t\t},\n\n\t\turl(url: URL | string) {\n\t\t\tmsg.Url = url.toString();\n\t\t\treturn this;\n\t\t},\n\n\t\tmethod(method: string) {\n\t\t\tmsg.Method = method;\n\t\t\treturn this;\n\t\t},\n\n\t\ttitle(title: string) {\n\t\t\tmsg.Title = title;\n\t\t\treturn this;\n\t\t},\n\n\t\tstatus(status: string) {\n\t\t\tmsg.Status = status;\n\t\t\treturn this;\n\t\t},\n\n\t\tbuild() {\n\t\t\treturn Object.keys(msg)\n\t\t\t\t.flatMap((key) => (msg[key] ? [`${key !== 'Title' ? `${key}: ` : ''}${msg[key]}`] : []))\n\t\t\t\t.join('\\n');\n\t\t}\n\t};\n};\n\ntype Fetch = typeof fetch;\n\nconst buildRequestLog = (args: Parameters<Fetch>) =>\n\thttpLogBuilder()\n\t\t.title('Request')\n\t\t.url(args[0])\n\t\t.method(args[1].method)\n\t\t.headers(args[1].headers)\n\t\t.body(args[1].body)\n\t\t.build();\n\nconst buildResponseLog = async (resp: Response) => {\n\tconst respBody = await resp.text();\n\t// eslint-disable-next-line no-param-reassign\n\tresp.text = () => Promise.resolve(respBody);\n\t// eslint-disable-next-line no-param-reassign\n\tresp.json = () => Promise.resolve(JSON.parse(respBody));\n\n\treturn httpLogBuilder()\n\t\t.title('Response')\n\t\t.url(resp.url.toString())\n\t\t.status(`${resp.status} ${resp.statusText}`)\n\t\t.headers(resp.headers)\n\t\t.body(respBody)\n\t\t.build();\n};\n\nconst createFetchLogger = (logger: Logger, receivedFetch?: Fetch) => {\n\tconst fetchInternal = receivedFetch || fetch;\n\tif (!fetchInternal) throw new Error('fetch is not defined');\n\n\tif (!logger) return fetchInternal;\n\n\treturn async (...args: Parameters<Fetch>) => {\n\t\tlogger.log(buildRequestLog(args));\n\t\tconst resp = await fetchInternal(...args);\n\t\tlogger[resp.ok ? 'log' : 'error'](await buildResponseLog(resp));\n\n\t\treturn resp;\n\t};\n};\n\nexport default createFetchLogger;\n","/* eslint-disable no-nested-ternary */\n\nconst getSrcArr = (source: HeadersInit) => {\n\tif (Array.isArray(source)) return source;\n\tif (source instanceof Headers) return Array.from(source.entries());\n\tif (!source) return [];\n\treturn Object.entries(source);\n};\n\nexport const mergeHeaders = (...sources: HeadersInit[]) =>\n\tnew Headers(\n\t\tsources.reduce((acc: Record<string, string>, source) => {\n\t\t\tconst srcArr = getSrcArr(source);\n\t\t\tsrcArr.reduce((_, [key, value]) => {\n\t\t\t\tacc[key] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, acc);\n\n\t\t\treturn acc;\n\t\t}, {})\n\t);\n\nexport const serializeBody = (body: Record<string, any>) =>\n\tbody === undefined ? undefined : JSON.stringify(body);\n","import { urlBuilder } from './urlBuilder';\nimport { CreateHttpClientConfig, HttpClient, RequestConfig, HTTPMethods } from './types';\nimport createFetchLogger from './helpers/createFetchLogger';\n\nimport { mergeHeaders, serializeBody } from './utils';\n\nconst createAuthorizationHeader = (projectId: string, token = '') => {\n\tlet bearer = projectId;\n\tif (token !== '') {\n\t\tbearer = bearer + ':' + token;\n\t}\n\treturn {\n\t\tAuthorization: `Bearer ${bearer}`\n\t};\n};\n\nconst createHttpClient = ({\n\tbaseUrl,\n\tprojectId,\n\tbaseConfig,\n\tlogger,\n\thooks,\n}: CreateHttpClientConfig): HttpClient => {\n\tconst fetchWithLogger = createFetchLogger(logger);\n\n\tconst sendRequest = (config: RequestConfig) => {\n\t\tconst requestConfig = hooks?.beforeRequest ? hooks.beforeRequest(config) : config;\n\t\n\t\tconst { path, body, headers, queryParams, method, token } = requestConfig;\n\n\t\treturn fetchWithLogger(urlBuilder({ path, baseUrl, queryParams }), {\n\t\t\theaders: mergeHeaders(\n\t\t\t\tcreateAuthorizationHeader(projectId, token),\n\t\t\t\tbaseConfig?.baseHeaders || {},\n\t\t\t\theaders\n\t\t\t),\n\t\t\tmethod,\n\t\t\tbody: serializeBody(body),\n\t\t\tcredentials: 'same-origin'\n\t\t});\n\t}\n\n\treturn {\n\t\tget: (path: string, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body: undefined, method: HTTPMethods.get, token }),\n\t\tpost: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.post, token }),\n\t\tput: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.put, token }),\n\t\tdelete: (path, body, { headers, queryParams, token } = {}) =>\n\t\t\tsendRequest({ path, headers, queryParams, body, method: HTTPMethods.delete, token })\n\t};\n\n};\n\nexport default createHttpClient;\nexport type { HttpClient };\n","export const urlBuilder = ({\n\tpath,\n\tbaseUrl,\n\tqueryParams\n}: {\n\tpath: string;\n\tbaseUrl: string;\n\tqueryParams: ConstructorParameters<typeof URLSearchParams>[0];\n}) => {\n\tconst url = new URL(path, baseUrl);\n\tif (queryParams) url.search = new URLSearchParams(queryParams).toString();\n\n\treturn url;\n};\n","import jwtDecode, { JwtPayload } from 'jwt-decode';\nimport { SdkResponse } from '../types';\n\nconst isJwtExpired = (token: string) => {\n\tif (typeof token !== 'string' || !token) throw new Error('Invalid token provided');\n\n\tconst { exp }: JwtPayload = jwtDecode(token);\n\tconst currentTime = new Date().getTime() / 1000;\n\n\treturn currentTime > exp;\n};\n\nexport default isJwtExpired;\n\nexport const pathJoin = (...args: string[]) => args.join('/').replace(/\\/{2,}/g, '/');\n\nexport const transformResponse = async (response: Promise<Response>): Promise<SdkResponse> => {\n\tconst resp = await response;\n\n\tconst ret: SdkResponse = {\n\t\tcode: resp.status,\n\t\tok: resp.ok,\n\t\tresponse: resp\n\t};\n\n\tconst data = await resp.json();\n\n\tif (resp.ok) {\n\t\tret.data = data;\n\t} else {\n\t\tret.error = data;\n\t}\n\n\treturn ret;\n};\n","type SdkFn = (...args: any[]) => Promise<SdkResponse>;\n\nexport type User = {\n\temail?: string;\n\tname?: string;\n\tphone?: string;\n};\n\nexport enum DeliveryPhone {\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport enum DeliveryMethods {\n\temail = 'email',\n\tsms = 'sms',\n\twhatsapp = 'whatsapp'\n}\n\nexport type Deliveries<T extends SdkFn> = Record<DeliveryMethods, T>;\n\nexport enum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify'\n}\n\nexport type SdkResponse = {\n\tcode?: number;\n\tok: boolean;\n\tresponse?: Response;\n\terror?: {\n\t\tmessage: string;\n\t\tcode: string;\n\t};\n\tdata?: any;\n};\n\nexport type Logger = Pick<Console, 'debug' | 'log' | 'error'>;","import { Validator, ValidationRule, MakeValidator } from './types';\n\nexport const createValidator =\n\t(rule: ValidationRule, defaultMsg?: string): MakeValidator =>\n\t(msg = defaultMsg) =>\n\t(val) =>\n\t\t!rule(val) ? msg.replace('{val}', val) : false;\n\nexport const createValidation = (...validators: Validator[]) => ({\n\tvalidate: (val: any) => {\n\t\tvalidators.forEach((validator) => {\n\t\t\tconst errMsg = validator(val);\n\t\t\tif (errMsg) throw new Error(errMsg);\n\t\t});\n\n\t\treturn true;\n\t}\n});\n","import get from 'lodash.get';\nimport { createValidation, createValidator } from './core';\nimport { Validator } from './types';\n\nconst regexMatch = (regex: RegExp) => (val: any) => regex.test(val);\n\nconst validateString = (val: any) => typeof val === 'string';\nconst validateEmail = regexMatch(\n\t/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/\n);\nconst validatePhone = regexMatch(/^\\+[1-9]{1}[0-9]{3,14}$/);\nconst validateMinLength = (min: number) => (val: any) => val.length >= min;\n// const validatePlainObject = (val: any) => !!val && Object.getPrototypeOf(val) === Object.prototype;\nconst validatePathValue = (path: string, rules: Validator[]) => (val: any) =>\n\tcreateValidation(...rules).validate(get(val, path));\n\nexport const isEmail = createValidator(validateEmail, '\"{val}\" is not a valid email');\nexport const isPhone = createValidator(validatePhone, '\"{val}\" is not a valid phone number');\nexport const isNotEmpty = createValidator(validateMinLength(1), 'Minimum length is 1');\nexport const isString = createValidator(validateString, 'Input is not a string');\n// export const isPlainObject = createValidator(validatePlainObject, 'Input is not a plain object');\nexport const hasPathValue = (path: string, rules: Validator[]) =>\n\tcreateValidator(validatePathValue(path, rules))();\n","import { createValidation } from './core';\nimport { Validator } from './types';\nimport { isEmail, isNotEmpty, isPhone, isString } from './validators';\n\n/**\n *\n * @params each parameter is an array of validators, those validators will be verified against the wrapped function argument which in the same place\n * @throws if any of the validators fails, an error with the relevant message will be thrown\n */\nexport const withValidations =\n\t(...argsRules: Validator[][]) =>\n\t<T extends Array<any>, U>(fn: (...args: T) => U) =>\n\t(...args: T): U => {\n\t\targsRules.forEach((rulesArr, i) => createValidation(...rulesArr).validate(args[i]));\n\n\t\treturn fn(...args);\n\t};\n\nexport const stringNonEmpty = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisNotEmpty(`\"${fieldName}\" must not be empty`)\n];\nexport const stringEmail = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisEmail()\n];\nexport const stringPhone = (fieldName: string) => [\n\tisString(`\"${fieldName}\" must be a string`),\n\tisPhone()\n];\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { pathJoin, transformResponse } from './helpers';\nimport { DeliveryMethods, Deliveries, User, SdkResponse, DeliveryPhone } from './types';\nimport { stringEmail, stringNonEmpty, stringPhone, withValidations } from './validations';\n\nenum Routes {\n\tsignUp = 'signup',\n\tsignIn = 'signin',\n\tverify = 'verify',\n\tupdatePhone = 'updatePhone'\n}\n\ntype VerifyFn = (identifier: string, code: string) => Promise<SdkResponse>;\ntype SignInFn = (identifier: string) => Promise<SdkResponse>;\ntype SignUpFn = (identifier: string, user?: User) => Promise<SdkResponse>;\ntype UpdatePhoneFn = (identifier: string, phone: string) => Promise<SdkResponse>;\n\ntype Otp = {\n\t[Routes.verify]: Deliveries<VerifyFn>;\n\t[Routes.signIn]: Deliveries<SignInFn>;\n\t[Routes.signUp]: Deliveries<SignUpFn>;\n\t[Routes.updatePhone]: Deliveries<UpdatePhoneFn>;\n};\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignValidations = withValidations(identifierValidations);\nconst withUpdatePhoneValidations = withValidations(identifierValidations, stringPhone('phone'));\nconst withUpdateEmailValidations = withValidations(identifierValidations, stringEmail('email'));\n\nconst withOtp = (httpClient: HttpClient) => ({\n\tverify: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withVerifyValidations(\n\t\t\t\t(externalId: string, code: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.verify, delivery), { code, externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.verify],\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signIn, delivery), { externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUp, delivery), { externalId, user })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.otp.signUpOrIn, delivery), { externalId })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as Otp[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.otp.update.email, { externalId: identifier, email }, { token })\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.otp.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as Otp[Routes.updatePhone]\n\t}\n});\n\nexport default withOtp;\n","import { stringNonEmpty, withValidations, stringPhone, stringEmail } from '../validations';\n\nexport const identifierValidations = stringNonEmpty('identifier');\nexport const uriValidations = stringNonEmpty('uri');\nexport const withVerifyValidations = withValidations(stringNonEmpty('token'));\nexport const withSignValidations = withValidations(identifierValidations, uriValidations);\nexport const withWaitForSessionValidations = withValidations(stringNonEmpty('pendingRef'));\nexport const withUpdatePhoneValidations = withValidations(\n\tidentifierValidations,\n\tstringPhone('phone'),\n\turiValidations\n);\nexport const withUpdateEmailValidations = withValidations(\n\tidentifierValidations,\n\tstringEmail('email'),\n\turiValidations\n);\n","import {\n\tapiPaths,\n\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n} from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport { MagicLink, Routes, WaitForSessionConfig } from './types';\nimport {\n\twithWaitForSessionValidations,\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst normalizeWaitForSessionConfig = ({\n\tpollingIntervalMs = MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\ttimeoutMs = MAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n} = {}) => ({\n\tpollingIntervalMs: Math.max(\n\t\tpollingIntervalMs || MAGIC_LINK_MIN_POLLING_INTERVAL_MS,\n\t\tMAGIC_LINK_MIN_POLLING_INTERVAL_MS\n\t),\n\ttimeoutMs: Math.min(\n\t\ttimeoutMs || MAGIC_LINK_MAX_POLLING_TIMEOUT_MS,\n\t\tMAGIC_LINK_MAX_POLLING_TIMEOUT_MS\n\t)\n});\n\nconst withMagicLinkCrossDevice = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser,\n\t\t\t\t\t\t\tcrossDevice: true\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\twaitForSession: withWaitForSessionValidations(\n\t\t(pendingRef: string, config?: WaitForSessionConfig): Promise<SdkResponse> =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tconst { pollingIntervalMs, timeoutMs } = normalizeWaitForSessionConfig(config);\n\t\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\t\tconst interval = setInterval(async () => {\n\t\t\t\t\tconst resp = await httpClient.post(apiPaths.magicLink.session, { pendingRef });\n\t\t\t\t\tif (resp.ok) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\t\tresolve(transformResponse(Promise.resolve(resp)));\n\t\t\t\t\t}\n\t\t\t\t}, pollingIntervalMs);\n\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tresolve({\n\t\t\t\t\t\terror: { message: `Session polling timeout exceeded: ${timeoutMs}ms`, code: '0' },\n\t\t\t\t\t\tok: false\n\t\t\t\t\t});\n\t\t\t\t\tclearInterval(interval);\n\t\t\t\t}, timeoutMs);\n\t\t\t})\n\t),\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, email, URI: uri, crossDevice: true },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone, URI: uri, crossDevice: true },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t}\n});\n\nexport default withMagicLinkCrossDevice;\n","export const DEFAULT_BASE_API_URL = 'https://api.descope.com';\n\nexport const MAGIC_LINK_MIN_POLLING_INTERVAL_MS = 1000; // 1 second\nexport const MAGIC_LINK_MAX_POLLING_TIMEOUT_MS = 1000 * 60 * 10; // 10 minutes\n\nexport { default as apiPaths } from './apiPaths';\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport { pathJoin, transformResponse } from '../helpers';\nimport { DeliveryMethods, DeliveryPhone, SdkResponse, User } from '../types';\nimport withMagicLinkCrossDevice from './crossDevice';\nimport { MagicLink, Routes } from './types';\nimport {\n\twithSignValidations,\n\twithVerifyValidations,\n\twithUpdateEmailValidations,\n\twithUpdatePhoneValidations\n} from './validations';\n\nconst withMagicLink = (httpClient: HttpClient) => ({\n\tverify: withVerifyValidations(\n\t\t(token: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.magicLink.verify, { token }))\n\t),\n\n\tsignIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signIn, delivery), { externalId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tsignUp: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string, user?: User): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUp, delivery), {\n\t\t\t\t\t\t\texternalId,\n\t\t\t\t\t\t\tURI,\n\t\t\t\t\t\t\tuser\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signUp],\n\n\tsignUpOrIn: Object.keys(DeliveryMethods).reduce(\n\t\t(acc, delivery) => ({\n\t\t\t...acc,\n\t\t\t[delivery]: withSignValidations(\n\t\t\t\t(externalId: string, URI: string): Promise<SdkResponse> =>\n\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\thttpClient.post(pathJoin(apiPaths.magicLink.signUpOrIn, delivery), { externalId, URI })\n\t\t\t\t\t)\n\t\t\t)\n\t\t}),\n\t\t{}\n\t) as MagicLink[Routes.signIn],\n\n\tupdate: {\n\t\temail: withUpdateEmailValidations(\n\t\t\t(identifier: string, email: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.magicLink.update.email,\n\t\t\t\t\t\t{ externalId: identifier, email, URI: uri },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\t\tphone: Object.keys(DeliveryPhone).reduce(\n\t\t\t(acc, delivery) => ({\n\t\t\t\t...acc,\n\t\t\t\t[delivery]: withUpdatePhoneValidations(\n\t\t\t\t\t(externalId: string, phone: string, uri: string, token?: string): Promise<SdkResponse> =>\n\t\t\t\t\t\ttransformResponse(\n\t\t\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\t\t\tpathJoin(apiPaths.magicLink.update.phone, delivery),\n\t\t\t\t\t\t\t\t{ externalId, phone, URI: uri },\n\t\t\t\t\t\t\t\t{ token }\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}),\n\t\t\t{}\n\t\t) as MagicLink[Routes.updatePhone]\n\t},\n\n\tcrossDevice: withMagicLinkCrossDevice(httpClient)\n});\n\nexport default withMagicLink;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withExchangeValidations = withValidations(stringNonEmpty('code'));\n\nconst withExchange = (httpClient: HttpClient) => ({\n\texchange: withExchangeValidations(\n\t\t(code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.get(apiPaths.exchange, { queryParams: { code } }))\n\t)\n});\n\nexport default withExchange;\n","import { SdkResponse } from '../types';\n\nenum OAuthProviders {\n\tfacebook = 'facebook',\n\tgithub = 'github',\n\tgoogle = 'google',\n\tmicrosoft = 'microsoft',\n\tgitlab = 'gitlab',\n\tapple = 'apple'\n}\n\ntype StartFn = <B extends { redirect: boolean }>(\n\tredirectURL?: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\ntype VerifyFn = (code: string) => Promise<SdkResponse>;\n\ntype Providers<T> = Record<keyof typeof OAuthProviders, T>;\n\nexport type Oauth = {\n\tstart: Providers<StartFn>;\n\tverify: Providers<VerifyFn>;\n};\n\nexport { OAuthProviders };\n","import { apiPaths } from '../../constants';\nimport { HttpClient } from '../../httpClient';\nimport withExchange from '../exchange';\nimport { transformResponse } from '../helpers';\nimport { Oauth, OAuthProviders } from './types';\n\nconst withOauth = (httpClient: HttpClient) => ({\n\tstart: Object.keys(OAuthProviders).reduce(\n\t\t(acc, provider) => ({\n\t\t\t...acc,\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\t[provider]: async (redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\t\tconst resp = await httpClient.get(apiPaths.oauth.start, {\n\t\t\t\t\tqueryParams: { provider, ...(redirectUrl && { redirectURL: redirectUrl }) }\n\t\t\t\t});\n\t\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\t\tconst { url } = await resp.json();\n\t\t\t\twindow.location.href = url;\n\t\t\t}\n\t\t}),\n\t\t{}\n\t) as Oauth['start'],\n\n\t...withExchange(httpClient)\n});\n\nexport default withOauth;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('flowId'));\nconst withNextValidations = withValidations(\n\tstringNonEmpty('executionId'),\n\tstringNonEmpty('stepId'),\n\tstringNonEmpty('actionId')\n);\n\nconst withFlow = (httpClient: HttpClient) => ({\n\tstart: withStartValidations((flowId: string) =>\n\t\ttransformResponse(httpClient.post(apiPaths.flow.start, { flowId }))\n\t),\n\tnext: withNextValidations(\n\t\t(\n\t\t\texecutionId: string,\n\t\t\tstepId: string,\n\t\t\tactionId: string,\n\t\t\tinput?: Record<string, FormDataEntryValue>\n\t\t) => {\n\t\t\treturn transformResponse(\n\t\t\t\thttpClient.post(apiPaths.flow.next, { executionId, stepId, actionId, input })\n\t\t\t);\n\t\t}\n\t)\n});\n\nexport default withFlow;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport withExchange from './exchange';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst withStartValidations = withValidations(stringNonEmpty('tenant'));\n\ntype StartFn = <B extends { redirect: boolean }>(\n\ttenantNameOrEmail: string,\n\tconfig?: B\n) => Promise<B extends { redirect: true } ? undefined : SdkResponse>;\n\nconst withSaml = (httpClient: HttpClient) => ({\n\t// eslint-disable-next-line consistent-return\n\tstart: withStartValidations(\n\t\tasync (tenantNameOrEmail: string, redirectUrl?: string, { redirect = false } = {}) => {\n\t\t\tconst resp = await httpClient.get(apiPaths.saml.start, {\n\t\t\t\tqueryParams: { tenant: tenantNameOrEmail, redirectURL: redirectUrl }\n\t\t\t});\n\n\t\t\tif (!redirect || !resp.ok) return transformResponse(Promise.resolve(resp));\n\n\t\t\tconst { url } = await resp.json();\n\t\t\twindow.location.href = url;\n\t\t}\n\t) as StartFn,\n\n\t...withExchange(httpClient)\n});\n\nexport default withSaml;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { User, SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst withVerifyValidations = withValidations(identifierValidations, stringNonEmpty('code'));\nconst withSignUpValidations = withValidations(identifierValidations);\nconst withUpdateValidations = withValidations(identifierValidations);\n\nconst withTotp = (httpClient: HttpClient) => ({\n\tsignUp: withSignUpValidations(\n\t\t(identifier: string, user?: User): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.signUp, { externalId: identifier, user }))\n\t),\n\n\tverify: withVerifyValidations(\n\t\t(identifier: string, code: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(httpClient.post(apiPaths.totp.verify, { externalId: identifier, code }))\n\t),\n\n\tupdate: withUpdateValidations(\n\t\t(identifier: string, token?: string): Promise<SdkResponse> =>\n\t\t\ttransformResponse(\n\t\t\t\thttpClient.post(apiPaths.totp.update, { externalId: identifier }, { token })\n\t\t\t)\n\t)\n});\n\nexport default withTotp;\n","import { apiPaths } from '../constants';\nimport { HttpClient } from '../httpClient';\nimport { transformResponse } from './helpers';\nimport { SdkResponse } from './types';\nimport { stringNonEmpty, withValidations } from './validations';\n\nconst identifierValidations = stringNonEmpty('identifier');\nconst originValidations = stringNonEmpty('origin');\n\nconst withSignUpStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('name')\n);\nconst withSignInStartValidations = withValidations(identifierValidations, originValidations);\nconst withUpdateStartValidations = withValidations(\n\tidentifierValidations,\n\toriginValidations,\n\tstringNonEmpty('token')\n);\nconst withFinishValidations = withValidations(\n\tstringNonEmpty('transactionId'),\n\tstringNonEmpty('response')\n);\n\nconst withWebauthn = (httpClient: HttpClient) => ({\n\tsignUp: {\n\t\tstart: withSignUpStartValidations(\n\t\t\t(identifier: string, origin: string, name: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.start, {\n\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\texternalId: identifier,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t},\n\t\t\t\t\t\torigin\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signUp.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tsignIn: {\n\t\tstart: withSignInStartValidations(\n\t\t\t(identifier: string, origin: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.start, { externalId: identifier, origin })\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.signIn.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t},\n\n\tupdate: {\n\t\tstart: withUpdateStartValidations(\n\t\t\t(identifier: string, origin: string, token: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(\n\t\t\t\t\t\tapiPaths.webauthn.update.start,\n\t\t\t\t\t\t{ externalId: identifier, origin },\n\t\t\t\t\t\t{ token }\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t),\n\n\t\tfinish: withFinishValidations(\n\t\t\t(transactionId: string, response: string): Promise<SdkResponse> =>\n\t\t\t\ttransformResponse(\n\t\t\t\t\thttpClient.post(apiPaths.webauthn.update.finish, { transactionId, response })\n\t\t\t\t)\n\t\t)\n\t}\n});\n\nexport default withWebauthn;\n","import withOtp from './otp';\nimport { HttpClient } from '../httpClient';\nimport isJwtExpired, { transformResponse } from './helpers';\nimport { stringNonEmpty, withValidations } from './validations';\nimport withMagicLink from './magicLink';\nimport { apiPaths } from '../constants';\nimport withOauth from './oauth';\nimport withFlow from './flow';\nimport withSaml from './saml';\nimport withTotp from './totp';\nimport withWebauthn from './webauthn';\n\nconst withValidateValidations = withValidations(stringNonEmpty('token'));\n\nexport default (httpClient: HttpClient) => ({\n\totp: withOtp(httpClient),\n\tmagicLink: withMagicLink(httpClient),\n\toauth: withOauth(httpClient),\n\tsaml: withSaml(httpClient),\n\ttotp: withTotp(httpClient),\n\twebauthn: withWebauthn(httpClient),\n\tflow: withFlow(httpClient),\n\trefresh: (token?: string) => transformResponse(httpClient.get(apiPaths.refresh, { token })),\n\tlogout: (token?: string) => transformResponse(httpClient.get(apiPaths.logout, { token })),\n\tisJwtExpired: withValidateValidations(isJwtExpired),\n\thttpClient\n});\n","import { DEFAULT_BASE_API_URL } from './constants';\nimport createHttpClient from './httpClient';\nimport createSdk from './sdk';\nimport { OAuthProviders } from './sdk/oauth/types';\nimport { DeliveryMethods, Logger } from './sdk/types';\nimport { Hooks, HTTPMethods } from './httpClient/types';\nimport { stringNonEmpty, withValidations } from './sdk/validations';\nimport { hasPathValue } from './sdk/validations/validators';\n\nconst withSdkConfigValidations = withValidations([\n\thasPathValue('projectId', stringNonEmpty('projectId'))\n]);\n\nconst sdk = withSdkConfigValidations(\n\t({ projectId, logger, baseUrl, hooks }: { projectId: string; logger?: Logger; baseUrl?: string; hooks?: Hooks; }) =>\n\t\tcreateSdk(createHttpClient({ baseUrl: baseUrl || DEFAULT_BASE_API_URL, projectId, logger, hooks }))\n);\n\nconst sdkWithAttributes = sdk as typeof sdk & { DeliveryMethods: typeof DeliveryMethods };\n\nsdkWithAttributes.DeliveryMethods = DeliveryMethods;\n\nexport default sdkWithAttributes;\n\nexport type DeliveryMethod = keyof typeof DeliveryMethods;\nexport type OAuthProvider = keyof typeof OAuthProviders;\nexport type { HTTPMethods };\nexport type { SdkResponse } from './sdk/types';\n"],"names":["apiPaths","verify","signIn","signUp","update","email","phone","signUpOrIn","session","start","finish","next","HTTPMethods","httpLogBuilder","msg","headers","headersObj","entries","Object","fromEntries","Headers","JSON","stringify","this","body","Body","url","Url","toString","method","Method","title","Title","status","Status","build","keys","flatMap","key","join","createFetchLogger","logger","receivedFetch","fetchInternal","fetch","Error","async","args","log","buildRequestLog","resp","ok","respBody","text","Promise","resolve","json","parse","statusText","buildResponseLog","mergeHeaders","sources","reduce","acc","source","srcArr","Array","isArray","from","getSrcArr","_","value","serializeBody","undefined","createAuthorizationHeader","projectId","token","bearer","Authorization","createHttpClient","baseUrl","baseConfig","hooks","fetchWithLogger","sendRequest","config","requestConfig","beforeRequest","path","queryParams","URL","search","URLSearchParams","urlBuilder","baseHeaders","credentials","get","post","put","delete","isJwtExpired","exp","jwtDecode","Date","getTime","pathJoin","replace","transformResponse","response","ret","code","data","error","DeliveryPhone","DeliveryMethods","Routes","createValidator","rule","defaultMsg","val","createValidation","validators","validate","forEach","validator","errMsg","regexMatch","regex","test","validateEmail","validatePhone","isEmail","isPhone","isNotEmpty","min","length","isString","withValidations","argsRules","fn","rulesArr","i","stringNonEmpty","fieldName","stringEmail","stringPhone","identifierValidations","withVerifyValidations","withSignValidations","withUpdatePhoneValidations","withUpdateEmailValidations","withOtp","httpClient","delivery","assign","externalId","user","identifier","uriValidations","withWaitForSessionValidations","withMagicLinkCrossDevice","URI","crossDevice","waitForSession","pendingRef","pollingIntervalMs","timeoutMs","Math","max","normalizeWaitForSessionConfig","timeout","interval","setInterval","clearInterval","clearTimeout","setTimeout","message","uri","withMagicLink","withExchangeValidations","withExchange","exchange","OAuthProviders","withOauth","provider","redirectUrl","redirect","redirectURL","window","location","href","withStartValidations","withNextValidations","withFlow","flowId","executionId","stepId","actionId","input","withSaml","tenantNameOrEmail","tenant","withSignUpValidations","withUpdateValidations","withTotp","originValidations","withSignUpStartValidations","withSignInStartValidations","withUpdateStartValidations","withFinishValidations","withWebauthn","origin","name","transactionId","withValidateValidations","rules","sdkWithAttributes","validatePathValue","withSdkConfigValidations","createSdk","otp","magicLink","oauth","saml","totp","webauthn","flow","refresh","logout"],"mappings":"oDAAA,IAAeA,EACT,CACJC,OAAQ,sB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,WAAYE,EAAYsD,UAC1B,CAAEvI,aAKNlE,OAAQuM,IACP,CAACI,EAAuBzG,IACvBD,EACC6C,EAAWvD,KAAKjG,EAAkBI,OAAOM,OAAQ,CAAE2M,gBAAezG,mBCnEjE0G,GAA0B7E,EAAgBK,EAAe,UdSnC,IAACtD,GAAc+H,GeR3C,MAKMC,GAT2B/E,EAAgB,EfYpBjD,GeXf,YfW6B+H,GeXhBzE,EAAe,afYzC1B,EATyB,EAAC5B,EAAc+H,IAAwBhG,GAChEC,KAAoB+F,GAAO7F,SAAS1B,EAAIuB,EAAK/B,IAQ7BiI,CAAkBjI,GAAM+H,IAAxCnG,KeTWsG,EACX,EAAG/I,YAAWlC,SAAQuC,UAASE,YAC9ByI,ODDcnE,ECCJzE,EAAiB,CAAEC,QAASA,GVfJ,0BUeqCL,YAAWlC,SAAQyC,UDDhD,CAC3C0I,IAAKrE,EAAQC,GACbqE,UAAW3C,GAAc1B,GACzBsE,MAAOvC,GAAU/B,GACjBuE,KAAMxB,GAAS/C,GACfwE,KAAMpB,GAASpD,GACfyE,SAAUf,GAAa1D,GACvB0E,KAAMjC,GAASzC,GACf2E,QAAUvJ,GAAmB+B,EAAkB6C,EAAWxD,IAAIhG,EAAkB,CAAE4E,WAClFwJ,OAASxJ,GAAmB+B,EAAkB6C,EAAWxD,IAAIhG,EAAiB,CAAE4E,WAChFwB,aAAckH,GAAwBlH,GACtCoD,cAXc,IAACA,CCCqF,IAKrGgE,GAAkBtG,gBAAkBA"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";var e={verify:"/v1/auth/code/verify",signIn:"/v1/auth/signin/otp",signUp:"/v1/auth/signup/otp",update:{email:"/v1/user/update/email/otp",phone:"/v1/user/update/phone/otp"},signUpOrIn:"/v1/auth/sign-up-or-in/otp"},t={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/signin/magiclink",signUp:"/v1/auth/signup/magiclink",session:"/v1/auth/magiclink/session",update:{email:"/v1/user/update/email/magiclink",phone:"/v1/user/update/phone/magiclink"},signUpOrIn:"/v1/auth/sign-up-or-in/magiclink"},n={start:"/v1/oauth/authorize"},r={start:"/v1/auth/saml/authorize"},s={verify:"/v1/auth/verify/totp",signUp:"/v1/auth/signup/totp",update:"/v1/user/update/totp"},o={signUp:{start:"/v1/webauthn/signup/start",finish:"/v1/webauthn/signup/finish"},signIn:{start:"/v1/webauthn/signin/start",finish:"/v1/webauthn/signin/finish"},add:{start:"/v1/webauthn/device/add/start",finish:"/v1/webauthn/device/add/finish"}},i="/v1/auth/refresh",a="/v1/auth/logoutall",c={start:"/v1/flow/start",next:"/v1/flow/next"},u="/v1/auth/exchange";const p=1e3,d=6e5;var l;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(l||(l={}));const h=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>h().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),h().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n},g=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),v=e=>void 0===e?void 0:JSON.stringify(e),y=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},b=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:s})=>{const o=f(r),i=r=>{const i=(null==s?void 0:s.beforeRequest)?s.beforeRequest(r):r,{path:a,body:c,headers:u,queryParams:p,method:d,token:l}=i;return o((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:a,baseUrl:e,queryParams:p}),{headers:g(y(t,l),(null==n?void 0:n.baseHeaders)||{},u),method:d,body:v(c)})};return{get:(e,{headers:t,queryParams:n,token:r}={})=>i({path:e,headers:t,queryParams:n,body:void 0,method:l.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:s}={})=>i({path:e,headers:n,queryParams:r,body:t,method:l.post,token:s}),put:(e,t,{headers:n,queryParams:r,token:s}={})=>i({path:e,headers:n,queryParams:r,body:t,method:l.put,token:s}),delete:(e,t,{headers:n,queryParams:r,token:s}={})=>i({path:e,headers:n,queryParams:r,body:t,method:l.delete,token:s})}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidCharacterError";var I="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new m("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,s=0,o=0,i="";r=t.charAt(o++);~r&&(n=s%4?64*n+r:r,s++%4)?i+=String.fromCharCode(255&n>>(-2*s&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return i};function j(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(I(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return I(t)}}function w(e){this.message=e}w.prototype=new Error,w.prototype.name="InvalidTokenError";const O=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=function(e,t){if("string"!=typeof e)throw new w("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(j(e.split(".")[n]))}catch(e){throw new w("Invalid token specified: "+e.message)}}(e);return(new Date).getTime()/1e3>t},k=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),_=async e=>{const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.json();return t.ok?n.data=r:n.error=r,n};var U,x,P;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(U||(U={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(P||(P={}));const R=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},E="__lodash_hash_undefined__",T="[object Function]",q="[object GeneratorFunction]",M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/,C=/^\./,D=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,z=/\\(\\)?/g,L=/^\[object .+?Constructor\]$/,F="object"==typeof $&&$&&$.Object===Object&&$,J="object"==typeof self&&self&&self.Object===Object&&self,H=F||J||Function("return this")();var N,Z=Array.prototype,B=Function.prototype,G=Object.prototype,K=H["__core-js_shared__"],Q=(N=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"",V=B.toString,W=G.hasOwnProperty,X=G.toString,Y=RegExp("^"+V.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=H.Symbol,te=Z.splice,ne=he(H,"Map"),re=he(Object,"create"),se=ee?ee.prototype:void 0,oe=se?se.toString:void 0;function ie(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ce(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ue(e,t){for(var n,r,s=e.length;s--;)if((n=e[s][0])===(r=t)||n!=n&&r!=r)return s;return-1}function pe(e,t){var n;t=function(e,t){if(ye(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||me(e))return!0;return A.test(e)||!M.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ye(n=t)?n:fe(n);for(var r=0,s=t.length;null!=e&&r<s;)e=e[ge(t[r++])];return r&&r==s?e:void 0}function de(e){if(!be(e)||(t=e,Q&&Q in t))return!1;var t,n=function(e){var t=be(e)?X.call(e):"";return t==T||t==q}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Y:L;return n.test(function(e){if(null!=e){try{return V.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function le(e,t){var n,r,s=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?s["string"==typeof t?"string":"hash"]:s.map}function he(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return de(n)?n:void 0}ie.prototype.clear=function(){this.__data__=re?re(null):{}},ie.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ie.prototype.get=function(e){var t=this.__data__;if(re){var n=t[e];return n===E?void 0:n}return W.call(t,e)?t[e]:void 0},ie.prototype.has=function(e){var t=this.__data__;return re?void 0!==t[e]:W.call(t,e)},ie.prototype.set=function(e,t){return this.__data__[e]=re&&void 0===t?E:t,this},ae.prototype.clear=function(){this.__data__=[]},ae.prototype.delete=function(e){var t=this.__data__,n=ue(t,e);return!(n<0)&&(n==t.length-1?t.pop():te.call(t,n,1),!0)},ae.prototype.get=function(e){var t=this.__data__,n=ue(t,e);return n<0?void 0:t[n][1]},ae.prototype.has=function(e){return ue(this.__data__,e)>-1},ae.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ce.prototype.clear=function(){this.__data__={hash:new ie,map:new(ne||ae),string:new ie}},ce.prototype.delete=function(e){return le(this,e).delete(e)},ce.prototype.get=function(e){return le(this,e).get(e)},ce.prototype.has=function(e){return le(this,e).has(e)},ce.prototype.set=function(e,t){return le(this,e).set(e,t),this};var fe=ve((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(me(e))return oe?oe.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return C.test(e)&&n.push(""),e.replace(D,(function(e,t,r,s){n.push(r?s.replace(z,"$1"):t||e)})),n}));function ge(e){if("string"==typeof e||me(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ve(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],o=n.cache;if(o.has(s))return o.get(s);var i=e.apply(this,r);return n.cache=o.set(s,i),i};return n.cache=new(ve.Cache||ce),n}ve.Cache=ce;var ye=Array.isArray;function be(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function me(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==X.call(e)}var Ie=function(e,t,n){var r=null==e?void 0:pe(e,t);return void 0===r?n:r};const je=e=>t=>e.test(t),we=je(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Oe=je(/^\+[1-9]{1}[0-9]{3,14}$/),ke=R(we,'"{val}" is not a valid email'),_e=R(Oe,'"{val}" is not a valid phone number'),Ue=R((xe=1,e=>e.length>=xe),"Minimum length is 1");var xe;const Pe=R((e=>"string"==typeof e),"Input is not a string"),Re=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Se=e=>[Pe(`"${e}" must be a string`),Ue(`"${e}" must not be empty`)],$e=e=>[Pe(`"${e}" must be a string`),ke()],Ee=e=>[Pe(`"${e}" must be a string`),_e()];var Te;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Te||(Te={}));const qe=Se("identifier"),Me=Re(qe,Se("code")),Ae=Re(qe),Ce=Re(qe,Ee("phone")),De=Re(qe,$e("email")),ze=t=>({verify:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Me(((n,s)=>_(t.post(k(e.verify,r),{code:s,externalId:n}))))})),{}),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae((n=>_(t.post(k(e.signIn,r),{externalId:n}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae(((n,s)=>_(t.post(k(e.signUp,r),{externalId:n,user:s}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae((n=>_(t.post(k(e.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:De(((n,r,s)=>_(t.post(e.update.email,{externalId:n,email:r},{token:s})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce(((n,s,o)=>_(t.post(k(e.update.phone,r),{externalId:n,phone:s},{token:o}))))})),{})}}),Le=Se("identifier"),Fe=Se("uri"),Je=Re(Se("token")),He=Re(Le,Fe),Ne=Re(Se("pendingRef")),Ze=Re(Le,Ee("phone"),Fe),Be=Re(Le,$e("email"),Fe),Ge=e=>({verify:Je((n=>_(e.post(t.verify,{token:n})))),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signIn,r),{externalId:n,URI:s,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signUpOrIn,r),{externalId:n,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s,o)=>_(e.post(k(t.signUp,r),{externalId:n,URI:s,user:o,crossDevice:!0}))))})),{}),waitForSession:Ne(((n,r)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:i}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||p,p),timeoutMs:Math.min(t||d,d)}))(r);let a;const c=setInterval((async()=>{const r=await e.post(t.session,{pendingRef:n});r.ok&&(clearInterval(c),a&&clearTimeout(a),s(_(Promise.resolve(r))))}),o);a=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${i}ms`,code:"0"},ok:!1}),clearInterval(c)}),i)})))),update:{email:Be(((n,r,s,o)=>_(e.post(t.update.email,{externalId:n,email:r,URI:s,crossDevice:!0},{token:o})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,s,o,i)=>_(e.post(k(t.update.phone,r),{externalId:n,phone:s,URI:o,crossDevice:!0},{token:i}))))})),{})}}),Ke=e=>({verify:Je((n=>_(e.post(t.verify,{token:n})))),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signIn,r),{externalId:n,URI:s}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s,o)=>_(e.post(k(t.signUp,r),{externalId:n,URI:s,user:o}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signUpOrIn,r),{externalId:n,URI:s}))))})),{}),update:{email:Be(((n,r,s,o)=>_(e.post(t.update.email,{externalId:n,email:r,URI:s},{token:o})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,s,o,i)=>_(e.post(k(t.update.phone,r),{externalId:n,phone:s,URI:o},{token:i}))))})),{})},crossDevice:Ge(e)}),Qe=Re(Se("code")),Ve=e=>({exchange:Qe((t=>_(e.get(u,{queryParams:{code:t}}))))});var We;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(We||(We={}));const Xe=e=>Object.assign({start:Object.keys(We).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:async(t,{redirect:s=!1}={})=>{const o=await e.get(n.start,{queryParams:Object.assign({provider:r},t&&{redirectURL:t})});if(!s||!o.ok)return _(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}})),{})},Ve(e)),Ye=Re(Se("flowId")),et=Re(Se("executionId"),Se("stepId"),Se("actionId")),tt=e=>({start:Ye((t=>_(e.post(c.start,{flowId:t})))),next:et(((t,n,r,s)=>_(e.post(c.next,{executionId:t,stepId:n,actionId:r,input:s}))))}),nt=Re(Se("tenant")),rt=e=>Object.assign({start:nt((async(t,n,{redirect:s=!1}={})=>{const o=await e.get(r.start,{queryParams:{tenant:t,redirectURL:n}});if(!s||!o.ok)return _(Promise.resolve(o));const{url:i}=await o.json();window.location.href=i}))},Ve(e)),st=Se("identifier"),ot=Re(st,Se("code")),it=Re(st),at=Re(st),ct=e=>({signUp:it(((t,n)=>_(e.post(s.signUp,{externalId:t,user:n})))),verify:ot(((t,n)=>_(e.post(s.verify,{externalId:t,code:n})))),update:at(((t,n)=>_(e.post(s.update,{externalId:t},{token:n}))))}),ut=Se("identifier"),pt=Se("origin"),dt=Re(ut,pt,Se("name")),lt=Re(ut,pt),ht=Re(ut,pt,Se("token")),ft=Re(Se("transactionId"),Se("response")),gt=e=>({signUp:{start:dt(((t,n,r)=>_(e.post(o.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:ft(((t,n)=>_(e.post(o.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:lt(((t,n)=>_(e.post(o.signIn.start,{externalId:t,origin:n})))),finish:ft(((t,n)=>_(e.post(o.signIn.finish,{transactionId:t,response:n}))))},add:{start:ht(((t,n,r)=>_(e.post(o.add.start,{externalId:t,origin:n},{token:r})))),finish:ft(((t,n)=>_(e.post(o.add.finish,{transactionId:t,response:n}))))}}),vt=Re(Se("token"));var yt,bt;const mt=Re([(yt="projectId",bt=Se("projectId"),R(((e,t)=>n=>S(...t).validate(Ie(n,e)))(yt,bt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r})=>{return s=b({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r}),{otp:ze(s),magicLink:Ke(s),oauth:Xe(s),saml:rt(s),totp:ct(s),webauthn:gt(s),flow:tt(s),refresh:e=>_(s.get(i,{token:e})),logout:e=>_(s.get(a,{token:e})),isJwtExpired:vt(O),httpClient:s};var s}));return mt.DeliveryMethods=x,mt}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).descopeSdk=t()}(this,(function(){"use strict";var e={verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},t={verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",session:"/v1/auth/magiclink/pending-session",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/email"},signUpOrIn:"/v1/auth/magiclink/signup-in"},n={start:"/v1/auth/oauth/authorize"},r={start:"/v1/auth/saml/authorize"},s={verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/user/totp/update"},o={signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},a="/v1/auth/refresh",i="/v1/auth/logoutall",u={start:"/v1/flow/start",next:"/v1/flow/next"},c="/v1/auth/exchange";const p=1e3,d=6e5;var l;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT"}(l||(l={}));const h=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},f=(e,t)=>{const n=t||fetch;if(!n)throw new Error("fetch is not defined");return e?async(...t)=>{e.log((e=>h().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const r=await n(...t);return e[r.ok?"log":"error"](await(async e=>{const t=await e.text();return e.text=()=>Promise.resolve(t),e.json=()=>Promise.resolve(JSON.parse(t)),h().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(r)),r}:n},g=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,r])=>(e[n]=r,e)),e),e}),{})),v=e=>void 0===e?void 0:JSON.stringify(e),y=(e,t="")=>{let n=e;return""!==t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},b=({baseUrl:e,projectId:t,baseConfig:n,logger:r,hooks:s})=>{const o=f(r),a=r=>{const a=(null==s?void 0:s.beforeRequest)?s.beforeRequest(r):r,{path:i,body:u,headers:c,queryParams:p,method:d,token:l}=a;return o((({path:e,baseUrl:t,queryParams:n})=>{const r=new URL(e,t);return n&&(r.search=new URLSearchParams(n).toString()),r})({path:i,baseUrl:e,queryParams:p}),{headers:g(y(t,l),(null==n?void 0:n.baseHeaders)||{},c),method:d,body:v(u),credentials:"same-origin"})};return{get:(e,{headers:t,queryParams:n,token:r}={})=>a({path:e,headers:t,queryParams:n,body:void 0,method:l.get,token:r}),post:(e,t,{headers:n,queryParams:r,token:s}={})=>a({path:e,headers:n,queryParams:r,body:t,method:l.post,token:s}),put:(e,t,{headers:n,queryParams:r,token:s}={})=>a({path:e,headers:n,queryParams:r,body:t,method:l.put,token:s}),delete:(e,t,{headers:n,queryParams:r,token:s}={})=>a({path:e,headers:n,queryParams:r,body:t,method:l.delete,token:s})}};function m(e){this.message=e}m.prototype=new Error,m.prototype.name="InvalidCharacterError";var I="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new m("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,s=0,o=0,a="";r=t.charAt(o++);~r&&(n=s%4?64*n+r:r,s++%4)?a+=String.fromCharCode(255&n>>(-2*s&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function j(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(I(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return I(t)}}function w(e){this.message=e}w.prototype=new Error,w.prototype.name="InvalidTokenError";const O=e=>{if("string"!=typeof e||!e)throw new Error("Invalid token provided");const{exp:t}=function(e,t){if("string"!=typeof e)throw new w("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(j(e.split(".")[n]))}catch(e){throw new w("Invalid token specified: "+e.message)}}(e);return(new Date).getTime()/1e3>t},k=(...e)=>e.join("/").replace(/\/{2,}/g,"/"),_=async e=>{const t=await e,n={code:t.status,ok:t.ok,response:t},r=await t.json();return t.ok?n.data=r:n.error=r,n};var U,x,P;!function(e){e.sms="sms",e.whatsapp="whatsapp"}(U||(U={})),function(e){e.email="email",e.sms="sms",e.whatsapp="whatsapp"}(x||(x={})),function(e){e.signUp="signup",e.signIn="signin",e.verify="verify"}(P||(P={}));const R=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),S=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)});var $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},E="__lodash_hash_undefined__",T="[object Function]",q="[object GeneratorFunction]",M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/,C=/^\./,D=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,z=/\\(\\)?/g,L=/^\[object .+?Constructor\]$/,F="object"==typeof $&&$&&$.Object===Object&&$,J="object"==typeof self&&self&&self.Object===Object&&self,H=F||J||Function("return this")();var N,Z=Array.prototype,B=Function.prototype,G=Object.prototype,K=H["__core-js_shared__"],Q=(N=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"",V=B.toString,W=G.hasOwnProperty,X=G.toString,Y=RegExp("^"+V.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=H.Symbol,te=Z.splice,ne=he(H,"Map"),re=he(Object,"create"),se=ee?ee.prototype:void 0,oe=se?se.toString:void 0;function ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ie(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ue(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ce(e,t){for(var n,r,s=e.length;s--;)if((n=e[s][0])===(r=t)||n!=n&&r!=r)return s;return-1}function pe(e,t){var n;t=function(e,t){if(ye(e))return!1;var n=typeof e;if("number"==n||"symbol"==n||"boolean"==n||null==e||me(e))return!0;return A.test(e)||!M.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:ye(n=t)?n:fe(n);for(var r=0,s=t.length;null!=e&&r<s;)e=e[ge(t[r++])];return r&&r==s?e:void 0}function de(e){if(!be(e)||(t=e,Q&&Q in t))return!1;var t,n=function(e){var t=be(e)?X.call(e):"";return t==T||t==q}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Y:L;return n.test(function(e){if(null!=e){try{return V.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function le(e,t){var n,r,s=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?s["string"==typeof t?"string":"hash"]:s.map}function he(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return de(n)?n:void 0}ae.prototype.clear=function(){this.__data__=re?re(null):{}},ae.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ae.prototype.get=function(e){var t=this.__data__;if(re){var n=t[e];return n===E?void 0:n}return W.call(t,e)?t[e]:void 0},ae.prototype.has=function(e){var t=this.__data__;return re?void 0!==t[e]:W.call(t,e)},ae.prototype.set=function(e,t){return this.__data__[e]=re&&void 0===t?E:t,this},ie.prototype.clear=function(){this.__data__=[]},ie.prototype.delete=function(e){var t=this.__data__,n=ce(t,e);return!(n<0)&&(n==t.length-1?t.pop():te.call(t,n,1),!0)},ie.prototype.get=function(e){var t=this.__data__,n=ce(t,e);return n<0?void 0:t[n][1]},ie.prototype.has=function(e){return ce(this.__data__,e)>-1},ie.prototype.set=function(e,t){var n=this.__data__,r=ce(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ue.prototype.clear=function(){this.__data__={hash:new ae,map:new(ne||ie),string:new ae}},ue.prototype.delete=function(e){return le(this,e).delete(e)},ue.prototype.get=function(e){return le(this,e).get(e)},ue.prototype.has=function(e){return le(this,e).has(e)},ue.prototype.set=function(e,t){return le(this,e).set(e,t),this};var fe=ve((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(me(e))return oe?oe.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t);var n=[];return C.test(e)&&n.push(""),e.replace(D,(function(e,t,r,s){n.push(r?s.replace(z,"$1"):t||e)})),n}));function ge(e){if("string"==typeof e||me(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ve(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],o=n.cache;if(o.has(s))return o.get(s);var a=e.apply(this,r);return n.cache=o.set(s,a),a};return n.cache=new(ve.Cache||ue),n}ve.Cache=ue;var ye=Array.isArray;function be(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function me(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==X.call(e)}var Ie=function(e,t,n){var r=null==e?void 0:pe(e,t);return void 0===r?n:r};const je=e=>t=>e.test(t),we=je(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Oe=je(/^\+[1-9]{1}[0-9]{3,14}$/),ke=R(we,'"{val}" is not a valid email'),_e=R(Oe,'"{val}" is not a valid phone number'),Ue=R((xe=1,e=>e.length>=xe),"Minimum length is 1");var xe;const Pe=R((e=>"string"==typeof e),"Input is not a string"),Re=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>S(...e).validate(n[t]))),t(...n)),Se=e=>[Pe(`"${e}" must be a string`),Ue(`"${e}" must not be empty`)],$e=e=>[Pe(`"${e}" must be a string`),ke()],Ee=e=>[Pe(`"${e}" must be a string`),_e()];var Te;!function(e){e.signUp="signup",e.signIn="signin",e.verify="verify",e.updatePhone="updatePhone"}(Te||(Te={}));const qe=Se("identifier"),Me=Re(qe,Se("code")),Ae=Re(qe),Ce=Re(qe,Ee("phone")),De=Re(qe,$e("email")),ze=t=>({verify:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Me(((n,s)=>_(t.post(k(e.verify,r),{code:s,externalId:n}))))})),{}),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae((n=>_(t.post(k(e.signIn,r),{externalId:n}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae(((n,s)=>_(t.post(k(e.signUp,r),{externalId:n,user:s}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ae((n=>_(t.post(k(e.signUpOrIn,r),{externalId:n}))))})),{}),update:{email:De(((n,r,s)=>_(t.post(e.update.email,{externalId:n,email:r},{token:s})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ce(((n,s,o)=>_(t.post(k(e.update.phone,r),{externalId:n,phone:s},{token:o}))))})),{})}}),Le=Se("identifier"),Fe=Se("uri"),Je=Re(Se("token")),He=Re(Le,Fe),Ne=Re(Se("pendingRef")),Ze=Re(Le,Ee("phone"),Fe),Be=Re(Le,$e("email"),Fe),Ge=e=>({verify:Je((n=>_(e.post(t.verify,{token:n})))),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signIn,r),{externalId:n,URI:s,crossDevice:!0}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signUpOrIn,r),{externalId:n,URI:s,crossDevice:!0}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s,o)=>_(e.post(k(t.signUp,r),{externalId:n,URI:s,user:o,crossDevice:!0}))))})),{}),waitForSession:Ne(((n,r)=>new Promise((s=>{const{pollingIntervalMs:o,timeoutMs:a}=(({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||p,p),timeoutMs:Math.min(t||d,d)}))(r);let i;const u=setInterval((async()=>{const r=await e.post(t.session,{pendingRef:n});r.ok&&(clearInterval(u),i&&clearTimeout(i),s(_(Promise.resolve(r))))}),o);i=setTimeout((()=>{s({error:{message:`Session polling timeout exceeded: ${a}ms`,code:"0"},ok:!1}),clearInterval(u)}),a)})))),update:{email:Be(((n,r,s,o)=>_(e.post(t.update.email,{externalId:n,email:r,URI:s,crossDevice:!0},{token:o})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,s,o,a)=>_(e.post(k(t.update.phone,r),{externalId:n,phone:s,URI:o,crossDevice:!0},{token:a}))))})),{})}}),Ke=e=>({verify:Je((n=>_(e.post(t.verify,{token:n})))),signIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signIn,r),{externalId:n,URI:s}))))})),{}),signUp:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s,o)=>_(e.post(k(t.signUp,r),{externalId:n,URI:s,user:o}))))})),{}),signUpOrIn:Object.keys(x).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:He(((n,s)=>_(e.post(k(t.signUpOrIn,r),{externalId:n,URI:s}))))})),{}),update:{email:Be(((n,r,s,o)=>_(e.post(t.update.email,{externalId:n,email:r,URI:s},{token:o})))),phone:Object.keys(U).reduce(((n,r)=>Object.assign(Object.assign({},n),{[r]:Ze(((n,s,o,a)=>_(e.post(k(t.update.phone,r),{externalId:n,phone:s,URI:o},{token:a}))))})),{})},crossDevice:Ge(e)}),Qe=Re(Se("code")),Ve=e=>({exchange:Qe((t=>_(e.get(c,{queryParams:{code:t}}))))});var We;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple"}(We||(We={}));const Xe=e=>Object.assign({start:Object.keys(We).reduce(((t,r)=>Object.assign(Object.assign({},t),{[r]:async(t,{redirect:s=!1}={})=>{const o=await e.get(n.start,{queryParams:Object.assign({provider:r},t&&{redirectURL:t})});if(!s||!o.ok)return _(Promise.resolve(o));const{url:a}=await o.json();window.location.href=a}})),{})},Ve(e)),Ye=Re(Se("flowId")),et=Re(Se("executionId"),Se("stepId"),Se("actionId")),tt=e=>({start:Ye((t=>_(e.post(u.start,{flowId:t})))),next:et(((t,n,r,s)=>_(e.post(u.next,{executionId:t,stepId:n,actionId:r,input:s}))))}),nt=Re(Se("tenant")),rt=e=>Object.assign({start:nt((async(t,n,{redirect:s=!1}={})=>{const o=await e.get(r.start,{queryParams:{tenant:t,redirectURL:n}});if(!s||!o.ok)return _(Promise.resolve(o));const{url:a}=await o.json();window.location.href=a}))},Ve(e)),st=Se("identifier"),ot=Re(st,Se("code")),at=Re(st),it=Re(st),ut=e=>({signUp:at(((t,n)=>_(e.post(s.signUp,{externalId:t,user:n})))),verify:ot(((t,n)=>_(e.post(s.verify,{externalId:t,code:n})))),update:it(((t,n)=>_(e.post(s.update,{externalId:t},{token:n}))))}),ct=Se("identifier"),pt=Se("origin"),dt=Re(ct,pt,Se("name")),lt=Re(ct,pt),ht=Re(ct,pt,Se("token")),ft=Re(Se("transactionId"),Se("response")),gt=e=>({signUp:{start:dt(((t,n,r)=>_(e.post(o.signUp.start,{user:{externalId:t,name:r},origin:n})))),finish:ft(((t,n)=>_(e.post(o.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:lt(((t,n)=>_(e.post(o.signIn.start,{externalId:t,origin:n})))),finish:ft(((t,n)=>_(e.post(o.signIn.finish,{transactionId:t,response:n}))))},update:{start:ht(((t,n,r)=>_(e.post(o.update.start,{externalId:t,origin:n},{token:r})))),finish:ft(((t,n)=>_(e.post(o.update.finish,{transactionId:t,response:n}))))}}),vt=Re(Se("token"));var yt,bt;const mt=Re([(yt="projectId",bt=Se("projectId"),R(((e,t)=>n=>S(...t).validate(Ie(n,e)))(yt,bt))())])((({projectId:e,logger:t,baseUrl:n,hooks:r})=>{return s=b({baseUrl:n||"https://api.descope.com",projectId:e,logger:t,hooks:r}),{otp:ze(s),magicLink:Ke(s),oauth:Xe(s),saml:rt(s),totp:ut(s),webauthn:gt(s),flow:tt(s),refresh:e=>_(s.get(a,{token:e})),logout:e=>_(s.get(i,{token:e})),isJwtExpired:vt(O),httpClient:s};var s}));return mt.DeliveryMethods=x,mt}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|