@naylence/runtime 0.3.19 → 0.3.20

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.
@@ -515,12 +515,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
515
515
  }
516
516
 
517
517
  // This file is auto-generated during build - do not edit manually
518
- // Generated from package.json version: 0.3.19
518
+ // Generated from package.json version: 0.3.20
519
519
  /**
520
520
  * The package version, injected at build time.
521
521
  * @internal
522
522
  */
523
- const VERSION = '0.3.19';
523
+ const VERSION = '0.3.20';
524
524
 
525
525
  let initialized = false;
526
526
  const runtimePlugin = {
@@ -40285,6 +40285,51 @@ class OAuth2ClientCredentialsTokenProvider {
40285
40285
  }
40286
40286
  return DEFAULT_EXPIRY_SECONDS;
40287
40287
  }
40288
+ async getIdentity() {
40289
+ const token = await this.getToken();
40290
+ const tokenValue = token.value;
40291
+ const parts = tokenValue.split('.');
40292
+ if (parts.length !== 3) {
40293
+ return undefined;
40294
+ }
40295
+ try {
40296
+ const payloadSegment = parts[1];
40297
+ // Fix padding for base64url
40298
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
40299
+ const base64 = (payloadSegment + padding)
40300
+ .replace(/-/g, '+')
40301
+ .replace(/_/g, '/');
40302
+ let jsonString;
40303
+ if (typeof Buffer !== 'undefined') {
40304
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
40305
+ }
40306
+ else if (typeof atob === 'function') {
40307
+ jsonString = atob(base64);
40308
+ try {
40309
+ jsonString = decodeURIComponent(jsonString
40310
+ .split('')
40311
+ .map(function (c) {
40312
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
40313
+ })
40314
+ .join(''));
40315
+ }
40316
+ catch {
40317
+ // ignore
40318
+ }
40319
+ }
40320
+ else {
40321
+ return undefined;
40322
+ }
40323
+ const payload = JSON.parse(jsonString);
40324
+ if (payload && typeof payload.sub === 'string') {
40325
+ return { subject: payload.sub, claims: payload };
40326
+ }
40327
+ }
40328
+ catch {
40329
+ // ignore decoding errors
40330
+ }
40331
+ return undefined;
40332
+ }
40288
40333
  }
40289
40334
 
40290
40335
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -513,12 +513,12 @@ async function ensureRuntimeFactoriesRegistered(registry = Registry) {
513
513
  }
514
514
 
515
515
  // This file is auto-generated during build - do not edit manually
516
- // Generated from package.json version: 0.3.19
516
+ // Generated from package.json version: 0.3.20
517
517
  /**
518
518
  * The package version, injected at build time.
519
519
  * @internal
520
520
  */
521
- const VERSION = '0.3.19';
521
+ const VERSION = '0.3.20';
522
522
 
523
523
  let initialized = false;
524
524
  const runtimePlugin = {
@@ -40283,6 +40283,51 @@ class OAuth2ClientCredentialsTokenProvider {
40283
40283
  }
40284
40284
  return DEFAULT_EXPIRY_SECONDS;
40285
40285
  }
40286
+ async getIdentity() {
40287
+ const token = await this.getToken();
40288
+ const tokenValue = token.value;
40289
+ const parts = tokenValue.split('.');
40290
+ if (parts.length !== 3) {
40291
+ return undefined;
40292
+ }
40293
+ try {
40294
+ const payloadSegment = parts[1];
40295
+ // Fix padding for base64url
40296
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
40297
+ const base64 = (payloadSegment + padding)
40298
+ .replace(/-/g, '+')
40299
+ .replace(/_/g, '/');
40300
+ let jsonString;
40301
+ if (typeof Buffer !== 'undefined') {
40302
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
40303
+ }
40304
+ else if (typeof atob === 'function') {
40305
+ jsonString = atob(base64);
40306
+ try {
40307
+ jsonString = decodeURIComponent(jsonString
40308
+ .split('')
40309
+ .map(function (c) {
40310
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
40311
+ })
40312
+ .join(''));
40313
+ }
40314
+ catch {
40315
+ // ignore
40316
+ }
40317
+ }
40318
+ else {
40319
+ return undefined;
40320
+ }
40321
+ const payload = JSON.parse(jsonString);
40322
+ if (payload && typeof payload.sub === 'string') {
40323
+ return { subject: payload.sub, claims: payload };
40324
+ }
40325
+ }
40326
+ catch {
40327
+ // ignore decoding errors
40328
+ }
40329
+ return undefined;
40330
+ }
40286
40331
  }
40287
40332
 
40288
40333
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -152,5 +152,50 @@ class OAuth2ClientCredentialsTokenProvider {
152
152
  }
153
153
  return DEFAULT_EXPIRY_SECONDS;
154
154
  }
155
+ async getIdentity() {
156
+ const token = await this.getToken();
157
+ const tokenValue = token.value;
158
+ const parts = tokenValue.split('.');
159
+ if (parts.length !== 3) {
160
+ return undefined;
161
+ }
162
+ try {
163
+ const payloadSegment = parts[1];
164
+ // Fix padding for base64url
165
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
166
+ const base64 = (payloadSegment + padding)
167
+ .replace(/-/g, '+')
168
+ .replace(/_/g, '/');
169
+ let jsonString;
170
+ if (typeof Buffer !== 'undefined') {
171
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
172
+ }
173
+ else if (typeof atob === 'function') {
174
+ jsonString = atob(base64);
175
+ try {
176
+ jsonString = decodeURIComponent(jsonString
177
+ .split('')
178
+ .map(function (c) {
179
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
180
+ })
181
+ .join(''));
182
+ }
183
+ catch {
184
+ // ignore
185
+ }
186
+ }
187
+ else {
188
+ return undefined;
189
+ }
190
+ const payload = JSON.parse(jsonString);
191
+ if (payload && typeof payload.sub === 'string') {
192
+ return { subject: payload.sub, claims: payload };
193
+ }
194
+ }
195
+ catch {
196
+ // ignore decoding errors
197
+ }
198
+ return undefined;
199
+ }
155
200
  }
156
201
  exports.OAuth2ClientCredentialsTokenProvider = OAuth2ClientCredentialsTokenProvider;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // This file is auto-generated during build - do not edit manually
3
- // Generated from package.json version: 0.3.19
3
+ // Generated from package.json version: 0.3.20
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  /**
7
7
  * The package version, injected at build time.
8
8
  * @internal
9
9
  */
10
- exports.VERSION = '0.3.19';
10
+ exports.VERSION = '0.3.20';
@@ -149,4 +149,49 @@ export class OAuth2ClientCredentialsTokenProvider {
149
149
  }
150
150
  return DEFAULT_EXPIRY_SECONDS;
151
151
  }
152
+ async getIdentity() {
153
+ const token = await this.getToken();
154
+ const tokenValue = token.value;
155
+ const parts = tokenValue.split('.');
156
+ if (parts.length !== 3) {
157
+ return undefined;
158
+ }
159
+ try {
160
+ const payloadSegment = parts[1];
161
+ // Fix padding for base64url
162
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
163
+ const base64 = (payloadSegment + padding)
164
+ .replace(/-/g, '+')
165
+ .replace(/_/g, '/');
166
+ let jsonString;
167
+ if (typeof Buffer !== 'undefined') {
168
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
169
+ }
170
+ else if (typeof atob === 'function') {
171
+ jsonString = atob(base64);
172
+ try {
173
+ jsonString = decodeURIComponent(jsonString
174
+ .split('')
175
+ .map(function (c) {
176
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
177
+ })
178
+ .join(''));
179
+ }
180
+ catch {
181
+ // ignore
182
+ }
183
+ }
184
+ else {
185
+ return undefined;
186
+ }
187
+ const payload = JSON.parse(jsonString);
188
+ if (payload && typeof payload.sub === 'string') {
189
+ return { subject: payload.sub, claims: payload };
190
+ }
191
+ }
192
+ catch {
193
+ // ignore decoding errors
194
+ }
195
+ return undefined;
196
+ }
152
197
  }
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated during build - do not edit manually
2
- // Generated from package.json version: 0.3.19
2
+ // Generated from package.json version: 0.3.20
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.19';
7
+ export const VERSION = '0.3.20';
@@ -14,12 +14,12 @@ var fastify = require('fastify');
14
14
  var websocketPlugin = require('@fastify/websocket');
15
15
 
16
16
  // This file is auto-generated during build - do not edit manually
17
- // Generated from package.json version: 0.3.19
17
+ // Generated from package.json version: 0.3.20
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.19';
22
+ const VERSION = '0.3.20';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -40087,6 +40087,51 @@ class OAuth2ClientCredentialsTokenProvider {
40087
40087
  }
40088
40088
  return DEFAULT_EXPIRY_SECONDS;
40089
40089
  }
40090
+ async getIdentity() {
40091
+ const token = await this.getToken();
40092
+ const tokenValue = token.value;
40093
+ const parts = tokenValue.split('.');
40094
+ if (parts.length !== 3) {
40095
+ return undefined;
40096
+ }
40097
+ try {
40098
+ const payloadSegment = parts[1];
40099
+ // Fix padding for base64url
40100
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
40101
+ const base64 = (payloadSegment + padding)
40102
+ .replace(/-/g, '+')
40103
+ .replace(/_/g, '/');
40104
+ let jsonString;
40105
+ if (typeof Buffer !== 'undefined') {
40106
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
40107
+ }
40108
+ else if (typeof atob === 'function') {
40109
+ jsonString = atob(base64);
40110
+ try {
40111
+ jsonString = decodeURIComponent(jsonString
40112
+ .split('')
40113
+ .map(function (c) {
40114
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
40115
+ })
40116
+ .join(''));
40117
+ }
40118
+ catch {
40119
+ // ignore
40120
+ }
40121
+ }
40122
+ else {
40123
+ return undefined;
40124
+ }
40125
+ const payload = JSON.parse(jsonString);
40126
+ if (payload && typeof payload.sub === 'string') {
40127
+ return { subject: payload.sub, claims: payload };
40128
+ }
40129
+ }
40130
+ catch {
40131
+ // ignore decoding errors
40132
+ }
40133
+ return undefined;
40134
+ }
40090
40135
  }
40091
40136
 
40092
40137
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.19
16
+ // Generated from package.json version: 0.3.20
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.19';
21
+ const VERSION = '0.3.20';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -40086,6 +40086,51 @@ class OAuth2ClientCredentialsTokenProvider {
40086
40086
  }
40087
40087
  return DEFAULT_EXPIRY_SECONDS;
40088
40088
  }
40089
+ async getIdentity() {
40090
+ const token = await this.getToken();
40091
+ const tokenValue = token.value;
40092
+ const parts = tokenValue.split('.');
40093
+ if (parts.length !== 3) {
40094
+ return undefined;
40095
+ }
40096
+ try {
40097
+ const payloadSegment = parts[1];
40098
+ // Fix padding for base64url
40099
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
40100
+ const base64 = (payloadSegment + padding)
40101
+ .replace(/-/g, '+')
40102
+ .replace(/_/g, '/');
40103
+ let jsonString;
40104
+ if (typeof Buffer !== 'undefined') {
40105
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
40106
+ }
40107
+ else if (typeof atob === 'function') {
40108
+ jsonString = atob(base64);
40109
+ try {
40110
+ jsonString = decodeURIComponent(jsonString
40111
+ .split('')
40112
+ .map(function (c) {
40113
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
40114
+ })
40115
+ .join(''));
40116
+ }
40117
+ catch {
40118
+ // ignore
40119
+ }
40120
+ }
40121
+ else {
40122
+ return undefined;
40123
+ }
40124
+ const payload = JSON.parse(jsonString);
40125
+ if (payload && typeof payload.sub === 'string') {
40126
+ return { subject: payload.sub, claims: payload };
40127
+ }
40128
+ }
40129
+ catch {
40130
+ // ignore decoding errors
40131
+ }
40132
+ return undefined;
40133
+ }
40089
40134
  }
40090
40135
 
40091
40136
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -4426,12 +4426,12 @@ async function ensureRuntimeFactoriesRegistered(registry = factory.Registry) {
4426
4426
  }
4427
4427
 
4428
4428
  // This file is auto-generated during build - do not edit manually
4429
- // Generated from package.json version: 0.3.19
4429
+ // Generated from package.json version: 0.3.20
4430
4430
  /**
4431
4431
  * The package version, injected at build time.
4432
4432
  * @internal
4433
4433
  */
4434
- const VERSION = '0.3.19';
4434
+ const VERSION = '0.3.20';
4435
4435
 
4436
4436
  let initialized = false;
4437
4437
  const runtimePlugin = {
@@ -42421,6 +42421,51 @@ class OAuth2ClientCredentialsTokenProvider {
42421
42421
  }
42422
42422
  return DEFAULT_EXPIRY_SECONDS;
42423
42423
  }
42424
+ async getIdentity() {
42425
+ const token = await this.getToken();
42426
+ const tokenValue = token.value;
42427
+ const parts = tokenValue.split('.');
42428
+ if (parts.length !== 3) {
42429
+ return undefined;
42430
+ }
42431
+ try {
42432
+ const payloadSegment = parts[1];
42433
+ // Fix padding for base64url
42434
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
42435
+ const base64 = (payloadSegment + padding)
42436
+ .replace(/-/g, '+')
42437
+ .replace(/_/g, '/');
42438
+ let jsonString;
42439
+ if (typeof Buffer !== 'undefined') {
42440
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
42441
+ }
42442
+ else if (typeof atob === 'function') {
42443
+ jsonString = atob(base64);
42444
+ try {
42445
+ jsonString = decodeURIComponent(jsonString
42446
+ .split('')
42447
+ .map(function (c) {
42448
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
42449
+ })
42450
+ .join(''));
42451
+ }
42452
+ catch {
42453
+ // ignore
42454
+ }
42455
+ }
42456
+ else {
42457
+ return undefined;
42458
+ }
42459
+ const payload = JSON.parse(jsonString);
42460
+ if (payload && typeof payload.sub === 'string') {
42461
+ return { subject: payload.sub, claims: payload };
42462
+ }
42463
+ }
42464
+ catch {
42465
+ // ignore decoding errors
42466
+ }
42467
+ return undefined;
42468
+ }
42424
42469
  }
42425
42470
 
42426
42471
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -4425,12 +4425,12 @@ async function ensureRuntimeFactoriesRegistered(registry = Registry) {
4425
4425
  }
4426
4426
 
4427
4427
  // This file is auto-generated during build - do not edit manually
4428
- // Generated from package.json version: 0.3.19
4428
+ // Generated from package.json version: 0.3.20
4429
4429
  /**
4430
4430
  * The package version, injected at build time.
4431
4431
  * @internal
4432
4432
  */
4433
- const VERSION = '0.3.19';
4433
+ const VERSION = '0.3.20';
4434
4434
 
4435
4435
  let initialized = false;
4436
4436
  const runtimePlugin = {
@@ -42420,6 +42420,51 @@ class OAuth2ClientCredentialsTokenProvider {
42420
42420
  }
42421
42421
  return DEFAULT_EXPIRY_SECONDS;
42422
42422
  }
42423
+ async getIdentity() {
42424
+ const token = await this.getToken();
42425
+ const tokenValue = token.value;
42426
+ const parts = tokenValue.split('.');
42427
+ if (parts.length !== 3) {
42428
+ return undefined;
42429
+ }
42430
+ try {
42431
+ const payloadSegment = parts[1];
42432
+ // Fix padding for base64url
42433
+ const padding = '='.repeat((4 - (payloadSegment.length % 4)) % 4);
42434
+ const base64 = (payloadSegment + padding)
42435
+ .replace(/-/g, '+')
42436
+ .replace(/_/g, '/');
42437
+ let jsonString;
42438
+ if (typeof Buffer !== 'undefined') {
42439
+ jsonString = Buffer.from(base64, 'base64').toString('utf-8');
42440
+ }
42441
+ else if (typeof atob === 'function') {
42442
+ jsonString = atob(base64);
42443
+ try {
42444
+ jsonString = decodeURIComponent(jsonString
42445
+ .split('')
42446
+ .map(function (c) {
42447
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
42448
+ })
42449
+ .join(''));
42450
+ }
42451
+ catch {
42452
+ // ignore
42453
+ }
42454
+ }
42455
+ else {
42456
+ return undefined;
42457
+ }
42458
+ const payload = JSON.parse(jsonString);
42459
+ if (payload && typeof payload.sub === 'string') {
42460
+ return { subject: payload.sub, claims: payload };
42461
+ }
42462
+ }
42463
+ catch {
42464
+ // ignore decoding errors
42465
+ }
42466
+ return undefined;
42467
+ }
42423
42468
  }
42424
42469
 
42425
42470
  var oauth2ClientCredentialsTokenProvider = /*#__PURE__*/Object.freeze({
@@ -1,6 +1,7 @@
1
1
  import { type CredentialProvider } from '../credential/credential-provider.js';
2
2
  import type { Token } from './token.js';
3
- import type { TokenProvider } from './token-provider.js';
3
+ import type { IdentityExposingTokenProvider } from './token-provider.js';
4
+ import type { AuthIdentity } from './auth-identity.js';
4
5
  interface FetchLike {
5
6
  (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
6
7
  }
@@ -13,7 +14,7 @@ export interface OAuth2ClientCredentialsTokenProviderOptions {
13
14
  fetchImpl?: FetchLike;
14
15
  clockSkewSeconds?: number;
15
16
  }
16
- export declare class OAuth2ClientCredentialsTokenProvider implements TokenProvider {
17
+ export declare class OAuth2ClientCredentialsTokenProvider implements IdentityExposingTokenProvider {
17
18
  private cachedToken;
18
19
  private readonly options;
19
20
  constructor(rawOptions: OAuth2ClientCredentialsTokenProviderOptions | Record<string, unknown>);
@@ -22,5 +23,6 @@ export declare class OAuth2ClientCredentialsTokenProvider implements TokenProvid
22
23
  private fetchNewToken;
23
24
  private resolveFetch;
24
25
  private resolveExpiresIn;
26
+ getIdentity(): Promise<AuthIdentity | undefined>;
25
27
  }
26
28
  export {};
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.19";
5
+ export declare const VERSION = "0.3.20";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",