UNPKG

@verdaccio/signature

Version:

Verdaccio Signature Utilities

38 lines (37 loc) 945 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseBasicPayload = parseBasicPayload; /** * * @param credentials * @returns */ function parseBasicPayload(credentials) { if (credentials.startsWith('{')) { try { var parsed = JSON.parse(credentials); if (typeof parsed.user === 'string' && typeof parsed.password === 'string') { return { user: parsed.user, password: parsed.password, tokenKey: typeof parsed.tokenKey === 'string' ? parsed.tokenKey : undefined }; } } catch (_unused) { // not a JSON payload, fall through to the legacy "user:password" parsing } } var index = credentials.indexOf(':'); if (index < 0) { return; } var user = credentials.slice(0, index); var password = credentials.slice(index + 1); return { user: user, password: password }; } //# sourceMappingURL=token.js.map