mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-09 02:24:48 +08:00
Add extracted source directory and README navigation
This commit is contained in:
44
extracted-source/node_modules/@azure/msal-common/dist/crypto/ICrypto.mjs
generated
vendored
Normal file
44
extracted-source/node_modules/@azure/msal-common/dist/crypto/ICrypto.mjs
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
||||
'use strict';
|
||||
import { createClientAuthError } from '../error/ClientAuthError.mjs';
|
||||
import { methodNotImplemented } from '../error/ClientAuthErrorCodes.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
||||
createNewGuid: () => {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
base64Decode: () => {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
base64Encode: () => {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
base64UrlEncode: () => {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
encodeKid: () => {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
async getPublicKeyThumbprint() {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
async removeTokenBindingKey() {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
async clearKeystore() {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
async signJwt() {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
async hashString() {
|
||||
throw createClientAuthError(methodNotImplemented);
|
||||
},
|
||||
};
|
||||
|
||||
export { DEFAULT_CRYPTO_IMPLEMENTATION };
|
||||
//# sourceMappingURL=ICrypto.mjs.map
|
||||
89
extracted-source/node_modules/@azure/msal-common/dist/crypto/PopTokenGenerator.mjs
generated
vendored
Normal file
89
extracted-source/node_modules/@azure/msal-common/dist/crypto/PopTokenGenerator.mjs
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
||||
'use strict';
|
||||
import { nowSeconds } from '../utils/TimeUtils.mjs';
|
||||
import { UrlString } from '../url/UrlString.mjs';
|
||||
import { PerformanceEvents } from '../telemetry/performance/PerformanceEvent.mjs';
|
||||
import { invokeAsync } from '../utils/FunctionWrappers.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
const KeyLocation = {
|
||||
SW: "sw"};
|
||||
/** @internal */
|
||||
class PopTokenGenerator {
|
||||
constructor(cryptoUtils, performanceClient) {
|
||||
this.cryptoUtils = cryptoUtils;
|
||||
this.performanceClient = performanceClient;
|
||||
}
|
||||
/**
|
||||
* Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
|
||||
* and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
|
||||
* @param request
|
||||
* @returns
|
||||
*/
|
||||
async generateCnf(request, logger) {
|
||||
this.performanceClient?.addQueueMeasurement(PerformanceEvents.PopTokenGenerateCnf, request.correlationId);
|
||||
const reqCnf = await invokeAsync(this.generateKid.bind(this), PerformanceEvents.PopTokenGenerateCnf, logger, this.performanceClient, request.correlationId)(request);
|
||||
const reqCnfString = this.cryptoUtils.base64UrlEncode(JSON.stringify(reqCnf));
|
||||
return {
|
||||
kid: reqCnf.kid,
|
||||
reqCnfString,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Generates key_id for a SHR token request
|
||||
* @param request
|
||||
* @returns
|
||||
*/
|
||||
async generateKid(request) {
|
||||
this.performanceClient?.addQueueMeasurement(PerformanceEvents.PopTokenGenerateKid, request.correlationId);
|
||||
const kidThumbprint = await this.cryptoUtils.getPublicKeyThumbprint(request);
|
||||
return {
|
||||
kid: kidThumbprint,
|
||||
xms_ksl: KeyLocation.SW,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Signs the POP access_token with the local generated key-pair
|
||||
* @param accessToken
|
||||
* @param request
|
||||
* @returns
|
||||
*/
|
||||
async signPopToken(accessToken, keyId, request) {
|
||||
return this.signPayload(accessToken, keyId, request);
|
||||
}
|
||||
/**
|
||||
* Utility function to generate the signed JWT for an access_token
|
||||
* @param payload
|
||||
* @param kid
|
||||
* @param request
|
||||
* @param claims
|
||||
* @returns
|
||||
*/
|
||||
async signPayload(payload, keyId, request, claims) {
|
||||
// Deconstruct request to extract SHR parameters
|
||||
const { resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, shrOptions, } = request;
|
||||
const resourceUrlString = resourceRequestUri
|
||||
? new UrlString(resourceRequestUri)
|
||||
: undefined;
|
||||
const resourceUrlComponents = resourceUrlString?.getUrlComponents();
|
||||
return this.cryptoUtils.signJwt({
|
||||
at: payload,
|
||||
ts: nowSeconds(),
|
||||
m: resourceRequestMethod?.toUpperCase(),
|
||||
u: resourceUrlComponents?.HostNameAndPort,
|
||||
nonce: shrNonce || this.cryptoUtils.createNewGuid(),
|
||||
p: resourceUrlComponents?.AbsolutePath,
|
||||
q: resourceUrlComponents?.QueryString
|
||||
? [[], resourceUrlComponents.QueryString]
|
||||
: undefined,
|
||||
client_claims: shrClaims || undefined,
|
||||
...claims,
|
||||
}, keyId, shrOptions, request.correlationId);
|
||||
}
|
||||
}
|
||||
|
||||
export { PopTokenGenerator };
|
||||
//# sourceMappingURL=PopTokenGenerator.mjs.map
|
||||
Reference in New Issue
Block a user